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

Multiplexer tests for payload-based stream channels #225

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Aug 3, 2020

Motivation:

As part of #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

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`
@glbrntt glbrntt requested a review from Lukasa August 3, 2020 15:07
@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Aug 3, 2020
Comment on lines +1046 to +1051
// 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)
}
}
Copy link
Contributor Author

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.

Comment on lines +1000 to +1005
// 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)
}
}
Copy link
Contributor Author

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.

Comment on lines +1575 to +1578
// 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())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is extra.

Comment on lines +1622 to +1623
// 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())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is extra.

Copy link
Contributor

@Lukasa Lukasa left a 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.

@Lukasa Lukasa merged commit b03b4e8 into apple:master Aug 3, 2020
@glbrntt glbrntt deleted the gb-mux-framepayload-tests branch August 3, 2020 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants