Skip to content

Commit

Permalink
Merge pull request #12271 from jaymode/test_zen_port_range
Browse files Browse the repository at this point in the history
restrict the test unicast zen discovery to the port range of the JVM
  • Loading branch information
jaymode committed Jul 15, 2015
2 parents 0820cb6 + 883d33b commit 5091a10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -164,8 +164,13 @@ public final class InternalTestCluster extends TestCluster {
*/
public static final String SETTING_CLUSTER_NODE_SEED = "test.cluster.node.seed";

/**
* The number of ports in the range used for this JVM
*/
public static final int PORTS_PER_JVM = 100;

private static final int JVM_ORDINAL = Integer.parseInt(System.getProperty(SysGlobals.CHILDVM_SYSPROP_JVM_ID, "0"));
public static final int BASE_PORT = 9300 + 100 * (JVM_ORDINAL + 1);
public static final int BASE_PORT = 9300 + PORTS_PER_JVM * (JVM_ORDINAL + 1);

private static final boolean ENABLE_MOCK_MODULES = RandomizedTest.systemPropertyAsBoolean(TESTS_ENABLE_MOCK_MODULES, true);

Expand Down
Expand Up @@ -142,11 +142,11 @@ protected synchronized static int[] unicastHostPorts(int numHosts) {
int[] unicastHostPorts = new int[numHosts];

final int basePort = calcBasePort();
final int maxPort = basePort + 1000;
final int maxPort = basePort + InternalTestCluster.PORTS_PER_JVM;
int tries = 0;
for (int i = 0; i < unicastHostPorts.length; i++) {
boolean foundPortInRange = false;
while (tries < 1000 && !foundPortInRange) {
while (tries < InternalTestCluster.PORTS_PER_JVM && !foundPortInRange) {
try (ServerSocket serverSocket = new ServerSocket()) {
// Set SO_REUSEADDR as we may bind here and not be able to reuse the address immediately without it.
serverSocket.setReuseAddress(NetworkUtils.defaultReuseAddress());
Expand Down

0 comments on commit 5091a10

Please sign in to comment.