From cd474df9725d63fb2b76481f44f3f26850c8768b Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 11 Dec 2017 15:40:10 -0500 Subject: [PATCH] Remove RPM and Debian integration tests We have tests that manually unpackage the RPM and Debian package distributions and start a cluster manually (not from the service) and run a basic suite of integration tests against them. This is problematic because it is not how the packages are intended to be used (instead, they are intended to be installed using the package installation tools, and started as services) and so violates assumptions that we make about directory paths. This commit removes these integration tests, instead relying on the packaging tests to ensure the packages are not broken. Additionally, we add a sanity check that the package distributions can be unpackaged. Finally, with this change we can remove some leniency from elasticsearch-env about checking for the existence of the environment file which the leniency was there solely for these integration tests. Relates #27725 --- .../gradle/test/ClusterFormationTasks.groovy | 29 --------------- distribution/build.gradle | 4 +- distribution/deb/build.gradle | 21 ++++++++--- .../test/rest/DebClientYamlTestSuiteIT.java | 36 ------------------ .../test/smoke_test_plugins/10_modules.yml | 13 ------- distribution/rpm/build.gradle | 34 ++++++++++++++--- .../test/rest/RpmClientYamlTestSuiteIT.java | 37 ------------------- .../test/smoke_test_plugins/10_modules.yml | 13 ------- 8 files changed, 46 insertions(+), 141 deletions(-) delete mode 100644 distribution/deb/src/test/java/org/elasticsearch/test/rest/DebClientYamlTestSuiteIT.java delete mode 100644 distribution/deb/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml delete mode 100644 distribution/rpm/src/test/java/org/elasticsearch/test/rest/RpmClientYamlTestSuiteIT.java delete mode 100644 distribution/rpm/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index f7637d23366..2b3b5abd82c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -269,35 +269,6 @@ class ClusterFormationTasks { into node.baseDir } break; - case 'rpm': - File rpmDatabase = new File(node.baseDir, 'rpm-database') - File rpmExtracted = new File(node.baseDir, 'rpm-extracted') - /* Delay reading the location of the rpm file until task execution */ - Object rpm = "${ -> configuration.singleFile}" - extract = project.tasks.create(name: name, type: LoggedExec, dependsOn: extractDependsOn) { - commandLine 'rpm', '--badreloc', '--nodeps', '--noscripts', '--notriggers', - '--dbpath', rpmDatabase, - '--relocate', "/=${rpmExtracted}", - '-i', rpm - doFirst { - rpmDatabase.deleteDir() - rpmExtracted.deleteDir() - } - outputs.dir rpmExtracted - } - break; - case 'deb': - /* Delay reading the location of the deb file until task execution */ - File debExtracted = new File(node.baseDir, 'deb-extracted') - Object deb = "${ -> configuration.singleFile}" - extract = project.tasks.create(name: name, type: LoggedExec, dependsOn: extractDependsOn) { - commandLine 'dpkg-deb', '-x', deb, debExtracted - doFirst { - debExtracted.deleteDir() - } - outputs.dir debExtracted - } - break; default: throw new InvalidUserDataException("Unknown distribution: ${node.config.distribution}") } diff --git a/distribution/build.gradle b/distribution/build.gradle index 3df81d24c6b..26221cad5c7 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -538,8 +538,8 @@ Map expansionsForDistribution(distributionType) { 'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; done', ], 'source.path.env': [ - 'deb': 'if [ -f /etc/default/elasticsearch ]; then source /etc/default/elasticsearch; fi', - 'rpm': 'if [ -f /etc/sysconfig/elasticsearch ]; then source /etc/sysconfig/elasticsearch; fi', + 'deb': 'source /etc/default/elasticsearch', + 'rpm': 'source /etc/sysconfig/elasticsearch', 'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi', ], 'path.logs': [ diff --git a/distribution/deb/build.gradle b/distribution/deb/build.gradle index 89d33597888..cfc9aa4d8ef 100644 --- a/distribution/deb/build.gradle +++ b/distribution/deb/build.gradle @@ -1,3 +1,5 @@ +import org.elasticsearch.gradle.LoggedExec + /* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with @@ -42,9 +44,18 @@ artifacts { archives buildDeb } -integTest { - /* We use real deb tools to extract the deb file for testing so we have to - skip the test if they aren't around. */ - enabled = new File('/usr/bin/dpkg-deb').exists() || // Standard location - new File('/usr/local/bin/dpkg-deb').exists() // Homebrew location +integTest.enabled = false +licenseHeaders.enabled = false + +// task that sanity checks if the Deb archive can be extracted +task checkDeb(type: LoggedExec) { + onlyIf { new File('/usr/bin/dpkg-deb').exists() || new File('/usr/local/bin/dpkg-deb').exists() } + final File debExtracted = new File("${buildDir}", 'deb-extracted') + commandLine 'dpkg-deb', '-x', "${buildDir}/distributions/elasticsearch-${project.version}.deb", debExtracted + doFirst { + debExtracted.deleteDir() + } } + +checkDeb.dependsOn buildDeb +check.dependsOn checkDeb diff --git a/distribution/deb/src/test/java/org/elasticsearch/test/rest/DebClientYamlTestSuiteIT.java b/distribution/deb/src/test/java/org/elasticsearch/test/rest/DebClientYamlTestSuiteIT.java deleted file mode 100644 index 0fcdecde068..00000000000 --- a/distribution/deb/src/test/java/org/elasticsearch/test/rest/DebClientYamlTestSuiteIT.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.rest; - -import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; - -/** Rest integration test. Runs against a cluster started by {@code gradle integTest} */ -public class DebClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { - public DebClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) { - super(testCandidate); - } - - @ParametersFactory - public static Iterable parameters() throws Exception { - return createParameters(); - } -} diff --git a/distribution/deb/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml b/distribution/deb/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml deleted file mode 100644 index da68232f8d8..00000000000 --- a/distribution/deb/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Integration tests for distributions with modules -# -"Correct Modules Count": - - do: - cluster.state: {} - - # Get master node id - - set: { master_node: master } - - - do: - nodes.info: {} - - - length: { nodes.$master.modules: ${expected.modules.count} } diff --git a/distribution/rpm/build.gradle b/distribution/rpm/build.gradle index 6f8299522ca..4432198f234 100644 --- a/distribution/rpm/build.gradle +++ b/distribution/rpm/build.gradle @@ -17,6 +17,8 @@ * under the License. */ +import org.elasticsearch.gradle.LoggedExec + task buildRpm(type: Rpm) { dependsOn preparePackagingFiles baseName 'elasticsearch' // this is what pom generation uses for artifactId @@ -54,10 +56,30 @@ artifacts { archives buildRpm } -integTest { - /* We use real rpm tools to extract the rpm file for testing so we have to - skip the test if they aren't around. */ - enabled = new File('/bin/rpm').exists() || // Standard location - new File('/usr/bin/rpm').exists() || // Debian location - new File('/usr/local/bin/rpm').exists() // Homebrew location +integTest.enabled = false +licenseHeaders.enabled = false + +// task that sanity checks if the RPM archive can be extracted +task checkRpm(type: LoggedExec) { + onlyIf { new File('/bin/rpm').exists() || new File('/usr/bin/rpm').exists() || new File('/usr/local/bin/rpm').exists() } + final File rpmDatabase = new File("${buildDir}", 'rpm-database') + final File rpmExtracted = new File("${buildDir}", 'rpm-extracted') + commandLine 'rpm', + '--badreloc', + '--nodeps', + '--noscripts', + '--notriggers', + '--dbpath', + rpmDatabase, + '--relocate', + "/=${rpmExtracted}", + '-i', + "${buildDir}/distributions/elasticsearch-${project.version}.rpm" + doFirst { + rpmDatabase.deleteDir() + rpmExtracted.deleteDir() + } } + +checkRpm.dependsOn buildRpm +check.dependsOn checkRpm diff --git a/distribution/rpm/src/test/java/org/elasticsearch/test/rest/RpmClientYamlTestSuiteIT.java b/distribution/rpm/src/test/java/org/elasticsearch/test/rest/RpmClientYamlTestSuiteIT.java deleted file mode 100644 index 388f5ee6517..00000000000 --- a/distribution/rpm/src/test/java/org/elasticsearch/test/rest/RpmClientYamlTestSuiteIT.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.rest; - -import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; - -import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; - -/** Rest integration test. Runs against a cluster started by {@code gradle integTest} */ -public class RpmClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { - public RpmClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) { - super(testCandidate); - } - - @ParametersFactory - public static Iterable parameters() throws Exception { - return createParameters(); - } -} diff --git a/distribution/rpm/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml b/distribution/rpm/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml deleted file mode 100644 index da68232f8d8..00000000000 --- a/distribution/rpm/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Integration tests for distributions with modules -# -"Correct Modules Count": - - do: - cluster.state: {} - - # Get master node id - - set: { master_node: master } - - - do: - nodes.info: {} - - - length: { nodes.$master.modules: ${expected.modules.count} }