Skip to content

Commit 1155c10

Browse files
committed
Fix continuously running ILM tasks in DataStreamsUpgradeIT (elastic#130283)
The ILM policies on these data streams were causing issues during the test cleanup phase. See elastic#129097 (comment) for more info. Fixes elastic#129097 Fixes elastic#129098
1 parent a3f77c6 commit 1155c10

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,6 @@ tests:
461461
- class: org.elasticsearch.packaging.test.DockerTests
462462
method: test073RunEsAsDifferentUserAndGroupWithoutBindMounting
463463
issue: https://github.com/elastic/elasticsearch/issues/128996
464-
- class: org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT
465-
method: test {p0=upgraded_cluster/70_ilm/Test Lifecycle Still There And Indices Are Still Managed}
466-
issue: https://github.com/elastic/elasticsearch/issues/129097
467-
- class: org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT
468-
method: test {p0=upgraded_cluster/90_ml_data_frame_analytics_crud/Get mixed cluster outlier_detection job}
469-
issue: https://github.com/elastic/elasticsearch/issues/129098
470464
- class: org.elasticsearch.packaging.test.DockerTests
471465
method: test081SymlinksAreFollowedWithEnvironmentVariableFiles
472466
issue: https://github.com/elastic/elasticsearch/issues/128867

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ public void testUpgradeDataStream() throws Exception {
216216

217217
if (ilmEnabled) {
218218
checkILMPhase(dataStreamName, upgradedIndicesMetadata);
219+
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
220+
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
221+
deleteDataStream(dataStreamName);
219222
} else {
220223
compareIndexMetadata(oldIndicesMetadata, upgradedIndicesMetadata);
221224
}
@@ -227,7 +230,7 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
227230
* This test makes sure that if reindex is run and completed, then when the cluster is upgraded the task
228231
* does not begin running again.
229232
*/
230-
String dataStreamName = "reindex_test_data_stream_ugprade_test";
233+
String dataStreamName = "reindex_test_data_stream_upgrade_test";
231234
int numRollovers = randomIntBetween(0, 5);
232235
boolean hasILMPolicy = randomBoolean();
233236
boolean ilmEnabled = hasILMPolicy && randomBoolean();
@@ -237,6 +240,9 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
237240
} else if (CLUSTER_TYPE == ClusterType.UPGRADED) {
238241
makeSureNoUpgrade(dataStreamName);
239242
cancelReindexTask(dataStreamName);
243+
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
244+
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
245+
deleteDataStream(dataStreamName);
240246
} else {
241247
makeSureNoUpgrade(dataStreamName);
242248
}
@@ -650,7 +656,7 @@ private void upgradeDataStream(
650656
int expectedErrorCount,
651657
boolean ilmEnabled
652658
) throws Exception {
653-
Set<String> indicesNeedingUpgrade = getDataStreamIndices(dataStreamName);
659+
List<String> indicesNeedingUpgrade = getDataStreamBackingIndexNames(dataStreamName);
654660
final int explicitRolloverOnNewClusterCount = randomIntBetween(0, 2);
655661
for (int i = 0; i < explicitRolloverOnNewClusterCount; i++) {
656662
String oldIndexName = rollover(dataStreamName);
@@ -726,7 +732,7 @@ private void upgradeDataStream(
726732
}
727733
assertThat(
728734
statusResponseString,
729-
getDataStreamIndices(dataStreamName).size(),
735+
getDataStreamBackingIndexNames(dataStreamName).size(),
730736
equalTo(expectedTotalIndicesInDataStream)
731737
);
732738
assertThat(statusResponseString, ((List<Object>) statusResponseMap.get("errors")).size(), equalTo(expectedErrorCount));
@@ -768,16 +774,6 @@ private void makeSureNoUpgrade(String dataStreamName) throws Exception {
768774
}
769775
}
770776

771-
@SuppressWarnings("unchecked")
772-
private Set<String> getDataStreamIndices(String dataStreamName) throws IOException {
773-
Response response = client().performRequest(new Request("GET", "_data_stream/" + dataStreamName));
774-
Map<String, Object> responseMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), false);
775-
List<Map<String, Object>> dataStreams = (List<Map<String, Object>>) responseMap.get("data_streams");
776-
Map<String, Object> dataStream = dataStreams.get(0);
777-
List<Map<String, Object>> indices = (List<Map<String, Object>>) dataStream.get("indices");
778-
return indices.stream().map(index -> index.get("index_name").toString()).collect(Collectors.toSet());
779-
}
780-
781777
/*
782778
* Similar to isOriginalClusterCurrent, but returns true if the major versions of the clusters are the same. So true
783779
* for 8.6 and 8.17, but false for 7.17 and 8.18.
@@ -859,6 +855,10 @@ private void createRole(String name, String dataStream) throws IOException {
859855
assertOK(adminClient().performRequest(request));
860856
}
861857

858+
private void deleteDataStream(String name) throws IOException {
859+
client().performRequest(new Request("DELETE", "_data_stream/" + name));
860+
}
861+
862862
private RestClient getClient(String user, String passwd) throws IOException {
863863
RestClientBuilder builder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
864864
String token = basicAuthHeaderValue(user, new SecureString(passwd.toCharArray()));

0 commit comments

Comments
 (0)