@@ -720,6 +720,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
720
720
idGenerator: . init( ) ,
721
721
maximumConcurrentHTTP1Connections: 8 ,
722
722
retryConnectionEstablishment: true ,
723
+ preferHTTP1: true ,
723
724
maximumConnectionUses: nil
724
725
)
725
726
@@ -811,6 +812,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
811
812
idGenerator: . init( ) ,
812
813
maximumConcurrentHTTP1Connections: 8 ,
813
814
retryConnectionEstablishment: true ,
815
+ preferHTTP1: false ,
814
816
maximumConnectionUses: nil
815
817
)
816
818
@@ -858,6 +860,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
858
860
idGenerator: . init( ) ,
859
861
maximumConcurrentHTTP1Connections: 8 ,
860
862
retryConnectionEstablishment: true ,
863
+ preferHTTP1: true ,
861
864
maximumConnectionUses: nil
862
865
)
863
866
@@ -998,6 +1001,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
998
1001
idGenerator: . init( ) ,
999
1002
maximumConcurrentHTTP1Connections: 8 ,
1000
1003
retryConnectionEstablishment: true ,
1004
+ preferHTTP1: false ,
1001
1005
maximumConnectionUses: nil
1002
1006
)
1003
1007
@@ -1014,11 +1018,11 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1014
1018
XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request1. id) )
1015
1019
let http2Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID, eventLoop: el1)
1016
1020
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) " )
1020
1024
}
1021
- XCTAssertEqual ( migrationAction1 . connection , . migration ( createConnections : [ ] , closeConnections : [ ] , scheduleTimeout : nil ) )
1025
+
1022
1026
XCTAssertEqual ( requests. count, 1 )
1023
1027
for request in requests {
1024
1028
XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1069,6 +1073,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1069
1073
idGenerator: . init( ) ,
1070
1074
maximumConcurrentHTTP1Connections: 8 ,
1071
1075
retryConnectionEstablishment: true ,
1076
+ preferHTTP1: false ,
1072
1077
maximumConnectionUses: nil
1073
1078
)
1074
1079
@@ -1085,11 +1090,11 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1085
1090
XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request1. id) )
1086
1091
let http2Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID, eventLoop: el1)
1087
1092
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) " )
1091
1096
}
1092
- XCTAssertEqual ( migrationAction1 . connection , . migration ( createConnections : [ ] , closeConnections : [ ] , scheduleTimeout : nil ) )
1097
+
1093
1098
XCTAssertEqual ( requests. count, 1 )
1094
1099
for request in requests {
1095
1100
XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1120,7 +1125,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1120
1125
}
1121
1126
XCTAssertTrue ( queuer. isEmpty)
1122
1127
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,
1124
1129
// close the connection and shutdown the pool
1125
1130
let http1Conn : HTTPConnectionPool . Connection = . __testOnly_connection( id: http1ConnId, eventLoop: el2)
1126
1131
XCTAssertNoThrow ( try connections. succeedConnectionCreationHTTP1 ( http1ConnId) )
@@ -1146,11 +1151,12 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1146
1151
idGenerator: . init( ) ,
1147
1152
maximumConcurrentHTTP1Connections: 8 ,
1148
1153
retryConnectionEstablishment: true ,
1154
+ preferHTTP1: false ,
1149
1155
maximumConnectionUses: nil
1150
1156
)
1151
1157
1152
1158
var connectionIDs : [ HTTPConnectionPool . Connection . ID ] = [ ]
1153
- for el in [ el1, el2, el2 ] {
1159
+ for el in [ el1, el2] {
1154
1160
let mockRequest = MockHTTPScheduableRequest ( eventLoop: el, requiresEventLoopForChannel: true )
1155
1161
let request = HTTPConnectionPool . Request ( mockRequest)
1156
1162
let action = state. executeRequest ( request)
@@ -1164,7 +1170,7 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1164
1170
XCTAssertNoThrow ( try queuer. queue ( mockRequest, id: request. id) )
1165
1171
}
1166
1172
1167
- // fail the two connections for el2
1173
+ // fail the connection for el2
1168
1174
for connectionID in connectionIDs. dropFirst ( ) {
1169
1175
struct SomeError : Error { }
1170
1176
XCTAssertNoThrow ( try connections. failConnectionCreation ( connectionID) )
@@ -1177,16 +1183,14 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1177
1183
}
1178
1184
let http2ConnID1 = connectionIDs [ 0 ]
1179
1185
let http2ConnID2 = connectionIDs [ 1 ]
1180
- let http2ConnID3 = connectionIDs [ 2 ]
1181
1186
1182
1187
// let the first connection on el1 succeed as a http2 connection
1183
1188
let http2Conn1 : HTTPConnectionPool . Connection = . __testOnly_connection( id: http2ConnID1, eventLoop: el1)
1184
1189
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) " )
1188
1193
}
1189
- XCTAssertEqual ( migrationAction1. connection, . migration( createConnections: [ ] , closeConnections: [ ] , scheduleTimeout: nil ) )
1190
1194
XCTAssertEqual ( requests. count, 1 )
1191
1195
for request in requests {
1192
1196
XCTAssertNoThrow ( try queuer. get ( request. id, request: request. __testOnly_wrapped_request ( ) ) )
@@ -1205,14 +1209,6 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase {
1205
1209
}
1206
1210
XCTAssertTrue ( eventLoop2 === el2)
1207
1211
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)
1216
1212
}
1217
1213
1218
1214
func testMaxConcurrentStreamsIsRespected( ) {
0 commit comments