From 6a6332f045062d718f853d244f36641273d2ab85 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Thu, 15 Aug 2024 16:45:04 -0400 Subject: [PATCH] server_test.go: wait to run tests until listeners have started Signed-off-by: Joe Lanford --- pkg/server/server_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index cdd5c33ac..307e47701 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -7,6 +7,7 @@ import ( "net" "os" "path/filepath" + "sync" "testing" "testing/fstest" "time" @@ -142,11 +143,14 @@ func TestMain(m *testing.M) { } fbcServerDeprecations := server(fbcDeprecationStore) + var wg sync.WaitGroup + wg.Add(3) go func() { lis, err := net.Listen("tcp", dbPort) if err != nil { logrus.Fatalf("failed to listen: %v", err) } + wg.Done() if err := grpcServer.Serve(lis); err != nil { logrus.Fatalf("failed to serve db: %v", err) } @@ -156,6 +160,7 @@ func TestMain(m *testing.M) { if err != nil { logrus.Fatalf("failed to listen: %v", err) } + wg.Done() if err := fbcServerSimple.Serve(lis); err != nil { logrus.Fatalf("failed to serve fbc cache: %v", err) } @@ -165,10 +170,12 @@ func TestMain(m *testing.M) { if err != nil { logrus.Fatalf("failed to listen: %v", err) } + wg.Done() if err := fbcServerDeprecations.Serve(lis); err != nil { logrus.Fatalf("failed to serve fbc cache: %v", err) } }() + wg.Wait() exit := m.Run() os.Exit(exit) }