Fix E2E testing

This commit is contained in:
Andras Schmelczer 2025-11-27 21:29:55 +00:00
parent 82f11d8c86
commit d45d2c0be3
2 changed files with 38 additions and 30 deletions

View file

@ -108,10 +108,10 @@ export class MockAgent extends MockClient {
}
}
if (Math.random() < 0.1 && this.doResets) {
options.push(this.resetClient.bind(this));
}
if (Math.random() < 0.015 && this.doResets) {
// we can't just queue this up as once it's destroyed, no more method calls can go to SyncClient
await this.resetClient();
} else {
this.pendingActions.push(
(async (): Promise<unknown> => {
try {
@ -120,7 +120,9 @@ export class MockAgent extends MockClient {
this.client.logger.error(
`Failed to perform an action: ${error}`
);
this.client.logger.info(JSON.stringify(this.data, null, 2));
this.client.logger.info(
JSON.stringify(this.data, null, 2)
);
this.client.logger.info(
JSON.stringify(this.localFiles, null, 2)
);
@ -129,11 +131,17 @@ export class MockAgent extends MockClient {
})()
);
}
}
public async finish(): Promise<void> {
await this.client.setSetting("isSyncEnabled", true);
// eslint-disable-next-line no-restricted-properties
await Promise.all(this.pendingActions);
await this.client.waitUntilFinished();
}
public async destroy(): Promise<void> {
await this.client.waitUntilFinished();
await this.client.destroy();
}

View file

@ -82,7 +82,7 @@ async function runTest({
// then we need a second pass to ensure that all agents pull the same state.
for (const client of clients) {
try {
await client.finish();
await client.destroy();
} catch (err) {
if (!slowFileEvents) {
throw err;
@ -116,6 +116,7 @@ async function runTest({
}
async function runTests(): Promise<void> {
for (let i = 0; i < TEST_ITERATIONS; i++) {
await runTest({
agentCount: 2,
concurrency: 16,
@ -126,7 +127,6 @@ async function runTests(): Promise<void> {
jitterScaleInSeconds: 0.75
});
for (let i = 0; i < TEST_ITERATIONS; i++) {
for (const useSlowFileEvents of [false, true]) {
for (const concurrency of [
16,