2018-03-09 11:54:30 -05:00
|
|
|
import org.elasticsearch.gradle.Version
|
|
|
|
import org.elasticsearch.gradle.test.NodeInfo
|
|
|
|
import org.elasticsearch.gradle.test.RestIntegTestTask
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets
|
|
|
|
|
|
|
|
apply plugin: 'elasticsearch.standalone-test'
|
|
|
|
|
|
|
|
dependencies {
|
2018-08-21 20:03:28 -04:00
|
|
|
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
|
|
|
testCompile project(path: xpackModule('core'), configuration: 'default')
|
2018-03-09 11:54:30 -05:00
|
|
|
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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'
|
|
|
|
}
|
|
|
|
|
2018-04-26 18:36:14 -04:00
|
|
|
String outputDir = "${buildDir}/generated-resources/${project.name}"
|
2018-03-09 11:54:30 -05:00
|
|
|
|
|
|
|
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")) {
|
2018-02-23 11:03:17 -05:00
|
|
|
if (version.before('6.3.0')) {
|
2018-06-06 11:59:16 -04:00
|
|
|
mavenPlugin 'x-pack', "org.elasticsearch.plugin:x-pack:${version}"
|
2018-02-23 11:03:17 -05:00
|
|
|
}
|
2018-03-09 11:54:30 -05:00
|
|
|
bwcVersion = version
|
2018-06-06 11:59:16 -04:00
|
|
|
numBwcNodes = 3
|
|
|
|
numNodes = 3
|
|
|
|
minimumMasterNodes = { 3 }
|
2018-03-09 11:54:30 -05:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:59:16 -04:00
|
|
|
Closure configureUpgradeCluster = {String name, Task lastRunner, int stopNode, Closure unicastSeed ->
|
|
|
|
configure(extensions.findByName("${baseName}#${name}")) {
|
|
|
|
dependsOn lastRunner, "${baseName}#oldClusterTestCluster#node${stopNode}.stop"
|
|
|
|
clusterName = 'rolling-upgrade-basic'
|
|
|
|
unicastTransportUri = { seedNode, node, ant -> unicastSeed() }
|
|
|
|
minimumMasterNodes = { 3 }
|
|
|
|
/* 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'
|
2018-06-07 11:19:34 -04:00
|
|
|
setting 'node.name', "upgraded-node-${stopNode}"
|
2018-06-06 11:59:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Task oneThirdUpgradedTest = tasks.create(name: "${baseName}#oneThirdUpgradedTest", type: RestIntegTestTask)
|
2018-03-09 11:54:30 -05:00
|
|
|
|
2018-06-07 13:05:36 -04:00
|
|
|
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() })
|
2018-06-06 11:59:16 -04:00
|
|
|
|
|
|
|
Task oneThirdUpgradedTestRunner = tasks.getByName("${baseName}#oneThirdUpgradedTestRunner")
|
|
|
|
oneThirdUpgradedTestRunner.configure {
|
|
|
|
systemProperty 'tests.rest.suite', 'mixed_cluster'
|
|
|
|
systemProperty 'tests.first_round', 'true'
|
|
|
|
finalizedBy "${baseName}#oldClusterTestCluster#node1.stop"
|
2018-03-09 11:54:30 -05:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:59:16 -04:00
|
|
|
Task twoThirdsUpgradedTest = tasks.create(name: "${baseName}#twoThirdsUpgradedTest", type: RestIntegTestTask)
|
|
|
|
|
2018-06-07 13:05:36 -04:00
|
|
|
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() })
|
2018-06-06 11:59:16 -04:00
|
|
|
|
|
|
|
Task twoThirdsUpgradedTestRunner = tasks.getByName("${baseName}#twoThirdsUpgradedTestRunner")
|
|
|
|
twoThirdsUpgradedTestRunner.configure {
|
2018-03-09 11:54:30 -05:00
|
|
|
systemProperty 'tests.rest.suite', 'mixed_cluster'
|
2018-06-06 11:59:16 -04:00
|
|
|
systemProperty 'tests.first_round', 'false'
|
|
|
|
finalizedBy "${baseName}#oldClusterTestCluster#node2.stop"
|
2018-03-09 11:54:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Task upgradedClusterTest = tasks.create(name: "${baseName}#upgradedClusterTest", type: RestIntegTestTask)
|
|
|
|
|
2018-06-07 13:05:36 -04:00
|
|
|
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() })
|
2018-03-09 11:54:30 -05:00
|
|
|
|
|
|
|
Task upgradedClusterTestRunner = tasks.getByName("${baseName}#upgradedClusterTestRunner")
|
|
|
|
upgradedClusterTestRunner.configure {
|
|
|
|
systemProperty 'tests.rest.suite', 'upgraded_cluster'
|
2018-06-06 11:59:16 -04:00
|
|
|
/*
|
|
|
|
* 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"
|
2018-03-09 11:54:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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 integTest {
|
|
|
|
if (project.bwc_tests_enabled) {
|
|
|
|
for (final def version : bwcVersions.snapshotsWireCompatible) {
|
|
|
|
dependsOn "v${version}#bwcTest"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
check.dependsOn(integTest)
|
|
|
|
|
|
|
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-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
|
|
|
|
}
|
|
|
|
|
|
|
|
task copyXPackPluginProps(type: Copy) {
|
|
|
|
dependsOn(copyXPackRestSpec)
|
|
|
|
from project(xpackModule('core')).file('src/main/plugin-metadata')
|
|
|
|
from project(xpackModule('core')).tasks.pluginProperties
|
|
|
|
into outputDir
|
|
|
|
}
|
|
|
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url "https://artifacts.elastic.co/maven"
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
url "https://snapshots.elastic.co/maven"
|
|
|
|
}
|
|
|
|
}
|