Skip to content

Commit

Permalink
Improve test avoidance
Browse files Browse the repository at this point in the history
This commit fixes a number of instances where we've broken test
avoidance due to dynamic or changing inputs that should be ignored.
Common instances are things like absolute paths or test fixture
addresses that contain changing ports.
  • Loading branch information
mark-vieira committed Oct 18, 2023
1 parent 3b8825c commit b7d5692
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 53 deletions.
4 changes: 2 additions & 2 deletions plugins/discovery-ec2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ tasks.named("test").configure {
// this is needed to manipulate com.amazonaws.sdk.ec2MetadataServiceEndpointOverride system property
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
if (BuildParams.inFipsJvm){
systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
nonInputProperties.systemProperty 'java.security.policy', "=file://${buildDir}/tmp/java.policy"
} else {
systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
nonInputProperties.systemProperty 'java.security.policy', "file://${buildDir}/tmp/java.policy"
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/repository-hdfs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ tasks.withType(RestIntegTestTask).configureEach { testTask ->
if (disabledIntegTestTaskNames.contains(name) == false) {
nonInputProperties.systemProperty "test.krb5.principal.es", "elasticsearch@${realm}"
nonInputProperties.systemProperty "test.krb5.principal.hdfs", "hdfs/hdfs.build.elastic.co@${realm}"
jvmArgs "-Djava.security.krb5.conf=${project.configurations.krb5Config.getSingleFile().getPath()}"
nonInputProperties.systemProperty "Djava.security.krb5.conf", "${project.configurations.krb5Config.getSingleFile().getPath()}"
nonInputProperties.systemProperty(
"test.krb5.keytab.hdfs",
new File(project.configurations.krb5Keytabs.singleFile, "hdfs_hdfs.build.elastic.co.keytab").getPath()
Expand All @@ -291,7 +291,7 @@ tasks.withType(RestIntegTestTask).configureEach { testTask ->

testClusters.matching { it.name == testTask.name }.configureEach {
if (testTask.name.contains("Secure")) {
systemProperty "java.security.krb5.conf", configurations.krb5Config.singleFile.getPath()
systemProperty "java.security.krb5.conf", configurations.krb5Config.singleFile.getPath(), IGNORE_VALUE
extraConfigFile(
"repository-hdfs/krb5.keytab",
new File(project.configurations.krb5Keytabs.singleFile, "elasticsearch.keytab"),
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -23,8 +24,7 @@ def followCluster = testClusters.register("follow-cluster") {
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'cluster.remote.leader_cluster.seeds', { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\""
}
setting 'cluster.remote.leader_cluster.seeds', { "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE
}

tasks.register("leader-cluster", RestIntegTestTask) {
Expand All @@ -51,8 +51,8 @@ tasks.register("writeJavaPolicy") {
tasks.register("follow-cluster", RestIntegTestTask) {
dependsOn 'writeJavaPolicy', "leader-cluster"
useCluster leaderCluster
systemProperty 'java.security.policy', "file://${policyFile}"
systemProperty 'tests.target_cluster', 'follow'
nonInputProperties.systemProperty 'java.security.policy', "file://${policyFile}"
nonInputProperties.systemProperty 'tests.leader_host', leaderCluster.map(c -> c.allHttpSocketURI.get(0))
nonInputProperties.systemProperty 'log', followCluster.map(c -> c.getFirstNode().getServerLog())
}
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugin/ccr/qa/multi-cluster/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -25,7 +26,7 @@ def middleCluster = testClusters.register('middle-cluster') {
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE
}

tasks.register("leader-cluster", RestIntegTestTask) {
Expand Down Expand Up @@ -60,9 +61,9 @@ testClusters.matching {it.name == "follow-cluster" }.configureEach {
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE
setting 'cluster.remote.middle_cluster.seeds',
{ "\"${middleCluster.get().getAllTransportPortURI().join(",")}\"" }
{ "\"${middleCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE
}


Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugin/ccr/qa/non-compliant-license/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -21,7 +22,7 @@ def followerCluster = testClusters.register('follow-cluster') {
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }
{ "\"${leaderCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE
}

tasks.register('leader-cluster', RestIntegTestTask) {
Expand All @@ -36,4 +37,4 @@ tasks.register('follow-cluster', RestIntegTestTask) {
nonInputProperties.systemProperty 'tests.leader_host', followerCluster.map(c -> c.allHttpSocketURI.get(0))
}

tasks.named("check").configure { dependsOn "follow-cluster" }
tasks.named("check").configure { dependsOn "follow-cluster" }
3 changes: 2 additions & 1 deletion x-pack/plugin/ccr/qa/restart/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -22,7 +23,7 @@ def followCluster = testClusters.register('follow-cluster') {
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${leaderCluster.get().getAllTransportPortURI().get(0)}\"" }
{ "\"${leaderCluster.get().getAllTransportPortURI().get(0)}\"" }, IGNORE_VALUE
nameCustomization = { 'follow' }
}

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugin/ccr/qa/security/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -22,7 +23,7 @@ testClusters.register('follow-cluster') {
testDistribution = 'DEFAULT'
setting 'cluster.remote.leader_cluster.seeds', {
"\"${leadCluster.get().getAllTransportPortURI().join(",")}\""
}
}, IGNORE_VALUE
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.enabled', 'true'
setting 'xpack.monitoring.collection.enabled', 'false' // will be enabled by tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'

Expand All @@ -24,7 +25,7 @@ def integTestClusterReg = testClusters.register('javaRestTest') {
setting 'xpack.watcher.enabled', 'false'
setting 'cluster.remote.my_remote_cluster.seeds', {
remoteClusterReg.get().getAllTransportPortURI().collect { "\"$it\"" }.toString()
}
}, IGNORE_VALUE
setting 'cluster.remote.connections_per_cluster', "1"
setting 'xpack.security.enabled', 'true'
setting 'xpack.security.autoconfiguration.enabled', 'false'
Expand Down
13 changes: 7 additions & 6 deletions x-pack/plugin/ilm/qa/multi-cluster/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import org.elasticsearch.gradle.internal.info.BuildParams
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -16,12 +17,12 @@ tasks.register('leader-cluster', RestIntegTestTask) {
mustRunAfter("precommit")
systemProperty 'tests.target_cluster', 'leader'
/* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', repoDir.absolutePath
nonInputProperties.systemProperty 'tests.path.repo', repoDir.absolutePath
}

testClusters.matching { it.name == 'leader-cluster' }.configureEach {
testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.ccr.enabled', 'true'
setting 'xpack.security.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
Expand All @@ -39,24 +40,24 @@ tasks.register('follow-cluster', RestIntegTestTask) {
nonInputProperties.systemProperty 'tests.leader_remote_cluster_seed',
"${-> testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}"
/* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', repoDir.absolutePath
nonInputProperties.systemProperty 'tests.path.repo', repoDir.absolutePath
}

testClusters.matching{ it.name == 'follow-cluster' }.configureEach {
testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.ccr.enabled', 'true'
setting 'xpack.security.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
setting 'indices.lifecycle.poll_interval', '1000ms'
setting 'cluster.remote.leader_cluster.seeds',
{ "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" }
{ "\"${testClusters.'leader-cluster'.getAllTransportPortURI().get(0)}\"" }, IGNORE_VALUE
}

tasks.named("check").configure { dependsOn 'follow-cluster' }
// Security is explicitly disabled for follow-cluster and leader-cluster, do not run these in FIPS mode
tasks.withType(Test).configureEach {
enabled = BuildParams.inFipsJvm == false
}
}
5 changes: 3 additions & 2 deletions x-pack/plugin/ilm/qa/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.internal.info.BuildParams
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'

Expand All @@ -12,14 +13,14 @@ File repoDir = file("$buildDir/testclusters/repo")

tasks.named("javaRestTest").configure {
/* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', repoDir
nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.configureEach {
testDistribution = 'DEFAULT'
numberOfNodes = 4

setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.searchable.snapshot.shared_cache.size', '16MB'
setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB'
setting 'xpack.security.enabled', 'false'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
Expand Down Expand Up @@ -39,7 +40,7 @@ testClusters.register('mixed-cluster') {
setting 'xpack.license.self_generated.type', 'trial'
setting 'cluster.remote.my_remote_cluster.seeds', {
remoteCluster.get().getAllTransportPortURI().collect { "\"$it\"" }.toString()
}
}, IGNORE_VALUE
setting 'cluster.remote.connections_per_cluster', "1"

user username: "test_user", password: "x-pack-test-password"
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugin/searchable-snapshots/qa/rest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test'
Expand All @@ -15,12 +17,12 @@ restResources {
}

tasks.withType(Test).configureEach {
systemProperty 'tests.path.repo', repoDir
nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.configureEach {
testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.license.self_generated.type', 'trial'

setting 'xpack.searchable.snapshot.shared_cache.size', '16MB'
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/searchable-snapshots/qa/url/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ File repositoryDir = fixture.fsRepositoryDir as File
tasks.named("javaRestTest").configure {
dependsOn fixture.getTasks().named("postProcessFixture")

systemProperty 'test.url.fs.repo.dir', repositoryDir.absolutePath
nonInputProperties.systemProperty 'test.url.fs.repo.dir', repositoryDir.absolutePath
nonInputProperties.systemProperty 'test.url.http', "${-> fixtureAddress('nginx-fixture')}"
}

testClusters.matching { it.name == "javaRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'path.repo', repositoryDir.absolutePath
setting 'path.repo', repositoryDir.absolutePath, IGNORE_VALUE
setting 'repositories.url.allowed_urls', { "${-> fixtureAddress('nginx-fixture')}" }, IGNORE_VALUE
setting 'xpack.license.self_generated.type', 'trial'
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugin/slm/qa/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.internal.info.BuildParams
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'

Expand All @@ -12,14 +13,14 @@ File repoDir = file("$buildDir/testclusters/repo")

tasks.named("javaRestTest").configure {
/* To support taking index snapshots, we have to set path.repo setting */
systemProperty 'tests.path.repo', repoDir
nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.configureEach {
testDistribution = 'DEFAULT'
numberOfNodes = 4

setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.searchable.snapshot.shared_cache.size', '16MB'
setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB'
setting 'xpack.security.enabled', 'false'
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugin/snapshot-based-recoveries/qa/fs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'
apply plugin: 'elasticsearch.rest-resources'

Expand All @@ -25,14 +27,14 @@ tasks.withType(Test).configureEach {
doFirst {
delete(repoDir)
}
systemProperty 'tests.path.repo', repoDir
nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.matching { it.name == "javaRestTest" }.configureEach {
testDistribution = 'DEFAULT'
numberOfNodes = 3

setting 'xpack.license.self_generated.type', 'trial'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.security.enabled', 'false'
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tasks.withType(Test).configureEach {
doFirst {
delete(repoDir)
}
systemProperty 'tests.path.repo', repoDir
nonInputPrperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.matching { it.name == "javaRestTest" }.configureEach {
Expand All @@ -37,6 +37,6 @@ testClusters.matching { it.name == "javaRestTest" }.configureEach {
// This project tests that enterprise licensing is enforced,
// therefore we use a basic license
setting 'xpack.license.self_generated.type', 'basic'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.security.enabled', 'false'
}
6 changes: 4 additions & 2 deletions x-pack/plugin/snapshot-repo-test-kit/qa/rest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.rest-resources'

Expand All @@ -9,12 +11,12 @@ dependencies {
final File repoDir = file("$buildDir/testclusters/repo")

tasks.named("yamlRestTest").configure {
systemProperty 'tests.path.repo', repoDir
nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.matching { it.name == "yamlRestTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'path.repo', repoDir.absolutePath
setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
setting 'xpack.security.enabled', 'false'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

apply plugin: 'elasticsearch.legacy-java-rest-test'

Expand All @@ -25,7 +26,7 @@ def javaRestTestClusterReg = testClusters.register('javaRestTest') {
setting 'xpack.watcher.enabled', 'false'
setting 'cluster.remote.my_remote_cluster.seeds', {
remoteClusterReg.get().getAllTransportPortURI().collect { "\"$it\"" }.toString()
}
}, IGNORE_VALUE
setting 'cluster.remote.connections_per_cluster', "1"
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
Expand Down
Loading

0 comments on commit b7d5692

Please sign in to comment.