rproxy tests: leave room for a busy host in five timing tests (closes #451)
check / check (push) Waiting to run
check / check (push) Waiting to run
Three tests that wait out a 2- or 3-second request time limit now use 5 seconds, so the request reaches the app before it runs out under load. The WebSocket test also uses 5-second limits, and renews its connection's deadline after the wait. TestFiveFailedAsksKeepTheNextRequestFromAskingWAF stops the breaker's clock like TestAnswersThatCannotBePassedOnOpenTheBreaker. Model: opus-5-5
This commit is contained in:
1 parent
419ee1c441
commit
bfdf17126c
2 files changed
+34
-14
No files matched your search
@@ -870,10 +870,14 @@ func TestAnAnswerRProxyGivesItselfHasTenSecondsToBeSentAtLeast(
|
||||
func TestAVisitorTooSlowToSendTheRestIsAnswered408(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// rproxy is waiting for the rest of the body well within this limit, even on
|
||||
// a busy host, and answers when it runs out, well before dial's deadline.
|
||||
const limit = 5 * time.Second
|
||||
|
||||
standIn := startWAF(t, allow)
|
||||
app := startApp(t, greet)
|
||||
addr, _ := startRProxy(t, standIn.URL, app.URL, map[string]string{
|
||||
maxRequestTime: "3000",
|
||||
maxRequestTime: strconv.FormatInt(limit.Milliseconds(), 10),
|
||||
})
|
||||
|
||||
conn := dial(t, addr)
|
||||
@@ -1262,7 +1266,9 @@ func TestAVisitorThatStopsALittleShortIsReadUntilTheRequestTimeLimit(
|
||||
) {
|
||||
t.Parallel()
|
||||
|
||||
const limit = 2 * time.Second
|
||||
// The app's answer arrives well within this limit, even on a busy host, and
|
||||
// the connection closes when it runs out, well before dial's deadline.
|
||||
const limit = 5 * time.Second
|
||||
|
||||
standIn := startWAF(t, allow)
|
||||
app := startApp(t, answerBeforeTheBody)
|
||||
@@ -1427,17 +1433,20 @@ func TestTheRequestTimeLimitDoesNotCutAnAnswerOnceTheAppHasTheRequest(
|
||||
|
||||
const answer = "the end of a long answer"
|
||||
|
||||
// The request reaches the app well within this limit, even on a busy host.
|
||||
const limit = 5 * time.Second
|
||||
|
||||
standIn := startWAF(t, allow)
|
||||
app := startApp(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = io.Copy(io.Discard, r.Body)
|
||||
_ = http.NewResponseController(w).Flush()
|
||||
|
||||
time.Sleep(2100 * time.Millisecond)
|
||||
time.Sleep(limit + 100*time.Millisecond)
|
||||
|
||||
_, _ = io.WriteString(w, answer)
|
||||
})
|
||||
addr, _ := startRProxy(t, standIn.URL, app.URL, map[string]string{
|
||||
maxRequestTime: "2000",
|
||||
maxRequestTime: strconv.FormatInt(limit.Milliseconds(), 10),
|
||||
})
|
||||
|
||||
got := visit(
|
||||
|
||||
@@ -1452,14 +1452,18 @@ func TestFiveFailedAsksKeepTheNextRequestFromAskingWAF(t *testing.T) {
|
||||
|
||||
greet(w, r)
|
||||
})
|
||||
addr, out := startRProxy(
|
||||
t,
|
||||
standIn.URL,
|
||||
app.URL,
|
||||
map[string]string{
|
||||
wafBackendTimeout: "200",
|
||||
},
|
||||
out := &output{}
|
||||
server := newServer(
|
||||
t, standIn.URL, app.URL,
|
||||
map[string]string{wafBackendTimeout: "200"},
|
||||
out, out,
|
||||
)
|
||||
// The breaker's clock stands still, as in
|
||||
// TestAnswersThatCannotBePassedOnOpenTheBreaker: on a slow host, the five
|
||||
// failures could take more than five seconds, and the next request could
|
||||
// come more than a second later.
|
||||
server.StopBreakerClock(time.Now())
|
||||
addr := serve(t, server)
|
||||
|
||||
// An ask can time out before it reaches the stand-in, so these
|
||||
// may leave fewer than five questions, or leave some late.
|
||||
@@ -1831,11 +1835,15 @@ func TestWaitForReportsWaitsForAReportBeingSent(t *testing.T) {
|
||||
func TestReportOfAWebSocketCountsWhatItCarried(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// The app's answer to the upgrade arrives well within these limits, even on a
|
||||
// busy host.
|
||||
const limit = 5 * time.Second
|
||||
|
||||
standIn := startWAF(t, allow)
|
||||
app := startApp(t, echoAfterUpgrade)
|
||||
addr, out := startRProxy(t, standIn.URL, app.URL, map[string]string{
|
||||
maxRequestTime: "2000",
|
||||
maxResponseTime: "2000",
|
||||
maxRequestTime: strconv.FormatInt(limit.Milliseconds(), 10),
|
||||
maxResponseTime: strconv.FormatInt(limit.Milliseconds(), 10),
|
||||
})
|
||||
|
||||
conn := dial(t, addr)
|
||||
@@ -1860,7 +1868,10 @@ func TestReportOfAWebSocketCountsWhatItCarried(t *testing.T) {
|
||||
}
|
||||
|
||||
// Past both time limits, the connection still carries what is sent.
|
||||
time.Sleep(2100 * time.Millisecond)
|
||||
time.Sleep(limit + 100*time.Millisecond)
|
||||
|
||||
// dial's deadline ran from before the upgrade and this wait.
|
||||
_ = conn.SetDeadline(time.Now().Add(waitLimit))
|
||||
|
||||
const message = "still here\n"
|
||||
|
||||
|
||||
Reference in new issue
Block a user