From 5583a4a8b933ae842ee97de5f85e3e7ab097d9d2 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Sun, 4 Oct 2026 05:17:09 +0000 Subject: [PATCH] Proxy timing tests outlast a hold-up of the test process (closes #53) smallwebwaf starts each timeout as the request arrives, before the step a test needs first: the upgrade answered, the app's buffers full, the first part of an answer passed on. A hold-up of the test process longer than the 300 ms timeout ran it out before that step. No test can make that step come first, and in the "waiting on the app" cases it cannot see which side smallwebwaf was waiting on, so the timeout is now 5 s, the hold-up wantTimedOut already allows. The timeout tests set when it must not run out goes from 10 s to 1 m to stay clear of it. The upgrade test waits 7.5 s past the upgrade. Judgement call: one shared value; the proxy tests take about 8 s, not 2 s. Model: opus-5-5 --- internal/proxy/passthrough_test.go | 5 +++-- internal/proxy/proxy_test.go | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/proxy/passthrough_test.go b/internal/proxy/passthrough_test.go index c788d1f..8f644bb 100644 --- a/internal/proxy/passthrough_test.go +++ b/internal/proxy/passthrough_test.go @@ -246,8 +246,9 @@ func TestUpgradedConnectionOutlastsTheTimeouts(t *testing.T) { t.Fatalf("status %d, want %d", res.StatusCode, http.StatusSwitchingProtocols) } - // Wait past every timeout, then use the connection. - time.Sleep(3 * shortTimeout) + // Every timeout started before the upgrade was answered: wait past + // them all, then use the connection. + time.Sleep(3 * shortTimeout / 2) send(t, conn, "still here\n") echoed, err := reader.ReadString('\n') diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index 7b4ebab..c6aefe1 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -21,11 +21,15 @@ import ( const ( // shortTimeout is what a test sets a timeout to, to see it run out. - shortTimeout = 300 * time.Millisecond + // It starts before the test has set up its case, such as an upgrade + // or the app's buffers filling, so it is as long as the hold-up of the + // test process that wantTimedOut allows, waitLimit/2: a shorter one + // can run out first on a busy host. + shortTimeout = 5 * time.Second // shortTimeoutSetting is shortTimeout as a setting's value. - shortTimeoutSetting = "300ms" + shortTimeoutSetting = "5s" // longTimeoutSetting is a timeout that does not run out in a test. - longTimeoutSetting = "10s" + longTimeoutSetting = "1m" // waitLimit bounds how long a test waits for what should happen. waitLimit = 10 * time.Second // pollInterval is how often a test looks for a log line.