test: Adds end2end tests for the case that Watch method returns unimplemented. (#2429)

Adds end2end tests for the case where Watch method is Unimplemented.
This commit is contained in:
Can Guler 2018-11-05 14:24:11 -08:00 коммит произвёл GitHub
Родитель 8f2842d4f0
Коммит 1b89e78fdf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -203,6 +203,45 @@ func TestHealthCheckWatchStateChange(t *testing.T) {
}
}
// If Watch returns Unimplemented, then the ClientConn should go into READY state.
func TestHealthCheckHealthServerNotRegistered(t *testing.T) {
defer leakcheck.Check(t)
s := grpc.NewServer()
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("failed to listen due to err: %v", err)
}
go s.Serve(lis)
defer s.Stop()
r, rcleanup := manual.GenerateAndRegisterManualResolver()
defer rcleanup()
cc, err := grpc.Dial(r.Scheme()+":///test.server", grpc.WithInsecure(), grpc.WithBalancerName("round_robin"))
if err != nil {
t.Fatalf("dial failed due to err: %v", err)
}
defer cc.Close()
r.NewServiceConfig(`{
"healthCheckConfig": {
"serviceName": "foo"
}
}`)
r.NewAddress([]resolver.Address{{Addr: lis.Addr().String()}})
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if ok := cc.WaitForStateChange(ctx, connectivity.Idle); !ok {
t.Fatal("ClientConn is still in IDLE state when the context times out.")
}
if ok := cc.WaitForStateChange(ctx, connectivity.Connecting); !ok {
t.Fatal("ClientConn is still in CONNECTING state when the context times out.")
}
if s := cc.GetState(); s != connectivity.Ready {
t.Fatalf("ClientConn is in %v state, want READY", s)
}
}
// In the case of a goaway received, the health check stream should be terminated and health check
// function should exit.
func TestHealthCheckWithGoAway(t *testing.T) {