removed jvm ordinal constant, only really needed now for test cluster

port numbering (moved to there)
This commit is contained in:
Ryan Ernst 2015-04-17 20:52:38 -07:00
parent 96f08a38e6
commit e4de0cb57f
7 changed files with 23 additions and 29 deletions

View File

@ -1694,8 +1694,8 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
}
return new InternalTestCluster(seed, createTempDir(), minNumDataNodes, maxNumDataNodes,
clusterName(scope.name(), Integer.toString(CHILD_JVM_ID), seed), settingsSource, getNumClientNodes(),
InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, CHILD_JVM_ID, nodePrefix);
scope.name() + "-cluster", settingsSource, getNumClientNodes(),
InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, nodePrefix);
}
/**

View File

@ -154,7 +154,7 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase
* Returns the name of the cluster used for the single test node.
*/
public static String clusterName() {
return InternalTestCluster.clusterName("single-node", Integer.toString(CHILD_JVM_ID), randomLong());
return "single-node-cluster";
}
/**

View File

@ -61,7 +61,6 @@ import org.elasticsearch.test.cache.recycler.MockPageCacheRecycler;
import org.elasticsearch.test.junit.listeners.LoggingListener;
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
import org.elasticsearch.test.search.MockSearchService;
import org.elasticsearch.test.store.MockDirectoryHelper;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.After;
import org.junit.AfterClass;
@ -171,11 +170,6 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
// old shit:
/**
* The child JVM ordinal of this JVM. Default is <tt>0</tt>
*/
public static final int CHILD_JVM_ID = Integer.parseInt(System.getProperty(SysGlobals.CHILDVM_SYSPROP_JVM_ID, "0"));
/**
* Annotation for REST tests
*/

View File

