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

test: add test for invalid streamID #6940

Merged
merged 28 commits into from
Feb 20, 2024
Merged

Conversation

AnandInguva
Copy link
Contributor

@AnandInguva AnandInguva commented Jan 24, 2024

Fixes: #104

RELEASE NOTES: none

Copy link

linux-foundation-easycla bot commented Jan 24, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

test/end2end_test.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Merging #6940 (3522f84) into master (d41b01d) will decrease coverage by 0.20%.
Report is 11 commits behind head on master.
The diff coverage is 62.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6940      +/-   ##
==========================================
- Coverage   82.62%   82.42%   -0.20%     
==========================================
  Files         296      296              
  Lines       31432    31461      +29     
==========================================
- Hits        25970    25933      -37     
- Misses       4422     4469      +47     
- Partials     1040     1059      +19     
Files Coverage Δ
internal/transport/http2_server.go 90.70% <62.50%> (+<0.01%) ⬆️

... and 27 files with indirect coverage changes

@AnandInguva
Copy link
Contributor Author

@dfawley @arvindbr8 can you suggest how could i assert/verify the error?

@arvindbr8 arvindbr8 self-requested a review January 24, 2024 17:44
@arvindbr8
Copy link
Member

@AnandInguva - Sure, taking a look

Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

I've taken a first pass at your PR. Please let me know if you have any questions

test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

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

I've made a few more comments. PTAL

test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
@AnandInguva
Copy link
Contributor Author

Yeah, let me make some changes soon

test/end2end_test.go Outdated Show resolved Hide resolved
internal/transport/transport_test.go Outdated Show resolved Hide resolved
internal/transport/transport_test.go Outdated Show resolved Hide resolved
internal/transport/transport_test.go Outdated Show resolved Hide resolved
internal/transport/transport_test.go Outdated Show resolved Hide resolved
internal/transport/transport_test.go Outdated Show resolved Hide resolved
Co-authored-by: Arvind Bright <arvind.bright100@gmail.com>
Comment on lines 3929 to 3931
got := string(goAwayFrame.DebugData()[:])
want := "received an illegal stream id: 2. headers frame: [FrameHeader HEADERS flags=END_STREAM|END_HEADERS stream=2 len=60]"
if got != want {
Copy link
Member

Choose a reason for hiding this comment

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

If you want to be fancy:

if got, want := string(goAwayFrame.DebugData()), "received ..."; got != want {
}

internal/transport/http2_server.go Show resolved Hide resolved
@dfawley dfawley changed the title Add test for testing invalid streamID test: add test for invalid streamID Feb 9, 2024
internal/transport/http2_server.go Outdated Show resolved Hide resolved
test/end2end_test.go Outdated Show resolved Hide resolved
// the transport throws an error.
//
// [HTTP/2 spec]: https://httpwg.org/specs/rfc7540.html#StreamIdentifiers
func (s) TestClientInvalidStreamID(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Since we have this test now, and if we don't already have tests for other invalid stream ID conditions (e.g. a lower ID than the previous, or a stream ID of zero for the first stream), then now might be a good time to add related test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will take a look today and add if tests are not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stream ID of zero for the first stream

For this case, the http2/frame itself throws an error when we write frames of streamID 0 using serverTester. So I am guessing we can't do this test end to end and ask for question if we need this test at all?

Copy link
Member

Choose a reason for hiding this comment

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

It would still be nice to have a test for this, but I'm fine with punting for now if it's difficult to write. Presumably this is a different code path on the server (the framer may error reading the frame), so a test would still be a good idea to have one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added one more test. PTAL

test/end2end_test.go Outdated Show resolved Hide resolved
@AnandInguva AnandInguva requested a review from dfawley February 16, 2024 20:44
if got := string(goAwayFrame.DebugData()); got != want {
want := "received an illegal stream id: 2."
if got := string(goAwayFrame.DebugData()); !strings.Contains(got, want) {
t.Fatalf("Error received: %v, want: %v", got, want)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: "want: Contains(%v)" or something to indicate what's happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

I see it changed below but not here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah right. changed in the previous test as well. thanks

@arvindbr8 arvindbr8 merged commit 7525e98 into grpc:master Feb 20, 2024
14 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Behavior Change Behavior changes not categorized as bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please test with broken HTTP/2 stream IDs
4 participants