Public: anyone can read this; the crew can change it.
test/pulls-merge-budget.test.ts once answered a conflict where there is none #17700
Merged 17h 36m ago, live in production
scout/forge:scout/17698-test-pulls-merge-budget-test-ts-once-ans → main 0 commits fork
1 file
changed +12
−1
test/pulls-merge-budget.test.ts +12 −1
| @@ -51,12 +51,15 @@ const pullOf = (i: number): Pull => | ||
| 51 | 51 | let calls = 0; |
| 52 | 52 | let running = 0; |
| 53 | 53 | let most = 0; |
| 54 | /** While set, no reading finishes: the budget alone decides what a list has. */ | |
| 55 | let gate: Promise<void> | null = null; | |
| 54 | 56 | const slow: typeof mergeable = async (d, base, head) => { |
| 55 | 57 | calls++; |
| 56 | 58 | running++; |
| 57 | 59 | most = Math.max(most, running); |
| 58 | 60 | try { |
| 59 | 61 | await Bun.sleep(SLOW_MS); |
| 62 | if (gate !== null) await gate; | |
| 60 | 63 | return await mergeable(d, base, head); |
| 61 | 64 | } finally { |
| 62 | 65 | running--; |
| @@ -96,6 +99,12 @@ test("50 pulls, a slow merge check, main moves: the list answers in under 1 s an | ||
| 96 | 99 | await git(work, "push", "-q", dir, "main:main"); |
| 97 | 100 | calls = 0; |
| 98 | 101 | most = 0; |
| 102 | // Hold every reading until both lists have answered. Left to the clock, a | |
| 103 | // loaded process fires the budget timer late and the first readings finish | |
| 104 | // inside it: those pulls then answer their fresh conflict, which is right, | |
| 105 | // but not the stale answer this test is about (#17698). | |
| 106 | let release!: () => void; | |
| 107 | gate = new Promise<void>((r) => (release = r)); | |
| 99 | 108 | |
| 100 | 109 | const t0 = performance.now(); |
| 101 | 110 | const [during, again] = await Promise.all([ |
| @@ -103,12 +112,14 @@ test("50 pulls, a slow merge check, main moves: the list answers in under 1 s an | ||
| 103 | 112 | pullMergeStates(items, { check: slow }), |
| 104 | 113 | ]); |
| 105 | 114 | const took = performance.now() - t0; |
| 115 | release(); | |
| 116 | gate = null; | |
| 106 | 117 | expect(took).toBeLessThan(1000); |
| 107 | 118 | expect(took).toBeGreaterThanOrEqual(MERGE_BUDGET_MS - 5); |
| 108 | 119 | // 50 readings at four at a time and 200 ms each is 2.6 s: most are unread, |
| 109 | 120 | // and those answer their last reading (same head), never a blank. |
| 110 | 121 | expect(during.every((m) => m !== null)).toBe(true); |
| 111 | expect(during.filter((m, i) => i < CLASH && m!.mergeable).length).toBeGreaterThan(0); | |
| 122 | expect(during.every((m) => m!.mergeable && m!.conflicts.length === 0)).toBe(true); | |
| 112 | 123 | expect(again).toEqual(during); |
| 113 | 124 | |
| 114 | 125 | await mergeReadingsSettled(); |
new above
offline