-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
Codecov Report
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
|
@dfawley @arvindbr8 can you suggest how could i assert/verify the error? |
@AnandInguva - Sure, taking a look |
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've taken a first pass at your PR. Please let me know if you have any questions
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've made a few more comments. PTAL
Yeah, let me make some changes soon |
Co-authored-by: Arvind Bright <arvind.bright100@gmail.com>
test/end2end_test.go
Outdated
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 { |
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.
If you want to be fancy:
if got, want := string(goAwayFrame.DebugData()), "received ..."; got != want {
}
// the transport throws an error. | ||
// | ||
// [HTTP/2 spec]: https://httpwg.org/specs/rfc7540.html#StreamIdentifiers | ||
func (s) TestClientInvalidStreamID(t *testing.T) { |
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.
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.
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 will take a look today and add if tests are not present.
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.
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?
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.
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.
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.
Added one more test. PTAL
test/end2end_test.go
Outdated
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) |
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.
Nit: "want: Contains(%v)
" or something to indicate what's happening.
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.
Done
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 see it changed below but not here.
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.
ah right. changed in the previous test as well. thanks
Fixes: #104
RELEASE NOTES: none