Skip to content

Commit 7142997

Browse files
committed
fix: flakey tests due to cron-timeout misalignment
Cron waits for up to 120 seconds between runs. The test has a 120 second timeout. So if cron is at the end of its random wait when the tests start, there can be a timeout. This is an edge case that causes flakiness. We bump the timeout to 150s to provide a buffer. These tests need to wait for a sync to happen, so they need to wait for the cron job to run.
1 parent 93fda47 commit 7142997

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-advanced.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe.sequential('External DB Sync - Advanced Tests', () => {
115115
throw err;
116116
}
117117
},
118-
{ description: 'User A to appear in both Project A databases', timeoutMs: 120000 }
118+
{ description: 'User A to appear in both Project A databases', timeoutMs: 150000 }
119119
);
120120

121121
await waitForCondition(
@@ -130,7 +130,7 @@ describe.sequential('External DB Sync - Advanced Tests', () => {
130130
throw err;
131131
}
132132
},
133-
{ description: 'User B to appear in all three Project B databases', timeoutMs: 120000 }
133+
{ description: 'User B to appear in all three Project B databases', timeoutMs: 150000 }
134134
);
135135

136136
const resA1 = await clientA1.query(`SELECT * FROM "users" WHERE "primary_email" = $1`, ['user-a@example.com']);
@@ -438,7 +438,7 @@ describe.sequential('External DB Sync - Advanced Tests', () => {
438438
const res = await externalClient.query(`SELECT COUNT(*) as count FROM "users"`);
439439
return parseInt(res.rows[0].count) >= userCount;
440440
},
441-
{ description: `all ${userCount} users to be synced`, timeoutMs: 120000 }
441+
{ description: `all ${userCount} users to be synced`, timeoutMs: 150000 }
442442
);
443443

444444
const res = await externalClient.query(`SELECT COUNT(*) as count FROM "users"`);
@@ -500,7 +500,7 @@ describe.sequential('External DB Sync - Advanced Tests', () => {
500500
throw err;
501501
}
502502
},
503-
{ description: 'initial 3 users sync', timeoutMs: 120000 }
503+
{ description: 'initial 3 users sync', timeoutMs: 150000 }
504504
);
505505

506506
let res = await client.query(`SELECT COUNT(*) as count FROM "users"`);
@@ -543,7 +543,7 @@ describe.sequential('External DB Sync - Advanced Tests', () => {
543543
throw err;
544544
}
545545
},
546-
{ description: 'final sync state correct', timeoutMs: 120000 }
546+
{ description: 'final sync state correct', timeoutMs: 150000 }
547547
);
548548

549549
res = await client.query(`SELECT * FROM "users" ORDER BY "primary_email"`);
@@ -728,7 +728,7 @@ $$;`);
728728
);
729729
return res.rows.length === 0;
730730
},
731-
{ description: 'deleted user should never appear', timeoutMs: 120000 }
731+
{ description: 'deleted user should never appear', timeoutMs: 150000 }
732732
);
733733

734734
const res = await client.query(
@@ -811,7 +811,7 @@ $$;`);
811811
);
812812
return followUp.rows.length === 1 && followUp.rows[0].display_name === 'Recreated Export';
813813
},
814-
{ description: 'recreated row persists after extra sync', timeoutMs: 120000 },
814+
{ description: 'recreated row persists after extra sync', timeoutMs: 150000 },
815815
);
816816
}, TEST_TIMEOUT);
817817

apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-race.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ describe.sequential('External DB Sync - Race Condition Tests', () => {
240240
const res = await externalClient.query(`SELECT COUNT(*) AS count FROM "users"`);
241241
return parseInt(res.rows[0].count, 10) === totalUsers;
242242
},
243-
{ description: 'initial >300 users exported', timeoutMs: 120000 },
243+
{ description: 'initial >300 users exported', timeoutMs: 150000 },
244244
);
245245

246246
// Delete user at index 1 (low sequence ID)
@@ -396,7 +396,7 @@ describe.sequential('External DB Sync - Race Condition Tests', () => {
396396
},
397397
{
398398
description: 'waiting for marker user to sync to external DB',
399-
timeoutMs: 120_000,
399+
timeoutMs: 150_000,
400400
},
401401
);
402402

apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export async function waitForSyncedData(client: Client, email: string, expectedN
175175
},
176176
{
177177
description: `data for ${email} to appear in external DB`,
178-
timeoutMs: 120000,
178+
timeoutMs: 150000,
179179
intervalMs: 500,
180180
}
181181
);
@@ -200,7 +200,7 @@ export async function waitForSyncedDeletion(client: Client, email: string) {
200200
},
201201
{
202202
description: `data for ${email} to be removed from external DB`,
203-
timeoutMs: 120000,
203+
timeoutMs: 150000,
204204
intervalMs: 500,
205205
}
206206
);
@@ -224,7 +224,7 @@ export async function waitForTable(client: Client, tableName: string) {
224224
},
225225
{
226226
description: `table ${tableName} to be created`,
227-
timeoutMs: 120000,
227+
timeoutMs: 150000,
228228
intervalMs: 500,
229229
}
230230
);

0 commit comments

Comments
 (0)