@@ -99,10 +99,11 @@ func (s *assertingService) PingStream(stream pb.TestService_PingStreamServer) er
9999type ProxyHappySuite struct {
100100 suite.Suite
101101
102- serverListener net.Listener
103- server * grpc.Server
104- proxyListener net.Listener
105- proxy * grpc.Server
102+ serverListener net.Listener
103+ server * grpc.Server
104+ proxyListener net.Listener
105+ proxy * grpc.Server
106+ serverClientConn * grpc.ClientConn
106107
107108 client * grpc.ClientConn
108109 testClient pb.TestServiceClient
@@ -201,7 +202,7 @@ func (s *ProxyHappySuite) SetupSuite() {
201202 pb .RegisterTestServiceServer (s .server , & assertingService {t : s .T ()})
202203
203204 // Setup of the proxy's Director.
204- proxyClientConn , err : = grpc .Dial (s .serverListener .Addr ().String (), grpc .WithInsecure (), grpc .WithCodec (proxy .Codec ()))
205+ s . serverClientConn , err = grpc .Dial (s .serverListener .Addr ().String (), grpc .WithInsecure (), grpc .WithCodec (proxy .Codec ()))
205206 require .NoError (s .T (), err , "must not error on deferred client Dial" )
206207 director := func (ctx context.Context , fullName string ) (* grpc.ClientConn , error ) {
207208 md , ok := metadata .FromContext (ctx )
@@ -210,7 +211,7 @@ func (s *ProxyHappySuite) SetupSuite() {
210211 return nil , grpc .Errorf (codes .PermissionDenied , "testing rejection" )
211212 }
212213 }
213- return proxyClientConn , nil
214+ return s . serverClientConn , nil
214215 }
215216 s .proxy = grpc .NewServer (
216217 grpc .CustomCodec (proxy .Codec ()),
@@ -237,6 +238,14 @@ func (s *ProxyHappySuite) SetupSuite() {
237238}
238239
239240func (s * ProxyHappySuite ) TearDownSuite () {
241+ if s .client != nil {
242+ s .client .Close ()
243+ }
244+ if s .serverClientConn != nil {
245+ s .serverClientConn .Close ()
246+ }
247+ // Close all transports so the logs don't get spammy.
248+ time .Sleep (10 * time .Millisecond )
240249 if s .proxy != nil {
241250 s .proxy .Stop ()
242251 s .proxyListener .Close ()
@@ -245,9 +254,6 @@ func (s *ProxyHappySuite) TearDownSuite() {
245254 s .server .Stop ()
246255 s .serverListener .Close ()
247256 }
248- if s .client != nil {
249- s .client .Close ()
250- }
251257}
252258
253259func TestProxyHappySuite (t * testing.T ) {
0 commit comments