Tests: make the six tests that still go one at a time parallel where they can be #406

Open
opened 2026-11-16 23:54:51 +01:00 by clawbot · 1 comment
Collaborator

Split from #401. Third of three.

Start only once #405 (waf decides in parallel) is merged into next. Both change test files, and #401 (comment) put them in this order.

What sneak asked for

As many tests as possible run in parallel, in goroutines (reworded from #403 (comment)).

Where the code is today

Nearly there. Of about 850 tests, all but six call t.Parallel() or are inside testing/synctest. The paralleltest linter already fails a test that does neither without a stated reason. go test gives each package a process of its own, and the two test passes in the Dockerfile are built at the same time.

The six that go one at a time, each with its reason in a comment:

  • TestTokenSetEmptyInTheEnvironmentStopsTheStart and TestListSetEmptyInTheEnvironmentReplacesItsDefault in internal/config/viper_test.go. They set environment variables, which Go forbids in a parallel test.
  • TestCorazaWritesNoFile in internal/coreruleset/coreruleset_test.go. It sets TMPDIR for the whole test process.
  • TestTheCoreRuleSetInspectsEachWorstCaseRequestInTime in internal/coreruleset/inspectiontime_test.go. It times inspections.
  • TestQueriesGoToTheResolverSWWDNSBLResolverNames in internal/reputation/dnsbl_test.go. The comment at the top of that file gives the reason.
  • TestASwitchNotPassedOnClosesTheAppsConnection in internal/rproxy/rproxy_test.go. Garbage collection started by other tests would hide a connection left open.

To build

  • For each of the six, make it parallel if that can be done without weakening what it checks. Change a test, never the code it tests, unless the code change is a few plain lines.
  • A test that must stay one at a time keeps a one-line comment that says why.
  • Look for tests, subtests and loops over cases that the scan above missed, and treat them the same way.
  • Add no setting, no script and no new check of the tree. The linter already holds the line.

Done when

  • Every test that can be parallel is, and each that is not says why in one line.
  • No test checks less than it did.
  • make check passes.

Not checked

The six come from a text scan of the test files, not from the linter. A subtest that does not call t.Parallel() inside a parallel test would not show in it.

Model: fable-5-2

Split from https://git.eeqj.de/sneak/smallwebwaf/issues/401. Third of three. Start only once https://git.eeqj.de/sneak/smallwebwaf/issues/405 (`waf` decides in parallel) is merged into `next`. Both change test files, and https://git.eeqj.de/sneak/smallwebwaf/issues/401#issuecomment-182199 put them in this order. ## What sneak asked for As many tests as possible run in parallel, in goroutines (reworded from https://git.eeqj.de/sneak/smallwebwaf/pulls/403#issuecomment-182172). ## Where the code is today Nearly there. Of about 850 tests, all but six call `t.Parallel()` or are inside `testing/synctest`. The `paralleltest` linter already fails a test that does neither without a stated reason. `go test` gives each package a process of its own, and the two test passes in the `Dockerfile` are built at the same time. The six that go one at a time, each with its reason in a comment: - `TestTokenSetEmptyInTheEnvironmentStopsTheStart` and `TestListSetEmptyInTheEnvironmentReplacesItsDefault` in `internal/config/viper_test.go`. They set environment variables, which Go forbids in a parallel test. - `TestCorazaWritesNoFile` in `internal/coreruleset/coreruleset_test.go`. It sets `TMPDIR` for the whole test process. - `TestTheCoreRuleSetInspectsEachWorstCaseRequestInTime` in `internal/coreruleset/inspectiontime_test.go`. It times inspections. - `TestQueriesGoToTheResolverSWWDNSBLResolverNames` in `internal/reputation/dnsbl_test.go`. The comment at the top of that file gives the reason. - `TestASwitchNotPassedOnClosesTheAppsConnection` in `internal/rproxy/rproxy_test.go`. Garbage collection started by other tests would hide a connection left open. ## To build - For each of the six, make it parallel if that can be done without weakening what it checks. Change a test, never the code it tests, unless the code change is a few plain lines. - A test that must stay one at a time keeps a one-line comment that says why. - Look for tests, subtests and loops over cases that the scan above missed, and treat them the same way. - Add no setting, no script and no new check of the tree. The linter already holds the line. ## Done when - Every test that can be parallel is, and each that is not says why in one line. - No test checks less than it did. - `make check` passes. ## Not checked The six come from a text scan of the test files, not from the linter. A subtest that does not call `t.Parallel()` inside a parallel test would not show in it. Model: fable-5-2
clawbot added the needs-decision label 2026-11-17 00:02:11 +01:00
Author
Collaborator

Waits on #405, which this issue says must merge into next first; it is still open with no PR.

Model: opus-5-5

Waits on https://git.eeqj.de/sneak/smallwebwaf/issues/405, which this issue says must merge into `next` first; it is still open with no PR. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sneak/smallwebwaf#406