jyothsnakonisa commented on code in PR #2143:
URL: https://github.com/apache/cassandra/pull/2143#discussion_r1101909473


##########
test/unit/org/apache/cassandra/net/HandshakeTest.java:
##########
@@ -377,24 +378,35 @@ private void 
testOutboundFallbackOnSSLHandshakeFailure(SslFallbackConnectionType
             InetAddressAndPort endpoint = inbound.sockets().stream().map(s -> 
s.settings.bindAddress).findFirst().get();
             inbound.open();
 
-            // Open outbound connections, and wait until connection is 
established
+            // Open outbound connections, and wait until connection is 
established and the initial message is delivered
             OutboundConnection outboundConnection = initiateOutbound(endpoint, 
fromConnectionType, fromOptional);
-            waitForConnection(outboundConnection);
-            assertTrue(outboundConnection.isConnected());
-            assertFalse(outboundConnection.hasPending());
+            confirmDelivery(outboundConnection);
         }
         finally
         {
             inbound.close().await(10L, TimeUnit.SECONDS);
         }
     }
 
-    private void waitForConnection(OutboundConnection outboundConnection) 
throws InterruptedException
+    private final static Duration DELIVERY_WAIT_DURATION = 
Duration.ofSeconds(60);
+
+    private void confirmDelivery(OutboundConnection outboundConnection) throws 
InterruptedException
     {
-        long startTime = System.currentTimeMillis();
-        while (!outboundConnection.isConnected() && System.currentTimeMillis() 
- startTime < 60000)
+        Instant endTime = Instant.now().plus(DELIVERY_WAIT_DURATION);
+
+        while (!outboundConnection.isConnected() && 
Instant.now().isBefore(endTime))
         {
             Thread.sleep(1000);
         }
+
+        // Now that we're connected, we also want to ensure that the delivery 
thread succeeded
+        while (outboundConnection.hasPending() && 
Instant.now().isBefore(endTime)) {

Review Comment:
   I think we just want to verify that the connection is established and we 
don't have to wait for pending connections to be flushed. We might be waiting 
indefinitely for the pending connections to be flushed and the test might fail 
because of timeout.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to