From e07a267276b9c00181c979ec65f26e25b8325beb Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 5 Oct 2022 11:40:41 -0600 Subject: [PATCH] caddytest: Revise sleep durations Attempt to reduce flakiness a bit more Test suite needs to be rewritten. --- caddytest/caddytest.go | 4 ++-- caddytest/integration/reverseproxy_test.go | 2 ++ modules/caddyhttp/reverseproxy/fastcgi/client_test.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/caddytest/caddytest.go b/caddytest/caddytest.go index 2ffd313c..ca10fab7 100644 --- a/caddytest/caddytest.go +++ b/caddytest/caddytest.go @@ -214,7 +214,7 @@ func (tc *Tester) ensureConfigRunning(rawConfig string, configType string) error return actual } - for retries := 4; retries > 0; retries-- { + for retries := 10; retries > 0; retries-- { if reflect.DeepEqual(expected, fetchConfig(client)) { return nil } @@ -243,7 +243,7 @@ func validateTestPrerequisites() error { }() // wait for caddy to start serving the initial config - for retries := 4; retries > 0 && isCaddyAdminRunning() != nil; retries-- { + for retries := 10; retries > 0 && isCaddyAdminRunning() != nil; retries-- { time.Sleep(10 * time.Millisecond) } } diff --git a/caddytest/integration/reverseproxy_test.go b/caddytest/integration/reverseproxy_test.go index 81aec714..049c7fd2 100644 --- a/caddytest/integration/reverseproxy_test.go +++ b/caddytest/integration/reverseproxy_test.go @@ -8,6 +8,7 @@ import ( "runtime" "strings" "testing" + "time" "github.com/caddyserver/caddy/v2/caddytest" ) @@ -441,6 +442,7 @@ func TestReverseProxyHealthCheck(t *testing.T) { } `, "caddyfile") + time.Sleep(100 * time.Millisecond) // TODO: for some reason this test seems particularly flaky, getting 503 when it should be 200, unless we wait tester.AssertGetResponse("http://localhost:9080/", 200, "Hello, World!") } diff --git a/modules/caddyhttp/reverseproxy/fastcgi/client_test.go b/modules/caddyhttp/reverseproxy/fastcgi/client_test.go index 78e5713a..29bb5785 100644 --- a/modules/caddyhttp/reverseproxy/fastcgi/client_test.go +++ b/modules/caddyhttp/reverseproxy/fastcgi/client_test.go @@ -171,7 +171,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[ log.Println("c: send data length ≈", length, string(content)) conn.Close() - time.Sleep(1 * time.Second) + time.Sleep(250 * time.Millisecond) if bytes.Contains(content, []byte("FAILED")) { globalt.Error("Server return failed message") @@ -230,7 +230,7 @@ func DisabledTest(t *testing.T) { } }() - time.Sleep(1 * time.Second) + time.Sleep(250 * time.Millisecond) // init fcgiParams := make(map[string]string)