You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/06/04 12:23:28 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3166: ARTEMIS-2792 Fix default network pinger command for linux

clebertsuconic commented on a change in pull request #3166:
URL: https://github.com/apache/activemq-artemis/pull/3166#discussion_r435211313



##########
File path: artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java
##########
@@ -326,4 +327,32 @@ public boolean purePing(InetAddress address) throws IOException, InterruptedExce
       Assert.assertEquals(0, purePing.get());
    }
 
+   @Test
+   public void testPurePingTimeout() throws Exception {
+      NetworkHealthCheck check = new NetworkHealthCheck(null, 100, 3000);
+
+      CountDownLatch purePingLatch = new CountDownLatch(1);
+      CountDownLatch purePingThreadLatch = new CountDownLatch(1);
+
+      Thread purePingThread = new Thread(new Runnable() {
+         @Override
+         public void run() {
+            try {
+               purePingThreadLatch.countDown();
+
+               //[RFC1166] reserves the address block 192.0.2.0/24 for test.
+               Assert.assertFalse(check.purePing(InetAddress.getByName("192.0.2.0")));
+
+               purePingLatch.countDown();
+            } catch (Exception e) {
+               Assert.fail("Unexpected exception: " + e.toString());
+            }
+         }
+      });
+
+      purePingThread.start();
+      purePingThreadLatch.await();
+      Assert.assertTrue(purePingLatch.await(5000, TimeUnit.MILLISECONDS));

Review comment:
       you need to assert the timeout was respected here.
   
   Can I amend your test as this and merge it?
   
   
   ```java
         purePingThread.start();
         long time = System.currentTimeMillis();
         purePingThreadLatch.await();
         Assert.assertTrue(purePingLatch.await(5000, TimeUnit.MILLISECONDS));
         Assert.assertTrue(System.currentTimeMillis() - time >= 2000);
   ```




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

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