You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "yifan-c (via GitHub)" <gi...@apache.org> on 2023/02/17 18:56:44 UTC

[GitHub] [cassandra] yifan-c commented on a diff in pull request #1706: CASSANDRA-17708 Fixing flaky tests in InternodeEncryptionEnforcementTest

yifan-c commented on code in PR #1706:
URL: https://github.com/apache/cassandra/pull/1706#discussion_r1110196443


##########
test/distributed/org/apache/cassandra/distributed/test/InternodeEncryptionEnforcementTest.java:
##########
@@ -103,16 +100,12 @@ public void testOutboundConnectionsAreRejectedWhenAuthFails() throws IOException
             executorService.submit(() -> openConnections(cluster));
 
             /*
-             * instance (1) should not connect to instance (2) as authentication fails;
-             * instance (2) should not connect to instance (1) as authentication fails.
+             * Instance (1) should not be able to make outbound connections to instance (2) but Instance (2) should be
+             * accepting outbound connections from Instance (1)

Review Comment:
   The comment is confusing to me.. 
   If instance 1 can never make outbound connections, how can instance 2 expect connections _from_ instance 1? Do you mean instance 2 can make outbound connections _to_ instance 1?



##########
test/distributed/org/apache/cassandra/distributed/test/InternodeEncryptionEnforcementTest.java:
##########
@@ -134,19 +125,14 @@ public void testOutboundConnectionsAreRejectedWhenAuthFails() throws IOException
     public void testOutboundConnectionsAreInterruptedWhenAuthFails() throws IOException, TimeoutException
     {
         Cluster.Builder builder = createCluster(AllowFirstAndRejectOtherOutboundAuthenticator.class);
+        final ExecutorService executorService = Executors.newSingleThreadExecutor();
+
         try (Cluster cluster = builder.start())

Review Comment:
   nit: it is safer to close the `ExecutorService` along with `cluster`. Otherwise, if the body of `try` throws, only `cluster` is closed, but `executorService.shutdown()` will not be called. 
   
   You can have multiple `closable`s in the try-with-resources statement, and remove `executorService.shutdown()` at the end of the test.
   ```
   try (Cluster cluster = builder.start(); AutoCloseable es = executorService::shutdown)
   ```



##########
test/distributed/org/apache/cassandra/distributed/test/InternodeEncryptionEnforcementTest.java:
##########
@@ -86,8 +84,7 @@ public void testInboundConnectionsAreRejectedWhenAuthFails() throws IOException,
             // Wait for authentication to fail
             cluster.get(1).logs().watchFor("Unable to authenticate peer");
             cluster.get(1).runOnInstance(runnable);
-            cluster.get(2).logs().watchFor("Unable to authenticate peer");
-            cluster.get(2).runOnInstance(runnable);

Review Comment:
   nit: how about adding a watch for "Connection reset by peer" in instances 2's log?
   
   ```
               cluster.get(2).logs().watchFor("Connection reset by peer");
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org