-
Notifications
You must be signed in to change notification settings - Fork 84
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
Multiplexer tests for payload-based stream channels #225
Conversation
Motivation: As part of apple#214 we added a stream channel which deals with `HTTP2Frame.FramePayload` as well as the relevant entry points in `HTTP2StreamMultiplexer` to create these streams. We didn't add a corresponding set of tests. Modifications: - Duplicate `HTTP2StreamMultiplexerTests` - Refactor to make use of new stream creation function and new inbound stream initializer - Fix up a couple of bugs in `HTTP2StreamMultiplexer`: - activate pending streams on `channelActive` - deactivate pending streams on `channelInactive` - change stream writability for pending streams on `channelWritabilityChanged` - add implementation for `childChannelClosed(channelID:)` Result: - Tests for payload-based stream creation via `HTTP2StreamMultiplexer`
// Write some headers: the flush will trigger a stream ID to be assigned to the channel. | ||
channel.writeAndFlush(HTTP2Frame.FramePayload.headers(.init(headers: [:]))).whenSuccess { | ||
channel.getOption(HTTP2StreamChannelOptions.streamID).whenSuccess { streamID in | ||
streamIDs.append(streamID) | ||
} | ||
} |
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.
There are some changes here.
// Write some headers: the flush will trigger a stream ID to be assigned to the channel. | ||
channel.writeAndFlush(HTTP2Frame.FramePayload.headers(.init(headers: [:]))).whenSuccess { | ||
channel.getOption(HTTP2StreamChannelOptions.streamID).whenSuccess { streamID in | ||
streamIDs.append(streamID) | ||
} | ||
} |
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.
There are some changes here.
// We need to write (and flush) some data so that the streams get stream IDs. | ||
for childChannel in channels { | ||
XCTAssertNoThrow(try childChannel.writeAndFlush(HTTP2Frame.FramePayload.headers(.init(headers: [:]))).wait()) | ||
} |
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 is extra.
// We need to write (and flush) some data so that the streams get stream IDs. | ||
XCTAssertNoThrow(try childChannel.writeAndFlush(HTTP2Frame.FramePayload.headers(.init(headers: [:]))).wait()) |
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 is extra.
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.
Ace, it's fantastic to see all these tests passing.
Motivation:
As part of #214 we added a stream channel which deals with
HTTP2Frame.FramePayload
as well as the relevant entry points inHTTP2StreamMultiplexer
to create these streams. We didn't add acorresponding set of tests.
Modifications:
HTTP2StreamMultiplexerTests
stream initializer
HTTP2StreamMultiplexer
:channelActive
channelInactive
channelWritabilityChanged
childChannelClosed(channelID:)
Result:
HTTP2StreamMultiplexer