sww tests: wait for every starting line as long as the start takes (closes #331) #340

Merged
clawbot merged 1 commits from issue-331-starting-wait-until-exit into next 2026-11-11 10:56:47 +01:00
Collaborator

Every wait for the starting line in internal/sww now uses output.lineBeforeExit: it waits until the line is written or sww exits. A slow Core Rule Set compile on a loaded host no longer fails these tests.

  • TestMainRunsWAF and startRProxyProcess run sww as a child process. A goroutine now waits on it and sends its exit status on a channel. They no longer kill sww after 30 seconds. Both start it with startProcess, whose cleanup still kills sww as the test ends and waits for it to exit.
  • startRProxyProcess returns a stop function, as startWAF does, in place of the process and its output. The stop sends SIGTERM and fails the test unless sww exits with status 0 within waitLimit.
  • startRProxy registers its stop cleanup after the wait. If sww exits before writing the line, the cleanup does not wait waitLimit for an exit status already read.

Disclosure: TestRProxyProcessLinesNameTheHostAndComeAtInfo keeps out.line for starting. startRProxy has already waited for that line, so the call returns at once.

Closes #331

Model: opus-5-5

Every wait for the `starting` line in `internal/sww` now uses `output.lineBeforeExit`: it waits until the line is written or sww exits. A slow Core Rule Set compile on a loaded host no longer fails these tests. - `TestMainRunsWAF` and `startRProxyProcess` run sww as a child process. A goroutine now waits on it and sends its exit status on a channel. They no longer kill sww after 30 seconds. Both start it with `startProcess`, whose cleanup still kills sww as the test ends and waits for it to exit. - `startRProxyProcess` returns a stop function, as `startWAF` does, in place of the process and its output. The stop sends SIGTERM and fails the test unless sww exits with status 0 within `waitLimit`. - `startRProxy` registers its stop cleanup after the wait. If sww exits before writing the line, the cleanup does not wait `waitLimit` for an exit status already read. Disclosure: `TestRProxyProcessLinesNameTheHostAndComeAtInfo` keeps `out.line` for `starting`. `startRProxy` has already waited for that line, so the call returns at once. Closes https://git.eeqj.de/sneak/smallwebwaf/issues/331 Model: opus-5-5
clawbot added the needs-review label 2026-11-11 08:00:32 +01:00
clawbot self-assigned this 2026-11-11 08:00:32 +01:00
Author
Collaborator

FAIL (needs-rework)

  1. internal/sww/waf_test.go (TestMainRunsWAF) and internal/sww/rproxy_test.go (startRProxyProcess): the t.Cleanup that killed the sww child process and waited for it is removed, and nothing replaces it. A child the test does not stop is killed only after the test has ended, by the test's context, and nothing waits for it to exit. When TestMainRunsWAF fails in ask or in its stop wait, nothing makes sure sww has exited before its t.TempDir state directory is removed. TestRProxyAsksAWAFThatSpeaksHTTP2OverHTTP1 discards the stop function, so the test never stops its rproxy process. Acceptable: every child is killed and waited for before its test ends, as before. For example, the goroutine closes a channel once Wait returns, and a t.Cleanup registered right after Start kills the process and receives from that channel.
  2. internal/sww/rproxy_test.go, the doc comment of startRProxyProcess: "what stops it as SIGTERM does" says the function acts like SIGTERM, but it sends SIGTERM. Acceptable: it returns where rproxy listens and a function that sends rproxy SIGTERM and fails the test unless it exits with status 0 within waitLimit.

Judgement call: the out.line for starting left in TestRProxyProcessLinesNameTheHostAndComeAtInfo is accepted, since startRProxy has already waited for that line.

Model: opus-5-5

**FAIL** (`needs-rework`) 1. `internal/sww/waf_test.go` (`TestMainRunsWAF`) and `internal/sww/rproxy_test.go` (`startRProxyProcess`): the `t.Cleanup` that killed the sww child process and waited for it is removed, and nothing replaces it. A child the test does not stop is killed only after the test has ended, by the test's context, and nothing waits for it to exit. When `TestMainRunsWAF` fails in `ask` or in its stop wait, nothing makes sure sww has exited before its `t.TempDir` state directory is removed. `TestRProxyAsksAWAFThatSpeaksHTTP2OverHTTP1` discards the stop function, so the test never stops its rproxy process. Acceptable: every child is killed and waited for before its test ends, as before. For example, the goroutine closes a channel once `Wait` returns, and a `t.Cleanup` registered right after `Start` kills the process and receives from that channel. 2. `internal/sww/rproxy_test.go`, the doc comment of `startRProxyProcess`: "what stops it as SIGTERM does" says the function acts like SIGTERM, but it sends SIGTERM. Acceptable: it returns where rproxy listens and a function that sends rproxy SIGTERM and fails the test unless it exits with status 0 within `waitLimit`. Judgement call: the `out.line` for `starting` left in `TestRProxyProcessLinesNameTheHostAndComeAtInfo` is accepted, since `startRProxy` has already waited for that line. Model: opus-5-5
Author
Collaborator

For the reworker. Fix the two findings of #340 (comment) as their "Acceptable" lines say:

  1. Every sww child process in internal/sww/waf_test.go and internal/sww/rproxy_test.go is killed and waited for before its test ends, as before this PR: for example the goroutine that calls Wait closes a channel when it returns, and a t.Cleanup registered right after Start kills the process and receives from that channel. TestRProxyAsksAWAFThatSpeaksHTTP2OverHTTP1 is covered by that cleanup.
  2. The doc comment of startRProxyProcess: it returns where rproxy listens and a function that sends rproxy SIGTERM and fails the test unless it exits with status 0 within waitLimit.

Rebase onto current next first. Change nothing else. Follow AGENTS.md: checks only through make targets. make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. git push --force-with-lease, label needs-review, reply one line per finding.

For the next reviewer: the two findings against the diff from the head reviewed at #340 (comment), and make check on the head. Fail only for one of these or for a bug the rework introduces.

Model: opus-5-5

**For the reworker.** Fix the two findings of https://git.eeqj.de/sneak/smallwebwaf/pulls/340#issuecomment-178065 as their "Acceptable" lines say: 1. Every sww child process in `internal/sww/waf_test.go` and `internal/sww/rproxy_test.go` is killed and waited for before its test ends, as before this PR: for example the goroutine that calls `Wait` closes a channel when it returns, and a `t.Cleanup` registered right after `Start` kills the process and receives from that channel. `TestRProxyAsksAWAFThatSpeaksHTTP2OverHTTP1` is covered by that cleanup. 2. The doc comment of `startRProxyProcess`: it returns where rproxy listens and a function that sends rproxy SIGTERM and fails the test unless it exits with status 0 within `waitLimit`. Rebase onto current `next` first. Change nothing else. Follow `AGENTS.md`: checks only through `make` targets. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. `git push --force-with-lease`, label `needs-review`, reply one line per finding. **For the next reviewer:** the two findings against the diff from the head reviewed at https://git.eeqj.de/sneak/smallwebwaf/pulls/340#issuecomment-178065, and `make check` on the head. Fail only for one of these or for a bug the rework introduces. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-11 08:27:49 +01:00
clawbot added 1 commit 2026-11-11 08:42:12 +01:00
Each test in internal/sww that waits for the starting line now waits until
the line is written or sww exits, so a slow Core Rule Set compile on a
loaded host no longer fails it. The two tests that run sww as a child
process get its exit status from a goroutine that waits on it, and no
longer kill it after 30 seconds; the waits after SIGTERM still end after
waitLimit. A cleanup still kills each child process as its test ends and
waits for it to exit. startRProxyProcess returns a stop function in place
of the process and its output.

Model: opus-5-5
clawbot force-pushed issue-331-starting-wait-until-exit from 08b05907a5 to 1740ac6061 2026-11-11 08:42:12 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-11-11 08:42:33 +01:00
Author
Collaborator
  1. Fixed: TestMainRunsWAF and startRProxyProcess start sww with the new startProcess, whose goroutine closes a channel once Wait returns and whose t.Cleanup, registered right after Start, kills sww and receives from that channel.
  2. Fixed with the wording of the Acceptable line.

Deviation: startProcess is one helper for both, not inline code, because the inline cleanup took TestMainRunsWAF past the 80-line funlen limit.

Model: opus-5-5

1. Fixed: `TestMainRunsWAF` and `startRProxyProcess` start sww with the new `startProcess`, whose goroutine closes a channel once `Wait` returns and whose `t.Cleanup`, registered right after `Start`, kills sww and receives from that channel. 2. Fixed with the wording of the Acceptable line. Deviation: `startProcess` is one helper for both, not inline code, because the inline cleanup took `TestMainRunsWAF` past the 80-line `funlen` limit. Model: opus-5-5
Author
Collaborator

PASS: the earlier review's two findings are fixed, and every wait for the starting line in internal/sww now lasts until sww writes it or exits, as the issue's definition of done asks.

Model: opus-5-5

**PASS**: the earlier review's two findings are fixed, and every wait for the `starting` line in `internal/sww` now lasts until sww writes it or exits, as the issue's definition of done asks. Model: opus-5-5
clawbot merged commit 1748a670f9 into next 2026-11-11 10:56:47 +01:00
clawbot deleted branch issue-331-starting-wait-until-exit 2026-11-11 10:56:47 +01:00
Sign in to join this conversation.