From fff26ba39e1fc78e46233688436c8a6031a3a83f Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 4 Jan 2017 15:45:28 -0800 Subject: [PATCH] Use tests.asserts flag to allow disabling assertions Randomized runner uses a flag, tests.asserts, which we have previously not used, but is used in lucene for disabling assertions. This change modifies the gradle configuration to look for this flag and pass through to the test runner to determine whether -ea and -esa are added to the java commandline for tests. --- .../groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 8 +++----- .../elasticsearch/gradle/test/ClusterConfiguration.groovy | 4 +--- .../groovy/org/elasticsearch/gradle/test/NodeInfo.groovy | 3 +++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 628e59de1a6..798f1d230ae 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -509,11 +509,9 @@ class BuildPlugin implements Plugin { } } - // System assertions (-esa) are disabled for now because of what looks like a - // JDK bug triggered by Groovy on JDK7. We should look at re-enabling system - // assertions when we upgrade to a new version of Groovy (currently 2.4.4) or - // require JDK8. See https://issues.apache.org/jira/browse/GROOVY-7528. - enableSystemAssertions false + boolean assertionsEnabled = Boolean.parseBoolean(System.getProperty('tests.asserts', 'true')) + enableSystemAssertions assertionsEnabled + enableAssertions assertionsEnabled testLogging { showNumFailuresAtEnd 25 diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy index 57adaa2576d..8d65f8c0d60 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy @@ -72,12 +72,10 @@ class ClusterConfiguration { boolean useMinimumMasterNodes = true @Input - String jvmArgs = "-ea" + - " " + "-Xms" + System.getProperty('tests.heap.size', '512m') + + String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') + " " + "-Xmx" + System.getProperty('tests.heap.size', '512m') + " " + System.getProperty('tests.jvm.argline', '') - /** * A closure to call which returns the unicast host to connect to for cluster formation. * 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 a9473cc28d2..73f32961fb3 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy @@ -151,6 +151,9 @@ class NodeInfo { args.addAll("-E", "node.portsfile=true") String collectedSystemProperties = config.systemProperties.collect { key, value -> "-D${key}=${value}" }.join(" ") String esJavaOpts = config.jvmArgs.isEmpty() ? collectedSystemProperties : collectedSystemProperties + " " + config.jvmArgs + if (Boolean.parseBoolean(System.getProperty('tests.asserts', 'true'))) { + esJavaOpts += " -ea -esa" + } env.put('ES_JAVA_OPTS', esJavaOpts) for (Map.Entry property : System.properties.entrySet()) { if (property.key.startsWith('tests.es.')) {