test(sync): pin the two-place rule of the scheduler
A single free place with a queued backlog starts no run until a second place frees up; the condition alone was not pinned by the latency test. Refs #178 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
589c01955a
commit
dc479e3618
1 changed files with 16 additions and 0 deletions
|
|
@ -225,6 +225,22 @@ test('with 300 ms per request, a 9-batch queue empties in bounded time and no ru
|
|||
assert.ok(maxInAnyWindow(server.requests) <= REQUEST_BUDGET, `max ${maxInAnyWindow(server.requests)} in a window`);
|
||||
});
|
||||
|
||||
test('with a single free place, no run starts until a second one frees up', async () => {
|
||||
const clock = fakeClock();
|
||||
const server = fakeServer(clock, { batches: 1 });
|
||||
const s = createSyncScheduler({ now: clock.now, setTimer: clock.setTimer, run: server.run });
|
||||
s.tracker.request();
|
||||
await clock.advance(1000);
|
||||
for (let i = 1; i < REQUEST_BUDGET - 1; i++) s.tracker.request();
|
||||
s.request();
|
||||
await clock.advance(BUDGET_WINDOW_MS - 1001);
|
||||
assert.equal(server.runs, 0, 'one place left: a run would only pull');
|
||||
await clock.advance(1);
|
||||
assert.equal(server.runs, 1, 'the run starts once the oldest request leaves the window');
|
||||
assert.equal(server.emptyPushRuns, 0);
|
||||
assert.equal(server.queue, 0);
|
||||
});
|
||||
|
||||
test('after a 429 with Retry-After: 20, no request before 20 s', async () => {
|
||||
const clock = fakeClock();
|
||||
let first = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue