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

added trailer match capability #1709 #1721

Closed
wants to merge 5 commits into from
Closed

added trailer match capability #1709 #1721

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 5, 2020

Related to #1697

Fixes #1697
(hopefully)

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@ghost ghost marked this pull request as draft October 5, 2020 21:42
@ghost
Copy link
Author

ghost commented Oct 5, 2020

@googlebot

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Oct 5, 2020
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! It seems that you're missing the logic for actually using the new field to filter the trailers. We'll need to add this somewhere in the ServeMux logic, I suggest looking at how outgoingHeaderMatcher is used.

Also I'd like a test for this before we can merge it. Again I suggest looking at how outgoingHeaderMatcher is tested.

Let me know if you need anymore pointers!

runtime/mux.go Outdated Show resolved Hide resolved
runtime/mux.go Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Oct 6, 2020

I am unsure of how to test the handler. Should I modify the TestForwardResponseMessage func to include tests with trailers in handler_test.go? Or append a spec to the TestMuxServeHTTP func in mux_test.go? I'm assuming the latter, even though the changes were made in handler.go.

@johanbrandhorst
Copy link
Collaborator

I am unsure of how to test the handler. Should I modify the TestForwardResponseMessage func to include tests with trailers in handler_test.go? Or append a spec to the TestMuxServeHTTP func in mux_test.go? I'm assuming the latter, even though the changes were made in handler.go.

Sorry if I wasn't clear. I thought we had some tests for outgoingHeaderMatcher but it doesn't look like it 😂. I think these tests would probably live in handler_test, maybe in a new test that can test the functionality of the outgoing trailer matcher. You can copy one of the existing tests and play around with it until it does what you want, but at the very least we should have a test without the trailer matcher set, and another test with a custom trailer matcher and check that the behaviour changes as expected.

Does that sound okay?

@ghost
Copy link
Author

ghost commented Oct 7, 2020

Got it. No worries. I didn't add the logic at first because I mistakenly thought the implementation of the interface would be done by the client, but even back then I still felt like I was incorrect. I will continue to work on this until it is up to standard.

@ghost
Copy link
Author

ghost commented Oct 7, 2020

Still unsure of how to test in handler_test.go, the only test headers I see are in mux_test.go.I feel like both test files need to be modified in order to test this functionality. The modified handler was the non-exported func handleForwardResponseServerMetadata(w http.ResponseWriter, mux *ServeMux, md ServerMetadata)

@ghost
Copy link
Author

ghost commented Oct 7, 2020

The CI tests pass because if there is no specified outgoingTrailerMatcher, "TE" will be passed. The original issue wanted to be agnostic to whether or not "TE" was passed.
However, gRPC trailers will be forwarded by default, so I believe this is in conflict with #1709

@johanbrandhorst
Copy link
Collaborator

I'm not sure what you're trying to say. There are two different concerns here:

These are separate concerns, there is no conflict between the two. This PR should tackle #1697. Don't worry about the other issue for the purposes of this PR.

Re: testing, I think you should be able to copy one of the tests in handler_test.go and adjust it so that it can test the behaviour of the outgoingTrailerMatcher. Have you tried doing this?

@ghost
Copy link
Author

ghost commented Oct 8, 2020

I am not necessarily saying there is a conflict between the concerns. I'm saying that the way I resolved issue #1697 the TE" header is set just returns "Grpc-Trailer-TE" and true by default, with or without values, similar to outgoingHeaderMatcher. Not sure if what I did is the correct approach, but it is why it passes the CI tests. I apologize for the confusion, I am still working on it.

Ok. I'll spend more time attempting to modify the handler_test.go.

Also, If you have any tips for me to improve my communication, please let me know. I am gladly willing to explain my current understanding of the problem, no matter how incorrect it may be, so that we can solve the issue. I took this on thinking it was OK for first timers.
The reason why I brought up the fact that the modified function is non exported is because current tests check Forwarded Streams and Messages, which call it internally. Since it didn't break those tests, and outgoingHeaderMatcher was not tested prior to this, I thought the tests that cover this are written somewhere outside of handler_test.go

@ghost ghost marked this pull request as ready for review October 9, 2020 16:43
@johanbrandhorst
Copy link
Collaborator

Hi, could you please rebase this on master? We've merged v2 into master.

@johanbrandhorst
Copy link
Collaborator

Are you still intending to merge this? Otherwise I will close it soon.

@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 6, 2021
@stale stale bot closed this Jan 14, 2021
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.

Support WithOutgoingTrailerMatcher
2 participants