mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
This commit removes xpack dependencies of many xpack qa modules. (for some qa modules this will require some more work) The reason behind this change is that qa rest modules should not depend on the x-pack plugins, because the plugins are an implementation detail and the tests should only know about the rest interface and qa cluster that is being tested. Also some qa modules rely on xpack plugins and hlrc (which is a valid dependency for rest qa tests) creates a cyclic dependency and this is something that we should avoid. Also Eclipse can't handle gradle cyclic dependencies (see #41064). * don't copy xpack-core's plugin property into the test resource of qa modules. Otherwise installing security manager fails, because it tries to find the XPackPlugin class.
154 lines
6.3 KiB
Groovy
154 lines
6.3 KiB
Groovy
import org.elasticsearch.gradle.Version
|
|
import org.elasticsearch.gradle.test.RestIntegTestTask
|
|
|
|
apply plugin: 'elasticsearch.standalone-test'
|
|
|
|
dependencies {
|
|
testCompile project(':x-pack:qa')
|
|
}
|
|
|
|
// This is a top level task which we will add dependencies to below.
|
|
// It is a single task that can be used to backcompat tests against all versions.
|
|
task bwcTest {
|
|
description = 'Runs backwards compatibility tests.'
|
|
group = 'verification'
|
|
}
|
|
|
|
String outputDir = "${buildDir}/generated-resources/${project.name}"
|
|
|
|
for (Version version : bwcVersions.wireCompatible) {
|
|
String baseName = "v${version}"
|
|
|
|
Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) {
|
|
mustRunAfter(precommit)
|
|
}
|
|
|
|
configure(extensions.findByName("${baseName}#oldClusterTestCluster")) {
|
|
if (version.before('6.3.0')) {
|
|
String depVersion = version;
|
|
if (project.bwcVersions.unreleased.contains(version)) {
|
|
depVersion += "-SNAPSHOT"
|
|
}
|
|
mavenPlugin 'x-pack', "org.elasticsearch.plugin:x-pack:${depVersion}"
|
|
|
|
}
|
|
bwcVersion = version
|
|
numBwcNodes = 3
|
|
numNodes = 3
|
|
clusterName = 'rolling-upgrade-basic'
|
|
setting 'xpack.security.enabled', 'false'
|
|
setting 'xpack.monitoring.enabled', 'false'
|
|
setting 'xpack.ml.enabled', 'false'
|
|
setting 'xpack.watcher.enabled', 'false'
|
|
setting 'xpack.license.self_generated.type', 'basic'
|
|
}
|
|
|
|
Task oldClusterTestRunner = tasks.getByName("${baseName}#oldClusterTestRunner")
|
|
oldClusterTestRunner.configure {
|
|
systemProperty 'tests.rest.suite', 'old_cluster'
|
|
}
|
|
|
|
Closure configureUpgradeCluster = {String name, Task lastRunner, int stopNode, Closure getOtherUnicastHostAddresses ->
|
|
configure(extensions.findByName("${baseName}#${name}")) {
|
|
dependsOn lastRunner, "${baseName}#oldClusterTestCluster#node${stopNode}.stop"
|
|
clusterName = 'rolling-upgrade-basic'
|
|
otherUnicastHostAddresses = { getOtherUnicastHostAddresses() }
|
|
minimumMasterNodes = { 2 }
|
|
autoSetInitialMasterNodes = false
|
|
/* Override the data directory so the new node always gets the node we
|
|
* just stopped's data directory. */
|
|
dataDir = { nodeNumber -> oldClusterTest.nodes[stopNode].dataDir }
|
|
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
|
|
setting 'xpack.security.enabled', 'false'
|
|
setting 'xpack.monitoring.enabled', 'false'
|
|
setting 'xpack.ml.enabled', 'false'
|
|
setting 'xpack.watcher.enabled', 'false'
|
|
setting 'xpack.license.self_generated.type', 'basic'
|
|
setting 'node.name', "upgraded-node-${stopNode}"
|
|
}
|
|
}
|
|
|
|
Task oneThirdUpgradedTest = tasks.create(name: "${baseName}#oneThirdUpgradedTest", type: RestIntegTestTask)
|
|
|
|
configureUpgradeCluster("oneThirdUpgradedTestCluster", oldClusterTestRunner, 0,
|
|
// Use all running nodes as seed nodes so there is no race between pinging and the tests
|
|
{ [oldClusterTest.nodes.get(1).transportUri(), oldClusterTest.nodes.get(2).transportUri()] })
|
|
|
|
Task oneThirdUpgradedTestRunner = tasks.getByName("${baseName}#oneThirdUpgradedTestRunner")
|
|
oneThirdUpgradedTestRunner.configure {
|
|
systemProperty 'tests.rest.suite', 'mixed_cluster'
|
|
systemProperty 'tests.first_round', 'true'
|
|
finalizedBy "${baseName}#oldClusterTestCluster#node1.stop"
|
|
}
|
|
|
|
Task twoThirdsUpgradedTest = tasks.create(name: "${baseName}#twoThirdsUpgradedTest", type: RestIntegTestTask)
|
|
|
|
configureUpgradeCluster("twoThirdsUpgradedTestCluster", oneThirdUpgradedTestRunner, 1,
|
|
// Use all running nodes as seed nodes so there is no race between pinging and the tests
|
|
{ [oldClusterTest.nodes.get(2).transportUri(), oneThirdUpgradedTest.nodes.get(0).transportUri()] })
|
|
|
|
Task twoThirdsUpgradedTestRunner = tasks.getByName("${baseName}#twoThirdsUpgradedTestRunner")
|
|
twoThirdsUpgradedTestRunner.configure {
|
|
systemProperty 'tests.rest.suite', 'mixed_cluster'
|
|
systemProperty 'tests.first_round', 'false'
|
|
finalizedBy "${baseName}#oldClusterTestCluster#node2.stop"
|
|
}
|
|
|
|
Task upgradedClusterTest = tasks.create(name: "${baseName}#upgradedClusterTest", type: RestIntegTestTask)
|
|
|
|
configureUpgradeCluster("upgradedClusterTestCluster", twoThirdsUpgradedTestRunner, 2,
|
|
// Use all running nodes as seed nodes so there is no race between pinging and the tests
|
|
{ [oneThirdUpgradedTest.nodes.get(0).transportUri(), twoThirdsUpgradedTest.nodes.get(0).transportUri()] })
|
|
|
|
Task upgradedClusterTestRunner = tasks.getByName("${baseName}#upgradedClusterTestRunner")
|
|
upgradedClusterTestRunner.configure {
|
|
systemProperty 'tests.rest.suite', 'upgraded_cluster'
|
|
/*
|
|
* Force stopping all the upgraded nodes after the test runner
|
|
* so they are alive during the test.
|
|
*/
|
|
finalizedBy "${baseName}#oneThirdUpgradedTestCluster#stop"
|
|
finalizedBy "${baseName}#twoThirdsUpgradedTestCluster#stop"
|
|
}
|
|
|
|
Task versionBwcTest = tasks.create(name: "${baseName}#bwcTest") {
|
|
dependsOn = [upgradedClusterTest]
|
|
}
|
|
|
|
if (project.bwc_tests_enabled) {
|
|
bwcTest.dependsOn(versionBwcTest)
|
|
}
|
|
}
|
|
|
|
test.enabled = false // no unit tests for rolling upgrades, only the rest integration test
|
|
|
|
// basic integ tests includes testing bwc against the most recent version
|
|
task bwcTestSnapshots {
|
|
if (project.bwc_tests_enabled) {
|
|
for (final def version : bwcVersions.unreleasedWireCompatible) {
|
|
dependsOn "v${version}#bwcTest"
|
|
}
|
|
}
|
|
}
|
|
check.dependsOn(bwcTestSnapshots)
|
|
|
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
|
|
|
// copy x-pack plugin info so it is on the classpath and security manager has the right permissions
|
|
task copyXPackRestSpec(type: Copy) {
|
|
dependsOn(project.configurations.restSpec, 'processTestResources')
|
|
from project(xpackProject('plugin').path).sourceSets.test.resources
|
|
include 'rest-api-spec/api/**'
|
|
into project.sourceSets.test.output.resourcesDir
|
|
}
|
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackRestSpec)
|
|
|
|
repositories {
|
|
maven {
|
|
url "https://artifacts.elastic.co/maven"
|
|
}
|
|
maven {
|
|
url "https://snapshots.elastic.co/maven"
|
|
}
|
|
}
|