From 155f9b4dcadea073d3fd6f618e4bd10e6586bcaf Mon Sep 17 00:00:00 2001 From: Umputun Date: Thu, 20 Aug 2026 19:21:01 -0500 Subject: [PATCH] test: stabilize health handler timing --- app/proxy/health_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/proxy/health_test.go b/app/proxy/health_test.go index 4c8b5b09..70ea5be2 100644 --- a/app/proxy/health_test.go +++ b/app/proxy/health_test.go @@ -64,7 +64,7 @@ func Test_healthHandlerDeadlock(t *testing.T) { func TestHttp_healthHandler(t *testing.T) { port, releasePort := getFreePort(t) h := Http{Timeouts: Timeouts{ResponseHeader: 200 * time.Millisecond}, Address: fmt.Sprintf("127.0.0.1:%d", port)} - ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() ds := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -107,8 +107,7 @@ func TestHttp_healthHandler(t *testing.T) { _ = h.Run(ctx) }() - // wait for discovery service to load mappers - time.Sleep(50 * time.Millisecond) + require.Eventually(t, func() bool { return len(svc.Mappers()) == 5 }, time.Second, 10*time.Millisecond) client := http.Client{} var resp *http.Response