@@ -24,11 +24,13 @@ import NIOSSL
24
24
import XCTest
25
25
26
26
class HTTP2ClientTests : XCTestCase {
27
- func makeDefaultHTTPClient( ) -> HTTPClient {
27
+ func makeDefaultHTTPClient(
28
+ eventLoopGroupProvider: HTTPClient . EventLoopGroupProvider = . createNew
29
+ ) -> HTTPClient {
28
30
var tlsConfig = TLSConfiguration . makeClientConfiguration ( )
29
31
tlsConfig. certificateVerification = . none
30
32
return HTTPClient (
31
- eventLoopGroupProvider: . createNew ,
33
+ eventLoopGroupProvider: eventLoopGroupProvider ,
32
34
configuration: HTTPClient . Configuration (
33
35
tlsConfiguration: tlsConfig,
34
36
httpVersion: . automatic
@@ -38,9 +40,10 @@ class HTTP2ClientTests: XCTestCase {
38
40
}
39
41
40
42
func makeClientWithActiveHTTP2Connection< RequestHandler> (
41
- to bin: HTTPBin < RequestHandler >
43
+ to bin: HTTPBin < RequestHandler > ,
44
+ eventLoopGroupProvider: HTTPClient . EventLoopGroupProvider = . createNew
42
45
) -> HTTPClient {
43
- let client = self . makeDefaultHTTPClient ( )
46
+ let client = self . makeDefaultHTTPClient ( eventLoopGroupProvider : eventLoopGroupProvider )
44
47
var response : HTTPClient . Response ?
45
48
XCTAssertNoThrow ( response = try client. get ( url: " https://localhost: \( bin. port) /get " ) . wait ( ) )
46
49
XCTAssertEqual ( . ok, response? . status)
@@ -202,7 +205,9 @@ class HTTP2ClientTests: XCTestCase {
202
205
func testUncleanShutdownCancelsExecutingAndQueuedTasks( ) {
203
206
let bin = HTTPBin ( . http2( compress: false ) )
204
207
defer { XCTAssertNoThrow ( try bin. shutdown ( ) ) }
205
- let client = self . makeClientWithActiveHTTP2Connection ( to: bin)
208
+ let clientGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
209
+ defer { XCTAssertNoThrow ( try clientGroup. syncShutdownGracefully ( ) ) }
210
+ let client = self . makeClientWithActiveHTTP2Connection ( to: bin, eventLoopGroupProvider: . shared( clientGroup) )
206
211
207
212
// start 20 requests which are guaranteed to never get any response
208
213
// 10 of them will executed and the other 10 will be queued
@@ -215,7 +220,7 @@ class HTTP2ClientTests: XCTestCase {
215
220
216
221
var results : [ Result < HTTPClient . Response , Error > ] = [ ]
217
222
XCTAssertNoThrow ( results = try EventLoopFuture
218
- . whenAllComplete ( responses, on: client . eventLoopGroup . next ( ) )
223
+ . whenAllComplete ( responses, on: clientGroup . next ( ) )
219
224
. timeout ( after: . seconds( 2 ) )
220
225
. wait ( ) )
221
226
0 commit comments