rproxy: breaker test no longer needs each failed ask to reach waf (closes #398)
check / check (push) Failing after 2m0s
check / check (push) Failing after 2m0s
TestFiveFailedAsksKeepTheNextRequestFromAskingWAF waited for a question from each of the five failing asks. Under load an ask could time out before the stand-in for waf saw it, and the test failed with "no question". It now waits only for each visitor's answer. It checks that the sixth request did not ask by its request ID, which the app records, so late questions from the failed asks cannot be mistaken for it. Model: opus-5-5
This commit is contained in:
1 parent
0a2b2d809f
commit
b4363206d2
1 file changed
+22
-4
@@ -1424,7 +1424,14 @@ func TestFiveFailedAsksKeepTheNextRequestFromAskingWAF(t *testing.T) {
|
|||||||
failure(w, r)
|
failure(w, r)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
app := startApp(t, greet)
|
nextID := make(chan string, 1)
|
||||||
|
app := startApp(t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if answering.Load() {
|
||||||
|
nextID <- r.Header.Get(requestIDHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
greet(w, r)
|
||||||
|
})
|
||||||
addr, out := startRProxy(
|
addr, out := startRProxy(
|
||||||
t,
|
t,
|
||||||
standIn.URL,
|
standIn.URL,
|
||||||
@@ -1434,19 +1441,30 @@ func TestFiveFailedAsksKeepTheNextRequestFromAskingWAF(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// An ask can time out before it reaches the stand-in, so these
|
||||||
|
// may leave fewer than five questions, or leave some late.
|
||||||
for range 5 {
|
for range 5 {
|
||||||
wantGreeting(t, get(t, addr, "/"))
|
wantGreeting(t, get(t, addr, "/"))
|
||||||
standIn.question(t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
answering.Store(true)
|
answering.Store(true)
|
||||||
wantGreeting(t, get(t, addr, "/"))
|
wantGreeting(t, get(t, addr, "/"))
|
||||||
out.waitFor(t, "the circuit breaker is open")
|
out.waitFor(t, "the circuit breaker is open")
|
||||||
|
|
||||||
|
// Had the next request asked waf, its question would have reached
|
||||||
|
// the stand-in before the request reached the app.
|
||||||
|
var id string
|
||||||
select {
|
select {
|
||||||
case <-standIn.questions:
|
case id = <-nextID:
|
||||||
|
default:
|
||||||
|
t.Fatal("the app did not get the next request")
|
||||||
|
}
|
||||||
|
|
||||||
|
for len(standIn.questions) > 0 {
|
||||||
|
asked := <-standIn.questions
|
||||||
|
if asked.header.Get(requestIDHeader) == id {
|
||||||
t.Error("waf was asked, want it not to be")
|
t.Error("waf was asked, want it not to be")
|
||||||
case <-time.After(10 * pollInterval):
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user