Skip to content

Commit 61d0aa4

Browse files
committed
test(run-engine): bound the ckManyKeys first-serve claim
The scenario said a bounded first-serve delay was fine without asserting any bound, so nothing stopped that delay growing. It now pins the measured values: the light key is first served on step 9 with the flag on against 72 with it off, and cardinality above the pass-1 window costs no throughput (drain 79 on, 81 off). The harness has no wall-clock wait and no randomness, so those figures are exact; the assertions carry a little slack for tie-break churn only.
1 parent 9053f34 commit 61d0aa4

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

internal-packages/run-engine/src/run-queue/tests/ckVtimeFairness.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,13 @@ describe("CK virtual-time fairness on the real batched dequeue path", () => {
463463
// single fair pass can even see every key. The property to hold is that this
464464
// does NOT permanently starve the light key: as attackers advance their tags
465465
// out of the bottom of the window, the light key (still at the floor) rises
466-
// into it and gets served, and every message drains exactly once. A bounded
467-
// first-serve delay is fine; permanent starvation or a stuck drain is not.
466+
// into it and gets served, and every message drains exactly once.
467+
//
468+
// The first-serve delay is bounded, and the bound is asserted rather than
469+
// described. Measured: light is first served on step 9 with the flag on and
470+
// step 72 with it off, and the run drains on step 79 (on) / 81 (off). The
471+
// harness has no wall-clock wait and no randomness, so those are exact; the
472+
// assertions below allow a little slack for tie-break churn only.
468473
redisTest(
469474
"ckManyKeys: light key is not starved when cardinality exceeds the fair window",
470475
async ({ redisContainer }) => {
@@ -512,6 +517,15 @@ describe("CK virtual-time fairness on the real batched dequeue path", () => {
512517
onDrainStep: on.drainStep,
513518
offDrainStep: off.drainStep,
514519
});
520+
521+
// The bound: light waits at most a couple of fair rounds past the point
522+
// where a 30-wide window has rotated the whole 61-variant set through it.
523+
expect(onFirstServe).toBeLessThanOrEqual(12);
524+
// And the fair order is what buys that: age order alone leaves light until
525+
// the attackers are nearly drained.
526+
expect(onFirstServe).toBeLessThan(0.25 * offFirstServe);
527+
// Cardinality above the window costs no throughput either.
528+
expect(on.drainStep).toBeLessThanOrEqual(off.drainStep + 5);
515529
}
516530
);
517531

0 commit comments

Comments
 (0)