OpenSearch/x-pack/qa/rolling-upgrade/build.gradle

202 lines
9.3 KiB
Groovy
Raw Normal View History

import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"
dependencies {
testImplementation project(':x-pack:qa')
testImplementation project(':client:rest-high-level')
}
[7.x] Smarter copying of the rest specs and tests (#52114) (#52798) * Smarter copying of the rest specs and tests (#52114) This PR addresses the unnecessary copying of the rest specs and allows for better semantics for which specs and tests are copied. By default the rest specs will get copied if the project applies `elasticsearch.standalone-rest-test` or `esplugin` and the project has rest tests or you configure the custom extension `restResources`. This PR also removes the need for dozens of places where the x-pack specs were copied by supporting copying of the x-pack rest specs too. The plugin/task introduced here can also copy the rest tests to the local project through a similar configuration. The new plugin/task allows a user to minimize the surface area of which rest specs are copied. Per project can be configured to include only a subset of the specs (or tests). Configuring a project to only copy the specs when actually needed should help with build cache hit rates since we can better define what is actually in use. However, project level optimizations for build cache hit rates are not included with this PR. Also, with this PR you can no longer use the includePackaged flag on integTest task. The following items are included in this PR: * new plugin: `elasticsearch.rest-resources` * new tasks: CopyRestApiTask and CopyRestTestsTask - performs the copy * new extension 'restResources' ``` restResources { restApi { includeCore 'foo' , 'bar' //will include the core specs that start with foo and bar includeXpack 'baz' //will include x-pack specs that start with baz } restTests { includeCore 'foo', 'bar' //will include the core tests that start with foo and bar includeXpack 'baz' //will include the x-pack tests that start with baz } } ```
2020-02-26 09:13:41 -05:00
restResources {
restApi {
includeCore '*'
includeXpack '*'
}
}
forbiddenPatterns {
exclude '**/system_key'
}
String outputDir = "${buildDir}/generated-resources/${project.name}"
task copyTestNodeKeyMaterial(type: Copy) {
from project(':x-pack:plugin:core').files('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem',
'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt')
into outputDir
}
for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) {
String baseName = "v${bwcVersion}"
testClusters {
"${baseName}" {
testDistribution = "DEFAULT"
versions = [bwcVersion.toString(), project.version]
numberOfNodes = 3
setting 'repositories.url.allowed_urls', 'http://snapshot.test*'
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'http.content_type.required', 'true'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
setting 'xpack.security.transport.ssl.enabled', 'true'
setting 'xpack.security.authc.token.enabled', 'true'
setting 'xpack.security.authc.token.timeout', '60m'
setting 'xpack.security.audit.enabled', 'true'
setting 'xpack.security.transport.ssl.key', 'testnode.pem'
setting 'xpack.security.transport.ssl.certificate', 'testnode.crt'
keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
if (bwcVersion.onOrAfter('7.0.0')) {
setting 'xpack.security.authc.realms.file.file1.order', '0'
setting 'xpack.security.authc.realms.native.native1.order', '1'
} else {
setting 'xpack.security.authc.realms.file1.type', 'file'
setting 'xpack.security.authc.realms.file1.order', '0'
setting 'xpack.security.authc.realms.native1.type', 'native'
setting 'xpack.security.authc.realms.native1.order', '1'
}
if (bwcVersion.onOrAfter('6.6.0')) {
setting 'ccr.auto_follow.wait_for_metadata_timeout', '1s'
}
user username: "test_user", password: "x-pack-test-password"
extraConfigFile 'testnode.pem', file("$outputDir/testnode.pem")
extraConfigFile 'testnode.crt', file("$outputDir/testnode.crt")
keystore 'xpack.watcher.encryption_key', file("${project.projectDir}/src/test/resources/system_key")
setting 'xpack.watcher.encrypt_sensitive_data', 'true'
// Old versions of the code contain an invalid assertion that trips
// during tests. Versions 5.6.9 and 6.2.4 have been fixed by removing
// the assertion, but this is impossible for released versions.
// However, released versions run without assertions, so end users won't
// be suffering the effects. This argument effectively removes the
// incorrect assertion from the older versions used in the BWC tests.
if (bwcVersion.before('5.6.9') || (bwcVersion.onOrAfter('6.0.0') && bwcVersion.before('6.2.4'))) {
jvmArgs '-da:org.elasticsearch.xpack.monitoring.exporter.http.HttpExportBulk'
}
setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG'
}
}
String oldVersion = bwcVersion.toString().replace('-SNAPSHOT', '')
tasks.register("${baseName}#oldClusterTest", RestTestRunnerTask) {
useCluster testClusters."${baseName}"
mustRunAfter(precommit)
dependsOn copyTestNodeKeyMaterial
systemProperty 'tests.rest.suite', 'old_cluster'
systemProperty 'tests.upgrade_from_version', oldVersion
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
def toBlackList = []
// Dataframe transforms were not added until 7.2.0
if (Version.fromString(oldVersion).before('7.2.0')) {
toBlackList << 'old_cluster/80_transform_jobs_crud/Test put batch transform on old cluster'
}
// continuous Dataframe transforms were not added until 7.3.0
if (Version.fromString(oldVersion).before('7.3.0')) {
toBlackList << 'old_cluster/80_transform_jobs_crud/Test put continuous transform on old cluster'
}
if (!toBlackList.empty) {
systemProperty 'tests.rest.blacklist', toBlackList.join(',')
}
}
tasks.register("${baseName}#oneThirdUpgradedTest", RestTestRunnerTask) {
dependsOn "${baseName}#oldClusterTest"
useCluster testClusters."${baseName}"
doFirst {
testClusters."${baseName}".nextNodeToNextVersion()
}
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.rest.suite', 'mixed_cluster'
systemProperty 'tests.first_round', 'true'
systemProperty 'tests.upgrade_from_version', oldVersion
// We only need to run these tests once so we may as well do it when we're two thirds upgraded
def toBlackList = [
'mixed_cluster/10_basic/Start scroll in mixed cluster on upgraded node that we will continue after upgrade',
'mixed_cluster/30_ml_jobs_crud/Create a job in the mixed cluster and write some data',
'mixed_cluster/40_ml_datafeed_crud/Put job and datafeed without aggs in mixed cluster',
'mixed_cluster/40_ml_datafeed_crud/Put job and datafeed with aggs in mixed cluster',
'mixed_cluster/80_transform_jobs_crud/Test put batch transform on mixed cluster',
'mixed_cluster/80_transform_jobs_crud/Test put continuous transform on mixed cluster',
]
// transform in mixed cluster is effectively disabled till 7.4, see gh#48019
if (Version.fromString(oldVersion).before('7.4.0')) {
toBlackList.addAll([
'mixed_cluster/80_transform_jobs_crud/Test GET, start, and stop old cluster batch transforms',
'mixed_cluster/80_transform_jobs_crud/Test GET, stop, start, old continuous transforms'
])
}
systemProperty 'tests.rest.blacklist', toBlackList.join(',')
}
tasks.register("${baseName}#twoThirdsUpgradedTest", RestTestRunnerTask) {
dependsOn "${baseName}#oneThirdUpgradedTest"
useCluster testClusters."${baseName}"
doFirst {
testClusters."${baseName}".nextNodeToNextVersion()
}
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.rest.suite', 'mixed_cluster'
systemProperty 'tests.first_round', 'false'
def toBlackList = []
// transform in mixed cluster is effectively disabled till 7.4, see gh#48019
if (Version.fromString(oldVersion).before('7.4.0')) {
toBlackList.addAll([
'mixed_cluster/80_transform_jobs_crud/Test put batch transform on mixed cluster',
'mixed_cluster/80_transform_jobs_crud/Test GET, start, and stop old cluster batch transforms',
'mixed_cluster/80_transform_jobs_crud/Test put continuous transform on mixed cluster',
'mixed_cluster/80_transform_jobs_crud/Test GET, stop, start, old continuous transforms'
])
}
if (!toBlackList.empty) {
systemProperty 'tests.rest.blacklist', toBlackList.join(',')
}
systemProperty 'tests.upgrade_from_version', oldVersion
}
tasks.register("${baseName}#upgradedClusterTest", RestTestRunnerTask) {
dependsOn "${baseName}#twoThirdsUpgradedTest"
useCluster testClusters."${baseName}"
doFirst {
testClusters."${baseName}".nextNodeToNextVersion()
}
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.rest.suite', 'upgraded_cluster'
systemProperty 'tests.upgrade_from_version', oldVersion
def toBlackList = []
// Dataframe transforms were not added until 7.2.0
if (Version.fromString(oldVersion).before('7.2.0')) {
toBlackList << 'upgraded_cluster/80_transform_jobs_crud/Get start, stop, and delete old cluster batch transform'
}
// continuous Dataframe transforms were not added until 7.3.0
if (Version.fromString(oldVersion).before('7.3.0')) {
toBlackList << 'upgraded_cluster/80_transform_jobs_crud/Test GET, stop, delete, old continuous transforms'
}
// transform in mixed cluster is effectively disabled till 7.4, see gh#48019
if (Version.fromString(oldVersion).before('7.4.0')) {
toBlackList << 'upgraded_cluster/80_transform_jobs_crud/Get start, stop mixed cluster batch transform'
toBlackList << 'upgraded_cluster/80_transform_jobs_crud/Test GET, mixed continuous transforms'
}
if (!toBlackList.empty) {
systemProperty 'tests.rest.blacklist', toBlackList.join(',')
}
}
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#upgradedClusterTest"
}
}