From 6ef45a9ae331082e488f837d72293bb04b583883 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 1 Apr 2014 18:11:39 +0200 Subject: [PATCH] [TEST] Print out the `tests.cluster` sys prop if available to be able to reproduce failures when using the external cluster Relates to #5630 --- .../elasticsearch/test/ElasticsearchIntegrationTest.java | 7 ++++++- .../java/org/elasticsearch/test/ExternalTestCluster.java | 5 +++++ .../test/junit/listeners/ReproduceInfoPrinter.java | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 0dd0c9a25aa..28fbbd35fa5 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -148,6 +148,11 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase */ public static final String TESTS_CLIENT_RATIO = "tests.client.ratio"; + /** + * Key used to eventually switch to using an external cluster and provide its transport addresses + */ + public static final String TESTS_CLUSTER = "tests.cluster"; + /** * Threshold at which indexing switches from frequently async to frequently bulk. */ @@ -190,7 +195,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase // Initialize lazily. No need for volatiles/ CASs since each JVM runs at most one test // suite at any given moment. if (GLOBAL_CLUSTER == null) { - String cluster = System.getProperty("tests.cluster"); + String cluster = System.getProperty(TESTS_CLUSTER); if (Strings.hasLength(cluster)) { String[] stringAddresses = cluster.split(","); TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length]; diff --git a/src/test/java/org/elasticsearch/test/ExternalTestCluster.java b/src/test/java/org/elasticsearch/test/ExternalTestCluster.java index 0b078eadb45..f5b4402b41e 100644 --- a/src/test/java/org/elasticsearch/test/ExternalTestCluster.java +++ b/src/test/java/org/elasticsearch/test/ExternalTestCluster.java @@ -24,6 +24,8 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.TransportAddress; @@ -38,6 +40,8 @@ import java.util.Iterator; */ public final class ExternalTestCluster extends ImmutableTestCluster { + private final ESLogger logger = Loggers.getLogger(getClass()); + private final Client client; private final InetSocketAddress[] httpAddresses; @@ -59,6 +63,7 @@ public final class ExternalTestCluster extends ImmutableTestCluster { } } this.dataNodes = dataNodes; + logger.info("Setup ExternalTestCluster [{}] made of [{}] nodes", nodeInfos.getClusterName().value(), size()); } @Override diff --git a/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index 2347a1067c7..0179b7f3299 100644 --- a/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -32,6 +32,7 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; import static com.carrotsearch.randomizedtesting.SysGlobals.SYSPROP_ITERATIONS; +import static org.elasticsearch.test.ElasticsearchIntegrationTest.TESTS_CLUSTER; /** * A {@link RunListener} that emits to {@link System#err} a string with command @@ -114,7 +115,7 @@ public class ReproduceInfoPrinter extends RunListener { } public ReproduceErrorMessageBuilder appendESProperties() { - appendProperties("es.logger.level", "es.node.mode", "es.node.local", TestCluster.TESTS_ENABLE_MOCK_MODULES, + appendProperties("es.logger.level", "es.node.mode", "es.node.local", TESTS_CLUSTER, TestCluster.TESTS_ENABLE_MOCK_MODULES, "tests.assertion.disabled", "tests.security.manager", "tests.nighly", "tests.jvms", "tests.client.ratio", "tests.heap.size"); if (System.getProperty("tests.jvm.argline") != null && !System.getProperty("tests.jvm.argline").isEmpty()) { appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");