From b1826907e708c089ef868d98e5576aa585030e8f Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 23 Nov 2025 21:55:57 +0000 Subject: [PATCH] Add resetting tests --- frontend/test-client/src/agent/mock-agent.ts | 11 +++++++++++ frontend/test-client/src/cli.ts | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index 22d6afcc..80413fe0 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -18,6 +18,7 @@ export class MockAgent extends MockClient { initialSettings: Partial, public readonly name: string, private readonly doDeletes: boolean, + private readonly doResets: boolean, useSlowFileEvents: boolean, private readonly jitterScaleInSeconds: number ) { @@ -107,6 +108,10 @@ export class MockAgent extends MockClient { } } + if (Math.random() < 0.1 && this.doResets) { + options.push(this.resetClient.bind(this)); + } + this.pendingActions.push( (async (): Promise => { try { @@ -229,6 +234,12 @@ export class MockAgent extends MockClient { } } + private async resetClient(): Promise { + this.client.logger.info(`Resetting client ${this.name}`); + await this.client.destroy(); + await this.init(); + } + private async createFileAction(): Promise { const file = this.getFileName(); diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 9ae920ac..7b81f800 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -14,6 +14,7 @@ async function runTest({ concurrency, iterations, doDeletes, + doResets, useSlowFileEvents, jitterScaleInSeconds }: { @@ -21,12 +22,13 @@ async function runTest({ concurrency: number; iterations: number; doDeletes: boolean; + doResets: boolean; useSlowFileEvents: boolean; jitterScaleInSeconds: number; }): Promise { slowFileEvents = useSlowFileEvents; - const settings = `with ${agentCount} agents, concurrency ${concurrency}, iterations ${iterations}, doDeletes ${doDeletes}, jitterScaleInSeconds ${jitterScaleInSeconds}, useSlowFileEvents ${useSlowFileEvents}`; + const settings = `with ${agentCount} agents, concurrency ${concurrency}, iterations ${iterations}, doDeletes ${doDeletes}, doResets ${doResets}, jitterScaleInSeconds ${jitterScaleInSeconds}, useSlowFileEvents ${useSlowFileEvents}`; console.info(`Running test ${settings}`); const vaultName = uuidv4(); @@ -46,6 +48,7 @@ async function runTest({ initialSettings, `agent-${i}`, doDeletes, + doResets, useSlowFileEvents, jitterScaleInSeconds ) @@ -113,6 +116,16 @@ async function runTest({ } async function runTests(): Promise { + await runTest({ + agentCount: 2, + concurrency: 16, + iterations: 100, + doDeletes: true, + doResets: true, + useSlowFileEvents: true, + jitterScaleInSeconds: 0.75 + }); + for (let i = 0; i < TEST_ITERATIONS; i++) { for (const useSlowFileEvents of [false, true]) { for (const concurrency of [ @@ -125,6 +138,7 @@ async function runTests(): Promise { concurrency, iterations: 100, doDeletes, + doResets: false, useSlowFileEvents, jitterScaleInSeconds: 0.75 });