Skip to content

Commit 632a8a1

Browse files
committed
Updated tests
- Shutdown ELG in testUploadStreamingBackpressure - Added isTestingNIOTS() - Added testCorrectEventLoopGroup
1 parent 4b108a5 commit 632a8a1

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

Tests/AsyncHTTPClientTests/HTTPClientInternalTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class HTTPClientInternalTests: XCTestCase {
239239
defer {
240240
XCTAssertNoThrow(try httpClient.syncShutdown(requiresCleanClose: true))
241241
XCTAssertNoThrow(try httpBin.shutdown())
242+
XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully())
242243
}
243244

244245
let request = try Request(url: "http://localhost:\(httpBin.port)/custom")

Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ import NIOHTTPCompression
2121
import NIOSSL
2222
import NIOTransportServices
2323

24+
/// Are we testing NIO Transport services
25+
func isTestingNIOTS() -> Bool {
26+
return ProcessInfo.processInfo.environment["ENABLE_TS_TESTS"] == "true"
27+
}
28+
2429
func getDefaultEventLoopGroup(numberOfThreads: Int) -> EventLoopGroup {
2530
#if canImport(Network)
2631
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *),
27-
ProcessInfo.processInfo.environment["ENABLE_TS_TESTS"] == "true" {
32+
isTestingNIOTS() {
2833
return NIOTSEventLoopGroup(loopCount: numberOfThreads, defaultQoS: .default)
2934
}
3035
#endif

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,11 +1094,9 @@ class HTTPClientTests: XCTestCase {
10941094
}
10951095

10961096
func testStressGetClose() throws {
1097-
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *) {
1098-
guard !(self.clientGroup is NIOTSEventLoopGroup) else {
1099-
XCTFail("Disabled test as it crashes");
1100-
return
1101-
}
1097+
guard !isTestingNIOTS() else {
1098+
XCTFail("Disabled test as it crashes");
1099+
return
11021100
}
11031101
let httpBin = HTTPBin(ssl: false)
11041102
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(self.clientGroup),
@@ -1671,4 +1669,18 @@ class HTTPClientTests: XCTestCase {
16711669
}
16721670
}
16731671
}
1672+
1673+
func testCorrectEventLoopGroup() {
1674+
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
1675+
defer {
1676+
XCTAssertNoThrow(try httpClient.syncShutdown())
1677+
}
1678+
#if canImport(Network)
1679+
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *) {
1680+
XCTAssertTrue(httpClient.eventLoopGroup is NIOTSEventLoopGroup)
1681+
return
1682+
}
1683+
#endif
1684+
XCTAssertTrue(httpClient.eventLoopGroup is MultiThreadedEventLoopGroup)
1685+
}
16741686
}

0 commit comments

Comments
 (0)