-
Notifications
You must be signed in to change notification settings - Fork 4.5k
cmd/protoc-gen-go-grpc: add protoc change detector test #6910
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #6910 +/- ##
==========================================
- Coverage 82.46% 82.25% -0.22%
==========================================
Files 296 296
Lines 31465 31465
==========================================
- Hits 25947 25880 -67
- Misses 4463 4515 +52
- Partials 1055 1070 +15 |
cmd/protoc-gen-go-grpc/grpc_test.go
Outdated
req := &pluginpb.CodeGeneratorRequest{ | ||
ProtoFile: initProtoFile(), | ||
FileToGenerate: []string{"test_unary.proto"}, | ||
CompilerVersion: &pluginpb.Version{ |
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.
This maybe can be an issue with up to date versions
Thanks for sending us this PR @zedGGs. At a high level, we want to be testing the
I'm more inclined for (1). Let me know when you have the PR ready for review again and we can take another pass at it. Also please find my responses inline for the questions asked. Feel free to reach out if you have more questions.
arvindbr8:
arvindbr8: I'm not sure if the code in this test might be reused in the future. Although inflating the init functions inplace might be better for readability, but I have no strong preference. Although this might not be required if we go with the new approach
arvindbr8: we should definitely add protos for all types of RPCs and tests as well. It might be easier to add this in this PR itself.
arvindbr8: Could you link to that please?
arvindbr8: Not relevant if we go with the new approach
arvindbr8: Not relevant if we go with the new approach
arvindbr8: We only want to be able to test changes made to
arvindbr8: can we add all of that in this same PR if thats not too much effort. Seems like we can reuse the same message and only add additional rpcs to the service.
arvindbr8: Let's remove them with cleanup
arvindbr8: Not application if we take the new approach |
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.
Please take a look at my comment above and let me know when its ready for review again.
@arvindbr8 thank you a lot for the awesome review and all the explanation and advices in general and in all inline comments I will go with first option as u advise, add all protos for different types of rpcs, use cleanup, all in same pr |
@zedGGs -- I guess your changes were not pushed to your branch? Please take a look |
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
@arvindbr8 yes, something similar ! and then I went on vacation, |
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
Since @dfawley has more context I'll reassign it to him |
bcde830
to
5b17419
Compare
5b17419
to
2ce2a54
Compare
@zedGGs - I would be cautious when I do a force push to your branch. Github UI handles that weirdly and sometimes have gotten rid of the previous conversations on the PR. Also, Doug is on vacation and will be back next week. |
@arvindbr8 sure, can agree on that, I think it's all ready and good at this point, an update with most important conversation, I think this could cover all of the idea: here: #6910 (comment) |
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 remember approving it already. Let's wait on dfawley's review before we can merge it
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.
Thanks for the PR.. I have a few comments but overall this looks really good!
@@ -37,8 +37,6 @@ jobs: | |||
# Run the main gRPC-Go tests. | |||
tests: | |||
# Proto checks are run in the above job. |
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.
This comment should be moved with the env lines and updated to something like in the vet-proto job
.
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.
make sense, I can do that
env: | ||
VET_BUILD_GO_PROTOC: 1 | ||
run: | | ||
./vet.sh -install | ||
protoc --version |
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.
This doesn't want to be run for every version of Go that we test, presumably.
Let's test it in extras
instead, below?
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.
sure, that's reasonable
) | ||
|
||
func TestProtocBinary(t *testing.T) { | ||
workingDir, err := os.Getwd() |
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 don't think we need this workingDir
at all. os.MkdirTemp
uses the default temp directory if the first parameter is ""
which seems perfectly fine and command.Dir
defaults to the current directory already.
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.
make sense, will do
protoFile: "test_bidirectional_streaming.proto", | ||
}, | ||
} { | ||
protoFilePath := "./proto/" + spec.protoFile |
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.
Please use path.Join
instead.
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.
sounds like a plan
if !reflect.DeepEqual(testPluginContent, protocPluginContent) { | ||
t.Errorf("error generated go test stubs are not equal") | ||
} |
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.
Please use cmp.Diff
and show the results so if things change we can see exactly what.
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.
sounds like an awesome plan
|
||
pbgoFile := strings.Replace(spec.protoFile, ".proto", "_grpc.pb.go", 1) | ||
|
||
testPluginContent, err := os.ReadFile(tmpDir + "/testdata/proto/" + pbgoFile) |
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 re: path.Join
and below.
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.
sure
# excluding grpc_testing_not_regenerate and cmd/protoc-gen-go-grpc directories | ||
rm -f $(find . -name '*.pb.go' | grep -v -e 'grpc_testing_not_regenerate' -e 'cmd/protoc-gen-go-grpc') |
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.
Actually, I have renamed the files in grpc_test_not_regenerate
to not be .pb.go
anymore, so you can delete this part.
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.
will do
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
Since this PR is going stale, I decided to open #7072 to attempt to fix it. |
Heey @arvindbr8 , is there still possibility for me to finalise this pr ? I happen to be on vacation so I haven't reply on time, but Im available now, |
Sorry about that @zedGGs. Please feel free to take up another issue in the repo. We would love to take a look at your PR. |
Heey !
Im adding this pull request for this issue: #6748
I will add more detailed explanation, thank you a lot for the time taken !
little gentle ping for @dfawley
and one for @arvindbr8
NOTICE: there's a little issue with added
test_unary.proto
file maybe invet.sh
I can update what's required
The goal of this pr is to add test coverage for using
protoc-gen-go-grpc
internaly and compare results with usage of actualprotoc —go-grpc=.out test.proto
from
google.golang.org/protobuf/compiler/protogen
A)
I have added tests for unary examples, but maybe it's good idea to make sure is this even good approach,
including my approach in tests, function naming, const naming, too much init functions ?
Is this code in tests reusable, for adding future examples of unary rpc proto file test examples
Can something be better in tests ?
Also I have added a little example of same test, but in other format.
If you maybe prefer more this way.
B)
One thing thats not the best, is
initPlugin
Compiler versions,Im using latest one, with
v4.24.3
but have no clue how to use or update to current ones in time,will take a closer look, so every time theres an update we don't have to update tests
C) Added Small Update on this since
vet.sh
is greping these comments , Will fix error handling betterAlso I have not included “authors” comments that are generated above in pb.go files from proto files,
since
generateFile
function, does not do that, and if I want to do thatI can create helper function, that's gonna be called inside
generateFile
to do that job for me.If this is even important.
D)
By the way, we are only using here
protoc —go-grpc_out=. test.proto
, command that is usedin wrapper function
generateFile
, that is using protogen, fromprotobuf/compiler/protogen
Is there maybe a plan of implementing
protoc —go_out=. test.proto
in other wrapper function,for generating remaining pb.go file ?
Does grpc.pb.go feels uncomplete without other pb.go file ?
My plan is also to add additional tests, for all of helper functions that are being used.
E)
Also I have already tested with sever streaming proto file, and seems to work,
I can add that in this pull request as separated commit,
or as totaly separated pull request ?
Then we can add client and bidirectional streaming examples
F)
Btw, do u prefer more to compare files that are being written to, and remove them with cleanup,
or just to compare files content ?
G)
Other unary rpc test example:
Do u prefer more naming of const with: dummySomething, mockSomething, or just smthng ?
RELEASE NOTES: none