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

Add checks in referenceclient to validate raw gRPC-Web trailers and actual HTTP trailers #780

Merged
merged 7 commits into from
Feb 12, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented Feb 8, 2024

This adds handling of the HTTP trailers and gRPC-Web end-stream messages to the reference client. When in reference mode, it will examine them and make sure they are appropriate, using stricter checks than connect-go (so we can't just rely on the base connect-go client implementation to raise these issues in the conformance results).

@jhump jhump force-pushed the jh/grpc-web-trailers branch 2 times, most recently from 0738a26 to 13c7660 Compare February 8, 2024 17:19
@jhump jhump changed the title Reference client returns actual gRPC-Web trailer data, for new test runner checks Add checks in test runner to validate raw gRPC-Web trailers and actual HTTP trailers Feb 8, 2024
@jhump jhump force-pushed the jh/grpc-web-trailers branch from 55286a5 to 9c0b785 Compare February 8, 2024 18:36
@jhump jhump marked this pull request as ready for review February 8, 2024 18:36
@jhump jhump requested a review from smaye81 February 8, 2024 18:36
return errs
}

func checkGRPCWebTrailers(rawGRPCWebTrailers string, reportedTrailers []*conformancev1.Header) multiErrors {
Copy link
Member

Choose a reason for hiding this comment

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

Might be good to have unit tests for this. It seems sufficiently complex enough that we'd want to test it.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I was being lazy programmer. I'll add tests.

@jhump jhump force-pushed the jh/grpc-web-trailers branch from 9c0b785 to a0c5006 Compare February 9, 2024 15:35
@jhump jhump changed the title Add checks in test runner to validate raw gRPC-Web trailers and actual HTTP trailers Add checks in referenceclient to validate raw gRPC-Web trailers and actual HTTP trailers Feb 9, 2024
@jhump jhump marked this pull request as draft February 9, 2024 15:48
@jhump jhump marked this pull request as ready for review February 10, 2024 02:35
@jhump
Copy link
Member Author

jhump commented Feb 10, 2024

@smaye81, okay, I've got this rebased now that all of the wire detail checks are just in the reference client. BTW, I think the best will be easiest to review one commit at a time (particularly because I renamed a file in the first commit, and viewing the diff for the whole PR shows it as one file removed and another added).

I updated this to use the same "printer" abstraction that the reference server uses for logging issues, but instead of getting written to stderr, these get recorded into a []string.

I've also added a test with numerous cases, to verify the logic. And, admittedly, that logic got more complicated so that (1) it can handle different kinds of line endings and complain about them, (2) it can correctly handle "obsolete line folding" described in the spec and complain about it, and (3) validate the field name (in previous iteration, I somehow missed that, and it was only checking the value).

@jhump jhump force-pushed the jh/grpc-web-trailers branch from aefbd29 to dfb7e40 Compare February 10, 2024 02:40
@jhump jhump force-pushed the jh/grpc-web-trailers branch from dfb7e40 to c307412 Compare February 10, 2024 02:41
// TODO
}

func examineGRPCEndStream(endStream string, printer internal.Printer) {
Copy link
Member

Choose a reason for hiding this comment

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

Holy cow, haha, this is great. This almost feels like it could be its own package to help others validate end streams.

…o some of the wire-details-related functions; fix racy behavior that can result in flaky failures with timeout test cases
@jhump
Copy link
Member Author

jhump commented Feb 12, 2024

@smaye81, I just pushed one more commit. Some stuff in that commit were a few small renames and additional doc comments in the wire details stuff, in the hopes of making things a little more clearly named and easier to read.

But I also had to change the capture stuff from using an atomic pointer to using a channel to await the value being available. This is because, sadly, it can't be helped that sometimes there will be some raciness between the goroutine executing the HTTP operation and the RPC caller's goroutine for the timeout cases (only for client- and bidi-stream RPCs; for other kinds of RPCs, the HTTP operation is issued on the same goroutine as the RPC caller).

See 6386c4c.

@jhump jhump enabled auto-merge (squash) February 12, 2024 17:59
@jhump jhump merged commit c31206d into main Feb 12, 2024
7 checks passed
@jhump jhump deleted the jh/grpc-web-trailers branch February 12, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants