Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ public void testUpgradeDataStream() throws Exception {

if (ilmEnabled) {
checkILMPhase(dataStreamName, upgradedIndicesMetadata);
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
deleteDataStream(dataStreamName);
} else {
compareIndexMetadata(oldIndicesMetadata, upgradedIndicesMetadata);
}
Expand All @@ -227,7 +230,7 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
* This test makes sure that if reindex is run and completed, then when the cluster is upgraded the task
* does not begin running again.
*/
String dataStreamName = "reindex_test_data_stream_ugprade_test";
String dataStreamName = "reindex_test_data_stream_upgrade_test";
int numRollovers = randomIntBetween(0, 5);
boolean hasILMPolicy = randomBoolean();
boolean ilmEnabled = hasILMPolicy && randomBoolean();
Expand All @@ -237,6 +240,9 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
} else if (CLUSTER_TYPE == ClusterType.UPGRADED) {
makeSureNoUpgrade(dataStreamName);
cancelReindexTask(dataStreamName);
// Delete the data streams to avoid ILM continuously running cluster state tasks, see
// https://github.com/elastic/elasticsearch/issues/129097#issuecomment-3016122739
deleteDataStream(dataStreamName);
} else {
makeSureNoUpgrade(dataStreamName);
}
Expand Down Expand Up @@ -650,7 +656,7 @@ private void upgradeDataStream(
int expectedErrorCount,
boolean ilmEnabled
) throws Exception {
Set<String> indicesNeedingUpgrade = getDataStreamIndices(dataStreamName);
List<String> indicesNeedingUpgrade = getDataStreamBackingIndexNames(dataStreamName);
final int explicitRolloverOnNewClusterCount = randomIntBetween(0, 2);
for (int i = 0; i < explicitRolloverOnNewClusterCount; i++) {
String oldIndexName = rollover(dataStreamName);
Expand Down Expand Up @@ -726,7 +732,7 @@ private void upgradeDataStream(
}
assertThat(
statusResponseString,
getDataStreamIndices(dataStreamName).size(),
getDataStreamBackingIndexNames(dataStreamName).size(),
equalTo(expectedTotalIndicesInDataStream)
);
assertThat(statusResponseString, ((List<Object>) statusResponseMap.get("errors")).size(), equalTo(expectedErrorCount));
Expand Down Expand Up @@ -768,16 +774,6 @@ private void makeSureNoUpgrade(String dataStreamName) throws Exception {
}
}

@SuppressWarnings("unchecked")
private Set<String> getDataStreamIndices(String dataStreamName) throws IOException {
Response response = client().performRequest(new Request("GET", "_data_stream/" + dataStreamName));
Map<String, Object> responseMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), false);
List<Map<String, Object>> dataStreams = (List<Map<String, Object>>) responseMap.get("data_streams");
Map<String, Object> dataStream = dataStreams.get(0);
List<Map<String, Object>> indices = (List<Map<String, Object>>) dataStream.get("indices");
return indices.stream().map(index -> index.get("index_name").toString()).collect(Collectors.toSet());
}

/*
* Similar to isOriginalClusterCurrent, but returns true if the major versions of the clusters are the same. So true
* for 8.6 and 8.17, but false for 7.17 and 8.18.
Expand Down Expand Up @@ -859,6 +855,10 @@ private void createRole(String name, String dataStream) throws IOException {
assertOK(adminClient().performRequest(request));
}

private void deleteDataStream(String name) throws IOException {
client().performRequest(new Request("DELETE", "_data_stream/" + name));
}

private RestClient getClient(String user, String passwd) throws IOException {
RestClientBuilder builder = RestClient.builder(adminClient().getNodes().toArray(new Node[0]));
String token = basicAuthHeaderValue(user, new SecureString(passwd.toCharArray()));
Expand Down