Skip to content

Commit 0d056c0

Browse files
committed
Test improvements
1 parent 4405796 commit 0d056c0

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

Tests/GRPCTests/ConnectionManagerTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ extension ConnectionManagerTests {
14221422
#if canImport(Network)
14231423
func testDefaultChannelProvider_NWParametersConfigurator() throws {
14241424
let counter = NIOLockedValueBox(0)
1425-
let group = NIOTSEventLoopGroup(loopCount: 1)
1425+
let group = NIOTSEventLoopGroup.singleton
14261426
var configuration = ClientConnection.Configuration.default(
14271427
target: .unixDomainSocket("/ignored"),
14281428
eventLoopGroup: group
@@ -1460,8 +1460,6 @@ extension ConnectionManagerTests {
14601460
try promise.futureResult.wait()
14611461

14621462
XCTAssertEqual(1, counter.withLockedValue({ $0 }))
1463-
1464-
try group.syncShutdownGracefully()
14651463
}
14661464
#endif
14671465

Tests/GRPCTests/ConnectionPool/GRPCChannelPoolTests.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,22 @@ final class GRPCChannelPoolTests: GRPCTestCase {
5555
super.tearDown()
5656
}
5757

58-
private func configureEventLoopGroup(threads: Int = System.coreCount) {
59-
self.group = MultiThreadedEventLoopGroup(numberOfThreads: threads)
58+
private enum TestEventLoopGroupType {
59+
case multiThreadedEventLoopGroup
60+
case transportServicesEventLoopGroup
61+
}
62+
63+
private func configureEventLoopGroup(
64+
threads: Int = System.coreCount,
65+
eventLoopGroupType: TestEventLoopGroupType = .multiThreadedEventLoopGroup
66+
) {
67+
switch eventLoopGroupType {
68+
case .multiThreadedEventLoopGroup:
69+
self.group = MultiThreadedEventLoopGroup(numberOfThreads: threads)
70+
71+
case .transportServicesEventLoopGroup:
72+
self.group = NIOTSEventLoopGroup(loopCount: threads)
73+
}
6074
}
6175

6276
private func makeServerBuilder(withTLS: Bool) -> Server.Builder {
@@ -627,7 +641,7 @@ final class GRPCChannelPoolTests: GRPCTestCase {
627641
#if canImport(Network)
628642
func testNWParametersConfigurator() {
629643
let counter = NIOLockedValueBox(0)
630-
self.group = NIOTSEventLoopGroup()
644+
self.configureEventLoopGroup(threads: 1, eventLoopGroupType: .transportServicesEventLoopGroup)
631645
self.startServer(withTLS: false)
632646
self.startChannel(withTLS: false) { configuration in
633647
configuration.transportServices.nwParametersConfigurator = { _ in

Tests/GRPCTests/ServerTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class ServerTests: GRPCTestCase {
3737
counter.withLockedValue { $0 += 1 }
3838
}
3939

40-
_ = try Server.start(configuration: serverConfiguration).wait()
40+
let server = try Server.start(configuration: serverConfiguration).wait()
4141
XCTAssertEqual(1, counter.withLockedValue({ $0 }))
42+
43+
try? server.close().wait()
4244
}
4345
#endif
4446
}

0 commit comments

Comments
 (0)