Skip to content
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

Merged
merged 14 commits into from
Jan 13, 2025

Conversation

janardhanvissa
Copy link
Contributor

Partially Addresses: #7291

RELEASE NOTES: None

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.22%. Comparing base (724f450) to head (136cc82).

Files with missing lines Patch % Lines
internal/stubserver/stubserver.go 50.00% 2 Missing ⚠️
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     
Files with missing lines Coverage Δ
internal/stubserver/stubserver.go 80.00% <50.00%> (-0.92%) ⬇️

... and 29 files with indirect coverage changes

@purnesh42H purnesh42H modified the milestones: 1.69 Release, 1.70 Release Dec 5, 2024
Copy link
Contributor

@purnesh42H purnesh42H left a 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!

authz/audit/audit_logging_test.go Show resolved Hide resolved
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
Copy link
Contributor

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

FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
?

Copy link
Contributor

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

@purnesh42H purnesh42H changed the title stubserver: Initializing StreamingInputCall and StreamingOutputCall in the stubserver authz: Modify the tests to use stubserver instead of testservice implementations Dec 6, 2024
@purnesh42H purnesh42H changed the title authz: Modify the tests to use stubserver instead of testservice implementations authz: modify the tests to use stubserver instead of testservice implementations Dec 6, 2024
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
Copy link
Contributor

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

@janardhanvissa janardhanvissa force-pushed the stubserver-streamingcall branch from cfba48c to ecdab23 Compare December 20, 2024 09:56
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
Copy link
Contributor

@purnesh42H purnesh42H Dec 21, 2024

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

Copy link
Contributor

@purnesh42H purnesh42H left a 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

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
Copy link
Contributor

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

@purnesh42H purnesh42H requested a review from easwars January 7, 2025 13:20
@purnesh42H purnesh42H assigned easwars and unassigned janardhanvissa Jan 7, 2025
@purnesh42H
Copy link
Contributor

@easwars for second review

t.Fatalf("Error listening: %v", err)
}
go s.Serve(lis)
ss.S = s
Copy link
Contributor

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 the for loop (via the call to t.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.

Copy link
Contributor

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/audit/audit_logging_test.go Outdated Show resolved Hide resolved
authz/grpc_authz_end2end_test.go Outdated Show resolved Hide resolved
authz/grpc_authz_end2end_test.go Outdated Show resolved Hide resolved
authz/grpc_authz_end2end_test.go Outdated Show resolved Hide resolved
authz/grpc_authz_end2end_test.go Show resolved Hide resolved
Comment on lines 62 to 63
StreamingInputCallF func(stream testgrpc.TestService_StreamingInputCallServer) error // Client-Streaming request
StreamingOutputCallF func(req *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error // Server-streaming response
Copy link
Contributor

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.

@easwars easwars assigned janardhanvissa and unassigned easwars Jan 7, 2025
@janardhanvissa
Copy link
Contributor Author

All the above mentioned comments are addressed.

@easwars easwars self-assigned this Jan 8, 2025
Copy link
Contributor

@easwars easwars left a 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
Copy link
Contributor

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.

return &testpb.SimpleResponse{}, nil
},
// Start a gRPC server with gRPC authz unary server interceptor.
S: grpc.NewServer(grpc.ChainUnaryInterceptor(i.UnaryInterceptor))}
Copy link
Contributor

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.

UnaryCallF: func(ctx context.Context, req *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil
},
S: grpc.NewServer(grpc.ChainUnaryInterceptor(i.UnaryInterceptor))}
Copy link
Contributor

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.

@easwars easwars removed their assignment Jan 9, 2025
@purnesh42H purnesh42H merged commit f35fb34 into grpc:master Jan 13, 2025
12 of 13 checks passed
janardhanvissa added a commit to janardhanvissa/grpc-go that referenced this pull request Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants