From 18fb63209bf8beb11323c3bda932212b7878e667 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 20 Aug 2019 13:12:15 -0700 Subject: [PATCH] Separate distro tests to be per distribution (#45565) The java based distribution tests currently have a single Tests class which encapsulates all of the tests for a particular distribution. The test task in gradle then depends on all distributions being built, and each individual tests class looks for the particular distribution it is trying to test. This means that reproducing a single test failure triggers all the distributions to be built, even though only one is needed for the test. This commit reworks the java distribution tests to pass in a particular distribution to be tested, and changes the base test classes to be actual test classes which have assumptions around which distributions they operate on. For example, the archives tests will be skipped when run with an rpm distribution, and vice versa for the package tests. This makes reproduction much more granular. It also also better splitting up tests around a particular use case. For example, all tests for systemd behavior can be in one test class, and run independently of all tests against rpm/deb distributions. --- .../gradle/test/DistroTestPlugin.java | 63 ++++++++++---- .../elasticsearch/packaging/VMTestRunner.java | 40 --------- ...ArchiveTestCase.java => ArchiveTests.java} | 29 ++++--- ...estCase.java => DebPreservationTests.java} | 17 +--- .../packaging/test/DefaultDebBasicTests.java | 31 ------- .../test/DefaultDebPreservationTests.java | 30 ------- .../packaging/test/DefaultLinuxTarTests.java | 30 ------- .../test/DefaultNoJdkDebBasicTests.java | 31 ------- .../test/DefaultNoJdkLinuxTarTests.java | 30 ------- .../test/DefaultNoJdkRpmBasicTests.java | 30 ------- .../test/DefaultNoJdkWindowsZipTests.java | 30 ------- .../packaging/test/DefaultRpmBasicTests.java | 30 ------- .../test/DefaultRpmPreservationTests.java | 30 ------- .../test/DefaultWindowsServiceTests.java | 30 ------- .../test/DefaultWindowsZipTests.java | 30 ------- .../packaging/test/OssDebBasicTests.java | 55 ------------- .../test/OssDebPreservationTests.java | 30 ------- .../packaging/test/OssLinuxTarTests.java | 30 ------- .../packaging/test/OssNoJdkDebBasicTests.java | 30 ------- .../packaging/test/OssNoJdkLinuxTarTests.java | 30 ------- .../packaging/test/OssNoJdkRpmBasicTests.java | 30 ------- .../test/OssNoJdkWindowsZipTests.java | 30 ------- .../packaging/test/OssRpmBasicTests.java | 58 ------------- .../test/OssRpmPreservationTests.java | 30 ------- .../test/OssWindowsServiceTests.java | 30 ------- .../packaging/test/OssWindowsZipTests.java | 30 ------- .../packaging/test/PackageConflictTests.java | 82 +++++++++++++++++++ ...PackageTestCase.java => PackageTests.java} | 5 +- .../packaging/test/PackagingTestCase.java | 11 ++- ...estCase.java => RpmPreservationTests.java} | 17 +--- ...TestCase.java => WindowsServiceTests.java} | 3 +- .../packaging/util/Archives.java | 25 +++--- .../packaging/util/Distribution.java | 61 +++----------- .../packaging/util/FileUtils.java | 20 ++--- .../packaging/util/Packages.java | 18 ++-- qa/os/windows-2012r2/build.gradle | 4 +- qa/os/windows-2016/build.gradle | 6 +- 37 files changed, 219 insertions(+), 897 deletions(-) delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/VMTestRunner.java rename qa/os/src/test/java/org/elasticsearch/packaging/test/{ArchiveTestCase.java => ArchiveTests.java} (94%) rename qa/os/src/test/java/org/elasticsearch/packaging/test/{DebPreservationTestCase.java => DebPreservationTests.java} (90%) delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebPreservationTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultLinuxTarTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkDebBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkLinuxTarTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkRpmBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkWindowsZipTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmPreservationTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsServiceTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsZipTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebPreservationTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssLinuxTarTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkDebBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkLinuxTarTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkRpmBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkWindowsZipTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmBasicTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmPreservationTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsServiceTests.java delete mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsZipTests.java create mode 100644 qa/os/src/test/java/org/elasticsearch/packaging/test/PackageConflictTests.java rename qa/os/src/test/java/org/elasticsearch/packaging/test/{PackageTestCase.java => PackageTests.java} (98%) rename qa/os/src/test/java/org/elasticsearch/packaging/test/{RpmPreservationTestCase.java => RpmPreservationTests.java} (92%) rename qa/os/src/test/java/org/elasticsearch/packaging/test/{WindowsServiceTestCase.java => WindowsServiceTests.java} (99%) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java index f9552c0c51d..ef839016314 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java @@ -36,6 +36,7 @@ import org.elasticsearch.gradle.vagrant.VagrantExtension; import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Plugin; import org.gradle.api.Project; +import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; import org.gradle.api.file.Directory; import org.gradle.api.plugins.ExtraPropertiesExtension; @@ -74,6 +75,7 @@ public class DistroTestPlugin implements Plugin { private static final String COPY_UPGRADE_TASK = "copyUpgradePackages"; private static final String COPY_PLUGINS_TASK = "copyPlugins"; private static final String IN_VM_SYSPROP = "tests.inVM"; + private static final String DISTRIBUTION_SYSPROP = "tests.distribution"; @Override public void apply(Project project) { @@ -88,14 +90,15 @@ public class DistroTestPlugin implements Plugin { Provider upgradeDir = project.getLayout().getBuildDirectory().dir("packaging/upgrade"); Provider pluginsDir = project.getLayout().getBuildDirectory().dir("packaging/plugins"); - configureDistributions(project, upgradeVersion); + List distributions = configureDistributions(project, upgradeVersion); TaskProvider copyDistributionsTask = configureCopyDistributionsTask(project, distributionsDir); TaskProvider copyUpgradeTask = configureCopyUpgradeTask(project, upgradeVersion, upgradeDir); TaskProvider copyPluginsTask = configureCopyPluginsTask(project, pluginsDir); - Map> distroTests = new HashMap<>(); Map> batsTests = new HashMap<>(); - distroTests.put("distribution", configureDistroTest(project, distributionsDir, copyDistributionsTask)); + for (ElasticsearchDistribution distribution : distributions) { + configureDistroTest(project, distribution); + } batsTests.put("bats oss", configureBatsTest(project, "oss", distributionsDir, copyDistributionsTask)); batsTests.put("bats default", configureBatsTest(project, "default", distributionsDir, copyDistributionsTask)); configureBatsTest(project, "plugins",distributionsDir, copyDistributionsTask, copyPluginsTask).configure(t -> @@ -108,17 +111,27 @@ public class DistroTestPlugin implements Plugin { vmProject.getPluginManager().apply(VagrantBasePlugin.class); vmProject.getPluginManager().apply(JdkDownloadPlugin.class); List vmDependencies = new ArrayList<>(configureVM(vmProject)); - // a hack to ensure the parent task has already been run. this will not be necessary once tests are per distribution - // which will eliminate the copy distributions task altogether - vmDependencies.add(copyDistributionsTask); vmDependencies.add(project.getConfigurations().getByName("testRuntimeClasspath")); - distroTests.forEach((desc, task) -> configureVMWrapperTask(vmProject, desc, task.getName(), vmDependencies)); - VagrantExtension vagrant = vmProject.getExtensions().getByType(VagrantExtension.class); + TaskProvider distroTest = vmProject.getTasks().register("distroTest"); + for (ElasticsearchDistribution distribution : distributions) { + String destructiveTaskName = destructiveDistroTestTaskName(distribution); + Platform platform = distribution.getPlatform(); + // this condition ensures windows boxes get windows distributions, and linux boxes get linux distributions + if (isWindows(vmProject) == (platform == Platform.WINDOWS)) { + TaskProvider vmTask = + configureVMWrapperTask(vmProject, distribution.getName() + " distribution", destructiveTaskName, vmDependencies); + vmTask.configure(t -> t.dependsOn(distribution)); + distroTest.configure(t -> t.dependsOn(vmTask)); + } + } + + batsTests.forEach((desc, task) -> { configureVMWrapperTask(vmProject, desc, task.getName(), vmDependencies).configure(t -> { t.setProgressHandler(new BatsProgressLogger(project.getLogger())); - t.onlyIf(spec -> vagrant.isWindowsVM() == false); // bats doesn't run on windows + t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows + t.dependsOn(copyDistributionsTask); }); }); }); @@ -166,7 +179,7 @@ public class DistroTestPlugin implements Plugin { VagrantExtension vagrant = project.getExtensions().getByType(VagrantExtension.class); vagrant.setBox(box); vagrant.vmEnv("PATH", convertPath(project, vagrant, gradleJdk, "/bin:$PATH", "\\bin;$Env:PATH")); - vagrant.setIsWindowsVM(box.contains("windows")); + vagrant.setIsWindowsVM(isWindows(project)); return Arrays.asList(gradleJdk); } @@ -271,15 +284,14 @@ public class DistroTestPlugin implements Plugin { }); } - private static TaskProvider configureDistroTest(Project project, Provider distributionsDir, - TaskProvider copyPackagingArchives) { - // TODO: don't run with security manager... - return project.getTasks().register("destructiveDistroTest", Test.class, + private static TaskProvider configureDistroTest(Project project, ElasticsearchDistribution distribution) { + return project.getTasks().register(destructiveDistroTestTaskName(distribution), Test.class, t -> { t.setMaxParallelForks(1); - t.setWorkingDir(distributionsDir); + t.setWorkingDir(project.getProjectDir()); + t.systemProperty(DISTRIBUTION_SYSPROP, distribution.toString()); if (System.getProperty(IN_VM_SYSPROP) == null) { - t.dependsOn(copyPackagingArchives); + t.dependsOn(distribution); } }); } @@ -299,7 +311,7 @@ public class DistroTestPlugin implements Plugin { }); } - private void configureDistributions(Project project, Version upgradeVersion) { + private List configureDistributions(Project project, Version upgradeVersion) { NamedDomainObjectContainer distributions = DistributionDownloadPlugin.getContainer(project); List currentDistros = new ArrayList<>(); List upgradeDistros = new ArrayList<>(); @@ -337,13 +349,15 @@ public class DistroTestPlugin implements Plugin { List distroUpgradeConfigs = upgradeDistros.stream().map(ElasticsearchDistribution::getConfiguration) .collect(Collectors.toList()); packagingUpgradeConfig.setExtendsFrom(distroUpgradeConfigs); + + return currentDistros; } private static void addDistro(NamedDomainObjectContainer distributions, Type type, Platform platform, Flavor flavor, boolean bundledJdk, String version, List container) { - String name = flavor + "-" + (type == Type.ARCHIVE ? platform + "-" : "") + type + (bundledJdk ? "" : "-no-jdk") + "-" + version; + String name = distroId(type, platform, flavor, bundledJdk) + "-" + version; if (distributions.findByName(name) != null) { return; } @@ -358,4 +372,17 @@ public class DistroTestPlugin implements Plugin { }); container.add(distro); } + + // return true if the project is for a windows VM, false otherwise + private static boolean isWindows(Project project) { + return project.getName().contains("windows"); + } + + private static String distroId(Type type, Platform platform, Flavor flavor, boolean bundledJdk) { + return flavor + "-" + (type == Type.ARCHIVE ? platform + "-" : "") + type + (bundledJdk ? "" : "-no-jdk"); + } + + private static String destructiveDistroTestTaskName(ElasticsearchDistribution distro) { + return "destructiveDistroTest." + distroId(distro.getType(), distro.getPlatform(), distro.getFlavor(), distro.getBundledJdk()); + } } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/VMTestRunner.java b/qa/os/src/test/java/org/elasticsearch/packaging/VMTestRunner.java deleted file mode 100644 index a8fd2c27707..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/VMTestRunner.java +++ /dev/null @@ -1,40 +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.packaging; - -import org.junit.runner.JUnitCore; - -import java.nio.file.Files; -import java.nio.file.Paths; - -/** - * Ensures that the current JVM is running on a virtual machine before delegating to {@link JUnitCore}. We just check for the existence - * of a special file that we create during VM provisioning. - */ -public class VMTestRunner { - public static void main(String[] args) { - if (Files.exists(Paths.get("/is_vagrant_vm"))) { - JUnitCore.main(args); - } else { - throw new RuntimeException("This filesystem does not have an expected marker file indicating it's a virtual machine. These " + - "tests should only run in a virtual machine because they're destructive."); - } - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTests.java similarity index 94% rename from qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTestCase.java rename to qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTests.java index d6ba57ba075..d06efb37a3d 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/ArchiveTests.java @@ -19,7 +19,6 @@ package org.elasticsearch.packaging.test; -import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering; import org.apache.http.client.fluent.Request; import org.elasticsearch.packaging.util.Archives; import org.elasticsearch.packaging.util.Distribution; @@ -29,6 +28,7 @@ import org.elasticsearch.packaging.util.Platforms; import org.elasticsearch.packaging.util.ServerUtils; import org.elasticsearch.packaging.util.Shell; import org.elasticsearch.packaging.util.Shell.Result; +import org.junit.BeforeClass; import java.nio.file.Files; import java.nio.file.Path; @@ -55,13 +55,15 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.Matchers.isEmptyString; import static org.junit.Assume.assumeThat; +import static org.junit.Assume.assumeTrue; -/** - * Tests that apply to the archive distributions (tar, zip). To add a case for a distribution, subclass and - * override {@link ArchiveTestCase#distribution()}. These tests should be the same across all archive distributions - */ -@TestCaseOrdering(TestCaseOrdering.AlphabeticOrder.class) -public abstract class ArchiveTestCase extends PackagingTestCase { +public class ArchiveTests extends PackagingTestCase { + + @BeforeClass + public static void assumptions() { + assumeTrue("only archive distributions", + distribution().packaging == Distribution.Packaging.TAR || distribution().packaging == Distribution.Packaging.ZIP); + } public void test10Install() throws Exception { installation = installArchive(distribution()); @@ -366,7 +368,7 @@ public abstract class ArchiveTestCase extends PackagingTestCase { final Installation.Executables bin = installation.executables(); final Shell sh = newShell(); - if (distribution().equals(Distribution.DEFAULT_LINUX) || distribution().equals(Distribution.DEFAULT_WINDOWS)) { + if (distribution().isDefault()) { assertTrue(Files.exists(installation.lib.resolve("tools").resolve("security-cli"))); final Platforms.PlatformAction action = () -> { Result result = sh.run(bin.elasticsearchCertutil + " --help"); @@ -379,7 +381,7 @@ public abstract class ArchiveTestCase extends PackagingTestCase { }; Platforms.onLinux(action); Platforms.onWindows(action); - } else if (distribution().equals(Distribution.OSS_LINUX) || distribution().equals(Distribution.OSS_WINDOWS)) { + } else { assertFalse(Files.exists(installation.lib.resolve("tools").resolve("security-cli"))); } } @@ -395,7 +397,8 @@ public abstract class ArchiveTestCase extends PackagingTestCase { assertThat(result.stdout, containsString("A CLI tool to remove corrupted parts of unrecoverable shards")); }; - if (distribution().equals(Distribution.DEFAULT_LINUX) || distribution().equals(Distribution.DEFAULT_WINDOWS)) { + // TODO: this should be checked on all distributions + if (distribution().isDefault()) { Platforms.onLinux(action); Platforms.onWindows(action); } @@ -413,7 +416,8 @@ public abstract class ArchiveTestCase extends PackagingTestCase { containsString("A CLI tool to do unsafe cluster and index manipulations on current node")); }; - if (distribution().equals(Distribution.DEFAULT_LINUX) || distribution().equals(Distribution.DEFAULT_WINDOWS)) { + // TODO: this should be checked on all distributions + if (distribution().isDefault()) { Platforms.onLinux(action); Platforms.onWindows(action); } @@ -458,7 +462,8 @@ public abstract class ArchiveTestCase extends PackagingTestCase { containsString("Manages elasticsearch file users")); }; - if (distribution().equals(Distribution.DEFAULT_LINUX) || distribution().equals(Distribution.DEFAULT_WINDOWS)) { + // TODO: this should be checked on all distributions + if (distribution().isDefault()) { Platforms.onLinux(action); Platforms.onWindows(action); } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTests.java similarity index 90% rename from qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTestCase.java rename to qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTests.java index 12597ae8b4d..dc87d685d3f 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/DebPreservationTests.java @@ -21,15 +21,12 @@ package org.elasticsearch.packaging.test; import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering; import org.elasticsearch.packaging.util.Distribution; -import org.elasticsearch.packaging.util.Installation; import org.elasticsearch.packaging.util.Shell; import org.junit.Before; -import org.junit.BeforeClass; import java.nio.file.Files; import java.nio.file.Paths; -import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; import static org.elasticsearch.packaging.util.FileUtils.assertPathsDontExist; import static org.elasticsearch.packaging.util.FileUtils.assertPathsExist; import static org.elasticsearch.packaging.util.Packages.SYSVINIT_SCRIPT; @@ -46,21 +43,13 @@ import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; @TestCaseOrdering(TestCaseOrdering.AlphabeticOrder.class) -public abstract class DebPreservationTestCase extends PackagingTestCase { - - private static Installation installation; - - protected abstract Distribution distribution(); - - @BeforeClass - public static void cleanup() throws Exception { - installation = null; - cleanEverything(); - } +public class DebPreservationTests extends PackagingTestCase { @Before public void onlyCompatibleDistributions() { assumeTrue("only dpkg platforms", isDPKG()); + assumeTrue("deb distributions", distribution().packaging == Distribution.Packaging.DEB); + assumeTrue("only bundled jdk", distribution().hasJdk); assumeTrue("only compatible distributions", distribution().packaging.compatible); } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebBasicTests.java deleted file mode 100644 index cd40c0e9e81..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebBasicTests.java +++ /dev/null @@ -1,31 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultDebBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_DEB; - } - -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebPreservationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebPreservationTests.java deleted file mode 100644 index d8b8c7f562b..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultDebPreservationTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultDebPreservationTests extends DebPreservationTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_DEB; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultLinuxTarTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultLinuxTarTests.java deleted file mode 100644 index bcca1a7e9e0..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultLinuxTarTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultLinuxTarTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_LINUX; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkDebBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkDebBasicTests.java deleted file mode 100644 index 23c87b6e936..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkDebBasicTests.java +++ /dev/null @@ -1,31 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultNoJdkDebBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_NO_JDK_DEB; - } - -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkLinuxTarTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkLinuxTarTests.java deleted file mode 100644 index fce7c556718..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkLinuxTarTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultNoJdkLinuxTarTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_NO_JDK_LINUX; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkRpmBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkRpmBasicTests.java deleted file mode 100644 index 3bb5aa8eae8..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkRpmBasicTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultNoJdkRpmBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_NO_JDK_RPM; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkWindowsZipTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkWindowsZipTests.java deleted file mode 100644 index d797bdaa9f3..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultNoJdkWindowsZipTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultNoJdkWindowsZipTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_NO_JDK_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmBasicTests.java deleted file mode 100644 index a8ce7b48685..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmBasicTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultRpmBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_RPM; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmPreservationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmPreservationTests.java deleted file mode 100644 index 633492cce6c..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultRpmPreservationTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultRpmPreservationTests extends RpmPreservationTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_RPM; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsServiceTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsServiceTests.java deleted file mode 100644 index 6fedd3b89db..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsServiceTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultWindowsServiceTests extends WindowsServiceTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsZipTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsZipTests.java deleted file mode 100644 index a7491d5b0ac..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/DefaultWindowsZipTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class DefaultWindowsZipTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.DEFAULT_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebBasicTests.java deleted file mode 100644 index 38ef9c36a29..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebBasicTests.java +++ /dev/null @@ -1,55 +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.packaging.test; - -import junit.framework.TestCase; -import org.elasticsearch.packaging.util.Distribution; -import org.elasticsearch.packaging.util.Platforms; -import org.elasticsearch.packaging.util.Shell; - -import java.util.regex.Pattern; - -import static org.elasticsearch.packaging.util.Distribution.DEFAULT_DEB; -import static org.elasticsearch.packaging.util.Distribution.OSS_DEB; -import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile; -import static org.junit.Assume.assumeTrue; - -public class OssDebBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_DEB; - } - - public void test11DebDependencies() { - assumeTrue(Platforms.isDPKG()); - - final Shell sh = new Shell(); - - final Shell.Result defaultResult = sh.run("dpkg -I " + getDistributionFile(DEFAULT_DEB)); - final Shell.Result ossResult = sh.run("dpkg -I " + getDistributionFile(OSS_DEB)); - - TestCase.assertTrue(Pattern.compile("(?m)^ Depends:.*bash.*").matcher(defaultResult.stdout).find()); - TestCase.assertTrue(Pattern.compile("(?m)^ Depends:.*bash.*").matcher(ossResult.stdout).find()); - - TestCase.assertTrue(Pattern.compile("(?m)^ Conflicts: elasticsearch-oss$").matcher(defaultResult.stdout).find()); - TestCase.assertTrue(Pattern.compile("(?m)^ Conflicts: elasticsearch$").matcher(ossResult.stdout).find()); - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebPreservationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebPreservationTests.java deleted file mode 100644 index cfce73bb160..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssDebPreservationTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssDebPreservationTests extends DebPreservationTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_DEB; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssLinuxTarTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssLinuxTarTests.java deleted file mode 100644 index bf4305aab53..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssLinuxTarTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssLinuxTarTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_LINUX; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkDebBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkDebBasicTests.java deleted file mode 100644 index 47d2f662f4d..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkDebBasicTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssNoJdkDebBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_NO_JDK_DEB; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkLinuxTarTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkLinuxTarTests.java deleted file mode 100644 index dae5068f362..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkLinuxTarTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssNoJdkLinuxTarTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_NO_JDK_LINUX; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkRpmBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkRpmBasicTests.java deleted file mode 100644 index 1ebf7043039..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkRpmBasicTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssNoJdkRpmBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_NO_JDK_RPM; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkWindowsZipTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkWindowsZipTests.java deleted file mode 100644 index 639137e8879..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssNoJdkWindowsZipTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssNoJdkWindowsZipTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_NO_JDK_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmBasicTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmBasicTests.java deleted file mode 100644 index 91abb5e0c5c..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmBasicTests.java +++ /dev/null @@ -1,58 +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.packaging.test; - -import junit.framework.TestCase; -import org.elasticsearch.packaging.util.Distribution; -import org.elasticsearch.packaging.util.Platforms; -import org.elasticsearch.packaging.util.Shell; - -import java.util.regex.Pattern; - -import static org.elasticsearch.packaging.util.Distribution.DEFAULT_RPM; -import static org.elasticsearch.packaging.util.Distribution.OSS_RPM; -import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile; -import static org.junit.Assume.assumeTrue; - -public class OssRpmBasicTests extends PackageTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_RPM; - } - - public void test11RpmDependencies() { - assumeTrue(Platforms.isRPM()); - - final Shell sh = new Shell(); - - final Shell.Result defaultDeps = sh.run("rpm -qpR " + getDistributionFile(DEFAULT_RPM)); - final Shell.Result ossDeps = sh.run("rpm -qpR " + getDistributionFile(OSS_RPM)); - - TestCase.assertTrue(Pattern.compile("(?m)^/bin/bash\\s*$").matcher(defaultDeps.stdout).find()); - TestCase.assertTrue(Pattern.compile("(?m)^/bin/bash\\s*$").matcher(ossDeps.stdout).find()); - - final Shell.Result defaultConflicts = sh.run("rpm -qp --conflicts " + getDistributionFile(DEFAULT_RPM)); - final Shell.Result ossConflicts = sh.run("rpm -qp --conflicts " + getDistributionFile(OSS_RPM)); - - TestCase.assertTrue(Pattern.compile("(?m)^elasticsearch-oss\\s*$").matcher(defaultConflicts.stdout).find()); - TestCase.assertTrue(Pattern.compile("(?m)^elasticsearch\\s*$").matcher(ossConflicts.stdout).find()); - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmPreservationTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmPreservationTests.java deleted file mode 100644 index 87071d687d0..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssRpmPreservationTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssRpmPreservationTests extends RpmPreservationTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_RPM; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsServiceTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsServiceTests.java deleted file mode 100644 index bfa220c6aaf..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsServiceTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssWindowsServiceTests extends WindowsServiceTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsZipTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsZipTests.java deleted file mode 100644 index 2a0df6cab96..00000000000 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/OssWindowsZipTests.java +++ /dev/null @@ -1,30 +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.packaging.test; - -import org.elasticsearch.packaging.util.Distribution; - -public class OssWindowsZipTests extends ArchiveTestCase { - - @Override - protected Distribution distribution() { - return Distribution.OSS_WINDOWS; - } -} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageConflictTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageConflictTests.java new file mode 100644 index 00000000000..93b1146d839 --- /dev/null +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageConflictTests.java @@ -0,0 +1,82 @@ +/* + * 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.packaging.test; + +import junit.framework.TestCase; +import org.elasticsearch.packaging.util.Distribution; +import org.elasticsearch.packaging.util.Platforms; +import org.elasticsearch.packaging.util.Shell; +import org.junit.Before; + +import java.util.regex.Pattern; + +import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile; +import static org.junit.Assume.assumeTrue; + +public class PackageConflictTests extends PackagingTestCase { + + private Shell sh; + + @Before + public void onlyCompatibleDistributions() throws Exception { + assumeTrue("only compatible distributions", distribution().packaging.compatible); + assumeTrue("rpm or deb", + distribution().packaging == Distribution.Packaging.DEB || distribution().packaging == Distribution.Packaging.RPM); + sh = newShell(); + } + + public void test11DebDependencies() { + // TODO: rewrite this test to not use a real second distro to try and install + assumeTrue(Platforms.isDPKG()); + + final Shell sh = new Shell(); + + final Shell.Result result = sh.run("dpkg -I " + getDistributionFile(distribution())); + + TestCase.assertTrue(Pattern.compile("(?m)^ Depends:.*bash.*").matcher(result.stdout).find()); + + String oppositePackageName = "elasticsearch"; + if (distribution().isDefault()) { + oppositePackageName += "-oss"; + } + + TestCase.assertTrue(Pattern.compile("(?m)^ Conflicts: " + oppositePackageName + "$").matcher(result.stdout).find()); + } + + public void test11RpmDependencies() { + // TODO: rewrite this test to not use a real second distro to try and install + assumeTrue(Platforms.isRPM()); + + final Shell sh = new Shell(); + + final Shell.Result deps = sh.run("rpm -qpR " + getDistributionFile(distribution())); + + TestCase.assertTrue(Pattern.compile("(?m)^/bin/bash\\s*$").matcher(deps.stdout).find()); + + final Shell.Result conflicts = sh.run("rpm -qp --conflicts " + getDistributionFile(distribution())); + + String oppositePackageName = "elasticsearch"; + if (distribution().isDefault()) { + oppositePackageName += "-oss"; + } + + TestCase.assertTrue(Pattern.compile("(?m)^" + oppositePackageName + "\\s*$").matcher(conflicts.stdout).find()); + } +} diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTests.java similarity index 98% rename from qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTestCase.java rename to qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTests.java index 05bc80c3263..f326fef9d07 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackageTests.java @@ -22,6 +22,7 @@ package org.elasticsearch.packaging.test; import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.apache.http.client.fluent.Request; +import org.elasticsearch.packaging.util.Distribution; import org.elasticsearch.packaging.util.FileUtils; import org.elasticsearch.packaging.util.Shell; import org.elasticsearch.packaging.util.Shell.Result; @@ -70,12 +71,14 @@ import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; @TestCaseOrdering(TestCaseOrdering.AlphabeticOrder.class) -public abstract class PackageTestCase extends PackagingTestCase { +public class PackageTests extends PackagingTestCase { private Shell sh; @Before public void onlyCompatibleDistributions() throws Exception { assumeTrue("only compatible distributions", distribution().packaging.compatible); + assumeTrue("rpm or deb", + distribution().packaging == Distribution.Packaging.DEB || distribution().packaging == Distribution.Packaging.RPM); sh = newShell(); } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java index bd7738aeac4..d9ecb62f9bc 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/PackagingTestCase.java @@ -36,6 +36,8 @@ import org.junit.Rule; import org.junit.rules.TestName; import org.junit.runner.RunWith; +import java.nio.file.Paths; + import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; import static org.junit.Assume.assumeTrue; @@ -52,6 +54,11 @@ public abstract class PackagingTestCase extends Assert { protected final Log logger = LogFactory.getLog(getClass()); + private static Distribution distribution; + static { + distribution = new Distribution(Paths.get(System.getProperty("tests.distribution"))); + } + @Rule public final TestName testNameRule = new TestName(); @@ -70,7 +77,9 @@ public abstract class PackagingTestCase extends Assert { } /** The {@link Distribution} that should be tested in this case */ - protected abstract Distribution distribution(); + protected static Distribution distribution() { + return distribution; + } protected Shell newShell() throws Exception { Shell sh = new Shell(); diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTests.java similarity index 92% rename from qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTestCase.java rename to qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTests.java index 7b6ac039fc5..79a1f1fe493 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/RpmPreservationTests.java @@ -21,16 +21,13 @@ package org.elasticsearch.packaging.test; import com.carrotsearch.randomizedtesting.annotations.TestCaseOrdering; import org.elasticsearch.packaging.util.Distribution; -import org.elasticsearch.packaging.util.Installation; import org.elasticsearch.packaging.util.Shell; import org.junit.Before; -import org.junit.BeforeClass; import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Stream; -import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; import static org.elasticsearch.packaging.util.FileUtils.append; import static org.elasticsearch.packaging.util.FileUtils.assertPathsDontExist; import static org.elasticsearch.packaging.util.Packages.SYSTEMD_SERVICE; @@ -48,21 +45,13 @@ import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; @TestCaseOrdering(TestCaseOrdering.AlphabeticOrder.class) -public abstract class RpmPreservationTestCase extends PackagingTestCase { - - private static Installation installation; - - protected abstract Distribution distribution(); - - @BeforeClass - public static void cleanup() throws Exception { - installation = null; - cleanEverything(); - } +public class RpmPreservationTests extends PackagingTestCase { @Before public void onlyCompatibleDistributions() { assumeTrue("only rpm platforms", isRPM()); + assumeTrue("rpm distributions", distribution().packaging == Distribution.Packaging.RPM); + assumeTrue("only bundled jdk", distribution().hasJdk); assumeTrue("only compatible distributions", distribution().packaging.compatible); } diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTestCase.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java similarity index 99% rename from qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTestCase.java rename to qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java index b0827513c92..faf1d13fec6 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTestCase.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java @@ -41,7 +41,7 @@ import static org.elasticsearch.packaging.util.FileUtils.mv; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; -public abstract class WindowsServiceTestCase extends PackagingTestCase { +public class WindowsServiceTests extends PackagingTestCase { private static final String DEFAULT_ID = "elasticsearch-service-x64"; private static final String DEFAULT_DISPLAY_NAME = "Elasticsearch " + FileUtils.getCurrentVersion() + " (elasticsearch-service-x64)"; @@ -57,6 +57,7 @@ public abstract class WindowsServiceTestCase extends PackagingTestCase { @BeforeClass public static void ensureWindows() { assumeTrue(Platforms.WINDOWS); + assumeTrue(distribution().hasJdk); } @After diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/Archives.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/Archives.java index e557b47fb89..62f927dc198 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/Archives.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/Archives.java @@ -19,6 +19,9 @@ package org.elasticsearch.packaging.util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -52,6 +55,8 @@ import static org.junit.Assert.assertTrue; */ public class Archives { + private static final Log logger = LogFactory.getLog(Archives.class); + // in the future we'll run as a role user on Windows public static final String ARCHIVE_OWNER = Platforms.WINDOWS ? "vagrant" @@ -71,27 +76,27 @@ public class Archives { assertThat("distribution file must exist: " + distributionFile.toString(), Files.exists(distributionFile), is(true)); assertThat("elasticsearch must not already be installed", lsGlob(baseInstallPath, "elasticsearch*"), empty()); + logger.info("Installing file: " + distributionFile); + final String installCommand; if (distribution.packaging == Distribution.Packaging.TAR) { - - Platforms.onLinux(() -> sh.run("tar -C " + baseInstallPath + " -xzpf " + distributionFile)); - if (Platforms.WINDOWS) { - throw new RuntimeException("Distribution " + distribution + " is not supported on windows"); + throw new IllegalStateException("Distribution " + distribution + " is not supported on windows"); } + installCommand = "tar -C " + baseInstallPath + " -xzpf " + distributionFile; } else if (distribution.packaging == Distribution.Packaging.ZIP) { - - Platforms.onLinux(() -> sh.run("unzip " + distributionFile + " -d " + baseInstallPath)); - - Platforms.onWindows(() -> sh.run( + if (Platforms.WINDOWS == false) { + throw new IllegalStateException("Distribution " + distribution + " is not supported on linux"); + } + installCommand = "Add-Type -AssemblyName 'System.IO.Compression.Filesystem'; " + - "[IO.Compression.ZipFile]::ExtractToDirectory('" + distributionFile + "', '" + baseInstallPath + "')" - )); + "[IO.Compression.ZipFile]::ExtractToDirectory('" + distributionFile + "', '" + baseInstallPath + "')"; } else { throw new RuntimeException("Distribution " + distribution + " is not a known archive type"); } + sh.run(installCommand); assertThat("archive was extracted", Files.exists(extractedPath), is(true)); mv(extractedPath, fullInstallPath); diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java index b73438bc4c9..9d78a998365 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/Distribution.java @@ -19,63 +19,26 @@ package org.elasticsearch.packaging.util; +import java.nio.file.Path; import java.util.Locale; -public enum Distribution { - - OSS_LINUX(Packaging.TAR, Platform.LINUX, Flavor.OSS, true), - OSS_WINDOWS(Packaging.ZIP, Platform.WINDOWS, Flavor.OSS, true), - OSS_DARWIN(Packaging.TAR, Platform.DARWIN, Flavor.OSS, true), - OSS_DEB(Packaging.DEB, Platform.LINUX, Flavor.OSS, true), - OSS_RPM(Packaging.RPM, Platform.LINUX, Flavor.OSS, true), - - DEFAULT_LINUX(Packaging.TAR, Platform.LINUX, Flavor.DEFAULT, true), - DEFAULT_WINDOWS(Packaging.ZIP, Platform.WINDOWS, Flavor.DEFAULT, true), - DEFAULT_DARWIN(Packaging.TAR, Platform.DARWIN, Flavor.DEFAULT, true), - DEFAULT_DEB(Packaging.DEB, Platform.LINUX, Flavor.DEFAULT, true), - DEFAULT_RPM(Packaging.RPM, Platform.LINUX, Flavor.DEFAULT, true), - - OSS_NO_JDK_LINUX(Packaging.TAR, Platform.LINUX, Flavor.OSS, false), - OSS_NO_JDK_WINDOWS(Packaging.ZIP, Platform.WINDOWS, Flavor.OSS, false), - OSS_NO_JDK_DARWIN(Packaging.TAR, Platform.DARWIN, Flavor.OSS, false), - OSS_NO_JDK_DEB(Packaging.DEB, Platform.LINUX, Flavor.OSS, false), - OSS_NO_JDK_RPM(Packaging.RPM, Platform.LINUX, Flavor.OSS, false), - - DEFAULT_NO_JDK_LINUX(Packaging.TAR, Platform.LINUX, Flavor.DEFAULT, false), - DEFAULT_NO_JDK_WINDOWS(Packaging.ZIP, Platform.WINDOWS, Flavor.DEFAULT, false), - DEFAULT_NO_JDK_DARWIN(Packaging.TAR, Platform.DARWIN, Flavor.DEFAULT, false), - DEFAULT_NO_JDK_DEB(Packaging.DEB, Platform.LINUX, Flavor.DEFAULT, false), - DEFAULT_NO_JDK_RPM(Packaging.RPM, Platform.LINUX, Flavor.DEFAULT, false); +public class Distribution { + public final Path path; public final Packaging packaging; public final Platform platform; public final Flavor flavor; public final boolean hasJdk; - Distribution(Packaging packaging, Platform platform, Flavor flavor, boolean hasJdk) { - this.packaging = packaging; - this.platform = platform; - this.flavor = flavor; - this.hasJdk = hasJdk; - } - - public String filename(String version) { - String classifier = ""; - if (version.startsWith("6.") == false) { - - if (hasJdk == false) { - classifier += "-no-jdk"; - } - if (packaging == Packaging.DEB) { - classifier += "-amd64"; - } else { - if (packaging != Packaging.RPM) { - classifier += "-" + platform.toString(); - } - classifier += "-x86_64"; - } - } - return flavor.name + "-" + version + classifier + packaging.extension; + public Distribution(Path path) { + this.path = path; + String filename = path.getFileName().toString(); + int lastDot = filename.lastIndexOf('.'); + String extension = filename.substring(lastDot + 1); + this.packaging = Packaging.valueOf(extension.equals("gz") ? "TAR" : extension.toUpperCase(Locale.ROOT)); + this.platform = filename.contains("windows") ? Platform.WINDOWS : Platform.LINUX; + this.flavor = filename.contains("oss") ? Flavor.OSS : Flavor.DEFAULT; + this.hasJdk = filename.contains("no-jdk") == false; } public boolean isDefault() { diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/FileUtils.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/FileUtils.java index 857fad55eea..94e156b1deb 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/FileUtils.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/FileUtils.java @@ -42,6 +42,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.StringJoiner; +import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import java.util.zip.ZipException; @@ -221,20 +222,19 @@ public class FileUtils { return getTempDir().resolve("elasticsearch"); } + private static final Pattern VERSION_REGEX = Pattern.compile("(\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?)"); public static String getCurrentVersion() { - return slurp(getPackagingArchivesDir().resolve("version")); - } - - public static Path getPackagingArchivesDir() { - return Paths.get(""); // tests are started in the packaging archives dir, ie the empty relative path + // TODO: just load this once + String distroFile = System.getProperty("tests.distribution"); + java.util.regex.Matcher matcher = VERSION_REGEX.matcher(distroFile); + if (matcher.find()) { + return matcher.group(1); + } + throw new IllegalStateException("Could not find version in filename: " + distroFile); } public static Path getDistributionFile(Distribution distribution) { - return getDistributionFile(distribution, getCurrentVersion()); - } - - public static Path getDistributionFile(Distribution distribution, String version) { - return getPackagingArchivesDir().resolve(distribution.filename(version)); + return distribution.path; } public static void assertPathsExist(Path... paths) { diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/util/Packages.java b/qa/os/src/test/java/org/elasticsearch/packaging/util/Packages.java index 70ac89dc3b7..8d456a4cdc0 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/util/Packages.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/util/Packages.java @@ -19,6 +19,8 @@ package org.elasticsearch.packaging.util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.elasticsearch.packaging.util.Shell.Result; import java.io.IOException; @@ -38,7 +40,6 @@ import static org.elasticsearch.packaging.util.FileMatcher.p660; import static org.elasticsearch.packaging.util.FileMatcher.p750; import static org.elasticsearch.packaging.util.FileMatcher.p755; import static org.elasticsearch.packaging.util.FileUtils.getCurrentVersion; -import static org.elasticsearch.packaging.util.FileUtils.getDistributionFile; import static org.elasticsearch.packaging.util.Platforms.isSysVInit; import static org.elasticsearch.packaging.util.Platforms.isSystemd; import static org.elasticsearch.packaging.util.ServerUtils.waitForElasticsearch; @@ -51,6 +52,8 @@ import static org.junit.Assert.assertTrue; public class Packages { + private static final Log logger = LogFactory.getLog(Packages.class); + public static final Path SYSVINIT_SCRIPT = Paths.get("/etc/init.d/elasticsearch"); public static final Path SYSTEMD_SERVICE = Paths.get("/usr/lib/systemd/system/elasticsearch.service"); @@ -81,6 +84,7 @@ public class Packages { final Shell sh = new Shell(); final Result result; + logger.info("Package type: " + distribution.packaging); if (distribution.packaging == Distribution.Packaging.RPM) { result = sh.runIgnoreExitCode("rpm -qe " + distribution.flavor.name); } else { @@ -91,18 +95,14 @@ public class Packages { } public static Installation install(Distribution distribution) throws IOException { - return install(distribution, getCurrentVersion()); - } - - public static Installation install(Distribution distribution, String version) throws IOException { Shell sh = new Shell(); String systemJavaHome = sh.run("echo $SYSTEM_JAVA_HOME").stdout.trim(); if (distribution.hasJdk == false) { sh.getEnv().put("JAVA_HOME", systemJavaHome); } - final Result result = runInstallCommand(distribution, version, sh); + final Result result = runInstallCommand(distribution, sh); if (result.exitCode != 0) { - throw new RuntimeException("Installing distribution " + distribution + " version " + version + " failed: " + result); + throw new RuntimeException("Installing distribution " + distribution + " failed: " + result); } Installation installation = Installation.ofPackage(distribution.packaging); @@ -114,8 +114,8 @@ public class Packages { return installation; } - public static Result runInstallCommand(Distribution distribution, String version, Shell sh) { - final Path distributionFile = getDistributionFile(distribution, version); + public static Result runInstallCommand(Distribution distribution, Shell sh) { + final Path distributionFile = distribution.path; if (Platforms.isRPM()) { return sh.runIgnoreExitCode("rpm -i " + distributionFile); diff --git a/qa/os/windows-2012r2/build.gradle b/qa/os/windows-2012r2/build.gradle index f49de70eae7..1a35b3ba915 100644 --- a/qa/os/windows-2012r2/build.gradle +++ b/qa/os/windows-2012r2/build.gradle @@ -1,3 +1,4 @@ +import org.elasticsearch.gradle.test.GradleDistroTestTask String boxId = project.properties.get('vagrant.windows-2012r2.id') if (boxId != null) { @@ -5,7 +6,8 @@ if (boxId != null) { hostEnv 'VAGRANT_WINDOWS_2012R2_BOX', boxId } } else { - tasks.named('distroTest').configure { + // box id was not supplied, so disable the distro tests + tasks.withType(GradleDistroTestTask).configureEach { onlyIf { false } } } diff --git a/qa/os/windows-2016/build.gradle b/qa/os/windows-2016/build.gradle index e0cfa1c6875..6f87222324b 100644 --- a/qa/os/windows-2016/build.gradle +++ b/qa/os/windows-2016/build.gradle @@ -1,3 +1,4 @@ +import org.elasticsearch.gradle.test.GradleDistroTestTask String boxId = project.properties.get('vagrant.windows-2016.id') if (boxId != null) { @@ -5,7 +6,8 @@ if (boxId != null) { hostEnv 'VAGRANT_WINDOWS_2016_BOX', boxId } } else { - tasks.named('distroTest').configure { - onlyIf { true } + // box id was not supplied, so disable the distro tests + tasks.withType(GradleDistroTestTask).configureEach { + onlyIf { false } } }