Skip to content

Commit 300893b

Browse files
authored
Convert CCR module tests to new testing framework (#125894) (#125998)
(cherry picked from commit 66ba3c2) # Conflicts: # x-pack/plugin/ccr/qa/build.gradle # x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle # x-pack/plugin/ccr/qa/multi-cluster/build.gradle # x-pack/plugin/ccr/src/javaRestTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java
1 parent 3c9adde commit 300893b

File tree

32 files changed

+1141
-602
lines changed

32 files changed

+1141
-602
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import org.elasticsearch.gradle.internal.info.BuildParams
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+
*/
27

38
apply plugin: 'elasticsearch.java'
49

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

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 15 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,20 @@
1-
import org.elasticsearch.gradle.Version
2-
import org.elasticsearch.gradle.internal.test.RestIntegTestTask
3-
import org.elasticsearch.gradle.testclusters.TestClusterValueSource
4-
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
5-
import org.elasticsearch.gradle.testclusters.TestClustersRegistry
6-
import org.elasticsearch.gradle.util.GradleUtils
7-
8-
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
9-
10-
apply plugin: 'elasticsearch.internal-testclusters'
11-
apply plugin: 'elasticsearch.standalone-rest-test'
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+
apply plugin: 'elasticsearch.internal-java-rest-test'
128

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

64-
tasks.register('follow-cluster', RestIntegTestTask) {
65-
dependsOn "leader-cluster", "middle-cluster"
66-
useCluster leaderCluster
67-
useCluster middleCluster
68-
systemProperty 'tests.target_cluster', 'follow'
69-
systemProperty 'tests.leader_cluster_repository_path', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/leader-cluster"
70-
71-
def leaderUri = getClusterInfo('leader-cluster').map { it.allHttpSocketURI.get(0) }
72-
def middleUri = getClusterInfo('middle-cluster').map { it.allHttpSocketURI.get(0) }
73-
nonInputProperties.systemProperty 'tests.leader_host', leaderUri
74-
nonInputProperties.systemProperty 'tests.middle_host', middleUri
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)
7520
}
76-
77-
testClusters.matching { it.name == "follow-cluster" }.configureEach {
78-
testDistribution = 'DEFAULT'
79-
setting 'xpack.monitoring.collection.enabled', 'true'
80-
setting 'xpack.license.self_generated.type', 'trial'
81-
setting 'xpack.security.enabled', 'true'
82-
user username: 'admin', password: 'admin-password', role: 'superuser'
83-
84-
Provider<TestClustersRegistry> serviceProvider = GradleUtils.getBuildService(
85-
project.gradle.sharedServices,
86-
TestClustersPlugin.REGISTRY_SERVICE_NAME
87-
)
88-
def leaderUris = project.getProviders().of(TestClusterValueSource.class) {
89-
it.parameters.path.set(clusterPath)
90-
it.parameters.clusterName.set("leader-cluster")
91-
it.parameters.service = serviceProvider
92-
}.map { it.getAllTransportPortURI() }
93-
94-
def middleUris = project.getProviders().of(TestClusterValueSource.class) {
95-
it.parameters.path.set(clusterPath)
96-
it.parameters.clusterName.set("middle-cluster")
97-
it.parameters.service = serviceProvider
98-
}.map { it.getAllTransportPortURI() }
99-
100-
setting 'cluster.remote.leader_cluster.seeds',
101-
{ "\"${leaderUris.get().join(",")}\"" }, IGNORE_VALUE
102-
setting 'cluster.remote.middle_cluster.seeds',
103-
{ "\"${middleUris.get().join(",")}\"" }, IGNORE_VALUE
104-
}
105-
106-
107-
testClusters.configureEach {
108-
requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0")
109-
}
110-
111-
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)