[TEST] Print out the `tests.cluster` sys prop if available to be able to reproduce failures when using the external cluster

Relates to #5630
This commit is contained in:
javanna 2014-04-01 18:11:39 +02:00 committed by Luca Cavanna
parent be33c99835
commit 6ef45a9ae3
3 changed files with 13 additions and 2 deletions

View File

@ -148,6 +148,11 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
*/ */
public static final String TESTS_CLIENT_RATIO = "tests.client.ratio"; 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. * 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 // Initialize lazily. No need for volatiles/ CASs since each JVM runs at most one test
// suite at any given moment. // suite at any given moment.
if (GLOBAL_CLUSTER == null) { if (GLOBAL_CLUSTER == null) {
String cluster = System.getProperty("tests.cluster"); String cluster = System.getProperty(TESTS_CLUSTER);
if (Strings.hasLength(cluster)) { if (Strings.hasLength(cluster)) {
String[] stringAddresses = cluster.split(","); String[] stringAddresses = cluster.split(",");
TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length]; TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length];

View File

@ -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.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient; 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.settings.ImmutableSettings;
import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.transport.TransportAddress;
@ -38,6 +40,8 @@ import java.util.Iterator;
*/ */
public final class ExternalTestCluster extends ImmutableTestCluster { public final class ExternalTestCluster extends ImmutableTestCluster {
private final ESLogger logger = Loggers.getLogger(getClass());
private final Client client; private final Client client;
private final InetSocketAddress[] httpAddresses; private final InetSocketAddress[] httpAddresses;
@ -59,6 +63,7 @@ public final class ExternalTestCluster extends ImmutableTestCluster {
} }
} }
this.dataNodes = dataNodes; this.dataNodes = dataNodes;
logger.info("Setup ExternalTestCluster [{}] made of [{}] nodes", nodeInfos.getClusterName().value(), size());
} }
@Override @Override

View File

@ -32,6 +32,7 @@ import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener; import org.junit.runner.notification.RunListener;
import static com.carrotsearch.randomizedtesting.SysGlobals.SYSPROP_ITERATIONS; 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 * 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() { 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"); "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()) { if (System.getProperty("tests.jvm.argline") != null && !System.getProperty("tests.jvm.argline").isEmpty()) {
appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\""); appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");