Skip to content

Commit a965052

Browse files
committed
Fix tests on nghttp2-1.34.0
Motivation: nghttp2 changed the error code it returns when the server sends a GOAWAY. It's now `.cancelled` instead of `.refusedStream`. Modifications: Don't require a specific error code in the tests, just require that an error matching the expected stream ID occurred. Result: Tests will pass on nghttp2-1.34.0.
1 parent 83d27d1 commit a965052

File tree

3 files changed

+121
-3
lines changed

3 files changed

+121
-3
lines changed
88 KB
Binary file not shown.

Tests/NIOHTTP2Tests/SimpleClientServerTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ class SimpleClientServerTests: XCTestCase {
966966
self.interactInMemory(self.clientChannel, self.serverChannel)
967967
try self.clientChannel.assertReceivedFrame().assertGoAwayFrame(lastStreamID: 0, errorCode: UInt32(http2ErrorCode: HTTP2ErrorCode.inadequateSecurity), opaqueData: nil)
968968

969-
// The data frame write should have exploded. nghttp2 synthesises a "refusedStream" error code for this.
970-
XCTAssertEqual(writeError as? NIOHTTP2Errors.StreamClosed, NIOHTTP2Errors.StreamClosed(streamID: clientStreamID, errorCode: .refusedStream))
969+
// The data frame write should have exploded. nghttp2 synthesises an error code for this.
970+
XCTAssertEqual((writeError as? NIOHTTP2Errors.StreamClosed)?.streamID, clientStreamID)
971971

972972
// No other frames should be emitted.
973973
self.clientChannel.assertNoFramesReceived()
@@ -1170,7 +1170,7 @@ class SimpleClientServerTests: XCTestCase {
11701170
// Now the streams are closed, they should have seen user events.
11711171
XCTAssertEqual(clientHandler.events.count, 1)
11721172
XCTAssertEqual(serverHandler.events.count, 1)
1173-
XCTAssertEqual(clientHandler.events[0] as? StreamClosedEvent, StreamClosedEvent(streamID: clientStreamID, reason: .refusedStream))
1173+
XCTAssertEqual((clientHandler.events[0] as? StreamClosedEvent)?.streamID, clientStreamID)
11741174
XCTAssertEqual(serverHandler.events[0] as? StreamClosedEvent, StreamClosedEvent(streamID: serverStreamID, reason: .refusedStream))
11751175

11761176
XCTAssertNoThrow(try self.clientChannel.finish())
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import XCTest
2+
3+
extension BasicTests {
4+
static let __allTests = [
5+
("testCanInitializeInnerSession", testCanInitializeInnerSession),
6+
("testThrowsErrorOnBasicProtocolViolation", testThrowsErrorOnBasicProtocolViolation),
7+
]
8+
}
9+
10+
extension HTTP2StreamMultiplexerTests {
11+
static let __allTests = [
12+
("testChannelsCloseAfterGoawayFrameFirstThenEvent", testChannelsCloseAfterGoawayFrameFirstThenEvent),
13+
("testChannelsCloseAfterResetStreamFrameFirstThenEvent", testChannelsCloseAfterResetStreamFrameFirstThenEvent),
14+
("testChannelsCloseThemselvesWhenToldTo", testChannelsCloseThemselvesWhenToldTo),
15+
("testClosePromiseFailsWithError", testClosePromiseFailsWithError),
16+
("testClosePromiseIsSatisfiedWithTheEvent", testClosePromiseIsSatisfiedWithTheEvent),
17+
("testClosingActiveChannels", testClosingActiveChannels),
18+
("testClosingIdleChannels", testClosingIdleChannels),
19+
("testCreatingOutboundChannel", testCreatingOutboundChannel),
20+
("testFailingInitializerDoesNotWrite", testFailingInitializerDoesNotWrite),
21+
("testFlushingOneChannelDoesntFlushThemAll", testFlushingOneChannelDoesntFlushThemAll),
22+
("testFramesAreNotDeliveredIfSetUpFails", testFramesAreNotDeliveredIfSetUpFails),
23+
("testFramesAreNotDeliveredUntilStreamIsSetUp", testFramesAreNotDeliveredUntilStreamIsSetUp),
24+
("testFramesForClosedStreamsAreReported", testFramesForClosedStreamsAreReported),
25+
("testFramesForUnknownStreamsAreReported", testFramesForUnknownStreamsAreReported),
26+
("testHandlersAreRemovedOnClosure", testHandlersAreRemovedOnClosure),
27+
("testHandlersAreRemovedOnClosureWithError", testHandlersAreRemovedOnClosureWithError),
28+
("testHeadersFramesCreateNewChannels", testHeadersFramesCreateNewChannels),
29+
("testMultipleClosePromisesAreSatisfied", testMultipleClosePromisesAreSatisfied),
30+
("testMultiplexerIgnoresFramesOnStream0", testMultiplexerIgnoresFramesOnStream0),
31+
("testReadIsPerChannel", testReadIsPerChannel),
32+
("testReadPullsInAllFrames", testReadPullsInAllFrames),
33+
("testReadWillCauseAutomaticFrameDelivery", testReadWillCauseAutomaticFrameDelivery),
34+
("testReadWithNoPendingDataCausesReadOnParentChannel", testReadWithNoPendingDataCausesReadOnParentChannel),
35+
("testUnflushedWritesFailOnClose", testUnflushedWritesFailOnClose),
36+
("testUnflushedWritesFailOnError", testUnflushedWritesFailOnError),
37+
("testWritesAreCancelledOnFailingInitializer", testWritesAreCancelledOnFailingInitializer),
38+
("testWritesFailOnClosedStreamChannels", testWritesFailOnClosedStreamChannels),
39+
("testWritesOnCreatedChannelAreDelayed", testWritesOnCreatedChannelAreDelayed),
40+
]
41+
}
42+
43+
extension HTTP2ToHTTP1CodecTests {
44+
static let __allTests = [
45+
("testBasicRequestServerSide", testBasicRequestServerSide),
46+
("testBasicResponseClientSide", testBasicResponseClientSide),
47+
("testPassingPromisesThroughWritesOnClient", testPassingPromisesThroughWritesOnClient),
48+
("testPassingPromisesThroughWritesOnServer", testPassingPromisesThroughWritesOnServer),
49+
("testRequestWithOnlyHeadServerSide", testRequestWithOnlyHeadServerSide),
50+
("testRequestWithoutTrailers", testRequestWithoutTrailers),
51+
("testRequestWithTrailers", testRequestWithTrailers),
52+
("testResponseWith100Blocks", testResponseWith100Blocks),
53+
("testResponseWith100BlocksClientSide", testResponseWith100BlocksClientSide),
54+
("testResponseWithOnlyHeadClientSide", testResponseWithOnlyHeadClientSide),
55+
("testResponseWithoutTrailers", testResponseWithoutTrailers),
56+
("testResponseWithTrailers", testResponseWithTrailers),
57+
("testSendingSimpleRequest", testSendingSimpleRequest),
58+
("testSendingSimpleResponse", testSendingSimpleResponse),
59+
]
60+
}
61+
62+
extension ReentrancyTests {
63+
static let __allTests = [
64+
("testReenterInactiveOnRead", testReenterInactiveOnRead),
65+
("testReenterReadEOFOnRead", testReenterReadEOFOnRead),
66+
("testReEnterReadOnRead", testReEnterReadOnRead),
67+
]
68+
}
69+
70+
extension SimpleClientServerTests {
71+
static let __allTests = [
72+
("test1XXResponseHeaderFields", test1XXResponseHeaderFields),
73+
("testAutomaticFlowControl", testAutomaticFlowControl),
74+
("testBadClientMagic", testBadClientMagic),
75+
("testBasicPingFrames", testBasicPingFrames),
76+
("testBasicRequestResponse", testBasicRequestResponse),
77+
("testCachingInteractionWithMaxConcurrentStreams", testCachingInteractionWithMaxConcurrentStreams),
78+
("testDontRemoveActiveStreams", testDontRemoveActiveStreams),
79+
("testFailingFlushedWritesForGoaway", testFailingFlushedWritesForGoaway),
80+
("testFailingFlushedWritesForResetStream", testFailingFlushedWritesForResetStream),
81+
("testFailingUnflushedWritesForGoaway", testFailingUnflushedWritesForGoaway),
82+
("testFailingUnflushedWritesForResetStream", testFailingUnflushedWritesForResetStream),
83+
("testFrameReceivesDoNotTriggerFlushes", testFrameReceivesDoNotTriggerFlushes),
84+
("testGoAwayWithStreamsUpQuiescing", testGoAwayWithStreamsUpQuiescing),
85+
("testLargeDataFramesAreSplit", testLargeDataFramesAreSplit),
86+
("testManyConcurrentInactiveStreams", testManyConcurrentInactiveStreams),
87+
("testManyRequestsAtOnce", testManyRequestsAtOnce),
88+
("testMoreRequestsThanMaxConcurrentStreamsAtOnce", testMoreRequestsThanMaxConcurrentStreamsAtOnce),
89+
("testNothingButGoaway", testNothingButGoaway),
90+
("testOverridingDefaultSettings", testOverridingDefaultSettings),
91+
("testPartialFrame", testPartialFrame),
92+
("testPriorityFramesAreNotEmitted", testPriorityFramesAreNotEmitted),
93+
("testSendingDataFrameWithLargeFile", testSendingDataFrameWithLargeFile),
94+
("testSendingDataFrameWithSmallFile", testSendingDataFrameWithSmallFile),
95+
("testSendingTrailers", testSendingTrailers),
96+
("testStreamClosedViaGoaway", testStreamClosedViaGoaway),
97+
("testStreamClosedViaRstStream", testStreamClosedViaRstStream),
98+
("testStreamClosedWithNoError", testStreamClosedWithNoError),
99+
("testStreamCloseEventForGoawayFiresAfterFrame", testStreamCloseEventForGoawayFiresAfterFrame),
100+
("testStreamCloseEventForRstStreamFiresAfterFrame", testStreamCloseEventForRstStreamFiresAfterFrame),
101+
("testUnflushedWritesAreFailedOnChannelInactive", testUnflushedWritesAreFailedOnChannelInactive),
102+
("testUnflushedWritesAreFailedOnChannelInactiveRentrant", testUnflushedWritesAreFailedOnChannelInactiveRentrant),
103+
("testUnflushedWritesAreFailedOnHalfClosure", testUnflushedWritesAreFailedOnHalfClosure),
104+
("testUnflushedWritesAreFailedOnHalfClosureReentrant", testUnflushedWritesAreFailedOnHalfClosureReentrant),
105+
]
106+
}
107+
108+
#if !os(macOS)
109+
public func __allTests() -> [XCTestCaseEntry] {
110+
return [
111+
testCase(BasicTests.__allTests),
112+
testCase(HTTP2StreamMultiplexerTests.__allTests),
113+
testCase(HTTP2ToHTTP1CodecTests.__allTests),
114+
testCase(ReentrancyTests.__allTests),
115+
testCase(SimpleClientServerTests.__allTests),
116+
]
117+
}
118+
#endif

0 commit comments

Comments
 (0)