mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 01:22:26 -04:00
Add forwards compatibility testing (#123436)
This commit is contained in:
parent
e4604a4432
commit
feb3a60e98
8 changed files with 70 additions and 8 deletions
|
@ -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.")
|
||||||
|
}
|
||||||
|
}
|
|
@ -145,7 +145,14 @@ public class BwcSetupExtension {
|
||||||
loggedExec.args("-DisCI");
|
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();
|
final LogLevel logLevel = project.getGradle().getStartParameter().getLogLevel();
|
||||||
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
|
List<LogLevel> nonDefaultLogLevels = Arrays.asList(LogLevel.QUIET, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG);
|
||||||
if (nonDefaultLogLevels.contains(logLevel)) {
|
if (nonDefaultLogLevels.contains(logLevel)) {
|
||||||
|
|
|
@ -355,8 +355,9 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
|
||||||
String bwcTaskName = buildBwcTaskName(projectName);
|
String bwcTaskName = buildBwcTaskName(projectName);
|
||||||
bwcSetupExtension.bwcTask(bwcTaskName, c -> {
|
bwcSetupExtension.bwcTask(bwcTaskName, c -> {
|
||||||
boolean useNativeExpanded = projectArtifact.expandedDistDir != null;
|
boolean useNativeExpanded = projectArtifact.expandedDistDir != null;
|
||||||
|
boolean isReleaseBuild = System.getProperty("tests.bwc.snapshot", "true").equals("false");
|
||||||
File expectedOutputFile = useNativeExpanded
|
File expectedOutputFile = useNativeExpanded
|
||||||
? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + "-SNAPSHOT")
|
? new File(projectArtifact.expandedDistDir, "elasticsearch-" + bwcVersion.get() + (isReleaseBuild ? "" : "-SNAPSHOT"))
|
||||||
: projectArtifact.distFile;
|
: projectArtifact.distFile;
|
||||||
c.getInputs().file(new File(project.getBuildDir(), "refspec")).withPathSensitivity(PathSensitivity.RELATIVE);
|
c.getInputs().file(new File(project.getBuildDir(), "refspec")).withPathSensitivity(PathSensitivity.RELATIVE);
|
||||||
if (useNativeExpanded) {
|
if (useNativeExpanded) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
|
||||||
apply plugin: 'elasticsearch.internal-java-rest-test'
|
apply plugin: 'elasticsearch.internal-java-rest-test'
|
||||||
apply plugin: 'elasticsearch.internal-test-artifact-base'
|
apply plugin: 'elasticsearch.internal-test-artifact-base'
|
||||||
apply plugin: 'elasticsearch.bwc-test'
|
apply plugin: 'elasticsearch.bwc-test'
|
||||||
|
apply plugin: 'elasticsearch.fwc-test'
|
||||||
|
|
||||||
testArtifacts {
|
testArtifacts {
|
||||||
registerTestArtifactFromSourceSet(sourceSets.javaRestTest)
|
registerTestArtifactFromSourceSet(sourceSets.javaRestTest)
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgra
|
||||||
import org.elasticsearch.client.Request;
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.client.ResponseException;
|
import org.elasticsearch.client.ResponseException;
|
||||||
import org.elasticsearch.test.XContentTestUtils;
|
import org.elasticsearch.test.XContentTestUtils;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,6 +31,11 @@ public class FeatureUpgradeIT extends AbstractRollingUpgradeTestCase {
|
||||||
super(upgradedNodes);
|
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 {
|
public void testGetFeatureUpgradeStatus() throws Exception {
|
||||||
|
|
||||||
final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct "
|
final String systemIndexWarning = "this request accesses system indices: [.tasks], but in a future major version, direct "
|
||||||
|
|
|
@ -103,8 +103,12 @@ public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase
|
||||||
for (int n = 0; n < requestedUpgradedNodes; n++) {
|
for (int n = 0; n < requestedUpgradedNodes; n++) {
|
||||||
if (upgradedNodes.add(n)) {
|
if (upgradedNodes.add(n)) {
|
||||||
try {
|
try {
|
||||||
logger.info("Upgrading node {} to version {}", n, Version.CURRENT);
|
Version upgradeVersion = System.getProperty("tests.new_cluster_version") == null
|
||||||
getUpgradeCluster().upgradeNodeToVersion(n, Version.CURRENT);
|
? 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) {
|
} catch (Exception e) {
|
||||||
upgradeFailed = true;
|
upgradeFailed = true;
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -11,13 +11,21 @@ package org.elasticsearch.test.cluster.local;
|
||||||
|
|
||||||
import org.elasticsearch.test.cluster.SystemPropertyProvider;
|
import org.elasticsearch.test.cluster.SystemPropertyProvider;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
|
||||||
|
|
||||||
public class DefaultSystemPropertyProvider implements SystemPropertyProvider {
|
public class DefaultSystemPropertyProvider implements SystemPropertyProvider {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> get(LocalClusterSpec.LocalNodeSpec nodeSpec) {
|
public Map<String, String> get(LocalClusterSpec.LocalNodeSpec nodeSpec) {
|
||||||
return Map.ofEntries(entry("ingest.geoip.downloader.enabled.default", "false"), entry("tests.testfeatures.enabled", "true"));
|
Map<String, String> 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class SnapshotDistributionResolver implements DistributionResolver {
|
||||||
|
|
||||||
// Snapshot distributions are never release builds and always use the default distribution
|
// Snapshot distributions are never release builds and always use the default distribution
|
||||||
Version realVersion = Version.fromString(System.getProperty("tests.bwc.main.version", version.toString()));
|
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);
|
return delegate.resolve(version, type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue