Skip to content

Commit

Permalink
server_test.go: wait to run tests until listeners have started
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <[email protected]>
  • Loading branch information
joelanford committed Aug 15, 2024
1 parent 5fb8c1c commit ffdee0f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
fbccache "github.com/operator-framework/operator-registry/pkg/cache"
"github.com/operator-framework/operator-registry/pkg/registry"
"github.com/operator-framework/operator-registry/pkg/sqlite"
"sync"
)

const (
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit ffdee0f

Please sign in to comment.