rproxy, sww: keep the breaker and stop tests from failing under load (closes #474) #475

Merged
clawbot merged 1 commits from issue-474-breaker-and-stop-tests-under-load into next 2026-11-19 19:59:34 +01:00
Collaborator

Closes #474

  • internal/rproxy: the handler gives the circuit breaker the time through a breakerClock field, time.Now in production. TestAnswersThatCannotBePassedOnOpenTheBreaker stops that clock before the server serves, through StopBreakerClock in export_test.go. Its five failures then fall inside the five-second window, and the next request comes within the one-second interval, however slow the host. The window and interval stay covered by the clock-driven tests in breaker_test.go.
  • startServerLogging is split into newServer and serve, so a test can change the server before it serves without a data race.
  • internal/sww: TestRProxyStoppingCutsOffARequestAfterFiveSeconds sets its read deadline to the stop plus five seconds plus waitLimit. sendAndKeepOpen no longer sets a deadline; this test was its only caller.

Disclosure: TestFiveFailedAsksKeepTheNextRequestFromAskingWAF still reads the real clock, so a slow enough host can fail it the same way. The issue does not name it, so it is unchanged; StopBreakerClock would fix it in two lines.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/474 - `internal/rproxy`: the handler gives the circuit breaker the time through a `breakerClock` field, `time.Now` in production. `TestAnswersThatCannotBePassedOnOpenTheBreaker` stops that clock before the server serves, through `StopBreakerClock` in `export_test.go`. Its five failures then fall inside the five-second window, and the next request comes within the one-second interval, however slow the host. The window and interval stay covered by the clock-driven tests in `breaker_test.go`. - `startServerLogging` is split into `newServer` and `serve`, so a test can change the server before it serves without a data race. - `internal/sww`: `TestRProxyStoppingCutsOffARequestAfterFiveSeconds` sets its read deadline to the stop plus five seconds plus `waitLimit`. `sendAndKeepOpen` no longer sets a deadline; this test was its only caller. Disclosure: `TestFiveFailedAsksKeepTheNextRequestFromAskingWAF` still reads the real clock, so a slow enough host can fail it the same way. The issue does not name it, so it is unchanged; `StopBreakerClock` would fix it in two lines. Model: opus-5-5
clawbot added the needs-review label 2026-11-19 19:36:56 +01:00
clawbot self-assigned this 2026-11-19 19:36:56 +01:00
clawbot added 1 commit 2026-11-19 19:36:56 +01:00
The circuit breaker reads the time through a clock the handler holds,
which is time.Now outside tests. The test that answers waf's
questions with answers rproxy cannot pass on stops that clock, so how
long its requests take on a slow host no longer decides whether the
breaker opens or turns the next request away.

The test that stops rproxy mid-request sets its read deadline from the
stop, not from the send, so a slow wait for the app no longer shortens
it.

Model: opus-5-5
Author
Collaborator

Verdict: PASS
Head: 123f34679f

The circuit breaker test and the five-second stop test no longer depend on host speed and still catch the behaviour they check, which meets #474.

  • Judgement call: TestFiveFailedAsksKeepTheNextRequestFromAskingWAF can still fail on a slow host, as the PR body says. The issue names only two tests, so this is not a finding here; that test needs its own issue.

Model: opus-5-5

Verdict: PASS Head: 123f34679fdbc3b141881b1728ac50d0315dd71d The circuit breaker test and the five-second stop test no longer depend on host speed and still catch the behaviour they check, which meets https://git.eeqj.de/sneak/smallwebwaf/issues/474. - Judgement call: `TestFiveFailedAsksKeepTheNextRequestFromAskingWAF` can still fail on a slow host, as the PR body says. The issue names only two tests, so this is not a finding here; that test needs its own issue. Model: opus-5-5
clawbot merged commit aaa28f541b into next 2026-11-19 19:59:34 +01:00
Sign in to join this conversation.