@ -20,6 +20,7 @@ package org.elasticsearch.test;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.SeedUtils;
import com.carrotsearch.randomizedtesting.SysGlobals;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
@ -173,6 +174,9 @@ public final class InternalTestCluster extends TestCluster {
*/
public static final String SETTING_CLUSTER_NODE_SEED = "test.cluster.node.seed";
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);
private static final boolean ENABLE_MOCK_MODULES = RandomizedTest.systemPropertyAsBoolean(TESTS_ENABLE_MOCK_MODULES, true);
static final int DEFAULT_MIN_NUM_DATA_NODES = 2;
@ -221,13 +225,13 @@ public final class InternalTestCluster extends TestCluster {
private ServiceDisruptionScheme activeDisruptionScheme;
public InternalTestCluster(long clusterSeed, Path baseDir, int minNumDataNodes, int maxNumDataNodes, String clusterName, int numClientNodes,
boolean enableHttpPipelining, int jvmOrdinal, String nodePrefix) {
this(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, DEFAULT_SETTINGS_SOURCE, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
boolean enableHttpPipelining, String nodePrefix) {
this(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, DEFAULT_SETTINGS_SOURCE, numClientNodes, enableHttpPipelining, nodePrefix);
}
public InternalTestCluster(long clusterSeed, Path baseDir,
int minNumDataNodes, int maxNumDataNodes, String clusterName, SettingsSource settingsSource, int numClientNodes,
boolean enableHttpPipelining, int jvmOrdinal, String nodePrefix) {
boolean enableHttpPipelining, String nodePrefix) {
super(clusterSeed);
this.baseDir = baseDir;
this.clusterName = clusterName;
@ -288,9 +292,8 @@ public final class InternalTestCluster extends TestCluster {
}
}
builder.put("path.home", baseDir);
final int basePort = 9300 + (100 * (jvmOrdinal+1));
builder.put("transport.tcp.port", basePort + "-" + (basePort+100));
builder.put("http.port", basePort+101 + "-" + (basePort+200));
builder.put("transport.tcp.port", BASE_PORT + "-" + (BASE_PORT+100));
builder.put("http.port", BASE_PORT+101 + "-" + (BASE_PORT+200));
builder.put("config.ignore_system_properties", true);
builder.put("node.mode", NODE_MODE);
builder.put("http.pipelining", enableHttpPipelining);

View File

@ -27,6 +27,7 @@ import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.SettingsSource;
import org.elasticsearch.transport.local.LocalTransport;
import org.omg.CORBA.INTERNAL;
import java.io.IOException;
import java.net.ServerSocket;
@ -114,9 +115,7 @@ public class ClusterDiscoveryConfiguration extends SettingsSource {
}
private static int calcBasePort() {
// note that this has properly co-exist with the port logic at InternalTestCluster's constructor
return 30000 +
1000 * (ElasticsearchIntegrationTest.CHILD_JVM_ID);
return 30000 + InternalTestCluster.BASE_PORT;
}
@Override

View File

@ -50,14 +50,12 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
String clusterName = randomRealisticUnicodeOfCodepointLengthBetween(1, 10);
SettingsSource settingsSource = SettingsSource.EMPTY;
int numClientNodes = randomIntBetween(0, 10);
boolean enableRandomBenchNodes = randomBoolean();
boolean enableHttpPipelining = randomBoolean();
int jvmOrdinal = randomIntBetween(0, 10);
String nodePrefix = randomRealisticUnicodeOfCodepointLengthBetween(1, 10);
Path baseDir = createTempDir();
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, nodePrefix);
InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, nodePrefix);
assertClusters(cluster0, cluster1, true);
}
@ -88,11 +86,11 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
long clusterSeed = randomLong();
int minNumDataNodes = randomIntBetween(0, 3);
int maxNumDataNodes = randomIntBetween(minNumDataNodes, 4);
final String clusterName = clusterName("shared", Integer.toString(CHILD_JVM_ID), clusterSeed);
String clusterName1 = clusterName("shared", Integer.toString(CHILD_JVM_ID), clusterSeed);
while (clusterName.equals(clusterName1)) {
final String clusterName1 = "shared1";//clusterName("shared1", clusterSeed);
final String clusterName2 = "shared2";//clusterName("shared", Integer.toString(CHILD_JVM_ID), clusterSeed);
/*while (clusterName.equals(clusterName1)) {
clusterName1 = clusterName("shared", Integer.toString(CHILD_JVM_ID), clusterSeed); // spin until the time changes
}
}*/
SettingsSource settingsSource = SettingsSource.EMPTY;
int numClientNodes = randomIntBetween(0, 2);
boolean enableHttpPipelining = randomBoolean();
@ -100,8 +98,8 @@ public class InternalTestClusterTests extends ElasticsearchTestCase {
String nodePrefix = "foobar";
Path baseDir = createTempDir();
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName1, settingsSource, numClientNodes, enableHttpPipelining, jvmOrdinal, nodePrefix);
InternalTestCluster cluster0 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName1, settingsSource, numClientNodes, enableHttpPipelining, nodePrefix);
InternalTestCluster cluster1 = new InternalTestCluster(clusterSeed, baseDir, minNumDataNodes, maxNumDataNodes, clusterName2, settingsSource, numClientNodes, enableHttpPipelining, nodePrefix);
assertClusters(cluster0, cluster1, false);
long seed = randomLong();

View File

@ -69,7 +69,7 @@ public class TribeTests extends ElasticsearchIntegrationTest {
public static void setupSecondCluster() throws Exception {
ElasticsearchIntegrationTest.beforeClass();
// create another cluster
cluster2 = new InternalTestCluster(randomLong(), createTempDir(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, CHILD_JVM_ID, SECOND_CLUSTER_NODE_PREFIX);
cluster2 = new InternalTestCluster(randomLong(), createTempDir(), 2, 2, Strings.randomBase64UUID(getRandom()), 0, false, SECOND_CLUSTER_NODE_PREFIX);
cluster2.beforeTest(getRandom(), 0.1);
cluster2.ensureAtLeastNumDataNodes(2);
}