Skip to content

Commit 9220792

Browse files
committed
Fix deletion
1 parent 04150f5 commit 9220792

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void testUpgradeDataStream() throws Exception {
218218
checkILMPhase(dataStreamName, upgradedIndicesMetadata);
219219
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
220220
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
221-
wipeDataStreams();
221+
deleteDataStream(dataStreamName);
222222
} else {
223223
compareIndexMetadata(oldIndicesMetadata, upgradedIndicesMetadata);
224224
}
@@ -242,7 +242,7 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
242242
cancelReindexTask(dataStreamName);
243243
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
244244
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
245-
wipeDataStreams();
245+
deleteDataStream(dataStreamName);
246246
} else {
247247
makeSureNoUpgrade(dataStreamName);
248248
}
@@ -656,7 +656,7 @@ private void upgradeDataStream(
656656
int expectedErrorCount,
657657
boolean ilmEnabled
658658
) throws Exception {
659-
Set<String> indicesNeedingUpgrade = getDataStreamIndices(dataStreamName);
659+
List<String> indicesNeedingUpgrade = getDataStreamBackingIndexNames(dataStreamName);
660660
final int explicitRolloverOnNewClusterCount = randomIntBetween(0, 2);
661661
for (int i = 0; i < explicitRolloverOnNewClusterCount; i++) {
662662
String oldIndexName = rollover(dataStreamName);
@@ -732,7 +732,7 @@ private void upgradeDataStream(
732732
}
733733
assertThat(
734734
statusResponseString,
735-
getDataStreamIndices(dataStreamName).size(),
735+
getDataStreamBackingIndexNames(dataStreamName).size(),
736736
equalTo(expectedTotalIndicesInDataStream)
737737
);
738738
assertThat(statusResponseString, ((List<Object>) statusResponseMap.get("errors")).size(), equalTo(expectedErrorCount));
@@ -774,16 +774,6 @@ private void makeSureNoUpgrade(String dataStreamName) throws Exception {
774774
}
775775
}
776776

777-
@SuppressWarnings("unchecked")
778-
private Set<String> getDataStreamIndices(String dataStreamName) throws IOException {
779-
Response response = client().performRequest(new Request("GET", "_data_stream/" + dataStreamName));
780-
Map<String, Object> responseMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), false);
781-
List<Map<String, Object>> dataStreams = (List<Map<String, Object>>) responseMap.get("data_streams");
782-
Map<String, Object> dataStream = dataStreams.get(0);
783-
List<Map<String, Object>> indices = (List<Map<String, Object>>) dataStream.get("indices");
784-
return indices.stream().map(index -> index.get("index_name").toString()).collect(Collectors.toSet());
785-
}
786-
787777
/*
788778
* Similar to isOriginalClusterCurrent, but returns true if the major versions of the clusters are the same. So true
789779
* for 8.6 and 8.17, but false for 7.17 and 8.18.
@@ -865,6 +855,10 @@ private void createRole(String name, String dataStream) throws IOException {
865855
assertOK(adminClient().performRequest(request));
866856
}
867857

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

0 commit comments

Comments
 (0)