Add resetting tests

This commit is contained in:
Andras Schmelczer 2025-11-23 21:55:57 +00:00
parent c3cbde052a
commit b1826907e7
2 changed files with 26 additions and 1 deletions

View file

@ -18,6 +18,7 @@ export class MockAgent extends MockClient {
initialSettings: Partial<SyncSettings>, initialSettings: Partial<SyncSettings>,
public readonly name: string, public readonly name: string,
private readonly doDeletes: boolean, private readonly doDeletes: boolean,
private readonly doResets: boolean,
useSlowFileEvents: boolean, useSlowFileEvents: boolean,
private readonly jitterScaleInSeconds: number 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( this.pendingActions.push(
(async (): Promise<unknown> => { (async (): Promise<unknown> => {
try { try {
@ -229,6 +234,12 @@ export class MockAgent extends MockClient {
} }
} }
private async resetClient(): Promise<void> {
this.client.logger.info(`Resetting client ${this.name}`);
await this.client.destroy();
await this.init();
}
private async createFileAction(): Promise<void> { private async createFileAction(): Promise<void> {
const file = this.getFileName(); const file = this.getFileName();

View file

@ -14,6 +14,7 @@ async function runTest({
concurrency, concurrency,
iterations, iterations,
doDeletes, doDeletes,
doResets,
useSlowFileEvents, useSlowFileEvents,
jitterScaleInSeconds jitterScaleInSeconds
}: { }: {
@ -21,12 +22,13 @@ async function runTest({
concurrency: number; concurrency: number;
iterations: number; iterations: number;
doDeletes: boolean; doDeletes: boolean;
doResets: boolean;
useSlowFileEvents: boolean; useSlowFileEvents: boolean;
jitterScaleInSeconds: number; jitterScaleInSeconds: number;
}): Promise<void> { }): Promise<void> {
slowFileEvents = useSlowFileEvents; 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}`); console.info(`Running test ${settings}`);
const vaultName = uuidv4(); const vaultName = uuidv4();
@ -46,6 +48,7 @@ async function runTest({
initialSettings, initialSettings,
`agent-${i}`, `agent-${i}`,
doDeletes, doDeletes,
doResets,
useSlowFileEvents, useSlowFileEvents,
jitterScaleInSeconds jitterScaleInSeconds
) )
@ -113,6 +116,16 @@ async function runTest({
} }
async function runTests(): Promise<void> { async function runTests(): Promise<void> {
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 (let i = 0; i < TEST_ITERATIONS; i++) {
for (const useSlowFileEvents of [false, true]) { for (const useSlowFileEvents of [false, true]) {
for (const concurrency of [ for (const concurrency of [
@ -125,6 +138,7 @@ async function runTests(): Promise<void> {
concurrency, concurrency,
iterations: 100, iterations: 100,
doDeletes, doDeletes,
doResets: false,
useSlowFileEvents, useSlowFileEvents,
jitterScaleInSeconds: 0.75 jitterScaleInSeconds: 0.75
}); });