@@ -23,6 +23,19 @@ class HTTPClientInternalTests: XCTestCase {
23
23
typealias Request = HTTPClient . Request
24
24
typealias Task = HTTPClient . Task
25
25
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
+
26
39
func testHTTPPartsHandler( ) throws {
27
40
let channel = EmbeddedChannel ( )
28
41
let recorder = RecordingHandler < HTTPClientResponsePart , HTTPClientRequestPart > ( )
@@ -105,7 +118,7 @@ class HTTPClientInternalTests: XCTestCase {
105
118
106
119
func testProxyStreaming( ) throws {
107
120
let httpBin = HTTPBin ( )
108
- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew )
121
+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
109
122
defer {
110
123
XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
111
124
XCTAssertNoThrow ( try httpBin. shutdown ( ) )
@@ -135,7 +148,7 @@ class HTTPClientInternalTests: XCTestCase {
135
148
136
149
func testProxyStreamingFailure( ) throws {
137
150
let httpBin = HTTPBin ( )
138
- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew )
151
+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
139
152
defer {
140
153
XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
141
154
XCTAssertNoThrow ( try httpBin. shutdown ( ) )
@@ -442,7 +455,7 @@ class HTTPClientInternalTests: XCTestCase {
442
455
443
456
func testResponseConnectionCloseGet( ) throws {
444
457
let httpBin = HTTPBin ( ssl: false )
445
- let httpClient = HTTPClient ( eventLoopGroupProvider: . createNew ,
458
+ let httpClient = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) ,
446
459
configuration: HTTPClient . Configuration ( certificateVerification: . none) )
447
460
defer {
448
461
XCTAssertNoThrow ( try httpClient. syncShutdown ( requiresCleanClose: true ) )
@@ -546,11 +559,7 @@ class HTTPClientInternalTests: XCTestCase {
546
559
}
547
560
548
561
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) )
554
563
defer {
555
564
XCTAssertNoThrow ( try client. syncShutdown ( ) )
556
565
}
@@ -591,7 +600,7 @@ class HTTPClientInternalTests: XCTestCase {
591
600
func testWeTolerateConnectionsGoingAwayWhilstPoolIsShuttingDown( ) {
592
601
struct NoChannelError : Error { }
593
602
594
- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
603
+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
595
604
var maybeServersAndChannels : [ ( HTTPBin , Channel ) ] ?
596
605
XCTAssertNoThrow ( maybeServersAndChannels = try ( 0 ..< 10 ) . map { _ in
597
606
let web = HTTPBin ( )
@@ -673,7 +682,7 @@ class HTTPClientInternalTests: XCTestCase {
673
682
XCTAssertNoThrow ( try web. shutdown ( ) )
674
683
}
675
684
676
- let client = HTTPClient ( eventLoopGroupProvider: . createNew )
685
+ let client = HTTPClient ( eventLoopGroupProvider: . shared ( self . clientGroup ) )
677
686
defer {
678
687
XCTAssertNoThrow ( try client. syncShutdown ( ) )
679
688
}
0 commit comments