diff --git a/balancer/roundrobin/roundrobin_test.go b/balancer/roundrobin/roundrobin_test.go index 7f953ff0..87acf85f 100644 --- a/balancer/roundrobin/roundrobin_test.go +++ b/balancer/roundrobin/roundrobin_test.go @@ -318,7 +318,7 @@ func TestOneServerDown(t *testing.T) { } defer test.cleanup() - cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithBalancerBuilder(rr)) + cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithBalancerBuilder(rr), grpc.WithWaitForHandshake()) if err != nil { t.Fatalf("failed to dial: %v", err) } @@ -372,6 +372,7 @@ func TestOneServerDown(t *testing.T) { var targetSeen int for i := 0; i < 1000; i++ { if _, err := testc.EmptyCall(context.Background(), &testpb.Empty{}, grpc.Peer(&p)); err != nil { + targetSeen = 0 t.Logf("EmptyCall() = _, %v, want _, ", err) // Due to a race, this RPC could possibly get the connection that // was closing, and this RPC may fail. Keep trying when this @@ -415,7 +416,7 @@ func TestAllServersDown(t *testing.T) { } defer test.cleanup() - cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithBalancerBuilder(rr)) + cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithBalancerBuilder(rr), grpc.WithWaitForHandshake()) if err != nil { t.Fatalf("failed to dial: %v", err) } diff --git a/balancer_test.go b/balancer_test.go index a1558f02..19f15e82 100644 --- a/balancer_test.go +++ b/balancer_test.go @@ -332,7 +332,7 @@ func TestOneServerDown(t *testing.T) { numServers := 2 servers, r, cleanup := startServers(t, numServers, math.MaxUint32) defer cleanup() - cc, err := Dial("passthrough:///foo.bar.com", WithBalancer(RoundRobin(r)), WithBlock(), WithInsecure(), WithCodec(testCodec{})) + cc, err := Dial("passthrough:///foo.bar.com", WithBalancer(RoundRobin(r)), WithBlock(), WithInsecure(), WithCodec(testCodec{}), WithWaitForHandshake()) if err != nil { t.Fatalf("Failed to create ClientConn: %v", err) } @@ -660,7 +660,7 @@ func TestPickFirstOrderOneServerDown(t *testing.T) { numServers := 3 servers, r, cleanup := startServers(t, numServers, math.MaxUint32) defer cleanup() - cc, err := Dial("passthrough:///foo.bar.com", WithBalancer(pickFirstBalancerV1(r)), WithBlock(), WithInsecure(), WithCodec(testCodec{})) + cc, err := Dial("passthrough:///foo.bar.com", WithBalancer(pickFirstBalancerV1(r)), WithBlock(), WithInsecure(), WithCodec(testCodec{}), WithWaitForHandshake()) if err != nil { t.Fatalf("Failed to create ClientConn: %v", err) } diff --git a/pickfirst_test.go b/pickfirst_test.go index e58b3422..6225b1ab 100644 --- a/pickfirst_test.go +++ b/pickfirst_test.go @@ -182,7 +182,7 @@ func TestOneServerDownPickfirst(t *testing.T) { servers, _, scleanup := startServers(t, numServers, math.MaxInt32) defer scleanup() - cc, err := Dial(r.Scheme()+":///test.server", WithInsecure(), WithBalancerBuilder(newPickfirstBuilder()), WithCodec(testCodec{})) + cc, err := Dial(r.Scheme()+":///test.server", WithInsecure(), WithBalancerBuilder(newPickfirstBuilder()), WithCodec(testCodec{}), WithWaitForHandshake()) if err != nil { t.Fatalf("failed to dial: %v", err) } @@ -224,7 +224,7 @@ func TestAllServersDownPickfirst(t *testing.T) { servers, _, scleanup := startServers(t, numServers, math.MaxInt32) defer scleanup() - cc, err := Dial(r.Scheme()+":///test.server", WithInsecure(), WithBalancerBuilder(newPickfirstBuilder()), WithCodec(testCodec{})) + cc, err := Dial(r.Scheme()+":///test.server", WithInsecure(), WithBalancerBuilder(newPickfirstBuilder()), WithCodec(testCodec{}), WithWaitForHandshake()) if err != nil { t.Fatalf("failed to dial: %v", err) } diff --git a/test/end2end_test.go b/test/end2end_test.go index 43a53a19..8621349c 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -468,6 +468,7 @@ type test struct { clientInitialWindowSize int32 clientInitialConnWindowSize int32 perRPCCreds credentials.PerRPCCredentials + customDialOptions []grpc.DialOption resolverScheme string // All test dialing is blocking by default. Set this to true if dial @@ -718,6 +719,7 @@ func (te *test) clientConn() *grpc.ClientConn { if te.srvAddr == "" { te.srvAddr = "client.side.only.test" } + opts = append(opts, te.customDialOptions...) var err error te.cc, err = grpc.Dial(scheme+te.srvAddr, opts...) if err != nil { @@ -803,6 +805,7 @@ func TestTimeoutOnDeadServer(t *testing.T) { func testTimeoutOnDeadServer(t *testing.T, e env) { te := newTest(t, e) + te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()} te.userAgent = testAppUA te.declareLogNoise( "transport: http2Client.notifyError got notified that the client transport was broken EOF",