Skip to content

Commit c5ebbee

Browse files
committed
test: widen the timing margins of the dedup extend tests
Two dedup extend tests left 40 to 50 ms between the extend and the TTL expiry, and failed on CI runners where a database round-trip took longer (Knex PostgreSQL and Kysely MySQL on 36477233496). They now use a 400 ms TTL with two 250 ms waits: without the extend the window still expires (250 + 250 > 400), and with it 150 ms of margin remain.
1 parent 1062c7f commit c5ebbee

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

‎tests/_utils/register_driver_test_suite.ts‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,29 +2506,30 @@ export function registerDriverTestSuite(options: DriverTestSuiteOptions) {
25062506
name: 'TestJob',
25072507
payload: { n: 1 },
25082508
attempts: 0,
2509-
dedup: { id: 'TestJob::ext-1', ttl: 100, extend: true },
2509+
dedup: { id: 'TestJob::ext-1', ttl: 400, extend: true },
25102510
})
25112511

2512-
await new Promise((r) => setTimeout(r, 60))
2512+
await new Promise((r) => setTimeout(r, 250))
25132513

25142514
const second = await adapter.pushOn('ext-queue', {
25152515
id: 'ext-uuid-2',
25162516
name: 'TestJob',
25172517
payload: { n: 2 },
25182518
attempts: 0,
2519-
dedup: { id: 'TestJob::ext-1', ttl: 100, extend: true },
2519+
dedup: { id: 'TestJob::ext-1', ttl: 400, extend: true },
25202520
})
25212521
assert.equal(second && typeof second === 'object' && second.outcome, 'extended')
25222522

2523-
await new Promise((r) => setTimeout(r, 60))
2523+
await new Promise((r) => setTimeout(r, 250))
25242524

2525-
// Without extend, 50ms elapsed > 40ms TTL would've expired.
2525+
// Without the extend at T=250, the window would have expired at T=400. With it,
2526+
// only 250ms of the new 400ms window have passed.
25262527
const third = await adapter.pushOn('ext-queue', {
25272528
id: 'ext-uuid-3',
25282529
name: 'TestJob',
25292530
payload: { n: 3 },
25302531
attempts: 0,
2531-
dedup: { id: 'TestJob::ext-1', ttl: 100, extend: true },
2532+
dedup: { id: 'TestJob::ext-1', ttl: 400, extend: true },
25322533
})
25332534
assert.equal(third && typeof third === 'object' && third.outcome, 'extended')
25342535
})
@@ -2867,11 +2868,11 @@ export function registerDriverTestSuite(options: DriverTestSuiteOptions) {
28672868
name: 'TestJob',
28682869
payload: { n: 1 },
28692870
attempts: 0,
2870-
dedup: { id: 'TestJob::active-ext-1', ttl: 200, extend: true },
2871+
dedup: { id: 'TestJob::active-ext-1', ttl: 400, extend: true },
28712872
})
28722873

28732874
// Move to active mid-window.
2874-
await new Promise((r) => setTimeout(r, 80))
2875+
await new Promise((r) => setTimeout(r, 250))
28752876
const popped = await adapter.popFrom('active-ext-queue')
28762877
assert.equal(popped!.id, 'active-ext-uuid-1')
28772878

@@ -2882,22 +2883,22 @@ export function registerDriverTestSuite(options: DriverTestSuiteOptions) {
28822883
name: 'TestJob',
28832884
payload: { n: 2 },
28842885
attempts: 0,
2885-
dedup: { id: 'TestJob::active-ext-1', ttl: 200, extend: true },
2886+
dedup: { id: 'TestJob::active-ext-1', ttl: 400, extend: true },
28862887
})
28872888
assert.equal(second && typeof second === 'object' && second.outcome, 'extended')
28882889
assert.equal(second && typeof second === 'object' && second.jobId, 'active-ext-uuid-1')
28892890

2890-
// Without the extend, the slot would have expired by now (80 + 150 > 200).
2891-
// With the extend at T=80, the window restarted; at T=230 only 150ms into
2891+
// Without the extend, the slot would have expired by now (250 + 250 > 400).
2892+
// With the extend at T=250, the window restarted; at T=500 only 250ms into
28922893
// new window → still blocking.
2893-
await new Promise((r) => setTimeout(r, 150))
2894+
await new Promise((r) => setTimeout(r, 250))
28942895

28952896
const third = await adapter.pushOn('active-ext-queue', {
28962897
id: 'active-ext-uuid-3',
28972898
name: 'TestJob',
28982899
payload: { n: 3 },
28992900
attempts: 0,
2900-
dedup: { id: 'TestJob::active-ext-1', ttl: 200, extend: true },
2901+
dedup: { id: 'TestJob::active-ext-1', ttl: 400, extend: true },
29012902
})
29022903
assert.equal(third && typeof third === 'object' && third.outcome, 'extended')
29032904
assert.equal(third && typeof third === 'object' && third.jobId, 'active-ext-uuid-1')

0 commit comments

Comments
 (0)