From 24d1f595a5bb789aa2b5a6de31343986e3bca37c Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 20 Apr 2015 18:29:27 +0200 Subject: [PATCH] [TEST] Add back old way for naming clusters --- .../test/ElasticsearchIntegrationTest.java | 10 +++------- .../test/ElasticsearchSingleNodeTest.java | 9 +-------- .../org/elasticsearch/test/InternalTestCluster.java | 5 +++-- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 63be122b390..b2c1f87b757 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -18,10 +18,7 @@ */ package org.elasticsearch.test; -import com.carrotsearch.randomizedtesting.LifecycleScope; -import com.carrotsearch.randomizedtesting.RandomizedContext; -import com.carrotsearch.randomizedtesting.RandomizedTest; -import com.carrotsearch.randomizedtesting.Randomness; +import com.carrotsearch.randomizedtesting.*; import com.carrotsearch.randomizedtesting.annotations.TestGroup; import com.carrotsearch.randomizedtesting.generators.RandomInts; import com.carrotsearch.randomizedtesting.generators.RandomPicks; @@ -1122,7 +1119,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase public void logSegmentsState(String... indices) throws Exception { IndicesSegmentResponse segsRsp = client().admin().indices().prepareSegments(indices).get(); logger.debug("segments {} state: \n{}", indices.length == 0 ? "[_all]" : indices, - segsRsp.toXContent(JsonXContent.contentBuilder().prettyPrint(), ToXContent.EMPTY_PARAMS).string()); + segsRsp.toXContent(JsonXContent.contentBuilder().prettyPrint(), ToXContent.EMPTY_PARAMS).string()); } /** @@ -1709,9 +1706,8 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase minNumDataNodes = getMinNumDataNodes(); maxNumDataNodes = getMaxNumDataNodes(); } - return new InternalTestCluster(seed, createTempDir(), minNumDataNodes, maxNumDataNodes, - scope.name() + "-cluster", settingsSource, getNumClientNodes(), + InternalTestCluster.clusterName(scope.name(), seed) + "-cluster", settingsSource, getNumClientNodes(), InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, nodePrefix); } diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java index c1c666dde3c..93f10ee5878 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java @@ -120,7 +120,7 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase private static Node newNode() { Node build = NodeBuilder.nodeBuilder().local(true).data(true).settings(ImmutableSettings.builder() - .put(ClusterName.SETTING, clusterName()) + .put(ClusterName.SETTING, InternalTestCluster.clusterName("single-node-cluster", randomLong())) .put("path.home", createTempDir()) .put("node.name", nodeName()) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) @@ -150,13 +150,6 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase return "node_s_0"; } - /** - * Returns the name of the cluster used for the single test node. - */ - public static String clusterName() { - return "single-node-cluster"; - } - /** * Return a reference to the singleton node. */ diff --git a/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/src/test/java/org/elasticsearch/test/InternalTestCluster.java index 6c0f41eb493..75df647c5d4 100644 --- a/src/test/java/org/elasticsearch/test/InternalTestCluster.java +++ b/src/test/java/org/elasticsearch/test/InternalTestCluster.java @@ -471,10 +471,11 @@ public final class InternalTestCluster extends TestCluster { return builder.build(); } - public static String clusterName(String prefix, String childVMId, long clusterSeed) { + public static String clusterName(String prefix, long clusterSeed) { StringBuilder builder = new StringBuilder(prefix); + final int childVM = RandomizedTest.systemPropertyAsInt(SysGlobals.CHILDVM_SYSPROP_JVM_ID, 0); builder.append('-').append(NetworkUtils.getLocalHostName("__default_host__")); - builder.append("-CHILD_VM=[").append(childVMId).append(']'); + builder.append("-CHILD_VM=[").append(childVM).append(']'); builder.append("-CLUSTER_SEED=[").append(clusterSeed).append(']'); // if multiple maven task run on a single host we better have an identifier that doesn't rely on input params builder.append("-HASH=[").append(SeedUtils.formatSeed(System.nanoTime())).append(']');