-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
authz: modify the tests to use stubserver instead of testservice implementations #7888
authz: modify the tests to use stubserver instead of testservice implementations #7888
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7888 +/- ##
==========================================
+ Coverage 82.05% 82.22% +0.17%
==========================================
Files 381 381
Lines 38539 38543 +4
==========================================
+ Hits 31622 31691 +69
+ Misses 5602 5552 -50
+ Partials 1315 1300 -15
|
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.
1 comment otherwise lgtm. Good work!
EmptyCallF func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) | ||
UnaryCallF func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) | ||
FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error | ||
StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error |
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.
@janardhanvissa i think we don't need to create extra functions for input and output. Can you just use the FullDuplexCallF for streaming calls
grpc-go/authz/audit/audit_logging_test.go
Line 250 in 66ba4b2
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { |
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.
Discussed offline. We need to use stream.CloseAndRecv() so we need a client streaming handler. We should rename it to ClientStreamingInputCall and ClientStreamingOutputCall though
internal/stubserver/stubserver.go
Outdated
UnaryCallF func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) | ||
FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error | ||
ClientStreamingInputCall func(stream testgrpc.TestService_StreamingInputCallServer) error | ||
ClientStreamingOutputCall func(req *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error |
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.
@janardhanvissa let's change this StreamingInputCall and StreamingOutputCall and in the comment mention that that input is for ClientStreaming and output is for ServerStreaming
cfba48c
to
ecdab23
Compare
…to stubserver-streamingcall
internal/stubserver/stubserver.go
Outdated
EmptyCallF func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) | ||
UnaryCallF func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) | ||
FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error | ||
StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error // ClientStreaming |
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.
Next to StreamingInputCallF
please mention Client-Streaming request
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.
lgtm. Please address the comment suggestion for Streaming calls
internal/stubserver/stubserver.go
Outdated
UnaryCallF func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) | ||
FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error | ||
StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error // ClientStreaming | ||
StreamingOutputCallF func(req *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error // ServerStreaming |
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.
Next to StreamingOutputCallF
please mention Server-streaming response
@easwars for second review |
t.Fatalf("Error listening: %v", err) | ||
} | ||
go s.Serve(lis) | ||
ss.S = s |
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.
While you are here, may I request you to make the following additional changes:
- Move the whole section under the comment
// Construct the credentials for the tests and the stub server
to here. That will make the subtests executed as part of thefor
loop (via the call tot.Run
) be independent of each other. - Pass the arguments to the call to
grpc.NewServer
in a single line. See: https://google.github.io/styleguide/go/guide#line-length
Thanks.
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.
You seemed to have moved it to the top of the test. That is not what I requested. I requested that the creation of the creds and the stubserver be moved inside of t.Run
. That is the only way to make the subtests hermetic.
internal/stubserver/stubserver.go
Outdated
StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error // Client-Streaming request | ||
StreamingOutputCallF func(req *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error // Server-streaming response |
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.
Nit: Please remove the trailing comments for the newly added fields since the other existing fields don't have them and there is a top-level comment saying these are customizable implementations of server handlers, which is explanatory enough I feel. Thanks.
…to stubserver-streamingcall
All the above mentioned comments are addressed. |
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.
LGTM, modulo minor nits raised in the most recent round of review.
t.Fatalf("Error listening: %v", err) | ||
} | ||
go s.Serve(lis) | ||
ss.S = s |
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.
You seemed to have moved it to the top of the test. That is not what I requested. I requested that the creation of the creds and the stubserver be moved inside of t.Run
. That is the only way to make the subtests hermetic.
authz/grpc_authz_end2end_test.go
Outdated
return &testpb.SimpleResponse{}, nil | ||
}, | ||
// Start a gRPC server with gRPC authz unary server interceptor. | ||
S: grpc.NewServer(grpc.ChainUnaryInterceptor(i.UnaryInterceptor))} |
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.
Nit: Please terminate that line with a ,
and move the }
to the next line. That way the opening and closing curly braces will match.
authz/grpc_authz_end2end_test.go
Outdated
UnaryCallF: func(ctx context.Context, req *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { | ||
return &testpb.SimpleResponse{}, nil | ||
}, | ||
S: grpc.NewServer(grpc.ChainUnaryInterceptor(i.UnaryInterceptor))} |
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.
Nit: Please terminate that line with a , and move the } to the next line. That way the opening and closing curly braces will match.
Partially Addresses: #7291
RELEASE NOTES: None