@@ -216,6 +216,9 @@ public void testUpgradeDataStream() throws Exception {
216
216
217
217
if (ilmEnabled ) {
218
218
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 );
219
222
} else {
220
223
compareIndexMetadata (oldIndicesMetadata , upgradedIndicesMetadata );
221
224
}
@@ -227,7 +230,7 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
227
230
* This test makes sure that if reindex is run and completed, then when the cluster is upgraded the task
228
231
* does not begin running again.
229
232
*/
230
- String dataStreamName = "reindex_test_data_stream_ugprade_test " ;
233
+ String dataStreamName = "reindex_test_data_stream_upgrade_test " ;
231
234
int numRollovers = randomIntBetween (0 , 5 );
232
235
boolean hasILMPolicy = randomBoolean ();
233
236
boolean ilmEnabled = hasILMPolicy && randomBoolean ();
@@ -237,6 +240,9 @@ public void testMigrateDoesNotRestartOnUpgrade() throws Exception {
237
240
} else if (CLUSTER_TYPE == ClusterType .UPGRADED ) {
238
241
makeSureNoUpgrade (dataStreamName );
239
242
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 );
240
246
} else {
241
247
makeSureNoUpgrade (dataStreamName );
242
248
}
@@ -650,7 +656,7 @@ private void upgradeDataStream(
650
656
int expectedErrorCount ,
651
657
boolean ilmEnabled
652
658
) throws Exception {
653
- Set <String > indicesNeedingUpgrade = getDataStreamIndices (dataStreamName );
659
+ List <String > indicesNeedingUpgrade = getDataStreamBackingIndexNames (dataStreamName );
654
660
final int explicitRolloverOnNewClusterCount = randomIntBetween (0 , 2 );
655
661
for (int i = 0 ; i < explicitRolloverOnNewClusterCount ; i ++) {
656
662
String oldIndexName = rollover (dataStreamName );
@@ -726,7 +732,7 @@ private void upgradeDataStream(
726
732
}
727
733
assertThat (
728
734
statusResponseString ,
729
- getDataStreamIndices (dataStreamName ).size (),
735
+ getDataStreamBackingIndexNames (dataStreamName ).size (),
730
736
equalTo (expectedTotalIndicesInDataStream )
731
737
);
732
738
assertThat (statusResponseString , ((List <Object >) statusResponseMap .get ("errors" )).size (), equalTo (expectedErrorCount ));
@@ -768,16 +774,6 @@ private void makeSureNoUpgrade(String dataStreamName) throws Exception {
768
774
}
769
775
}
770
776
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
-
781
777
/*
782
778
* Similar to isOriginalClusterCurrent, but returns true if the major versions of the clusters are the same. So true
783
779
* 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 {
859
855
assertOK (adminClient ().performRequest (request ));
860
856
}
861
857
858
+ private void deleteDataStream (String name ) throws IOException {
859
+ client ().performRequest (new Request ("DELETE" , "_data_stream/" + name ));
860
+ }
861
+
862
862
private RestClient getClient (String user , String passwd ) throws IOException {
863
863
RestClientBuilder builder = RestClient .builder (adminClient ().getNodes ().toArray (new Node [0 ]));
864
864
String token = basicAuthHeaderValue (user , new SecureString (passwd .toCharArray ()));
0 commit comments