This commit is contained in:
Clebert Suconic 2020-06-04 08:28:40 -04:00
commit 1623c3f359
2 changed files with 12 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.activemq.artemis.utils.Env;
import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
import org.jboss.logging.Logger;
@ -51,7 +52,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
public static final String IPV6_DEFAULT_COMMAND = "ping6 -c 1 %2$s";
public static final String IPV4_DEFAULT_COMMAND = "ping -c 1 -t %d %s";
public static final String IPV4_DEFAULT_COMMAND = Env.isMacOs() ? "ping -c 1 -t %d %s" : "ping -c 1 -w %d %s";
private String ipv4Command = IPV4_DEFAULT_COMMAND;

View File

@ -326,4 +326,14 @@ public class NetworkHealthTest {
Assert.assertEquals(0, purePing.get());
}
@Test(timeout = 30_000)
public void testPurePingTimeout() throws Exception {
NetworkHealthCheck check = new NetworkHealthCheck(null, 100, 2000);
long time = System.currentTimeMillis();
//[RFC1166] reserves the address block 192.0.2.0/24 for test.
Assert.assertFalse(check.purePing(InetAddress.getByName("192.0.2.0")));
Assert.assertTrue(System.currentTimeMillis() - time >= 2000);
}
}