rproxy, sww: keep the breaker and stop tests from failing under load (closes #474)
check / check (push) Failing after 2m10s
check / check (push) Failing after 2m10s
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
This commit was merged in pull request #475.
This commit is contained in:
1 parent
98d7432077
commit
aaa28f541b
5 files changed
+44
-17
No files matched your search
@@ -10,7 +10,6 @@ import (
|
||||
"maps"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"sneak.berlin/go/smallwebwaf/internal/waf"
|
||||
)
|
||||
@@ -97,7 +96,7 @@ func (rq *request) askUnlessBreakerOpen(
|
||||
ctx context.Context,
|
||||
) (*wafAnswer, error) {
|
||||
b := &rq.h.breaker
|
||||
if !b.mayAsk(time.Now()) {
|
||||
if !b.mayAsk(rq.h.breakerClock()) {
|
||||
return nil, errBreakerOpen
|
||||
}
|
||||
|
||||
@@ -107,7 +106,7 @@ func (rq *request) askUnlessBreakerOpen(
|
||||
case err == nil:
|
||||
b.noteAnswer()
|
||||
case ctx.Err() == nil:
|
||||
b.noteFailure(time.Now())
|
||||
b.noteFailure(rq.h.breakerClock())
|
||||
}
|
||||
|
||||
return answer, err
|
||||
|
||||
Reference in new issue
Block a user