@@ -23,6 +23,19 @@ class HTTPClientInternalTests: XCTestCase {
2323 typealias Request = HTTPClient . Request
2424 typealias Task = HTTPClient . Task
2525
26+ var clientGroup : EventLoopGroup !
27+
28+ override func setUp( ) {
29+ XCTAssertNil ( self . clientGroup)
30+ self . clientGroup = getDefaultEventLoopGroup ( numberOfThreads: 1 )
31+ }
32+
33+ override func tearDown( ) {
34+ XCTAssertNotNil ( self . clientGroup)
35+ XCTAssertNoThrow ( try self . clientGroup. syncShutdownGracefully ( ) )
36+ self . clientGroup = nil
37+ }
38+
2639 func testHTTPPartsHandler( ) throws {
2740 let channel = EmbeddedChannel ( )
2841 let recorder = RecordingHandler < HTTPClientResponsePart , HTTPClientRequestPart > ( )
@@ -105,7 +118,7 @@ class HTTPClientInternalTests: XCTestCase {
105118
106119 func testProxyStreaming( ) throws {
107120 let httpBin = HTTPBin ( )
108- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew )
121+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
109122 defer {
110123 XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
111124 XCTAssertNoThrow ( try httpBin. shutdown ( ) )
@@ -135,7 +148,7 @@ class HTTPClientInternalTests: XCTestCase {
135148
136149 func testProxyStreamingFailure( ) throws {
137150 let httpBin = HTTPBin ( )
138- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew )
151+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
139152 defer {
140153 XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
141154 XCTAssertNoThrow ( try httpBin. shutdown ( ) )
@@ -445,7 +458,7 @@ class HTTPClientInternalTests: XCTestCase {
445458
446459 func testResponseConnectionCloseGet( ) throws {
447460 let httpBin = HTTPBin ( ssl: false )
448- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew ,
461+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) ,
449462 configuration: HTTPClient . Configuration ( certificateVerification: . none) )
450463 defer {
451464 XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
@@ -549,11 +562,7 @@ class HTTPClientInternalTests: XCTestCase {
549562 }
550563
551564 let url = " http://127.0.0.1: \( server. localAddress!. port!) "
552- let elg = getDefaultEventLoopGroup ( numberOfThreads: 1 )
553- defer {
554- XCTAssertNoThrow ( try elg. syncShutdownGracefully ( ) )
555- }
556- let client = HTTPClient ( eventLoopGroupProvider: . shared( elg) )
565+ let client = HTTPClient ( eventLoopGroupProvider: . shared( self . clientGroup) )
557566 defer {
558567 XCTAssertNoThrow ( try client. syncShutdown ( ) )
559568 }
@@ -594,7 +603,7 @@ class HTTPClientInternalTests: XCTestCase {
594603 func testWeTolerateConnectionsGoingAwayWhilstPoolIsShuttingDown( ) {
595604 struct NoChannelError : Error { }
596605
597- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
606+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
598607 var maybeServersAndChannels : [ ( HTTPBin , Channel ) ] ?
599608 XCTAssertNoThrow ( maybeServersAndChannels = try ( 0 ..< 10 ) . map { _ in
600609 let web = HTTPBin ( )
@@ -676,7 +685,7 @@ class HTTPClientInternalTests: XCTestCase {
676685 XCTAssertNoThrow ( try web. shutdown ( ) )
677686 }
678687
679- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
688+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
680689 defer {
681690 XCTAssertNoThrow ( try client. syncShutdown ( ) )
682691 }
0 commit comments