Repository navigation
test: run the test files in parallel with shorter test-only waits - #4
Conversation
…tkernel#2) Each test file gets its own two local ports, from the number its name starts with, so the files no longer queue on port 18435 and run in parallel. A test-only RUNCODER_TIME_SCALE (default 1) scales the keep-alive retry gap, the delete retry gap and the minute behind the idle, time-limit and download timers; the tests set it to 0.2 with a half-second tick. pnpm check goes from 316s to 75s on Linux, with the same 38 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rigel-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head a02d97e.
Verdict: approve. I found no merge blockers.
What I checked and how
Checks. check (ubuntu-latest), check (macos-latest) and check (windows-latest) are all completed with success on head a02d97e.
Local run. On Linux I ran pnpm install --frozen-lockfile, then time pnpm check on the head:
- exit 0,
syntax: 21/21 files ok; tests 38, pass 38, fail 0, skipped 0,duration_ms 75042;- wall time 1m16.8s.
Straight after the run, ss -ltn showed nothing listening on :184xx. ps showed no runcoder, fake gcloud, Ollama or Qwen process. git status was clean.
Acceptance criteria (#2)
- Own port, own fake Google, files in parallel.
tests/helpers.mjs:16-17givesPORT = 18435 + 2 × n, so files 1–5 use 18437–18446, withPORT + 1for the second-instance tests.startGoogle()listens on port 0, and each file runs in its ownnode --testprocess, so each file already had its own server and its owngooglestate.--test-concurrency=8is set in bothpackage.jsonandscripts/check.mjs:29.- I grepped for anything shared across files. No test hard-codes 18435. Proxies and Qwen are killed by PID from each sandbox's own state folder (
src/tunnel.mjs:68,killLeftovers), not by name. Sandbox folder names are unique.
- I grepped for anything shared across files. No test hard-codes 18435. Proxies and Qwen are killed by PID from each sandbox's own state folder (
- Test-only timer setting, defaults unchanged.
RUNCODER_TIME_SCALEdefaults to 1 (src/config.mjs:94). It scales:- the keep-alive retry gap (
src/session.mjs:90); - the idle and time-limit minute (
src/session.mjs:127,137); - the download deadline (
src/tunnel.mjs:106); - the delete and list retry gaps (
src/cloud.mjs:55,64).
With the default of 1, every expression equals the old value.
- the keep-alive retry gap (
- No test removed or weakened. The only test-file edit is
tests/2-recovery.test.mjs. Its test names are identical to base (diffed thetest("…"lines), and 38 tests still run. Noassertline changed. The edited values are timing inputs, rescaled to the new 1 s retry gap:- "lost the model":
setReady40 → 10. That still outlasts the roughly 2 s retry window, and the test still asserts both "lost the model" and "ready again". - "brief hiccup": outage 7 s → 1.5 s against a 2 s window, before 7 s against 10 s; post-wait 12 s → 5 s. The outage still ends before the third check, and a real loss would still be reported inside the wait.
- The issue asks for this rescaling ("can be shortened by a test-only setting").
- "lost the model":
- [~] Under 2 minutes on macOS; CI on all three systems. CI passes on all three. Not checked: the macOS duration. I have no access to the CI logs in this run, so I can't confirm under 2 minutes there. Linux is 75 s.
- No port or process left behind. Shown by the
ssandpsresults above.
Correctness. I read the full diff and how each scaled value is used, and found no caller broken.
Scope. src/tunnel.mjs and src/cloud.mjs are not in the issue's file list.
tunnel.mjsholds the download timer, which the criterion names, so it is required.cloud.mjsscales the delete retry gap. The PR explains why: without it, the delete-failure test alone takes 57 s. It is the same setting and has no user-visible effect at the default.
I don't consider either one out of scope.
Org rules. No secrets in the diff. I read the one existing-test edit; see the "no test removed or weakened" item above.
Nits (non-blocking)
RUNCODER_TIME_SCALE=0or a negative value is accepted bynum(). With 0,minutesatsrc/session.mjs:127becomesInfinity, and the session shuts down on its first tick. This is test-only and not documented, likeRUNCODER_TICK, but a> 0check would be cheap.- The hiccup test's margin is now 0.5 s: the 1.5 s outage against the third check at about 2 s. Before, it was 3 s (7 s against 10 s). Each
modelReadyrequest adds some slack, and CI passed on all three systems. Still, if the test process stalls for more than about 0.5 s between itssleep(1.5)and thermSync, it could report a false "lost". An outage of 1 s would double the margin. I did not reproduce a flake. AGENTS.mdstill sayspnpm checktakes "about 5 minutes, one at a time". The PR notes this; a follow-up could fix it.
vega-setkernel
left a comment
There was a problem hiding this comment.
Reviewed head a02d97e.
Approve. I found no merge blockers. The test files now run in parallel on separate ports. The waits are scaled down only in tests, and user defaults stay the same. pnpm check passes in 77 s here, with nothing left behind.
What I checked
Checks: check (ubuntu-latest), check (macos-latest) and check (windows-latest) all completed with success on head a02d97e.
Local run (Linux, Node 26.13.1, pnpm install --frozen-lockfile, then pnpm check):
- exit 0,
syntax: 21/21 files ok,tests 38,pass 38,fail 0,skipped 0,duration_ms 75370, wall time 1m17s. - Right after the run,
ss -ltnshowed nothing listening on184xx.psshowed no runcoder, gcloud, Qwen Code or Ollama process.
Acceptance criteria (#2)
- Own port, own fake Google server, files run in parallel: met.
tests/helpers.mjs:16-17takesPORTfrom the number at the start of the file name.- I imported
helpers.mjsfrom two probe files,1-p.test.mjsand3-p.test.mjs, and ran them undernode --test --test-concurrency=8. They printedPORT=18437andPORT=18441, soprocess.argv[1]is the test file in each child process. I deleted the probe files afterwards. startGoogle()already runs in each file's own process. I checked that nosandbox("…")name appears in two files.--test-concurrency=8is set in bothpackage.jsonandscripts/check.mjs:29.
- Test-only setting for the keep-alive retry gap and the idle, time-limit and download timers; user defaults unchanged: met.
timeScale: num("TIME_SCALE", 1)is atsrc/config.mjs:94.- It is applied to the keep-alive retry gap at
src/session.mjs:90, the time limit atsrc/session.mjs:127, the idle timer atsrc/session.mjs:137and the download timeout atsrc/tunnel.mjs:106. - With the default of 1, every expression is the same as before.
- No test removed or weakened: met.
- The run has 38 tests, the same as base and more than the issue's 37.
- The only existing test file edited is
tests/2-recovery.test.mjs. It changes three timing inputs and no assertion. - "the server lost the model":
setReady(ctx, 10)replaces 40. The fake stays empty longer than the retry window, which is now about 3 s (three checks 1 s apart,src/session.mjs:87-91). - "a brief hiccup": the outage is 1.5 s instead of 7 s, and the wait after it is 5 s instead of 12 s. The third check comes at least 2 s after the first failed one, so it always lands after a 1.5 s outage has ended. Before the change, the outage was about 70% of the window (7 s of 10 s); it is now 75% (1.5 s of 2 s). The test still checks the same thing.
- The guard question: the values changed are test inputs, not expected values, and the issue asks for shorter waits. This passes.
- Under 2 minutes on macOS; CI passes on ubuntu, macos and windows: CI passes on all three. The suite took 77 s on Linux here. Not checked: the macOS duration. I can't see CI logs from this run, and the PR says it was not measured.
- No port or process left behind: met for Linux. See the
ssandpsresults above.
Scope
src/tunnel.mjsis not in the issue's file list, but criterion 2 names the download timer, which lives there.src/cloud.mjs(the delete retry gap) is not named either. It uses the same test-only factor, defaults to unchanged behaviour, and the PR explains why criterion 4 needs it.- Neither file is a change outside the issue.
Org rules: no secrets, no workflow changes and no dependency changes in the diff. Nothing in the PR text asked for anything outside the review.
Nits (non-blocking)
RUNCODER_TIME_SCALE=0, or a negative value, passesnum()(src/config.mjs:68-72). With 0,src/session.mjs:127divides by zero, sominutesbecomesInfinityand the run stops at its first tick with "Reached the …-minute limit". The setting is test-only and not documented, but a> 0check would make a mistyped value fail clearly.- Ports depend on the file name starting with
<n>-. Every file without a number gets18435, so two such files would collide when run in parallel. A one-line note intests/helpers.mjs(or in AGENTS.md) would help whoever adds the next test file. AGENTS.md:23still sayspnpm checktakes "about 5 minutes, one at a time". This could be a follow-up, as the PR notes.- Please put the macOS CI duration of
pnpm checkin the PR or the issue when closing, so criterion 4's "under 2 minutes on macOS" has its evidence.
Summary
pnpm checknow takes 75 s instead of 316 s on Linux (6 cores). The same 38 tests run, and all of them pass. The tests still run runcoder end to end against the fakes. What changed is that the five test files now run in parallel, and the fixed waits are shorter in tests. Defaults for users are unchanged.What changed
tests/helpers.mjs): each test file has its ownPORTandPORT + 1, taken from the number its file name starts with:18435 + 2 × n, so files 1–5 use 18437–18446.node --testruns each file in its own process, so each file already had its own fake Google server (startGoogle()listens on port 0) and its owngooglestate. Sandbox folder names were already unique across files.package.jsontest script,scripts/check.mjs):--test-concurrency=1becomes--test-concurrency=8, which is enough for all five files at once, even on 3-core CI runners where Node's default would be 2.RUNCODER_TIME_SCALE(src/config.mjs, default1). LikeRUNCODER_TICK, it is not in the README. It multiplies:src/session.mjs);src/session.mjs) and by the download timeout (src/tunnel.mjs);src/cloud.mjs). This one is not in the issue's list. Without it, "a delete that keeps failing" alone takes 57 s, and the recovery file cannot finish in under 2 minutes.RUNCODER_TIME_SCALE=0.2andRUNCODER_TICK=0.5(the tick was 2). Two timing tests intests/2-recovery.test.mjsare rescaled to match, and each still asserts the same thing:No test was removed, and no assertion was changed.
How it was tested
pnpm checkexit 0,tests 38, pass 38,duration_ms 315653.pnpm checktwice in a row: both exit 0,syntax: 21/21 files ok,tests 38, pass 38, fail 0, skipped 0,duration_ms 75106and75323. Slowest files: recovery (about 75 s) and qwen.psshowed no runcoder, gcloud, Qwen Code or Ollama process, andss -ltnshowed nothing listening on 184xx.WARNING: The server restarted and lost the model4 s in, so the test would fail. The value was set back to 1.5 s afterwards.Not run
RUNCODER_TIME_SCALEdefaults to 1).Notes
AGENTS.mdstill sayspnpm checktakes "about 5 minutes, one at a time". It isn't in this issue's file list, so I left it.🤖 Generated with Claude Code
Closes #2