exceptionfactory commented on code in PR #11924:
URL: https://github.com/apache/nifi/pull/11924#discussion_r4590257439
##########
nifi-framework-bundle/nifi-framework/nifi-framework-cluster-protocol/src/test/java/org/apache/nifi/io/socket/SocketUtilsTest.java:
##########
@@ -89,6 +100,49 @@ void testCreateSocketRejectsMismatchedHostname() throws
Exception {
assertThrows(SSLHandshakeException.class, () ->
connectAndHandshake(keyPair, certificate));
}
+ @Test
+ void testCreateSocketConnected() throws IOException {
+ try (ServerSocket serverSocket = new ServerSocket(0, 1,
InetAddress.getLoopbackAddress())) {
+ final SocketConfiguration config = new SocketConfiguration();
+ config.setConnectTimeout(CONNECT_TIMEOUT_MILLISECONDS);
+ config.setSocketTimeout(TIMEOUT_MILLISECONDS);
+
+ try (Socket socket =
SocketUtils.createSocket(InetSocketAddress.createUnresolved(LOCALHOST,
serverSocket.getLocalPort()), config)) {
+ assertTrue(socket.isConnected());
+ assertEquals(TIMEOUT_MILLISECONDS, socket.getSoTimeout());
+ }
+ }
+ }
+
+ /**
+ * Linux drops SYNs once the accept queue of a listener is full, which
makes connect() hang like it does against an unreachable peer.
+ * We use this to simulate dropped packages here - depends on the value of
tcp_abort_on_overflow on the host, should works for the
+ * linux default.
+ */
+ @Test
+ @EnabledOnOs(OS.LINUX)
+ @Timeout(value = 30, unit = TimeUnit.SECONDS)
+ void testCreateSocketConnectTimeout() throws IOException {
Review Comment:
Sounds good, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]