Skip to content

Commit 132dc3e

Browse files
authored
Make testSSLHandshakeErrorPropagation less flaky (#380)
### Motivation - The `testSSLHandshakeErrorPropagation` has a very short connect timeout (100ms). The reason for this is, that a failing TLS handshake manifest in NIOTS as a connect timeout and we don’t want to wait for the timeout for to long in our tests. - Using a the NIOSSL however we expect a proper NIOSSLError. Sometimes though the connection is not setup fast enough (because of the very short 100ms connect timeout), that we get a connectionTimeout error instead. ### Modifications - Setting the short connect timeout to 100ms when using NIOTS only. This will make sure we get the proper NIOSSLError when using NIOSSL
1 parent 92bcf49 commit 132dc3e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: Tests/AsyncHTTPClientTests/HTTPClientTests.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -2715,9 +2715,14 @@ class HTTPClientTests: XCTestCase {
27152715
XCTAssertNoThrow(try server.close().wait())
27162716
}
27172717

2718-
// We set the connect timeout down very low here because on NIOTS this manifests as a connect
2719-
// timeout.
2720-
let config = HTTPClient.Configuration(timeout: HTTPClient.Configuration.Timeout(connect: .milliseconds(100), read: nil))
2718+
var timeout = HTTPClient.Configuration.Timeout(connect: .seconds(10))
2719+
if isTestingNIOTS() {
2720+
// If we are using Network.framework, we set the connect timeout down very low here
2721+
// because on NIOTS a failing TLS handshake manifests as a connect timeout.
2722+
timeout.connect = .milliseconds(100)
2723+
}
2724+
2725+
let config = HTTPClient.Configuration(timeout: timeout)
27212726
let client = HTTPClient(eventLoopGroupProvider: .shared(self.clientGroup), configuration: config)
27222727
defer {
27232728
XCTAssertNoThrow(try client.syncShutdown())

0 commit comments

Comments
 (0)