Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,8 +9,6 @@
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 @@ -38,17 +36,5 @@ 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 @@ -89,7 +89,7 @@ public void execute(Task t) {
test.getJvmArgumentProviders().add(nonInputProperties);
test.getExtensions().add("nonInputProperties", nonInputProperties);

test.setWorkingDir(project.file(project.getBuildDir() + "/testrun/" + test.getName().replace("#", "_")));
test.setWorkingDir(project.file(project.getBuildDir() + "/testrun/" + test.getName()));
test.setMaxParallelForks(Integer.parseInt(System.getProperty("tests.jvms", BuildParams.getDefaultParallel().toString())));

test.exclude("**/*$*.class");
Expand Down
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() + "-test-artifacts", "1.0");
featureSpec.capability("org.elasticsearch.gradle", project.getName() + "-" + name + "-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,8 +13,6 @@
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 @@ -60,8 +58,6 @@ 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 @@ -83,17 +79,16 @@ public void apply(Project project) {
project.getPluginManager().apply(InternalDistributionDownloadPlugin.class);

// Register integ-test and default distributions
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
);
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);
});

// Create configures for module and plugin dependencies
Configuration modulesConfiguration = createPluginConfiguration(project, MODULES_CONFIGURATION, true, false);
Expand Down Expand Up @@ -156,62 +151,13 @@ 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())) {
// 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: 53 additions & 9 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,64 @@
* 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-java-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact-base'
apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'
apply plugin: 'elasticsearch.bwc-test'

testArtifacts {
registerTestArtifactFromSourceSet(sourceSets.javaRestTest)
}

BuildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName ->
tasks.register(bwcTaskName(bwcVersion), StandaloneRestIntegTestTask) {
usesBwcDistribution(bwcVersion)
systemProperty("tests.old_cluster_version", bwcVersion)
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)
}

tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#upgradedClusterTest")
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading