From 0dbdc7481cf169253c3503d483d8270d864872fb Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 15 Nov 2026 08:05:40 +0800 Subject: [PATCH] ci: Test runs internal/gateway in chunks, one process per core, as Race does (#2191) f1c9014cd's macOS Test run went red with internal/gateway past go test's 30m alarm while the test then running was 1s in: no test hung, the package as a whole ran out. Its tests run one at a time (t.Setenv rules out t.Parallel), and the package grew from 450-600s on macOS runners (10-28, 56602426d) to 965s on the green run before, and 892s for 4286 tests on mote, none over 20s. A longer timeout would be met again the same way; Race already runs the same tests in chunks through build/race-shards.sh (#5361). The Test step now runs every other package as before, and the gateway's plain test binary through race-shards.sh. The plain run stays: it sends the full 64 MB bodies and runs the pool tests -race skips (raceOn). Run on mote at this change (origin/main a5e3972a7): - go test -c ./internal/gateway/, then build/race-shards.sh with 18 workers and -test.timeout=20m: 4300 tests in 135 chunks, 125s, exit 0 (twice; the second run's status taken from the script, not a pipe) - go list ./... | grep -v '/internal/gateway$': 121 packages, the gateway's subpackage kept Not run: the workflow itself; this push's own Test run is its check, on Linux (gtk3 tags) and macOS. --- .github/workflows/test.yml | 14 +++++++++++--- build/race-shards.sh | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8571fb40..6617c15e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,11 +65,19 @@ jobs: with: bun-version: 1.4.2 - # internal/gateway takes 450-600s on macOS runners, and go test's - # default 10m timed it out in 3 of 8 finished main runs (#2108). + # internal/gateway's tests run one at a time (t.Setenv rules out + # t.Parallel): 892s on mote for 4286 tests on 11-15, none over 20s, + # 965s on macOS CI, and past the 30m alarm on f1c9014cd with no test + # hung (#2191). It grew from 450-600s on 10-28, so a longer timeout + # would only be met again. Its plain run goes in chunks, one process + # per core, as the Race step's does; the other packages run as before. - name: Test if: runner.os != 'Windows' - run: go test -timeout 30m -tags "${{ steps.tags.outputs.tags }}" ./... + shell: bash + run: | + go test -timeout 30m -tags "${{ steps.tags.outputs.tags }}" $(go list -tags "${{ steps.tags.outputs.tags }}" ./... | grep -v '/internal/gateway$') + go test -c -o "$RUNNER_TEMP/gateway.test" -tags "${{ steps.tags.outputs.tags }}" ./internal/gateway/ + build/race-shards.sh internal/gateway "$RUNNER_TEMP/gateway.test" "$(getconf _NPROCESSORS_ONLN)" -test.timeout=20m # Windows skips the Test step above, so the two plugin stderr tests run # here. The end-to-end one needs bun on PATH; without it it skips. diff --git a/build/race-shards.sh b/build/race-shards.sh index c1520bfb2..37321b2a9 100755 --- a/build/race-shards.sh +++ b/build/race-shards.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # race-shards.sh DIR BIN N [FLAGS]: runs the tests of BIN, a package's test -# binary (go test -c), from the package's DIR in N processes at once, and +# binary (go test -c, with -race or without: CI's Test step runs the +# gateway's plain binary through it too, #2191), from the package's DIR in N +# processes at once, and # fails if any test process does. FLAGS go to every process. A package's # tests run one at a time unless they call t.Parallel, which t.Setenv rules # out, so the gateway's suite under the race detector keeps one core busy;