Public: anyone can read this; the crew can change it.

test/origins-reconnect.test.ts's frozen-mirror suite passes every time on a loaded check machine #4621

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/4578-test-origins-reconnect-test-ts-s-frozen → main 1 commit fork

  • Merged. scout/4578-test-origins-reconnect-test-ts-s-frozen was merged into main as d770150.

Review

Sign in to review this change.
1 file changed +17 −15
test/origins-reconnect.test.ts +17 −15
@@ -148,12 +148,21 @@ describe("a frozen mirror is said, and reconnected in one click", () => {
148148 );
149149
150150 /** The sync after a reconnect runs in the background; wait for its refs. */
151 async function mirrorReaches(oid: string, ms = 15_000): Promise<void> {
152 const start = Date.now();
153 while ((await mirrorMain()) !== oid) {
154 if (Date.now() - start > ms)
155 throw new Error(`mirror main never reached ${oid}`);
156 await Bun.sleep(50);
151 async function mirrorReaches(oid: string): Promise<void> {
152 await refReaches(() => mirrorMain(), oid);
153 }
154
155 /**
156 * Wait for a ref to reach an oid. No deadline of its own: the sync that
157 * moves it is awaited, and the test's timeout is the only bound, so a
158 * loaded machine slows it and never fails it.
159 */
160 async function refReaches(
161 read: () => Promise<string | undefined>,
162 oid: string,
163 ): Promise<void> {
164 while ((await read()) !== oid) {
165 await Promise.race([syncsSettled(), Bun.sleep(50)]);
157166 }
158167 }
159168
@@ -298,9 +307,7 @@ describe("a frozen mirror is said, and reconnected in one click", () => {
298307 afterAll(async () => {
299308 // A sync started by a reconnect may outlive the test that waited for its
300309 // refs; it must not write into a directory being removed.
301 // Bounded: a sync wedged on a loaded machine must not take the hook's
302 // own timeout, which fails the file under no name.
303 await Promise.race([syncsSettled(), Bun.sleep(30_000)]);
310 await syncsSettled();
304311 octo.stop();
305312 mona.stop();
306313 servers.stop();
@@ -678,12 +685,7 @@ describe("a frozen mirror is said, and reconnected in one click", () => {
678685
679686 // And the fork, which has nothing of its own, follows its parent again.
680687 const forkDir = repoDir(app.reposRoot, "alice", "widgets-fork");
681 const start = Date.now();
682 while ((await resolveOid(forkDir, "refs/heads/main")) !== tip) {
683 if (Date.now() - start > 10_000)
684 throw new Error("the fork never followed");
685 await Bun.sleep(50);
686 }
688 await refReaches(() => resolveOid(forkDir, "refs/heads/main"), tip);
687689 await syncOrigin(app, getOriginById(app.db, again)!);
688690 });
689691 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs