-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing testservice implementation and using stubserver #12
base: master
Are you sure you want to change the base?
Conversation
…-error-flow, var-declaration
Optimising the code by fixing var-declaration, indent-error-flow, increment-decrement, superfluous-else
…low, increment-decrement, superfluous-else"
Revert "Optimising the code by fixing var-declaration, indent-error-flow, increment-decrement, superfluous-else"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look fine overall. But I think in all tests, if possible we should let the stubserver register the test service instead of explicitly doing it from the test.
server, err := xds.NewGRPCServer(grpc.Creds(insecure.NewCredentials()), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)) | ||
if err != nil { | ||
t.Fatalf("Failed to create an xDS enabled gRPC server: %v", err) | ||
} | ||
t.Cleanup(server.Stop) | ||
testgrpc.RegisterTestServiceServer(server, &testService{}) | ||
testgrpc.RegisterTestServiceServer(server, stub) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be doing something like:
stub := &stubserver.StubServer{
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {
return &testpb.Empty{}, nil
},
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil
},
}
// Create the xDS-enabled gRPC server like how we are doing today
stub.S = server
stubserver.StartTestService(t, stub) // instead of manually registering the test service
@@ -161,7 +162,7 @@ func (s) TestServerSideXDS_WithNoCertificateProvidersInBootstrap_Failure(t *test | |||
if err != nil { | |||
t.Fatalf("Failed to create an xDS enabled gRPC server: %v", err) | |||
} | |||
testgrpc.RegisterTestServiceServer(server, &testService{}) | |||
testgrpc.RegisterTestServiceServer(server, &stubserver.StubServer{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
server, err := xds.NewGRPCServer(grpc.Creds(creds), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)) | ||
if err != nil { | ||
t.Fatalf("Failed to create an xDS enabled gRPC server: %v", err) | ||
} | ||
testgrpc.RegisterTestServiceServer(server, &testService{}) | ||
testgrpc.RegisterTestServiceServer(server, stub) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here too.
I see that while some tests create an empty stub server like |
An empty stub server will give invalid memory address or nil pointer dereference right? How to approach these, please suggest. |
Ah, there is a check for |
Yes, there is a check for that. Sure will raise a PR on the main repo. Thanks for the confirmation. |
No description provided.