Skip to content

Commit 1ff6cb4

Browse files
committed
Convert CCR module tests to new testing framework
1 parent a02241b commit 1ff6cb4

File tree

28 files changed

+717
-630
lines changed

28 files changed

+717
-630
lines changed

x-pack/plugin/ccr/build.gradle

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,60 @@
11
apply plugin: 'elasticsearch.internal-es-plugin'
22
apply plugin: 'elasticsearch.internal-cluster-test'
3+
apply plugin: 'elasticsearch.internal-java-rest-test'
4+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
5+
apply plugin: 'elasticsearch.internal-test-artifact'
6+
37
esplugin {
48
name = 'x-pack-ccr'
59
description = 'Elasticsearch Expanded Pack Plugin - CCR'
6-
classname ='org.elasticsearch.xpack.ccr.Ccr'
7-
hasNativeController =false
8-
requiresKeystore =true
10+
classname = 'org.elasticsearch.xpack.ccr.Ccr'
11+
hasNativeController = false
12+
requiresKeystore = true
913
extendedPlugins = ['x-pack-core']
1014
}
15+
1116
base {
1217
archivesName = 'x-pack-ccr'
1318
}
1419

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

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'
23+
compileOnly project(path: xpackModule('core'))
24+
testImplementation(testArtifact(project(xpackModule('core'))))
25+
testImplementation(testArtifact(project(xpackModule('monitoring'))))
26+
testImplementation(project(":modules:analysis-common"))
27+
testImplementation(project(":modules:data-streams"))
28+
javaRestTestImplementation(testImplementation(testArtifact(project(xpackModule('core')))))
29+
30+
clusterModules project(":modules:analysis-common")
31+
clusterModules project(":modules:mapper-extras")
32+
clusterModules project(":modules:data-streams")
33+
clusterModules project(":modules:ingest-common")
34+
clusterModules project(xpackModule("monitoring"))
35+
clusterModules project(xpackModule("ilm"))
36+
clusterModules project(xpackModule("wildcard"))
37+
clusterModules project(xpackModule("stack"))
38+
clusterModules project(xpackModule("mapper-constant-keyword"))
39+
clusterModules project(xpackModule("searchable-snapshots"))
2340
}
24-
tasks.named("check").configure { dependsOn 'internalClusterTestNoSecurityManager' }
2541

26-
tasks.named('internalClusterTest').configure {
27-
exclude noSecurityManagerITClasses
42+
restResources {
43+
restApi {
44+
include '_common', 'cluster', 'nodes', 'indices', 'index', 'info', 'ccr'
45+
}
2846
}
2947

30-
tasks.named('internalClusterTestTestingConventions').configure {
48+
tasks.named('internalClusterTest') {
49+
systemProperty 'tests.security.manager', 'false'
50+
}
51+
52+
tasks.named('internalClusterTestTestingConventions') {
3153
baseClass 'org.elasticsearch.xpack.CcrIntegTestCase'
3254
baseClass 'org.elasticsearch.xpack.CcrSingleNodeTestCase'
3355
baseClass 'org.elasticsearch.test.ESIntegTestCase'
3456
}
3557

36-
addQaCheckDependencies(project)
37-
38-
dependencies {
39-
compileOnly project(":server")
40-
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"))
58+
tasks.named("yamlRestTest") {
59+
usesDefaultDistribution("uses _xpack info api")
4660
}

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: 6 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,14 @@
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")
6917
}
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" }

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java renamed to x-pack/plugin/ccr/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/ccr/XPackUsageIT.java

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
*/
77
package org.elasticsearch.xpack.ccr;
88

9+
import com.carrotsearch.randomizedtesting.annotations.Name;
10+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
11+
912
import org.elasticsearch.client.Request;
1013
import org.elasticsearch.client.RestClient;
1114
import org.elasticsearch.common.settings.SecureString;
1215
import org.elasticsearch.common.settings.Settings;
1316
import org.elasticsearch.common.util.concurrent.ThreadContext;
17+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
18+
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
19+
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
1420
import org.elasticsearch.xcontent.ObjectPath;
21+
import org.junit.ClassRule;
22+
import org.junit.rules.RuleChain;
1523

1624
import java.io.IOException;
1725
import java.util.Map;
@@ -20,10 +28,45 @@
2028
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
2129
import static org.hamcrest.Matchers.nullValue;
2230

23-
public class XPackUsageIT extends ESCCRRestTestCase {
31+
public class XPackUsageIT extends AbstractCCRRestTestCase {
32+
33+
public static LocalClusterConfigProvider commonConfig = c -> c.distribution(DistributionType.DEFAULT)
34+
.setting("xpack.security.enabled", "true")
35+
.setting("xpack.license.self_generated.type", "trial")
36+
.user("admin", "admin-password", "superuser", false);
37+
38+
public static ElasticsearchCluster leaderCluster = ElasticsearchCluster.local().name("leader-cluster").apply(commonConfig).build();
39+
40+
public static ElasticsearchCluster followerCluster = ElasticsearchCluster.local()
41+
.name("follow-cluster")
42+
.apply(commonConfig)
43+
.setting("cluster.remote.leader_cluster.seeds", () -> "\"" + leaderCluster.getTransportEndpoints() + "\"")
44+
.build();
45+
46+
@ClassRule
47+
public static RuleChain ruleChain = RuleChain.outerRule(leaderCluster).around(followerCluster);
48+
49+
public XPackUsageIT(@Name("targetCluster") TargetCluster targetCluster) {
50+
super(targetCluster);
51+
}
52+
53+
@ParametersFactory
54+
public static Iterable<Object[]> parameters() throws Exception {
55+
return leaderFollower();
56+
}
57+
58+
@Override
59+
protected ElasticsearchCluster getLeaderCluster() {
60+
return leaderCluster;
61+
}
62+
63+
@Override
64+
protected ElasticsearchCluster getFollowerCluster() {
65+
return followerCluster;
66+
}
2467

2568
public void testXPackCcrUsage() throws Exception {
26-
if ("follow".equals(targetCluster) == false) {
69+
if (targetCluster != TargetCluster.FOLLOWER) {
2770
logger.info("skipping test, waiting for target cluster [follow]");
2871
return;
2972
}

0 commit comments

Comments
 (0)