From 8815e60a36544b39bb57d5c0ca5fe53e54cdc0e4 Mon Sep 17 00:00:00 2001 From: Herman Slatman Date: Thu, 3 Apr 2025 13:36:06 +0200 Subject: [PATCH] Fix flaky client timeout test It looks like the server sleep wasn't always enough to trigger the timeout of the `fail with timeout` test. The server sleep has been increased, and the timeout decreased to prevent this from happening. --- ca/client_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ca/client_test.go b/ca/client_test.go index 56825bb6..715266d7 100644 --- a/ca/client_test.go +++ b/ca/client_test.go @@ -1019,7 +1019,7 @@ func TestClient_GetCaURL(t *testing.T) { func TestClient_WithTimeout(t *testing.T) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - time.Sleep(100 * time.Millisecond) + time.Sleep(200 * time.Millisecond) render.JSONStatus(w, r, api.HealthResponse{Status: "ok"}, 200) })) defer srv.Close() @@ -1030,8 +1030,8 @@ func TestClient_WithTimeout(t *testing.T) { assertion assert.ErrorAssertionFunc }{ {"ok", []ClientOption{WithTransport(http.DefaultTransport)}, assert.NoError}, - {"ok with timeout", []ClientOption{WithTransport(http.DefaultTransport), WithTimeout(time.Second)}, assert.NoError}, - {"fail with timeout", []ClientOption{WithTransport(http.DefaultTransport), WithTimeout(100 * time.Millisecond)}, assert.Error}, + {"ok with timeout", []ClientOption{WithTransport(http.DefaultTransport), WithTimeout(5 * time.Second)}, assert.NoError}, + {"fail with timeout", []ClientOption{WithTransport(http.DefaultTransport), WithTimeout(10 * time.Millisecond)}, assert.Error}, } for _, tt := range tests {