reverseproxy: align trailer tests with consumed-stream retry safety

Follow up report de1bcf6d-457c-4348-9d4e-5eeb41cc120b. Expect one transport attempt for consumed partial streams while keeping unread dial retries and fully buffered trailer replay covered.

Validated the entire reverseproxy package with offline race-short tests in a loopback-only network namespace.

Code written by GitHub Copilot (GPT-6.1 Sol, Claude Opus 5.5); reviewed by mholt.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Matthew Holt 2026-11-10 19:08:14 -07:00
parent d52d097109
commit 2ee6bdf837

View file

@ -349,10 +349,7 @@ func TestRequestTrailersRetry(t *testing.T) {
return nil, err
}
if tc.partial {
_, err := io.ReadAll(r.Body)
if err == nil {
t.Error("partially consumed request body became replayable")
}
t.Error("partially consumed request body was retried")
return nil, errors.New("consumed body is not replayable")
}
return transport.RoundTrip(r)
@ -367,8 +364,14 @@ func TestRequestTrailersRetry(t *testing.T) {
req = req.WithContext(ctx)
rec := httptest.NewRecorder()
err := h.ServeHTTP(rec, req, nil)
if attempts != 2 {
t.Fatalf("attempts=%d, want 2", attempts)
wantAttempts := 2
if tc.partial {
// Consumed streams must stop before another transport attempt;
// unread dial failures and fully buffered bodies remain replayable.
wantAttempts = 1
}
if attempts != wantAttempts {
t.Fatalf("attempts=%d, want %d", attempts, wantAttempts)
}
if tc.partial {
if err == nil {