@@ -720,6 +720,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
720720 idGenerator: . init( ) ,
721721 maximumConcurrentHTTP1Connections: 8 ,
722722 retryConnectionEstablishment: true ,
723+ preferHTTP1: true ,
723724 maximumConnectionUses: nil
724725 )
725726
@@ -811,6 +812,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
811812 idGenerator: . init( ) ,
812813 maximumConcurrentHTTP1Connections: 8 ,
813814 retryConnectionEstablishment: true ,
815+ preferHTTP1: false ,
814816 maximumConnectionUses: nil
815817 )
816818
@@ -858,6 +860,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
858860 idGenerator: . init( ) ,
859861 maximumConcurrentHTTP1Connections: 8 ,
860862 retryConnectionEstablishment: true ,
863+ preferHTTP1: true ,
861864 maximumConnectionUses: nil
862865 )
863866
@@ -998,6 +1001,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
9981001 idGenerator: . init( ) ,
9991002 maximumConcurrentHTTP1Connections: 8 ,
10001003 retryConnectionEstablishment: true ,
1004+ preferHTTP1: false ,
10011005 maximumConnectionUses: nil
10021006 )
10031007
@@ -1014,11 +1018,11 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
10141018 XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request1. id) )
10151019 let http2Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID, eventLoop: el1)
10161020 XCTAssertNoThrow ( try connections. succeedConnectionCreationHTTP2 ( http2ConnID, maxConcurrentStreams: 10 ) )
1017- let migrationAction1 = state. newHTTP2ConnectionCreated ( http2Conn, maxConcurrentStreams: 10 )
1018- guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn) = migrationAction1 . request else {
1019- return XCTFail ( " unexpected request action \( migrationAction1 . request) " )
1021+ let executeAction1 = state. newHTTP2ConnectionCreated ( http2Conn, maxConcurrentStreams: 10 )
1022+ guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn) = executeAction1 . request else {
1023+ return XCTFail ( " unexpected request action \( executeAction1 . request) " )
10201024 }
1021- XCTAssertEqual ( migrationAction1 . connection , . migration ( createConnections : [ ] , closeConnections : [ ] , scheduleTimeout : nil ) )
1025+
10221026 XCTAssertEqual ( requests. count, 1 )
10231027 for request in requests {
10241028 XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1069,6 +1073,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
10691073 idGenerator: . init( ) ,
10701074 maximumConcurrentHTTP1Connections: 8 ,
10711075 retryConnectionEstablishment: true ,
1076+ preferHTTP1: false ,
10721077 maximumConnectionUses: nil
10731078 )
10741079
@@ -1085,11 +1090,11 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
10851090 XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request1. id) )
10861091 let http2Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID, eventLoop: el1)
10871092 XCTAssertNoThrow ( try connections. succeedConnectionCreationHTTP2 ( http2ConnID, maxConcurrentStreams: 10 ) )
1088- let migrationAction1 = state. newHTTP2ConnectionCreated ( http2Conn, maxConcurrentStreams: 10 )
1089- guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn) = migrationAction1 . request else {
1090- return XCTFail ( " unexpected request action \( migrationAction1 . request) " )
1093+ let executeAction1 = state. newHTTP2ConnectionCreated ( http2Conn, maxConcurrentStreams: 10 )
1094+ guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn) = executeAction1 . request else {
1095+ return XCTFail ( " unexpected request action \( executeAction1 . request) " )
10911096 }
1092- XCTAssertEqual ( migrationAction1 . connection , . migration ( createConnections : [ ] , closeConnections : [ ] , scheduleTimeout : nil ) )
1097+
10931098 XCTAssertEqual ( requests. count, 1 )
10941099 for request in requests {
10951100 XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1120,7 +1125,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
11201125 }
11211126 XCTAssertTrue ( queuer. isEmpty)
11221127
1123- // if we established a new http/1 connection we should migrate back to http/1,
1128+ // if we established a new http/1 connection we should migrate to http/1,
11241129 // close the connection and shutdown the pool
11251130 let http1Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http1ConnId, eventLoop: el2)
11261131 XCTAssertNoThrow ( try connections. succeedConnectionCreationHTTP1 ( http1ConnId) )
@@ -1146,11 +1151,12 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
11461151 idGenerator: . init( ) ,
11471152 maximumConcurrentHTTP1Connections: 8 ,
11481153 retryConnectionEstablishment: true ,
1154+ preferHTTP1: false ,
11491155 maximumConnectionUses: nil
11501156 )
11511157
11521158 var connectionIDs : [ HTTPConnectionPool . Connection . ID ] = [ ]
1153- for el in [ el1, el2, el2 ] {
1159+ for el in [ el1, el2] {
11541160 let mockRequest = MockHTTPScheduableRequest ( eventLoop: el, requiresEventLoopForChannel: true )
11551161 let request = HTTPConnectionPool . Request ( mockRequest)
11561162 let action = state. executeRequest ( request)
@@ -1164,7 +1170,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
11641170 XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request. id) )
11651171 }
11661172
1167- // fail the two connections for el2
1173+ // fail the connection for el2
11681174 for connectionID in connectionIDs. dropFirst ( ) {
11691175 struct SomeError : Error { }
11701176 XCTAssertNoThrow ( try connections. failConnectionCreation ( connectionID) )
@@ -1177,16 +1183,14 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
11771183 }
11781184 let http2ConnID1 = connectionIDs [ 0 ]
11791185 let http2ConnID2 = connectionIDs [ 1 ]
1180- let http2ConnID3 = connectionIDs [ 2 ]
11811186
11821187 // let the first connection on el1 succeed as a http2 connection
11831188 let http2Conn1 : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID1, eventLoop: el1)
11841189 XCTAssertNoThrow ( try connections. succeedConnectionCreationHTTP2 ( http2ConnID1, maxConcurrentStreams: 10 ) )
1185- let migrationAction1 = state. newHTTP2ConnectionCreated ( http2Conn1, maxConcurrentStreams: 10 )
1186- guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn1) = migrationAction1 . request else {
1187- return XCTFail ( " unexpected request action \( migrationAction1 . request) " )
1190+ let connectionAction = state. newHTTP2ConnectionCreated ( http2Conn1, maxConcurrentStreams: 10 )
1191+ guard case . executeRequestsAndCancelTimeouts( let requests, http2Conn1) = connectionAction . request else {
1192+ return XCTFail ( " unexpected request action \( connectionAction . request) " )
11881193 }
1189- XCTAssertEqual ( migrationAction1. connection, . migration( createConnections: [ ] , closeConnections: [ ] , scheduleTimeout: nil ) )
11901194 XCTAssertEqual ( requests. count, 1 )
11911195 for request in requests {
11921196 XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1205,14 +1209,6 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
12051209 }
12061210 XCTAssertTrue ( eventLoop2 === el2)
12071211 XCTAssertNoThrow ( try connections. createConnection ( newHttp2ConnID2, on: el2) )
1208-
1209- // we now have a starting connection for el2 and another one backing off
1210-
1211- // if the backoff timer fires now for a connection on el2, we should *not* start a new connection
1212- XCTAssertNoThrow ( try connections. connectionBackoffTimerDone ( http2ConnID3) )
1213- let action3 = state. connectionCreationBackoffDone ( http2ConnID3)
1214- XCTAssertEqual ( action3. request, . none)
1215- XCTAssertEqual ( action3. connection, . none)
12161212 }
12171213
12181214 func testMaxConcurrentStreamsIsRespected( ) {
0 commit comments