@@ -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 ( ) )
@@ -442,7 +455,7 @@ class HTTPClientInternalTests: XCTestCase {
442455
443456 func testResponseConnectionCloseGet( ) throws {
444457 let httpBin = HTTPBin ( ssl: false )
445- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew ,
458+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) ,
446459 configuration: HTTPClient . Configuration ( certificateVerification: . none) )
447460 defer {
448461 XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
@@ -546,11 +559,7 @@ class HTTPClientInternalTests: XCTestCase {
546559 }
547560
548561 let url = " http://127.0.0.1: \( server. localAddress!. port!) "
549- let elg = getDefaultEventLoopGroup ( numberOfThreads: 1 )
550- defer {
551- XCTAssertNoThrow ( try elg. syncShutdownGracefully ( ) )
552- }
553- let client = HTTPClient ( eventLoopGroupProvider: . shared( elg) )
562+ let client = HTTPClient ( eventLoopGroupProvider: . shared( self . clientGroup) )
554563 defer {
555564 XCTAssertNoThrow ( try client. syncShutdown ( ) )
556565 }
@@ -591,7 +600,7 @@ class HTTPClientInternalTests: XCTestCase {
591600 func testWeTolerateConnectionsGoingAwayWhilstPoolIsShuttingDown( ) {
592601 struct NoChannelError : Error { }
593602
594- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
603+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
595604 var maybeServersAndChannels : [ ( HTTPBin , Channel ) ] ?
596605 XCTAssertNoThrow ( maybeServersAndChannels = try ( 0 ..< 10 ) . map { _ in
597606 let web = HTTPBin ( )
@@ -673,7 +682,7 @@ class HTTPClientInternalTests: XCTestCase {
673682 XCTAssertNoThrow ( try web. shutdown ( ) )
674683 }
675684
676- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
685+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
677686 defer {
678687 XCTAssertNoThrow ( try client. syncShutdown ( ) )
679688 }
0 commit comments