@@ -109,13 +109,6 @@ func (tss *testServiceServer) EmptyCall(context.Context, *testpb.Empty) (*testpb
109
109
110
110
//invoke the EmptyCall RPC
111
111
func invokeEmptyCall (address string , dialOptions []grpc.DialOption ) (* testpb.Empty , error ) {
112
-
113
- //add DialOptions
114
- dialOptions = append (
115
- dialOptions ,
116
- grpc .WithDefaultCallOptions (grpc .FailFast (true )),
117
- grpc .FailOnNonTempDialError (true ),
118
- grpc .WithBlock ())
119
112
ctx := context .Background ()
120
113
ctx , _ = context .WithTimeout (ctx , timeout )
121
114
//create GRPC client conn
@@ -650,7 +643,8 @@ func TestNewSecureGRPCServer(t *testing.T) {
650
643
RootCAs : certPool ,
651
644
MinVersion : tlsVersion ,
652
645
MaxVersion : tlsVersion ,
653
- }))})
646
+ })),
647
+ grpc .WithBlock ()})
654
648
t .Logf ("TLSVersion [%d] failed with [%s]" , tlsVersion , err )
655
649
assert .Error (t , err , "Should not have been able to connect with TLS version < 1.2" )
656
650
assert .Contains (t , err .Error (), "context deadline exceeded" )
@@ -1386,8 +1380,8 @@ func TestKeepaliveNoClientResponse(t *testing.T) {
1386
1380
t .Parallel ()
1387
1381
// set up GRPCServer instance
1388
1382
kap := & comm.KeepaliveOptions {
1389
- ServerInterval : time . Duration ( 2 ) * time .Second ,
1390
- ServerTimeout : time . Duration ( 1 ) * time .Second ,
1383
+ ServerInterval : 2 * time .Second ,
1384
+ ServerTimeout : 1 * time .Second ,
1391
1385
}
1392
1386
testAddress := "localhost:9400"
1393
1387
srv , err := comm .NewGRPCServer (testAddress , comm.ServerConfig {KaOpts : kap })
@@ -1417,8 +1411,8 @@ func TestKeepaliveClientResponse(t *testing.T) {
1417
1411
t .Parallel ()
1418
1412
// set up GRPCServer instance
1419
1413
kap := & comm.KeepaliveOptions {
1420
- ServerInterval : time . Duration ( 2 ) * time .Second ,
1421
- ServerTimeout : time . Duration ( 1 ) * time .Second ,
1414
+ ServerInterval : 1 * time .Second ,
1415
+ ServerTimeout : 1 * time .Second ,
1422
1416
}
1423
1417
testAddress := "localhost:9401"
1424
1418
srv , err := comm .NewGRPCServer (testAddress , comm.ServerConfig {KaOpts : kap })
@@ -1427,16 +1421,22 @@ func TestKeepaliveClientResponse(t *testing.T) {
1427
1421
defer srv .Stop ()
1428
1422
1429
1423
// test that connection does not close with response to ping
1430
- clientTransport , err := transport . NewClientTransport (
1424
+ connectCtx , cancel := context . WithDeadline (
1431
1425
context .Background (),
1426
+ time .Now ().Add (1 * time .Second ))
1427
+ clientTransport , err := transport .NewClientTransport (
1428
+ connectCtx ,
1432
1429
context .Background (),
1433
1430
transport.TargetInfo {Addr : testAddress },
1434
1431
transport.ConnectOptions {},
1435
1432
func () {})
1433
+ if err != nil {
1434
+ cancel ()
1435
+ }
1436
1436
assert .NoError (t , err , "Unexpected error creating client transport" )
1437
1437
defer clientTransport .Close ()
1438
1438
// sleep past keepalive timeout
1439
- time .Sleep (4 * time .Second )
1439
+ time .Sleep (1500 * time .Millisecond )
1440
1440
// try to create a stream
1441
1441
_ , err = clientTransport .NewStream (context .Background (), & transport.CallHdr {})
1442
1442
assert .NoError (t , err , "Unexpected error creating stream" )
@@ -1480,7 +1480,8 @@ func TestUpdateTLSCert(t *testing.T) {
1480
1480
_ , err = invokeEmptyCall ("localhost:8333" ,
1481
1481
[]grpc.DialOption {grpc .WithTransportCredentials (
1482
1482
credentials .NewTLS (& tls.Config {
1483
- RootCAs : certPool }))})
1483
+ RootCAs : certPool })),
1484
+ grpc .WithBlock ()})
1484
1485
return err
1485
1486
}
1486
1487
0 commit comments