Skip to content

Commit d93ba87

Browse files
mark-vieiraelasticsearchmachine
andauthored
[8.17] Add forwards compatibility testing (#123436) (#123539)
* Add forwards compatibility testing (#123436) (cherry picked from commit feb3a60) # Conflicts: # server/src/main/java/org/elasticsearch/indices/IndicesFeatures.java # test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent 2386c1e commit d93ba87

File tree

8 files changed

+66
-9
lines changed

8 files changed

+66
-9
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import org.elasticsearch.gradle.VersionProperties
11+
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
12+
13+
def fwcVersions = buildParams.bwcVersions.released.findAll { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor }
14+
def previousMinorSnapshot = buildParams.bwcVersions.unreleased.find { it.major == VersionProperties.elasticsearchVersion.major && it.minor == VersionProperties.elasticsearchVersion.minor - 1 }
15+
16+
fwcVersions.each { fwcVersion ->
17+
tasks.register("v${fwcVersion}#fwcTest", StandaloneRestIntegTestTask) {
18+
usesBwcDistribution(previousMinorSnapshot)
19+
usesBwcDistribution(fwcVersion)
20+
systemProperty("tests.old_cluster_version", previousMinorSnapshot)
21+
systemProperty("tests.new_cluster_version", fwcVersion)
22+
nonInputProperties.systemProperty 'tests.fwc', 'true'
23+
}
24+
}
25+
26+
gradle.taskGraph.whenReady { graph ->
27+
if (graph.allTasks.any { it.name.endsWith('#fwcTest') } && Boolean.parseBoolean(System.getProperty("tests.bwc.snapshot", "true"))) {
28+
throw new GradleException("Running forward compatibility tests requires passing `-Dtests.bwc.snapshot=false`.")
29+
}
30+
31+
if (graph.allTasks.any { it.name.endsWith('#fwcTest') } && graph.allTasks.any { it.name.endsWith('#bwcTest') }) {
32+
throw new GradleException("Backward compatibility and forward compatibility tests cannot be executed in the same build.")
33+
}
34+
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ private static TaskProvider<LoggedExec> createRunBwcGradleTask(
138138
loggedExec.args("-DisCI");
139139
}
140140

141-
loggedExec.args("-Dbuild.snapshot=true", "-Dscan.tag.NESTED");
141+
loggedExec.args("-Dscan.tag.NESTED");
142+
143+
if (System.getProperty("tests.bwc.snapshot", "true").equals("false")) {
144+
loggedExec.args("-Dbuild.snapshot=false", "-Dlicense.key=x-pack/plugin/core/snapshot.key");
145+
} else {
146+
loggedExec.args("-Dbuild.snapshot=true");
147+
}
148+
142149
final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel();
143150
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
144151
if (nonDefaultLogLevels.contains(logLevel)) {

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ static void createBuildBwcTask(
336336
String bwcTaskName = buildBwcTaskName(projectName);
337337
bwcSetupExtension.bwcTask(bwcTaskName, c -> {
338338
boolean useNativeExpanded = projectArtifact.expandedDistDir != null;
339+
boolean isReleaseBuild = System.getProperty("tests.bwc.snapshot", "true").equals("false");
339340
File expectedOutputFile = useNativeExpanded
340-
? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + "-SNAPSHOT")
341+
? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + (isReleaseBuild ? "" : "-SNAPSHOT"))
341342
: projectArtifact.distFile;
342343
c.getInputs().file(new File(project.getBuildDir(), "refspec"));
343344
if (useNativeExpanded) {

qa/rolling-upgrade/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
1313
apply plugin: 'elasticsearch.internal-java-rest-test'
1414
apply plugin: 'elasticsearch.internal-test-artifact-base'
1515
apply plugin: 'elasticsearch.bwc-test'
16+
apply plugin: 'elasticsearch.fwc-test'
1617

1718
testArtifacts {
1819
registerTestArtifactFromSourceSet(sourceSets.javaRestTest)

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.client.Request;
1616
import org.elasticsearch.client.ResponseException;
1717
import org.elasticsearch.test.XContentTestUtils;
18+
import org.junit.BeforeClass;
1819

1920
import java.util.Collections;
2021
import java.util.List;
@@ -30,6 +31,11 @@ public FeatureUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
3031
super(upgradedNodes);
3132
}
3233

34+
@BeforeClass
35+
public static void ensureNotForwardCompatTest() {
36+
assumeFalse("Only supported by bwc tests", Boolean.parseBoolean(System.getProperty("tests.fwc", "false")));
37+
}
38+
3339
public void testGetFeatureUpgradeStatus() throws Exception {
3440

3541
final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct "

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ public void upgradeNode() throws Exception {
103103
for (int n = 0; n < requestedUpgradedNodes; n++) {
104104
if (upgradedNodes.add(n)) {
105105
try {
106-
logger.info("Upgrading node {} to version {}", n, Version.CURRENT);
107-
getUpgradeCluster().upgradeNodeToVersion(n, Version.CURRENT);
106+
Version upgradeVersion = System.getProperty("tests.new_cluster_version") == null
107+
? Version.CURRENT
108+
: Version.fromString(System.getProperty("tests.new_cluster_version"));
109+
110+
logger.info("Upgrading node {} to version {}", n, upgradeVersion);
111+
getUpgradeCluster().upgradeNodeToVersion(n, upgradeVersion);
108112
} catch (Exception e) {
109113
upgradeFailed = true;
110114
throw e;

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ public final class DefaultLocalClusterSpecBuilder extends AbstractLocalClusterSp
1919

2020
public DefaultLocalClusterSpecBuilder() {
2121
super();
22-
this.apply(
23-
c -> c.systemProperty("ingest.geoip.downloader.enabled.default", "false").systemProperty("tests.testfeatures.enabled", "true")
24-
);
22+
this.apply(c -> {
23+
c.systemProperty("ingest.geoip.downloader.enabled.default", "false");
24+
// enable test features unless we are running forwards compatibility tests
25+
if (Boolean.parseBoolean(System.getProperty("tests.fwc", "false")) == false) {
26+
c.systemProperty("tests.testfeatures.enabled", "true");
27+
}
28+
});
2529
this.apply(new FipsEnabledClusterConfigProvider());
2630
this.settings(new DefaultSettingsProvider());
2731
this.environment(new DefaultEnvironmentProvider());

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public DistributionDescriptor resolve(Version version, DistributionType type) {
3737
);
3838
}
3939

40-
// Snapshot distributions are never release builds and always use the default distribution
41-
return new DefaultDistributionDescriptor(version, true, distributionDir, DistributionType.DEFAULT);
40+
boolean isSnapshot = System.getProperty("tests.bwc.snapshot", "true").equals("false") == false;
41+
return new DefaultDistributionDescriptor(version, isSnapshot, distributionDir, DistributionType.DEFAULT);
4242
}
4343

4444
return delegate.resolve(version, type);

0 commit comments

Comments
 (0)