-
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
Accept PING frames even when fully quiesced #455
Merged
gjcairo
merged 5 commits into
apple:main
from
clintonpi:accept-pings-when-fully-quiesced
Aug 30, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b9901cb
Accept PING frames even when fully quiesced
clintonpi aae3b17
Patch
clintonpi b97f845
Adjust E2E test
clintonpi 6c066d5
Merge branch 'main' into accept-pings-when-fully-quiesced
clintonpi 4812228
Merge branch 'main' into accept-pings-when-fully-quiesced
gjcairo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -864,6 +864,42 @@ class SimpleClientServerTests: XCTestCase { | |||||||||||||||||
XCTAssertTrue(error is NIOHTTP2Errors.UnableToParseFrame) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@available(*, deprecated, message: "Deprecated so deprecated functionality can be tested without warnings") | ||||||||||||||||||
func testSuccessfullyReceiveAndSendPingEvenWhenConnectionIsFullyQuiesced() throws { | ||||||||||||||||||
let serverHandler = FrameRecorderHandler() | ||||||||||||||||||
try self.basicHTTP2Connection() { channel, streamID in | ||||||||||||||||||
return channel.pipeline.addHandler(serverHandler) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
let goAwayFrame = HTTP2Frame(streamID: .rootStream, payload: .goAway(lastStreamID: .rootStream, errorCode: .noError, opaqueData: nil)) | ||||||||||||||||||
|
||||||||||||||||||
// Fully quiesce the connection on the server. | ||||||||||||||||||
serverChannel.writeAndFlush(goAwayFrame, promise: nil) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The go away frame is strongly coupled with this write so it makes sense to group it with it and the comment.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
let pingFrame = HTTP2Frame(streamID: .rootStream, payload: .ping(HTTP2PingData(), ack: false)) | ||||||||||||||||||
|
||||||||||||||||||
// Send PING frame to the server. | ||||||||||||||||||
clientChannel.writeAndFlush(pingFrame, promise: nil) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here:
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
self.interactInMemory(self.clientChannel, self.serverChannel) | ||||||||||||||||||
|
||||||||||||||||||
// The client receives the GOAWAY frame and fully quiesces the connection. | ||||||||||||||||||
try self.clientChannel.assertReceivedFrame().assertGoAwayFrame(lastStreamID: .rootStream, errorCode: 0, opaqueData: nil) | ||||||||||||||||||
|
||||||||||||||||||
// The server receives and responds to the PING. | ||||||||||||||||||
try self.serverChannel.assertReceivedFrame().assertPingFrame(ack: false, opaqueData: HTTP2PingData()) | ||||||||||||||||||
|
||||||||||||||||||
// The client receives the PING response. | ||||||||||||||||||
try self.clientChannel.assertReceivedFrame().assertPingFrame(ack: true, opaqueData: HTTP2PingData()) | ||||||||||||||||||
|
||||||||||||||||||
// No frames left. | ||||||||||||||||||
self.clientChannel.assertNoFramesReceived() | ||||||||||||||||||
self.serverChannel.assertNoFramesReceived() | ||||||||||||||||||
|
||||||||||||||||||
XCTAssertNoThrow(try self.clientChannel.finish()) | ||||||||||||||||||
XCTAssertNoThrow(try self.serverChannel.finish()) | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
final class ActionOnFlushHandler: ChannelOutboundHandler { | ||||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm afraid you've fallen into one of the many deprecated-API traps 🪤
This whole test class is deprecated because it's testing deprecated APIs. There's an equivalent set of tests in
SimpleClientServerInlineStreamMultiplexerTests
where this test should live. I think in this instance your test should just work without modifications.An aside on the deprecated APIs. The original APIs for multiplexing created child channels for streams where you'd read and write
HTTP2Frame
s.Each
HTTP2Frame
holds a stream ID and its payload (headers, data etc.) However, when you open a stream the connection state machine wouldn't know about the stream until you did the first write on that stream.This means that a client could create stream 1 and then stream 3 but write on stream 3 first. A subsequent write on stream 1 would be a protocol violation (new streams must have higher IDs than previously created streams).
To fix this we added new stream creation APIs where the child channels operate on
HTTP2Frame.FramePayload
s and only when they do their first write do they get assigned a stream ID.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, that makes sense. Thanks.