Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e0340d3
Convert full cluster restart tests to new rest testing framework
mark-vieira Jan 18, 2023
0f64f84
Fix NPE
mark-vieira Jan 18, 2023
fc6d36f
Merge branch 'main' into test_containers_bwc_testing
mark-vieira Jan 18, 2023
4b77453
Wait for cluster ready
mark-vieira Jan 18, 2023
b6b5b6f
Avoid clashing with Object#wait
mark-vieira Jan 18, 2023
6652275
Skip test when non-applicable
mark-vieira Jan 18, 2023
d1240a2
Disable parallel test execution temporarily
mark-vieira Jan 18, 2023
45eadbb
Revert "Disable parallel test execution temporarily"
mark-vieira Jan 18, 2023
21d0ed8
Reset upgrade failure status after test class
mark-vieira Jan 18, 2023
ae0f99c
Fix test
mark-vieira Jan 19, 2023
c271e6e
Remove unused import
mark-vieira Jan 19, 2023
b3f2966
Merge branch 'main' into test_containers_bwc_testing
mark-vieira Jan 19, 2023
aa8a3bc
Fixes
mark-vieira Jan 19, 2023
afc66a8
Warning might not always happen
mark-vieira Jan 19, 2023
8cfd734
Merge branch 'main' into test_containers_bwc_testing
mark-vieira Jan 23, 2023
40bf0f6
Merge branch 'main' into test_containers_bwc_testing
elasticmachine Jan 26, 2023
8d4bd49
Fix compilation error
mark-vieira Jan 26, 2023
b8d6eaa
Avoid unnecessary restarts when testing current version
mark-vieira Jan 26, 2023
42a8c56
Merge branch 'main' into test_containers_bwc_testing
elasticmachine Jan 27, 2023
a14906c
Review feedback
mark-vieira Jan 27, 2023
7669d79
Always call deletePortsFiles when stopping a node
mark-vieira Jan 27, 2023
999fefe
Spotless
mark-vieira Jan 27, 2023
b38ee09
Merge branch 'main' into test_containers_bwc_testing
elasticmachine Jan 30, 2023
b12398e
Fix some possible NPEs in strange JVM configs (#93352)
DaveCTurner Jan 30, 2023
b0cc642
Download the geoip databases only when needed (#92335)
masseyke Jan 30, 2023
9d03b14
Add JDK 20 to Java support compatibility testing matrix
mark-vieira Jan 30, 2023
180caf0
Bump bundled JDK to Java 19.0.2 (#93354)
mark-vieira Jan 30, 2023
de8eda4
Make `--debug-server-jvm` work with new test framework (#93355)
mark-vieira Jan 30, 2023
c97e56e
Fix MapperSizeClientYamlTestSuiteIT when FIPS is enabled (#93357)
mark-vieira Jan 30, 2023
c839c40
Add ActionListener#run (#93338)
DaveCTurner Jan 31, 2023
0603827
[ML] Wait for _infer to work after restart in full cluster restart te…
davidkyle Jan 31, 2023
39ba013
Unpromotables skip replication and peer recovery (#93210)
kingherc Jan 31, 2023
3d38173
Add a section about token-based authentication (#93344)
mjrlgue Jan 31, 2023
71c280b
Build role for remote access authentication (#93316)
n1v0lg Jan 31, 2023
0e87d58
Cleanup allocation commands test (#93368)
idegtiarenko Jan 31, 2023
4dd3b9a
Link to the time-units doc in S3 repository docs instead of explainin…
fcofdez Jan 31, 2023
4fb06b2
Migrate misc packages to TransportVersion (#93272)
thecoop Jan 31, 2023
8aa4054
Update rollup dependencies (#93369)
martijnvg Jan 31, 2023
9354479
Avoiding race conditions in GeoIpDownloaderIT (#93363)
masseyke Jan 31, 2023
e68c258
Set forced_refresh to true when using stateless refresh work-around (…
pxsalehi Jan 31, 2023
845178b
Cache the creation of parsers within `DateProcessor` (#92880)
Jan 31, 2023
85a3187
Add `ignore_missing_component_templates` config option (#92436)
ruflin Jan 31, 2023
c6a6ed4
Merge branch 'main' into test_containers_bwc_testing
mark-vieira Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.ElasticsearchTestBasePlugin
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

ext.bwcTaskName = { Version version ->
return "v${version}#bwcTest"
Expand Down Expand Up @@ -36,5 +38,17 @@ plugins.withType(ElasticsearchTestBasePlugin) {
}
}

plugins.withType(InternalJavaRestTestPlugin) {
tasks.named("javaRestTest") {
enabled = false
}

tasks.withType(StandaloneRestIntegTestTask).configureEach {
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
classpath = sourceSets.javaRestTest.runtimeClasspath
usesDefaultDistribution()
}
}

tasks.matching { it.name.equals("check") }.configureEach {dependsOn(bwcTestSnapshots) }
tasks.matching { it.name.equals("test") }.configureEach {enabled = false}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void registerTestArtifactFromSourceSet(SourceSet sourceSet) {
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
javaPluginExtension.registerFeature(name + "Artifacts", featureSpec -> {
featureSpec.usingSourceSet(sourceSet);
featureSpec.capability("org.elasticsearch.gradle", project.getName() + "-" + name + "-artifacts", "1.0");
featureSpec.capability("org.elasticsearch.gradle", project.getName() + "-test-artifacts", "1.0");
// This feature is only used internally in the
// elasticsearch build so we do not need any publication.
featureSpec.disablePublication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.elasticsearch.gradle.Architecture;
import org.elasticsearch.gradle.DistributionDownloadPlugin;
import org.elasticsearch.gradle.ElasticsearchDistribution;
import org.elasticsearch.gradle.ElasticsearchDistributionType;
import org.elasticsearch.gradle.Version;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes;
import org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin;
Expand Down Expand Up @@ -58,6 +60,8 @@ public class RestTestBasePlugin implements Plugin<Project> {
private static final String TESTS_RUNTIME_JAVA_SYSPROP = "tests.runtime.java";
private static final String DEFAULT_DISTRIBUTION_SYSPROP = "tests.default.distribution";
private static final String INTEG_TEST_DISTRIBUTION_SYSPROP = "tests.integ-test.distribution";
private static final String BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX = "tests.snapshot.distribution.";
private static final String BWC_RELEASED_DISTRIBUTION_SYSPROP_PREFIX = "tests.release.distribution.";
private static final String TESTS_CLUSTER_MODULES_PATH_SYSPROP = "tests.cluster.modules.path";
private static final String TESTS_CLUSTER_PLUGINS_PATH_SYSPROP = "tests.cluster.plugins.path";
private static final String DEFAULT_REST_INTEG_TEST_DISTRO = "default_distro";
Expand All @@ -79,16 +83,17 @@ public void apply(Project project) {
project.getPluginManager().apply(InternalDistributionDownloadPlugin.class);

// Register integ-test and default distributions
NamedDomainObjectContainer<ElasticsearchDistribution> distributions = DistributionDownloadPlugin.getContainer(project);
ElasticsearchDistribution defaultDistro = distributions.create(DEFAULT_REST_INTEG_TEST_DISTRO, distro -> {
distro.setVersion(VersionProperties.getElasticsearch());
distro.setArchitecture(Architecture.current());
});
ElasticsearchDistribution integTestDistro = distributions.create(INTEG_TEST_REST_INTEG_TEST_DISTRO, distro -> {
distro.setVersion(VersionProperties.getElasticsearch());
distro.setArchitecture(Architecture.current());
distro.setType(ElasticsearchDistributionTypes.INTEG_TEST_ZIP);
});
ElasticsearchDistribution defaultDistro = createDistribution(
project,
DEFAULT_REST_INTEG_TEST_DISTRO,
VersionProperties.getElasticsearch()
);
ElasticsearchDistribution integTestDistro = createDistribution(
project,
INTEG_TEST_REST_INTEG_TEST_DISTRO,
VersionProperties.getElasticsearch(),
ElasticsearchDistributionTypes.INTEG_TEST_ZIP
);

// Create configures for module and plugin dependencies
Configuration modulesConfiguration = createPluginConfiguration(project, MODULES_CONFIGURATION, true, false);
Expand Down Expand Up @@ -151,13 +156,62 @@ public Void call(Object... args) {
return null;
}
});

// Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution
task.getExtensions().getExtraProperties().set("usesBwcDistribution", new Closure<Void>(task) {
@Override
public Void call(Object... args) {
if (args.length != 1 && args[0] instanceof Version == false) {
throw new IllegalArgumentException("Expected exactly one argument of type org.elasticsearch.gradle.Version");
}

Version version = (Version) args[0];
boolean isReleased = BuildParams.getBwcVersions().unreleasedInfo(version) == null;
String versionString = version.toString();
ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString);

task.dependsOn(bwcDistro);
registerDistributionInputs(task, bwcDistro);

nonInputSystemProperties.systemProperty(
(isReleased ? BWC_RELEASED_DISTRIBUTION_SYSPROP_PREFIX : BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX) + versionString,
providerFactory.provider(() -> bwcDistro.getExtracted().getSingleFile().getPath())
);

if (version.before(BuildParams.getBwcVersions().getMinimumWireCompatibleVersion())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this additional version dep be added explicitly for the tests that need it? I'm wondering if we will always want this, and it seems sneeky, it would be easier to see both calls to usesBwcDistribution explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no BWC test that I'm aware of against earlier versions that would not require an upgrade to 7.17 first.

// If we are upgrade testing older versions we also need to upgrade to 7.last
this.call(BuildParams.getBwcVersions().getMinimumWireCompatibleVersion());
}
return null;
}
});
});

project.getTasks()
.named(JavaBasePlugin.CHECK_TASK_NAME)
.configure(check -> check.dependsOn(project.getTasks().withType(StandaloneRestIntegTestTask.class)));
}

private ElasticsearchDistribution createDistribution(Project project, String name, String version) {
return createDistribution(project, name, version, null);
}

private ElasticsearchDistribution createDistribution(Project project, String name, String version, ElasticsearchDistributionType type) {
NamedDomainObjectContainer<ElasticsearchDistribution> distributions = DistributionDownloadPlugin.getContainer(project);
ElasticsearchDistribution maybeDistro = distributions.findByName(name);
if (maybeDistro == null) {
return distributions.create(name, distro -> {
distro.setVersion(version);
distro.setArchitecture(Architecture.current());
if (type != null) {
distro.setType(type);
}
});
} else {
return maybeDistro;
}
}

private FileTree getDistributionFiles(ElasticsearchDistribution distribution, Action<PatternFilterable> patternFilter) {
return distribution.getExtracted().getAsFileTree().matching(patternFilter);
}
Expand Down
62 changes: 9 additions & 53 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,20 @@
* Side Public License, v 1.
*/


import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact-base'
apply plugin: 'elasticsearch.bwc-test'

BuildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName ->
def baseCluster = testClusters.register(baseName) {
if (bwcVersion.before(BuildParams.bwcVersions.minimumWireCompatibleVersion)) {
// When testing older versions we have to first upgrade to 7.last
versions = [bwcVersion.toString(), BuildParams.bwcVersions.minimumWireCompatibleVersion.toString(), project.version]
} else {
versions = [bwcVersion.toString(), project.version]
}
numberOfNodes = 2
// some tests rely on the translog not being flushed
setting 'indices.memory.shard_inactive_time', '60m'
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'xpack.security.enabled', 'false'
requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0")
}

tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) {
useCluster baseCluster
mustRunAfter("precommit")
doFirst {
delete("${buildDir}/cluster/shared/repo/${baseName}")
}

systemProperty 'tests.is_old_cluster', 'true'
}

tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) {
useCluster baseCluster
dependsOn "${baseName}#oldClusterTest"
doFirst {
baseCluster.get().goToNextVersion()
if (bwcVersion.before(BuildParams.bwcVersions.minimumWireCompatibleVersion)) {
// When doing a full cluster restart of older versions we actually have to upgrade twice. First to 7.last, then to the current version.
baseCluster.get().goToNextVersion()
}
}
systemProperty 'tests.is_old_cluster', 'false'
}

String oldVersion = bwcVersion.toString().minus("-SNAPSHOT")
tasks.matching { it.name.startsWith(baseName) && it.name.endsWith("ClusterTest") }.configureEach {
it.systemProperty 'tests.old_cluster_version', oldVersion
it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
it.nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(",")))
it.nonInputProperties.systemProperty('tests.clustername', baseName)
}
testArtifacts {
registerTestArtifactFromSourceSet(sourceSets.javaRestTest)
}

tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
BuildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName ->
tasks.register(bwcTaskName(bwcVersion), StandaloneRestIntegTestTask) {
usesBwcDistribution(bwcVersion)
systemProperty("tests.old_cluster_version", bwcVersion)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package org.elasticsearch.upgrades;

import com.carrotsearch.randomizedtesting.annotations.Name;

import org.apache.http.util.EntityUtils;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.settings.RestClusterGetSettingsResponse;
Expand All @@ -28,13 +30,21 @@
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.elasticsearch.test.NotEqualMessageBuilder;
import org.elasticsearch.test.XContentTestUtils;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.transport.Compression;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -44,7 +54,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -80,13 +89,41 @@
* version is started with the same data directories and then this is rerun
* with {@code tests.is_old_cluster} set to {@code false}.
*/
public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCase {

private static TemporaryFolder repoDirectory = new TemporaryFolder();

protected static LocalClusterConfigProvider clusterConfig = c -> {};

private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.nodes(2)
.setting("path.repo", () -> repoDirectory.getRoot().getPath())
.setting("xpack.security.enabled", "false")
// some tests rely on the translog not being flushed
.setting("indices.memory.shard_inactive_time", "60m")
.apply(() -> clusterConfig)
.feature(FeatureFlag.TIME_SERIES_MODE)
.build();

@ClassRule
public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);

private String index;

public FullClusterRestartIT(@Name("cluster") FullClusterRestartUpgradeStatus upgradeStatus) {
super(upgradeStatus);
}

@Override
protected ElasticsearchCluster getUpgradeCluster() {
return cluster;
}

@Before
public void setIndex() {
index = getTestName().toLowerCase(Locale.ROOT);
index = getRootTestName();
}

public void testSearch() throws Exception {
Expand Down Expand Up @@ -1051,7 +1088,7 @@ public void testSnapshotRestore() throws IOException {
repoConfig.startObject("settings");
{
repoConfig.field("compress", randomBoolean());
repoConfig.field("location", System.getProperty("tests.path.repo"));
repoConfig.field("location", repoDirectory.getRoot().getPath());
}
repoConfig.endObject();
}
Expand Down Expand Up @@ -1725,7 +1762,7 @@ public void testEnableSoftDeletesOnRestore() throws Exception {
repoConfig.startObject("settings");
{
repoConfig.field("compress", randomBoolean());
repoConfig.field("location", System.getProperty("tests.path.repo"));
repoConfig.field("location", repoDirectory.getRoot().getPath());
}
repoConfig.endObject();
}
Expand Down Expand Up @@ -1785,7 +1822,7 @@ public void testForbidDisableSoftDeletesOnRestore() throws Exception {
repoConfig.startObject("settings");
{
repoConfig.field("compress", randomBoolean());
repoConfig.field("location", System.getProperty("tests.path.repo"));
repoConfig.field("location", repoDirectory.getRoot().getPath());
}
repoConfig.endObject();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.upgrades;

import com.carrotsearch.randomizedtesting.TestMethodAndParams;

import java.util.Comparator;

public class FullClusterRestartTestOrdering implements Comparator<TestMethodAndParams> {
@Override
public int compare(TestMethodAndParams o1, TestMethodAndParams o2) {
return Integer.compare(getOrdinal(o1), getOrdinal(o2));
}

private int getOrdinal(TestMethodAndParams t) {
return ((FullClusterRestartUpgradeStatus) t.getInstanceArguments().get(0)).ordinal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.upgrades;

public enum FullClusterRestartUpgradeStatus {
OLD,
UPGRADED
}
Loading