From fc46356377fac69d10ffb0454e8944ac66476171 Mon Sep 17 00:00:00 2001
From: Evan Cordell <cordell.evan@gmail.com>
Date: Tue, 5 Nov 2019 15:40:21 -0500
Subject: [PATCH] test(server): wait for connection to go healthy before
 running tests

this may reduce flakiness for the server e2e tests
---
 pkg/server/server_test.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go
index 0225ee500..be74bc7da 100644
--- a/pkg/server/server_test.go
+++ b/pkg/server/server_test.go
@@ -6,11 +6,13 @@ import (
 	"net"
 	"os"
 	"testing"
+	"time"
 
 	"github.com/sirupsen/logrus"
 	"github.com/stretchr/testify/require"
 	"golang.org/x/net/context"
 	"google.golang.org/grpc"
+	"google.golang.org/grpc/connectivity"
 
 	"github.com/operator-framework/operator-registry/pkg/api"
 	"github.com/operator-framework/operator-registry/pkg/sqlite"
@@ -75,6 +77,10 @@ func client(t *testing.T) (api.RegistryClient, *grpc.ClientConn) {
 	if err != nil {
 		t.Fatalf("did not connect: %v", err)
 	}
+
+	ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
+	conn.WaitForStateChange(ctx, connectivity.TransientFailure)
+
 	return api.NewRegistryClient(conn), conn
 }