Skip to content

Commit 633ab24

Browse files
authored
[CCR] Restructured QA modules (#36404)
Renamed the follow qa modules: `multi-cluster-downgraded-to-basic-license` to `downgraded-to-basic-license` `multi-cluster-with-non-compliant-license` to `non-compliant-license` `multi-cluster-with-security` to `security` Moved the `chain` module into the `multi-cluster` module and changed the `multi-cluster` to start 3 clusters. Followup from #36031
1 parent bba9bb2 commit 633ab24

File tree

13 files changed

+79
-110
lines changed

13 files changed

+79
-110
lines changed

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

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

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,48 @@ leaderClusterTestCluster {
1616
numNodes = 1
1717
clusterName = 'leader-cluster'
1818
setting 'xpack.license.self_generated.type', 'trial'
19+
setting 'node.name', 'leader'
1920
}
2021

2122
leaderClusterTestRunner {
2223
systemProperty 'tests.target_cluster', 'leader'
2324
}
2425

26+
task middleClusterTest(type: RestIntegTestTask) {}
27+
28+
middleClusterTestCluster {
29+
dependsOn leaderClusterTestRunner
30+
numNodes = 1
31+
clusterName = 'middle-cluster'
32+
setting 'xpack.license.self_generated.type', 'trial'
33+
setting 'cluster.remote.leader_cluster.seeds', "\"${-> leaderClusterTest.nodes.get(0).transportUri()}\""
34+
setting 'node.name', 'middle'
35+
}
36+
37+
middleClusterTestRunner {
38+
systemProperty 'tests.target_cluster', 'middle'
39+
systemProperty 'tests.leader_host', "${-> leaderClusterTest.nodes.get(0).httpUri()}"
40+
}
41+
2542
task followClusterTest(type: RestIntegTestTask) {}
2643

2744
followClusterTestCluster {
28-
dependsOn leaderClusterTestRunner
45+
dependsOn middleClusterTestRunner
2946
numNodes = 1
3047
clusterName = 'follow-cluster'
3148
setting 'xpack.monitoring.collection.enabled', 'true'
3249
setting 'xpack.license.self_generated.type', 'trial'
3350
setting 'cluster.remote.leader_cluster.seeds', "\"${-> leaderClusterTest.nodes.get(0).transportUri()}\""
51+
setting 'cluster.remote.middle_cluster.seeds', "\"${-> middleClusterTest.nodes.get(0).transportUri()}\""
52+
setting 'node.name', 'follow'
3453
}
3554

3655
followClusterTestRunner {
3756
systemProperty 'tests.target_cluster', 'follow'
3857
systemProperty 'tests.leader_host', "${-> leaderClusterTest.nodes.get(0).httpUri()}"
58+
systemProperty 'tests.middle_host', "${-> middleClusterTest.nodes.get(0).httpUri()}"
3959
finalizedBy 'leaderClusterTestCluster#stop'
60+
finalizedBy 'middleClusterTestCluster#stop'
4061
}
4162

4263
check.dependsOn followClusterTest

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

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@
1111
import org.elasticsearch.common.Strings;
1212
import org.elasticsearch.common.settings.Settings;
1313

14+
import java.io.IOException;
1415
import java.util.Map;
16+
import java.util.concurrent.TimeUnit;
1517

1618
import static org.hamcrest.Matchers.equalTo;
1719

1820
public class AutoFollowIT extends ESCCRRestTestCase {
1921

20-
public void testAutoFollowPatterns() throws Exception {
22+
public void testMultipleAutoFollowPatternsDifferentClusters() throws Exception {
2123
if ("follow".equals(targetCluster) == false) {
24+
logger.info("skipping test, waiting for target cluster [follow]" );
2225
return;
2326
}
27+
28+
int initialNumberOfSuccessfulFollowedIndices = getNumberOfSuccessfulFollowedIndices();
2429
Request putPatternRequest = new Request("PUT", "/_ccr/auto_follow/leader_cluster_pattern");
2530
putPatternRequest.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
2631
assertOK(client().performRequest(putPatternRequest));
@@ -54,10 +59,7 @@ public void testAutoFollowPatterns() throws Exception {
5459
}
5560
}
5661
assertBusy(() -> {
57-
Request statsRequest = new Request("GET", "/_ccr/stats");
58-
Map<?, ?> response = toMap(client().performRequest(statsRequest));
59-
Map<?, ?> autoFollowStats = (Map<?, ?>) response.get("auto_follow_stats");
60-
assertThat(autoFollowStats.get("number_of_successful_follow_indices"), equalTo(2));
62+
assertThat(getNumberOfSuccessfulFollowedIndices(), equalTo(initialNumberOfSuccessfulFollowedIndices + 2));
6163

6264
ensureYellow("logs-20190101");
6365
ensureYellow("logs-20200101");
@@ -66,4 +68,49 @@ public void testAutoFollowPatterns() throws Exception {
6668
});
6769
}
6870

71+
public void testAutoFollowPatterns() throws Exception {
72+
if ("follow".equals(targetCluster) == false) {
73+
logger.info("skipping test, waiting for target cluster [follow]" );
74+
return;
75+
}
76+
77+
int initialNumberOfSuccessfulFollowedIndices = getNumberOfSuccessfulFollowedIndices();
78+
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
79+
request.setJsonEntity("{\"leader_index_patterns\": [\"metrics-*\"], \"remote_cluster\": \"leader_cluster\"}");
80+
assertOK(client().performRequest(request));
81+
82+
try (RestClient leaderClient = buildLeaderClient()) {
83+
Settings settings = Settings.builder()
84+
.put("index.soft_deletes.enabled", true)
85+
.build();
86+
request = new Request("PUT", "/metrics-20210101");
87+
request.setJsonEntity("{\"settings\": " + Strings.toString(settings) +
88+
", \"mappings\": {\"_doc\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}} }");
89+
assertOK(leaderClient.performRequest(request));
90+
91+
for (int i = 0; i < 5; i++) {
92+
String id = Integer.toString(i);
93+
index(leaderClient, "metrics-20210101", id, "field", i, "filtered_field", "true");
94+
}
95+
}
96+
97+
assertBusy(() -> {
98+
assertThat(getNumberOfSuccessfulFollowedIndices(), equalTo(initialNumberOfSuccessfulFollowedIndices + 1));
99+
ensureYellow("metrics-20210101");
100+
verifyDocuments("metrics-20210101", 5, "filtered_field:true");
101+
});
102+
assertBusy(() -> {
103+
verifyCcrMonitoring("metrics-20210101", "metrics-20210101");
104+
verifyAutoFollowMonitoring();
105+
}, 30, TimeUnit.SECONDS);
106+
}
107+
108+
private int getNumberOfSuccessfulFollowedIndices() throws IOException {
109+
Request statsRequest = new Request("GET", "/_ccr/stats");
110+
Map<?, ?> response = toMap(client().performRequest(statsRequest));
111+
response = (Map<?, ?>) response.get("auto_follow_stats");
112+
return (Integer) response.get("number_of_successful_follow_indices");
113+
}
114+
115+
69116
}

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import org.elasticsearch.client.Request;
99
import org.elasticsearch.client.ResponseException;
1010
import org.elasticsearch.client.RestClient;
11-
import org.elasticsearch.common.Strings;
1211
import org.elasticsearch.common.settings.Settings;
1312

14-
import java.util.Map;
1513
import java.util.concurrent.TimeUnit;
1614

1715
import static org.hamcrest.Matchers.containsString;
@@ -44,7 +42,7 @@ public void testFollowIndex() throws Exception {
4442
}
4543
refresh(leaderIndexName);
4644
verifyDocuments(leaderIndexName, numDocs, "filtered_field:true");
47-
} else {
45+
} else if ("follow".equals(targetCluster)) {
4846
logger.info("Running against follow cluster");
4947
final String followIndexName = "test_index2";
5048
followIndex(leaderIndexName, followIndexName);
@@ -70,7 +68,10 @@ public void testFollowIndex() throws Exception {
7068
}
7169

7270
public void testFollowNonExistingLeaderIndex() throws Exception {
73-
assumeFalse("Test should only run when both clusters are running", "leader".equals(targetCluster));
71+
if ("follow".equals(targetCluster) == false) {
72+
logger.info("skipping test, waiting for target cluster [follow]" );
73+
return;
74+
}
7475
ResponseException e = expectThrows(ResponseException.class, () -> resumeFollow("non-existing-index"));
7576
assertThat(e.getMessage(), containsString("no such index [non-existing-index]"));
7677
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
@@ -80,41 +81,4 @@ public void testFollowNonExistingLeaderIndex() throws Exception {
8081
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
8182
}
8283

83-
public void testAutoFollowPatterns() throws Exception {
84-
assumeFalse("Test should only run when both clusters are running", "leader".equals(targetCluster));
85-
86-
Request request = new Request("PUT", "/_ccr/auto_follow/test_pattern");
87-
request.setJsonEntity("{\"leader_index_patterns\": [\"logs-*\"], \"remote_cluster\": \"leader_cluster\"}");
88-
assertOK(client().performRequest(request));
89-
90-
try (RestClient leaderClient = buildLeaderClient()) {
91-
Settings settings = Settings.builder()
92-
.put("index.soft_deletes.enabled", true)
93-
.build();
94-
request = new Request("PUT", "/logs-20190101");
95-
request.setJsonEntity("{\"settings\": " + Strings.toString(settings) +
96-
", \"mappings\": {\"_doc\": {\"properties\": {\"field\": {\"type\": \"keyword\"}}}} }");
97-
assertOK(leaderClient.performRequest(request));
98-
99-
for (int i = 0; i < 5; i++) {
100-
String id = Integer.toString(i);
101-
index(leaderClient, "logs-20190101", id, "field", i, "filtered_field", "true");
102-
}
103-
}
104-
105-
assertBusy(() -> {
106-
Request statsRequest = new Request("GET", "/_ccr/stats");
107-
Map<?, ?> response = toMap(client().performRequest(statsRequest));
108-
response = (Map<?, ?>) response.get("auto_follow_stats");
109-
assertThat(response.get("number_of_successful_follow_indices"), equalTo(1));
110-
111-
ensureYellow("logs-20190101");
112-
verifyDocuments("logs-20190101", 5, "filtered_field:true");
113-
});
114-
assertBusy(() -> {
115-
verifyCcrMonitoring("logs-20190101", "logs-20190101");
116-
verifyAutoFollowMonitoring();
117-
}, 30, TimeUnit.SECONDS);
118-
}
119-
12084
}

0 commit comments

Comments
 (0)