Add TestFailFastRPCWithNoBalancerErrorOnBadCertificates TestNonFailFastRPCWithNoBalancerErrorOnBadCertificates
This commit is contained in:
@ -369,6 +369,7 @@ type test struct {
|
|||||||
serverCompression bool
|
serverCompression bool
|
||||||
unaryInt grpc.UnaryServerInterceptor
|
unaryInt grpc.UnaryServerInterceptor
|
||||||
streamInt grpc.StreamServerInterceptor
|
streamInt grpc.StreamServerInterceptor
|
||||||
|
balancer grpc.Balancer
|
||||||
|
|
||||||
// srv and srvAddr are set once startServer is called.
|
// srv and srvAddr are set once startServer is called.
|
||||||
srv *grpc.Server
|
srv *grpc.Server
|
||||||
@ -404,6 +405,8 @@ func newTest(t *testing.T, e env) *test {
|
|||||||
maxStream: math.MaxUint32,
|
maxStream: math.MaxUint32,
|
||||||
}
|
}
|
||||||
te.ctx, te.cancel = context.WithCancel(context.Background())
|
te.ctx, te.cancel = context.WithCancel(context.Background())
|
||||||
|
// Install roundrobin balancer by default.
|
||||||
|
te.balancer = grpc.RoundRobin(nil)
|
||||||
return te
|
return te
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,6 +505,9 @@ func (te *test) clientConn() *grpc.ClientConn {
|
|||||||
default:
|
default:
|
||||||
opts = append(opts, grpc.WithInsecure())
|
opts = append(opts, grpc.WithInsecure())
|
||||||
}
|
}
|
||||||
|
if te.balancer != nil {
|
||||||
|
opts = append(opts, grpc.WithBalancer(te.balancer))
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
te.cc, err = grpc.Dial(te.srvAddr, opts...)
|
te.cc, err = grpc.Dial(te.srvAddr, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2317,6 +2323,34 @@ func TestFailFastRPCErrorOnBadCertificates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFailFastRPCWithNoBalancerErrorOnBadCertificates(t *testing.T) {
|
||||||
|
te := newTest(t, env{name: "bad-cred", network: "tcp", security: "clientAlwaysFailCred"})
|
||||||
|
// Uninstall balancer.
|
||||||
|
te.balancer = nil
|
||||||
|
te.startServer(&testServer{security: "clientAlwaysFailCred"})
|
||||||
|
defer te.tearDown()
|
||||||
|
|
||||||
|
cc := te.clientConn()
|
||||||
|
tc := testpb.NewTestServiceClient(cc)
|
||||||
|
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); !strings.Contains(err.Error(), clientAlwaysFailCredErrorMsg) {
|
||||||
|
te.t.Fatalf("Dial(%q) = %v, want err.Error() contains %q", te.srvAddr, err, clientAlwaysFailCredErrorMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNonFailFastRPCWithNoBalancerErrorOnBadCertificates(t *testing.T) {
|
||||||
|
te := newTest(t, env{name: "bad-cred", network: "tcp", security: "clientAlwaysFailCred"})
|
||||||
|
// Uninstall balancer.
|
||||||
|
te.balancer = nil
|
||||||
|
te.startServer(&testServer{security: "clientAlwaysFailCred"})
|
||||||
|
defer te.tearDown()
|
||||||
|
|
||||||
|
cc := te.clientConn()
|
||||||
|
tc := testpb.NewTestServiceClient(cc)
|
||||||
|
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}, grpc.FailFast(false)); !strings.Contains(err.Error(), clientAlwaysFailCredErrorMsg) {
|
||||||
|
te.t.Fatalf("Dial(%q) = %v, want err.Error() contains %q", te.srvAddr, err, clientAlwaysFailCredErrorMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// interestingGoroutines returns all goroutines we care about for the purpose
|
// interestingGoroutines returns all goroutines we care about for the purpose
|
||||||
// of leak checking. It excludes testing or runtime ones.
|
// of leak checking. It excludes testing or runtime ones.
|
||||||
func interestingGoroutines() (gs []string) {
|
func interestingGoroutines() (gs []string) {
|
||||||
|
Reference in New Issue
Block a user