From b49635539d929d6cb5ee56153e2f95872fe4bb16 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Mon, 23 May 2016 13:19:25 -0400 Subject: [PATCH] Remove support for -Des.* system properties in integration tests This now requires that system properties passed to Gradle must be in the form of "-Dtests.es.*" instead of "-Des.*". It then chops off "tests.es." and passes that as a "-E" property to Elasticsearch. Also changed system properties: - `tests.logger.level` became `tests.es.logger.level` - `node.mode` became `tests.es.node.mode` - `node.local` became `tests.es.node.local` --- TESTING.asciidoc | 8 ++++---- .../org/elasticsearch/gradle/test/NodeInfo.groovy | 8 ++------ .../elasticsearch/test/InternalTestCluster.java | 15 +++++++-------- .../junit/listeners/ReproduceInfoPrinter.java | 4 ++-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index 50953f16378..ce81f97548f 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -18,18 +18,18 @@ gradle assemble == Other test options -To disable and enable network transport, set the `Des.node.mode`. +To disable and enable network transport, set the `tests.es.node.mode` system property. Use network transport: ------------------------------------ --Des.node.mode=network +-Dtests.es.node.mode=network ------------------------------------ Use local transport (default since 1.3): ------------------------------------- --Des.node.mode=local +-Dtests.es.node.mode=local ------------------------------------- === Running Elasticsearch from a checkout @@ -195,7 +195,7 @@ gradle test -Dtests.timeoutSuite=5000! ... Change the logging level of ES (not gradle) -------------------------------- -gradle test -Dtests.logger.level=DEBUG +gradle test -Dtests.es.logger.level=DEBUG -------------------------------- Print all the logging output from the test runs to the commandline diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy index cd0475d2aea..5d9961a0425 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy @@ -130,17 +130,13 @@ class NodeInfo { env = [ 'JAVA_HOME' : project.javaHome ] args.addAll("-E", "node.portsfile=true") - String loggerLevel = System.getProperty("tests.logger.level") - if (loggerLevel != null) { - args.addAll("-E", "logger.level=${loggerLevel}") - } String collectedSystemProperties = config.systemProperties.collect { key, value -> "-D${key}=${value}" }.join(" ") String esJavaOpts = config.jvmArgs.isEmpty() ? collectedSystemProperties : collectedSystemProperties + " " + config.jvmArgs env.put('ES_JAVA_OPTS', esJavaOpts) for (Map.Entry property : System.properties.entrySet()) { - if (property.getKey().startsWith('es.')) { + if (property.key.startsWith('tests.es.')) { args.add("-E") - args.add("${property.getKey()}=${property.getValue()}") + args.add("${property.key.substring('tests.es.'.size())}=${property.value}") } } env.put('ES_JVM_OPTIONS', new File(confDir, 'jvm.options')) diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 995ca5480f3..69f811b7d07 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -80,7 +80,6 @@ import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.node.MockNode; import org.elasticsearch.node.Node; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.ScriptService; @@ -293,8 +292,8 @@ public final class InternalTestCluster extends TestCluster { builder.put("http.port", HTTP_BASE_PORT + "-" + (HTTP_BASE_PORT + PORTS_PER_CLUSTER)); builder.put(Node.NODE_MODE_SETTING.getKey(), nodeMode); builder.put("http.pipelining", enableHttpPipelining); - if (Strings.hasLength(System.getProperty("tests.logger.level"))) { - builder.put("logger.level", System.getProperty("tests.logger.level")); + if (Strings.hasLength(System.getProperty("tests.es.logger.level"))) { + builder.put("logger.level", System.getProperty("tests.es.logger.level")); } if (Strings.hasLength(System.getProperty("es.logger.prefix"))) { builder.put("logger.prefix", System.getProperty("es.logger.prefix")); @@ -318,14 +317,14 @@ public final class InternalTestCluster extends TestCluster { public static String configuredNodeMode() { Builder builder = Settings.builder(); - if (Strings.isEmpty(System.getProperty("node.mode")) && Strings.isEmpty(System.getProperty("node.local"))) { + if (Strings.isEmpty(System.getProperty("tests.es.node.mode")) && Strings.isEmpty(System.getProperty("tests.node.local"))) { return "local"; // default if nothing is specified } - if (Strings.hasLength(System.getProperty("node.mode"))) { - builder.put(Node.NODE_MODE_SETTING.getKey(), System.getProperty("node.mode")); + if (Strings.hasLength(System.getProperty("tests.es.node.mode"))) { + builder.put(Node.NODE_MODE_SETTING.getKey(), System.getProperty("tests.es.node.mode")); } - if (Strings.hasLength(System.getProperty("node.local"))) { - builder.put(Node.NODE_LOCAL_SETTING.getKey(), System.getProperty("node.local")); + if (Strings.hasLength(System.getProperty("tests.es.node.local"))) { + builder.put(Node.NODE_LOCAL_SETTING.getKey(), System.getProperty("tests.es.node.local")); } if (DiscoveryNode.isLocalNode(builder.build())) { return "local"; diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index 75bc916ab94..2bdec79f3a0 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -137,10 +137,10 @@ public class ReproduceInfoPrinter extends RunListener { } public ReproduceErrorMessageBuilder appendESProperties() { - appendProperties("tests.logger.level"); + appendProperties("tests.es.logger.level"); if (inVerifyPhase()) { // these properties only make sense for integration tests - appendProperties("node.mode", "node.local", TESTS_CLUSTER, + appendProperties("tests.es.node.mode", "tests.es.node.local", TESTS_CLUSTER, ESIntegTestCase.TESTS_ENABLE_MOCK_MODULES); } appendProperties("tests.assertion.disabled", "tests.security.manager", "tests.nightly", "tests.jvms",