Skip to content

Commit e07a267

Browse files
committed
caddytest: Revise sleep durations
Attempt to reduce flakiness a bit more Test suite needs to be rewritten.
1 parent e4fac12 commit e07a267

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

caddytest/caddytest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (tc *Tester) ensureConfigRunning(rawConfig string, configType string) error
214214
return actual
215215
}
216216

217-
for retries := 4; retries > 0; retries-- {
217+
for retries := 10; retries > 0; retries-- {
218218
if reflect.DeepEqual(expected, fetchConfig(client)) {
219219
return nil
220220
}
@@ -243,7 +243,7 @@ func validateTestPrerequisites() error {
243243
}()
244244

245245
// wait for caddy to start serving the initial config
246-
for retries := 4; retries > 0 && isCaddyAdminRunning() != nil; retries-- {
246+
for retries := 10; retries > 0 && isCaddyAdminRunning() != nil; retries-- {
247247
time.Sleep(10 * time.Millisecond)
248248
}
249249
}

caddytest/integration/reverseproxy_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"runtime"
99
"strings"
1010
"testing"
11+
"time"
1112

1213
"github.com/caddyserver/caddy/v2/caddytest"
1314
)
@@ -441,6 +442,7 @@ func TestReverseProxyHealthCheck(t *testing.T) {
441442
}
442443
`, "caddyfile")
443444

445+
time.Sleep(100 * time.Millisecond) // TODO: for some reason this test seems particularly flaky, getting 503 when it should be 200, unless we wait
444446
tester.AssertGetResponse("http://localhost:9080/", 200, "Hello, World!")
445447
}
446448

modules/caddyhttp/reverseproxy/fastcgi/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
171171

172172
log.Println("c: send data length ≈", length, string(content))
173173
conn.Close()
174-
time.Sleep(1 * time.Second)
174+
time.Sleep(250 * time.Millisecond)
175175

176176
if bytes.Contains(content, []byte("FAILED")) {
177177
globalt.Error("Server return failed message")
@@ -230,7 +230,7 @@ func DisabledTest(t *testing.T) {
230230
}
231231
}()
232232

233-
time.Sleep(1 * time.Second)
233+
time.Sleep(250 * time.Millisecond)
234234

235235
// init
236236
fcgiParams := make(map[string]string)

0 commit comments

Comments
 (0)