public static void assertPortsAvailableEventually(final Map<String, Integer> ports) { // If we get into a TCP TIMED-WAIT state, it could take 4 minutes for the port to come available. // Could that be causing our integration tests to fail sometimes when run in the suite?! // Let's wait for the required ports in setup, rather than running+failing the test. assertPortsAvailableEventually(ports, Duration.minutes(4)); }
@Override public void run() { try { assertPortsAvailable(ports); } catch (Throwable t) { if (!logged) { LOG.warn("Port(s) not available; waiting for up to "+timeout+" ("+Exceptions.getFirstInteresting(t)+")"); logged = true; } throw Exceptions.propagate(t); } }}); LOG.debug("Ports are available: "+ports);
public JmxService() throws Exception { this("localhost", NetworkingTestUtils.randomPortAround(28000)); // TODO why this message if the constructor is not actually deprecated, and it seems useful? //logger.warn("use of deprecated default host and port in JmxService"); }
public static void assertCassandraPortsAvailableEventually() { Map<String, Integer> ports = getCassandraDefaultPorts(); NetworkingTestUtils.assertPortsAvailableEventually(ports); LOG.info("Confirmed Cassandra ports are available: "+ports); }
@Override public void init() { sensors().set(Attributes.HOSTNAME, JmxHelperTest.LOCALHOST_NAME); sensors().set(UsesJmx.JMX_PORT, LocalhostMachineProvisioningLocation.obtainPort(PortRanges.fromString( // just doing "40123+" was not enough to avoid collisions (on 40125), // observed on jenkins, not sure why but // maybe something else had a UDP connection we weren't detected, // or the static lock our localhost uses was being bypassed; // this should improve things (2016-01) NetworkingTestUtils.randomPortAround(40000)+"+"))); // only supports no-agent, at the moment config().set(UsesJmx.JMX_AGENT_MODE, JmxAgentModes.NONE); sensors().set(UsesJmx.RMI_REGISTRY_PORT, -1); // -1 means to use the JMX_PORT only ConfigToAttributes.apply(this, UsesJmx.JMX_CONTEXT); } }