diff --git a/pkg/probe/grpc/grpc_test.go b/pkg/probe/grpc/grpc_test.go index 14e58657e5a..1e625b67532 100644 --- a/pkg/probe/grpc/grpc_test.go +++ b/pkg/probe/grpc/grpc_test.go @@ -44,6 +44,16 @@ func TestNew(t *testing.T) { type successServerMock struct { } +func (s successServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) { + return &grpchealth.HealthListResponse{ + Statuses: map[string]*grpchealth.HealthCheckResponse{ + "grpc": { + Status: grpchealth.HealthCheckResponse_SERVING, + }, + }, + }, nil +} + func (s successServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) { return &grpchealth.HealthCheckResponse{ Status: grpchealth.HealthCheckResponse_SERVING, @@ -59,6 +69,16 @@ func (s successServerMock) Watch(_ *grpchealth.HealthCheckRequest, stream grpche type errorTimeoutServerMock struct { } +func (e errorTimeoutServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) { + return &grpchealth.HealthListResponse{ + Statuses: map[string]*grpchealth.HealthCheckResponse{ + "grpc": { + Status: grpchealth.HealthCheckResponse_SERVING, + }, + }, + }, nil +} + func (e errorTimeoutServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) { time.Sleep(time.Second * 4) return &grpchealth.HealthCheckResponse{ @@ -76,6 +96,16 @@ func (e errorTimeoutServerMock) Watch(_ *grpchealth.HealthCheckRequest, stream g type errorNotServeServerMock struct { } +func (e errorNotServeServerMock) List(ctx context.Context, request *grpchealth.HealthListRequest) (*grpchealth.HealthListResponse, error) { + return &grpchealth.HealthListResponse{ + Statuses: map[string]*grpchealth.HealthCheckResponse{ + "grpc": { + Status: grpchealth.HealthCheckResponse_NOT_SERVING, + }, + }, + }, nil +} + func (e errorNotServeServerMock) Check(context.Context, *grpchealth.HealthCheckRequest) (*grpchealth.HealthCheckResponse, error) { return &grpchealth.HealthCheckResponse{ Status: grpchealth.HealthCheckResponse_NOT_SERVING, diff --git a/test/images/agnhost/grpc-health-checking/grpc-health-checking.go b/test/images/agnhost/grpc-health-checking/grpc-health-checking.go index 0ec9dd3e8cd..f1a6233ca37 100644 --- a/test/images/agnhost/grpc-health-checking/grpc-health-checking.go +++ b/test/images/agnhost/grpc-health-checking/grpc-health-checking.go @@ -70,6 +70,10 @@ type HealthChecker struct { started time.Time } +func (s *HealthChecker) List(ctx context.Context, request *grpc_health_v1.HealthListRequest) (*grpc_health_v1.HealthListResponse, error) { + return nil, status.Error(codes.Unimplemented, "unimplemented") +} + func (s *HealthChecker) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) { log.Printf("Serving the Check request for health check, started at %v", s.started)