Skip to content

Commit 1b97c6f

Browse files
authored
test: isolate server admission lifecycle and synchronize quota switching (#6279)
1 parent d4480b7 commit 1b97c6f

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎scripts/test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ export const SERIAL_FULL_SUITE_FILES = [
374374
// Its management API import stalled the long-lived macOS isolate pool before
375375
// any case ran; the complete file finishes in under a second in a fresh process.
376376
"routing/subagent-roster-retention.test.ts",
377+
// Linux run 36610213506 stalled this file after its WebSocket admission case
378+
// in a multi-file process; all 11 cases completed in the attribution process.
379+
// Keep its real listener lifecycle in a fresh process on every platform.
380+
"codex-integration/active-registry-admission.test.ts",
377381
"update/update-stop-first.test.ts",
378382
// Relays a 50 MiB WebSocket frame end to end against a 15s deadline, so its result is a
379383
// measurement of the whole process, not of the relay. On a healthy 3-CPU macOS runner the

‎tests/ci-workflows/test-runner.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,14 @@ describe("bun test argv", () => {
575575
}
576576
});
577577

578+
test("server admission fixtures finish in a dedicated process", () => {
579+
const plan = resolveBunTestPlan([]);
580+
expect(plan[0]?.args).toContain("**/active-registry-admission.test.ts");
581+
expect(plan.find(lane => lane.label === "active-registry-admission.test.ts")?.args).toEqual([
582+
"--isolate", "--parallel=1", "./tests/codex-integration/active-registry-admission.test.ts",
583+
]);
584+
});
585+
578586
test("serial lanes override caller parallelism without changing the main lane", () => {
579587
const plan = resolveBunTestPlan(["--parallel=2", "--only-failures"]);
580588
expect(plan[0]?.args).toContain("--parallel=2");

‎tests/codex-integration/active-registry-admission.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe("active registry admission", () => {
143143
} finally {
144144
settle?.();
145145
await server.stop(true);
146-
upstream.stop(true);
146+
await upstream.stop(true);
147147
if (previousHome === undefined) delete process.env.OPENCODEX_HOME;
148148
else process.env.OPENCODEX_HOME = previousHome;
149149
removeTreeWithRetry(home);

‎tests/providers/provider-account-quota.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,13 @@ describe("fetchProviderAccountQuotas", () => {
342342
let releaseUsage!: () => void;
343343
const usageGate = new Promise<void>(resolve => { releaseUsage = resolve; });
344344
let usageCalls = 0;
345+
let usageStarted!: () => void;
346+
const usageEntered = new Promise<void>(resolve => { usageStarted = resolve; });
345347
globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => {
346348
const auth = new Headers(init?.headers).get("authorization") ?? "";
347349
if (auth.endsWith("token-first")) {
348350
usageCalls += 1;
351+
usageStarted();
349352
await usageGate;
350353
return new Response(usageBody(70, 15), { status: 200 });
351354
}
@@ -365,8 +368,10 @@ describe("fetchProviderAccountQuotas", () => {
365368
};
366369
const reportPromise = fetchProviderQuotaReports(config, true);
367370
// Switch active mid-flight before Anthropic responds.
368-
await setActiveAccount("anthropic", second!.id);
369-
releaseUsage();
371+
try {
372+
await usageEntered;
373+
await setActiveAccount("anthropic", second!.id);
374+
} finally { releaseUsage(); }
370375
const switchedReport = await reportPromise;
371376
expect(switchedReport.reports).toEqual([]);
372377
expect(getCachedProviderAccountQuota("anthropic", first!.id)?.fiveHourPercent).toBe(70);

0 commit comments

Comments
 (0)