From 5099448f79a287fa633be238236d8abce16a4836 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Thu, 19 Nov 2026 11:43:01 +0100 Subject: [PATCH] Keep the sww and rproxy tests from failing on a busy host (closes #420) The rproxy package's tests and sww's startRProxyProcess give rproxy a minute for waf's answers unless a test sets SWW_RPROXY_WAF_BACKEND_TIMEOUT_MS. At the 2-second default, a slow host made rproxy drop questions and reports. TestMainRunsWAF runs waf with the Core Rule Set off. Main keeps waf's 500 ms limit for its checks, and under the race detector the Core Rule Set's inspection could pass it and get 503. Model: opus-5-5 --- internal/rproxy/rproxy_test.go | 4 +++- internal/sww/rproxy_test.go | 7 +++++-- internal/sww/waf_test.go | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/rproxy/rproxy_test.go b/internal/rproxy/rproxy_test.go index d45e5f6..74e8eae 100644 --- a/internal/rproxy/rproxy_test.go +++ b/internal/rproxy/rproxy_test.go @@ -324,7 +324,8 @@ func greet(w http.ResponseWriter, r *http.Request) { // startRProxy starts rproxy with waf at backend and the app at appURL, and // the settings in env on top of the defaults. It returns where rproxy listens -// and what it writes. +// and what it writes. SWW_RPROXY_WAF_BACKEND_TIMEOUT_MS is a minute unless env +// sets it, so that a busy host cannot make rproxy drop a question or a report. func startRProxy( t *testing.T, backend, appURL string, env map[string]string, ) (string, *output) { @@ -357,6 +358,7 @@ func startServerLogging( settings := map[string]string{ "SWW_RPROXY_WAF_BACKEND": backend, "SWW_RPROXY_UPSTREAM_URL": appURL, + wafBackendTimeout: "60000", } maps.Copy(settings, env) diff --git a/internal/sww/rproxy_test.go b/internal/sww/rproxy_test.go index 00b154b..8d54d66 100644 --- a/internal/sww/rproxy_test.go +++ b/internal/sww/rproxy_test.go @@ -552,7 +552,9 @@ func TestAStatusWAFDoesNotTakeIsReportedAs599(t *testing.T) { // startRProxyProcess runs `sww rproxy` in a process of its own, with the // settings in env, each as NAME=value. It returns where rproxy listens and a // function that sends rproxy SIGTERM and fails the test unless it exits with -// status 0 within waitLimit. +// status 0 within waitLimit. It waits a minute for waf's answers unless env +// sets SWW_RPROXY_WAF_BACKEND_TIMEOUT_MS, so that a busy host cannot make it +// drop a question. func startRProxyProcess(t *testing.T, env ...string) (string, func()) { t.Helper() @@ -568,7 +570,8 @@ func startRProxyProcess(t *testing.T, env ...string) (string, func()) { cmd.Env = append(os.Environ(), commandForMain+"=rproxy", - "SWW_RPROXY_LISTEN_ADDR="+localhost+":0") + "SWW_RPROXY_LISTEN_ADDR="+localhost+":0", + wafBackendTimeout+"=60000") cmd.Env = append(cmd.Env, env...) exited := startProcess(t, cmd) diff --git a/internal/sww/waf_test.go b/internal/sww/waf_test.go index ab825cf..8ad703c 100644 --- a/internal/sww/waf_test.go +++ b/internal/sww/waf_test.go @@ -90,6 +90,8 @@ func TestMainRunsWAF(t *testing.T) { cmd := exec.CommandContext(t.Context(), binary) cmd.Stdout = out + // The Core Rule Set is off. Main keeps waf's own limit for its checks, + // and on a busy host the Core Rule Set's inspection can pass it. cmd.Env = append(os.Environ(), "TZ="+zone, commandForMain+"="+wafCommand, @@ -97,7 +99,8 @@ func TestMainRunsWAF(t *testing.T) { stateDir+"="+dir, cacheDir+"="+dir, ruleFilesDir+"="+t.TempDir(), - lookupSource+"=off") + lookupSource+"=off", + "SWW_WAF_CORE_RULE_SET_MODE=off") exited := startProcess(t, cmd)