Skip to content

Commit 66ba3c2

Browse files
authored
Convert CCR module tests to new testing framework (#125894)
1 parent 70de5a8 commit 66ba3c2

File tree

32 files changed

+1131
-631
lines changed

32 files changed

+1131
-631
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
5858
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack");
5959
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:async-search:qa:rest");
6060
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:autoscaling:qa:rest");
61-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:downgrade-to-basic-license");
62-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:multi-cluster");
63-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:non-compliant-license");
64-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:rest");
65-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:restart");
66-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ccr:qa:security");
6761
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest");
6862
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest");
6963
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security");

x-pack/plugin/ccr/build.gradle

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,68 @@
1+
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
2+
13
apply plugin: 'elasticsearch.internal-es-plugin'
24
apply plugin: 'elasticsearch.internal-cluster-test'
5+
apply plugin: 'elasticsearch.internal-java-rest-test'
6+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
7+
apply plugin: 'elasticsearch.internal-test-artifact'
8+
39
esplugin {
410
name = 'x-pack-ccr'
511
description = 'Elasticsearch Expanded Pack Plugin - CCR'
6-
classname ='org.elasticsearch.xpack.ccr.Ccr'
7-
hasNativeController =false
8-
requiresKeystore =true
12+
classname = 'org.elasticsearch.xpack.ccr.Ccr'
13+
hasNativeController = false
14+
requiresKeystore = true
915
extendedPlugins = ['x-pack-core']
1016
}
17+
1118
base {
1219
archivesName = 'x-pack-ccr'
1320
}
1421

15-
// Integration Test classes that cannot run with the security manager
16-
String[] noSecurityManagerITClasses = ["**/CloseFollowerIndexIT.class"]
22+
dependencies {
23+
compileOnly project(":server")
1724

18-
tasks.register('internalClusterTestNoSecurityManager', Test) {
19-
testClassesDirs = sourceSets.internalClusterTest.output.classesDirs
20-
classpath = sourceSets.internalClusterTest.runtimeClasspath
21-
include noSecurityManagerITClasses
22-
systemProperty 'tests.security.manager', 'false'
25+
compileOnly project(path: xpackModule('core'))
26+
testImplementation(testArtifact(project(xpackModule('core'))))
27+
testImplementation(testArtifact(project(xpackModule('monitoring'))))
28+
testImplementation(project(":modules:analysis-common"))
29+
testImplementation(project(":modules:data-streams"))
30+
javaRestTestImplementation(testImplementation(testArtifact(project(xpackModule('core')))))
31+
32+
clusterModules project(":modules:analysis-common")
33+
clusterModules project(":modules:mapper-extras")
34+
clusterModules project(":modules:data-streams")
35+
clusterModules project(":modules:ingest-common")
36+
clusterModules project(xpackModule("monitoring"))
37+
clusterModules project(xpackModule("ilm"))
38+
clusterModules project(xpackModule("wildcard"))
39+
clusterModules project(xpackModule("stack"))
40+
clusterModules project(xpackModule("mapper-constant-keyword"))
41+
clusterModules project(xpackModule("searchable-snapshots"))
2342
}
24-
tasks.named("check").configure { dependsOn 'internalClusterTestNoSecurityManager' }
2543

26-
tasks.named('internalClusterTest').configure {
27-
exclude noSecurityManagerITClasses
44+
restResources {
45+
restApi {
46+
include '_common', 'cluster', 'nodes', 'indices', 'index', 'info', 'ccr'
47+
}
2848
}
2949

30-
tasks.named('internalClusterTestTestingConventions').configure {
50+
tasks.named('internalClusterTest') {
51+
systemProperty 'tests.security.manager', 'false'
52+
}
53+
54+
tasks.named('internalClusterTestTestingConventions') {
3155
baseClass 'org.elasticsearch.xpack.CcrIntegTestCase'
3256
baseClass 'org.elasticsearch.xpack.CcrSingleNodeTestCase'
3357
baseClass 'org.elasticsearch.test.ESIntegTestCase'
3458
}
3559

36-
addQaCheckDependencies(project)
37-
38-
dependencies {
39-
compileOnly project(":server")
60+
tasks.named("yamlRestTest") {
61+
usesDefaultDistribution("uses _xpack info api")
62+
}
4063

41-
compileOnly project(path: xpackModule('core'))
42-
testImplementation(testArtifact(project(xpackModule('core'))))
43-
testImplementation(testArtifact(project(xpackModule('monitoring'))))
44-
testImplementation(project(":modules:analysis-common"))
45-
testImplementation(project(":modules:data-streams"))
64+
tasks.withType(StandaloneRestIntegTestTask).configureEach {
65+
// These fail in CI but only when run as part of checkPart2 and not individually.
66+
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
67+
buildParams.withFipsEnabledOnly(it)
4668
}

x-pack/plugin/ccr/qa/build.gradle

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +0,0 @@
1-
/*
2-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the Elastic License
4-
* 2.0; you may not use this file except in compliance with the Elastic License
5-
* 2.0.
6-
*/
7-
8-
apply plugin: 'elasticsearch.java'
9-
10-
dependencies {
11-
api project(':test:framework')
12-
}
13-
14-
subprojects {
15-
tasks.withType(Test).configureEach {
16-
// These fail in CI but only when run as part of checkPart2 and not individually.
17-
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
18-
buildParams.withFipsEnabledOnly(it)
19-
}
20-
}

x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle

Lines changed: 0 additions & 85 deletions
This file was deleted.

x-pack/plugin/ccr/qa/multi-cluster/build.gradle

Lines changed: 9 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,17 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
8-
import org.elasticsearch.gradle.Version
9-
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
10-
import org.elasticsearch.gradle.testclusters.TestClusterValueSource
11-
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
12-
import org.elasticsearch.gradle.testclusters.TestClustersRegistry
13-
import org.elasticsearch.gradle.util.GradleUtils
14-
15-
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
16-
17-
apply plugin: 'elasticsearch.internal-testclusters'
18-
apply plugin: 'elasticsearch.standalone-rest-test'
7+
apply plugin: 'elasticsearch.internal-java-rest-test'
198

209
dependencies {
21-
testImplementation(testArtifact(project(xpackModule('core'))))
22-
testImplementation project(xpackModule('ccr'))
23-
testImplementation project(':x-pack:plugin:ccr:qa')
24-
}
25-
26-
def clusterPath = getPath()
27-
def leaderCluster = testClusters.register('leader-cluster') {
28-
testDistribution = 'DEFAULT'
29-
setting 'xpack.license.self_generated.type', 'trial'
30-
setting 'xpack.security.enabled', 'true'
31-
user username: 'admin', password: 'admin-password', role: 'superuser'
32-
setting 'path.repo', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
33-
}
34-
35-
def middleCluster = testClusters.register('middle-cluster') {
36-
testDistribution = 'DEFAULT'
37-
setting 'xpack.license.self_generated.type', 'trial'
38-
setting 'xpack.security.enabled', 'true'
39-
user username: 'admin', password: 'admin-password', role: 'superuser'
40-
41-
Provider<TestClustersRegistry> serviceProvider = GradleUtils.getBuildService(
42-
project.gradle.sharedServices,
43-
TestClustersPlugin.REGISTRY_SERVICE_NAME
44-
)
45-
def leaderInfo = project.getProviders().of(TestClusterValueSource.class) {
46-
it.parameters.path.set(clusterPath)
47-
it.parameters.clusterName.set("leader-cluster")
48-
it.parameters.service = serviceProvider
49-
}
50-
def leaderUris = leaderInfo.map { it.getAllTransportPortURI() }
51-
setting 'cluster.remote.leader_cluster.seeds',
52-
{ "\"${leaderUris.get().join(",")}\"" }, IGNORE_VALUE
53-
}
54-
55-
tasks.register("leader-cluster", RestIntegTestTask) {
56-
mustRunAfter("precommit")
57-
systemProperty 'tests.target_cluster', 'leader'
58-
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
10+
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
11+
javaRestTestImplementation(testArtifact(project(xpackModule('ccr')), 'javaRestTest'))
12+
javaRestTestImplementation project(xpackModule('ccr'))
5913
}
6014

61-
tasks.register("middle-cluster", RestIntegTestTask) {
62-
dependsOn "leader-cluster"
63-
useCluster testClusters.named("leader-cluster")
64-
systemProperty 'tests.target_cluster', 'middle'
65-
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
66-
67-
def leaderUri = getClusterInfo('leader-cluster').map { it.allHttpSocketURI.get(0) }
68-
nonInputProperties.systemProperty 'tests.leader_host', leaderUri
15+
tasks.named("javaRestTest") {
16+
usesDefaultDistribution("uses _xpack usage api")
17+
// These fail in CI but only when run as part of checkPart2 and not individually.
18+
// Tracked in : https://github.com/elastic/elasticsearch/issues/66661
19+
buildParams.withFipsEnabledOnly(it)
6920
}
70-
71-
tasks.register('follow-cluster', RestIntegTestTask) {
72-
dependsOn "leader-cluster", "middle-cluster"
73-
useCluster leaderCluster
74-
useCluster middleCluster
75-
systemProperty 'tests.target_cluster', 'follow'
76-
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
77-
78-
def leaderUri = getClusterInfo('leader-cluster').map { it.allHttpSocketURI.get(0) }
79-
def middleUri = getClusterInfo('middle-cluster').map { it.allHttpSocketURI.get(0) }
80-
nonInputProperties.systemProperty 'tests.leader_host', leaderUri
81-
nonInputProperties.systemProperty 'tests.middle_host', middleUri
82-
}
83-
84-
testClusters.matching { it.name == "follow-cluster" }.configureEach {
85-
testDistribution = 'DEFAULT'
86-
setting 'xpack.monitoring.collection.enabled', 'true'
87-
setting 'xpack.license.self_generated.type', 'trial'
88-
setting 'xpack.security.enabled', 'true'
89-
user username: 'admin', password: 'admin-password', role: 'superuser'
90-
91-
Provider<TestClustersRegistry> serviceProvider = GradleUtils.getBuildService(
92-
project.gradle.sharedServices,
93-
TestClustersPlugin.REGISTRY_SERVICE_NAME
94-
)
95-
def leaderUris = project.getProviders().of(TestClusterValueSource.class) {
96-
it.parameters.path.set(clusterPath)
97-
it.parameters.clusterName.set("leader-cluster")
98-
it.parameters.service = serviceProvider
99-
}.map { it.getAllTransportPortURI() }
100-
101-
def middleUris = project.getProviders().of(TestClusterValueSource.class) {
102-
it.parameters.path.set(clusterPath)
103-
it.parameters.clusterName.set("middle-cluster")
104-
it.parameters.service = serviceProvider
105-
}.map { it.getAllTransportPortURI() }
106-
107-
setting 'cluster.remote.leader_cluster.seeds',
108-
{ "\"${leaderUris.get().join(",")}\"" }, IGNORE_VALUE
109-
setting 'cluster.remote.middle_cluster.seeds',
110-
{ "\"${middleUris.get().join(",")}\"" }, IGNORE_VALUE
111-
}
112-
113-
114-
testClusters.configureEach {
115-
requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0")
116-
}
117-
118-
tasks.named("check").configure { dependsOn "follow-cluster" }

0 commit comments

Comments
 (0)