@@ -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