Run the internal/handlers tests in parallel (closes #194) #204

Merged
clawbot merged 1 commits from issue-194-handlers-test-time into next 2026-10-27 08:28:29 +01:00
Collaborator

Cause: the internal/handlers tests ran one at a time, because config.New writes the global viper instance. Each test spends most of its time in SQLite under the race detector, so in a row they took longer than the 20-second target.

What changed, in the internal/handlers test files only:

  • Every test and subtest calls t.Parallel(), as the internal/ircserver and internal/db tests already do. The file-level //nolint:paralleltest lines are gone, so the linter asks it of new tests too.
  • newTestServerWith holds a mutex, viperMu, while it builds and starts a server, so servers start one at a time. config.New writes viper, and the server reads it as it starts, in internal/server/routes.go.

What the diff does not show:

  • Each test still has its own server and database, so no test sees another's data.
  • The Dockerfile and script/ are unchanged: -race, -p 4 and the test timeout stay as they are.

Disclosures:

  • Rule suppressed: gochecknoglobals on viperMu, which all tests must share; internal/db/export_test.go does the same for its test counter.
  • Judgement call: -p 4 limits how many packages test at once, not how many tests in one package run together. This package now does what most packages here already do.
  • Judgement call: tests that depend on timing keep their limits and now share the CPU with other tests. These are the long-poll deadlines and the login rate limit, which refills once a second.

Model: opus-5-5

Cause: the `internal/handlers` tests ran one at a time, because `config.New` writes the global viper instance. Each test spends most of its time in SQLite under the race detector, so in a row they took longer than the 20-second target. What changed, in the `internal/handlers` test files only: - Every test and subtest calls `t.Parallel()`, as the `internal/ircserver` and `internal/db` tests already do. The file-level `//nolint:paralleltest` lines are gone, so the linter asks it of new tests too. - `newTestServerWith` holds a mutex, `viperMu`, while it builds and starts a server, so servers start one at a time. `config.New` writes viper, and the server reads it as it starts, in `internal/server/routes.go`. What the diff does not show: - Each test still has its own server and database, so no test sees another's data. - The `Dockerfile` and `script/` are unchanged: `-race`, `-p 4` and the test timeout stay as they are. Disclosures: - Rule suppressed: `gochecknoglobals` on `viperMu`, which all tests must share; `internal/db/export_test.go` does the same for its test counter. - Judgement call: `-p 4` limits how many packages test at once, not how many tests in one package run together. This package now does what most packages here already do. - Judgement call: tests that depend on timing keep their limits and now share the CPU with other tests. These are the long-poll deadlines and the login rate limit, which refills once a second. Model: opus-5-5
clawbot added the needs-review label 2026-10-27 07:47:00 +01:00
clawbot self-assigned this 2026-10-27 07:47:00 +01:00
clawbot added 1 commit 2026-10-27 07:47:01 +01:00
The handlers tests ran one at a time because config.New writes the
global viper instance. Each test spends most of its time in SQLite
under the race detector, so run in a row they took longer than the
20-second target.

Every test and subtest now calls t.Parallel(), as the ircserver and
db tests already do. A mutex in newTestServerWith makes tests start
their servers one at a time, since config.New writes viper and the
server reads it as it starts. No test is removed or otherwise
changed.

Model: opus-5-5
Author
Collaborator

PASS: the internal/handlers tests now run in parallel, one lock covers every use of the global viper instance, each test still has its own server and database, and the package is well under the 20-second target of #194.

  • Judgement call: making the tests run in parallel, by removing the global-viper reason they had to run one at a time, counts as removing the cost at its cause.
  • Judgement call: TestIntegrationKill in internal/ircserver, which this PR does not touch, once timed out waiting for the victim's QUIT and did not fail again with or without this change, so I did not count it against this PR.
  • Unverified: whether the added lines were typed by hand; nothing in the change or its description points to a scripted edit.

Model: opus-5-5

PASS: the `internal/handlers` tests now run in parallel, one lock covers every use of the global viper instance, each test still has its own server and database, and the package is well under the 20-second target of https://git.eeqj.de/sneak/neoirc/issues/194. - Judgement call: making the tests run in parallel, by removing the global-viper reason they had to run one at a time, counts as removing the cost at its cause. - Judgement call: `TestIntegrationKill` in `internal/ircserver`, which this PR does not touch, once timed out waiting for the victim's QUIT and did not fail again with or without this change, so I did not count it against this PR. - Unverified: whether the added lines were typed by hand; nothing in the change or its description points to a scripted edit. Model: opus-5-5
clawbot merged commit a7f9bebe6a into next 2026-10-27 08:28:29 +01:00
clawbot deleted branch issue-194-handlers-test-time 2026-10-27 08:28:30 +01:00
Sign in to join this conversation.