diff --git a/build-tools-internal/src/main/groovy/elasticsearch.fwc-test.gradle b/build-tools-internal/src/main/groovy/elasticsearch.fwc-test.gradle new file mode 100644 index 000000000000..51301b405e51 --- /dev/null +++ b/build-tools-internal/src/main/groovy/elasticsearch.fwc-test.gradle @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import org.elasticsearch.gradle.VersionProperties +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask + +def fwcVersions = buildParams.bwcVersions.released.findAll { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor } +def previousMinorSnapshot = buildParams.bwcVersions.unreleased.find { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor - 1 } + +fwcVersions.each { fwcVersion -> + tasks.register("v${fwcVersion}#fwcTest", StandaloneRestIntegTestTask) { + usesBwcDistribution(previousMinorSnapshot) + usesBwcDistribution(fwcVersion) + systemProperty("tests.old_cluster_version", previousMinorSnapshot) + systemProperty("tests.new_cluster_version", fwcVersion) + nonInputProperties.systemProperty 'tests.fwc', 'true' + } +} + +gradle.taskGraph.whenReady { graph -> + if (graph.allTasks.any { it.name.endsWith('#fwcTest') } && Boolean.parseBoolean(System.getProperty("tests.bwc.snapshot", "true"))) { + throw new GradleException("Running forward compatibility tests requires passing `-Dtests.bwc.snapshot=false`.") + } + + if (graph.allTasks.any { it.name.endsWith('#fwcTest') } && graph.allTasks.any { it.name.endsWith('#bwcTest') }) { + throw new GradleException("Backward compatibility and forward compatibility tests cannot be executed in the same build.") + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java index 6050e5c9a60d..ccf7a6ea6350 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java @@ -145,7 +145,14 @@ public class BwcSetupExtension { loggedExec.args("-DisCI"); } - loggedExec.args("-Dbuild.snapshot=true", "-Dscan.tag.NESTED"); + loggedExec.args("-Dscan.tag.NESTED"); + + if (System.getProperty("tests.bwc.snapshot", "true").equals("false")) { + loggedExec.args("-Dbuild.snapshot=false", "-Dlicense.key=x-pack/plugin/core/snapshot.key"); + } else { + loggedExec.args("-Dbuild.snapshot=true"); + } + final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel(); List nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG); if (nonDefaultLogLevels.contains(logLevel)) { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java index b6c36285ca3a..fea895f90f91 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java @@ -355,8 +355,9 @@ public class InternalDistributionBwcSetupPlugin implements Plugin { String bwcTaskName = buildBwcTaskName(projectName); bwcSetupExtension.bwcTask(bwcTaskName, c -> { boolean useNativeExpanded = projectArtifact.expandedDistDir != null; + boolean isReleaseBuild = System.getProperty("tests.bwc.snapshot", "true").equals("false"); File expectedOutputFile = useNativeExpanded - ? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + "-SNAPSHOT") + ? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + (isReleaseBuild ? "" : "-SNAPSHOT")) : projectArtifact.distFile; c.getInputs().file(new File(project.getBuildDir(), "refspec")).withPathSensitivity(PathSensitivity.RELATIVE); if (useNativeExpanded) { diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index 1d7475427b33..27ae740af7c8 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -12,6 +12,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask apply plugin: 'elasticsearch.internal-java-rest-test' apply plugin: 'elasticsearch.internal-test-artifact-base' apply plugin: 'elasticsearch.bwc-test' +apply plugin: 'elasticsearch.fwc-test' testArtifacts { registerTestArtifactFromSourceSet(sourceSets.javaRestTest) diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java index 9cc3fff5828c..6e936e9b1601 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgra import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; import org.elasticsearch.test.XContentTestUtils; +import org.junit.BeforeClass; import java.util.Collections; import java.util.List; @@ -30,6 +31,11 @@ public class FeatureUpgradeIT extends AbstractRollingUpgradeTestCase { super(upgradedNodes); } + @BeforeClass + public static void ensureNotForwardCompatTest() { + assumeFalse("Only supported by bwc tests", Boolean.parseBoolean(System.getProperty("tests.fwc", "false"))); + } + public void testGetFeatureUpgradeStatus() throws Exception { final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct " diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java index a20981a119d8..296ee5180d5d 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java @@ -103,8 +103,12 @@ public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase for (int n = 0; n < requestedUpgradedNodes; n++) { if (upgradedNodes.add(n)) { try { - logger.info("Upgrading node {} to version {}", n, Version.CURRENT); - getUpgradeCluster().upgradeNodeToVersion(n, Version.CURRENT); + Version upgradeVersion = System.getProperty("tests.new_cluster_version") == null + ? Version.CURRENT + : Version.fromString(System.getProperty("tests.new_cluster_version")); + + logger.info("Upgrading node {} to version {}", n, upgradeVersion); + getUpgradeCluster().upgradeNodeToVersion(n, upgradeVersion); } catch (Exception e) { upgradeFailed = true; throw e; diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSystemPropertyProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSystemPropertyProvider.java index 62bbd10bcf85..fa1f38600719 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSystemPropertyProvider.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSystemPropertyProvider.java @@ -11,13 +11,21 @@ package org.elasticsearch.test.cluster.local; import org.elasticsearch.test.cluster.SystemPropertyProvider; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; -import static java.util.Map.entry; - public class DefaultSystemPropertyProvider implements SystemPropertyProvider { @Override public Map get(LocalClusterSpec.LocalNodeSpec nodeSpec) { - return Map.ofEntries(entry("ingest.geoip.downloader.enabled.default", "false"), entry("tests.testfeatures.enabled", "true")); + Map properties = new HashMap<>(); + properties.put("ingest.geoip.downloader.enabled.default", "false"); + + // enable test features unless we are running forwards compatibility tests + if (Boolean.parseBoolean(System.getProperty("tests.fwc", "false")) == false) { + properties.put("tests.testfeatures.enabled", "true"); + } + + return Collections.unmodifiableMap(properties); } } diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java index a84211674f8c..db71f8cec9ab 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java @@ -39,7 +39,8 @@ public class SnapshotDistributionResolver implements DistributionResolver { // Snapshot distributions are never release builds and always use the default distribution Version realVersion = Version.fromString(System.getProperty("tests.bwc.main.version", version.toString())); - return new DefaultDistributionDescriptor(realVersion, true, distributionDir, DistributionType.DEFAULT); + boolean isSnapshot = System.getProperty("tests.bwc.snapshot", "true").equals("false") == false; + return new DefaultDistributionDescriptor(realVersion, isSnapshot, distributionDir, DistributionType.DEFAULT); } return delegate.resolve(version, type);