Skip to content

Commit dd1540e

Browse files
HUSTtoKTHlevanli
andauthored
InterceptorTestSuite client connection optimize (#455)
Co-authored-by: levanli <[email protected]>
1 parent f8899ff commit dd1540e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

testing/testpb/interceptor_suite.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (s *InterceptorTestSuite) RestartServer(delayedStart time.Duration) <-chan
113113

114114
func (s *InterceptorTestSuite) NewClient(dialOpts ...grpc.DialOption) TestServiceClient {
115115
newDialOpts := append(dialOpts, grpc.WithBlock())
116+
var err error
116117
if *flagTls {
117118
cp := x509.NewCertPool()
118119
if !cp.AppendCertsFromPEM(certPEM) {
@@ -125,9 +126,9 @@ func (s *InterceptorTestSuite) NewClient(dialOpts ...grpc.DialOption) TestServic
125126
}
126127
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
127128
defer cancel()
128-
clientConn, err := grpc.DialContext(ctx, s.ServerAddr(), newDialOpts...)
129+
s.clientConn, err = grpc.DialContext(ctx, s.ServerAddr(), newDialOpts...)
129130
require.NoError(s.T(), err, "must not error on client Dial")
130-
return NewTestServiceClient(clientConn)
131+
return NewTestServiceClient(s.clientConn)
131132
}
132133

133134
func (s *InterceptorTestSuite) ServerAddr() string {

0 commit comments

Comments
 (0)