Skip to content

Commit 7e9d072

Browse files
committed
Add extra waits to fix tests
1 parent 15abc01 commit 7e9d072

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ public void testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped() throws
339339
// rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index
340340
indexDocument(client(), dataStream, true);
341341

342-
var backingIndices = getDataStreamBackingIndexNames(dataStream);
343-
String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndices.get(0);
342+
String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst();
343+
String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName;
344344
assertTrue(waitUntil(() -> {
345345
try {
346346
return indexExists(restoredIndexName);
@@ -354,6 +354,8 @@ public void testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped() throws
354354
assertThat(stepKeyForIndex.phase(), is("hot"));
355355
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
356356
}, 30, TimeUnit.SECONDS);
357+
// Wait for the original index to be deleted, to ensure ILM has finished
358+
awaitIndexDoesNotExist(backingIndexName);
357359

358360
createPolicy(
359361
client(),
@@ -431,6 +433,8 @@ public void testRestoredIndexManagedByLocalPolicySkipsIllegalActions() throws Ex
431433
assertThat(stepKeyForIndex.phase(), is("hot"));
432434
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
433435
}, 30, TimeUnit.SECONDS);
436+
// Wait for the original index to be deleted, to ensure ILM has finished
437+
awaitIndexDoesNotExist(backingIndexName);
434438

435439
// snapshot the data stream
436440
String dsSnapshotName = "snapshot_ds_" + dataStream;
@@ -535,6 +539,9 @@ public void testIdenticalSearchableSnapshotActionIsNoop() throws Exception {
535539
assertThat(stepKeyForIndex.phase(), is("cold"));
536540
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
537541
}, 30, TimeUnit.SECONDS);
542+
// Wait for the original index to be deleted, to ensure ILM has finished
543+
awaitIndexDoesNotExist(index);
544+
538545

539546
Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
540547
Response response = client().performRequest(getSnaps);
@@ -596,6 +603,8 @@ public void testConvertingSearchableSnapshotFromFullToPartial() throws Exception
596603
assertThat(stepKeyForIndex.phase(), is("frozen"));
597604
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
598605
}, 30, TimeUnit.SECONDS);
606+
// Wait for the original index to be deleted, to ensure ILM has finished
607+
awaitIndexDoesNotExist(index);
599608

600609
Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
601610
Response response = client().performRequest(getSnaps);
@@ -1011,6 +1020,8 @@ public void testSearchableSnapshotTotalShardsPerNode() throws Exception {
10111020
assertThat(stepKeyForIndex.phase(), is("frozen"));
10121021
assertThat(stepKeyForIndex.name(), is(PhaseCompleteStep.NAME));
10131022
}, 30, TimeUnit.SECONDS);
1023+
// Wait for the original index to be deleted, to ensure ILM has finished
1024+
awaitIndexDoesNotExist(index);
10141025

10151026
// validate total_shards_per_node setting
10161027
Map<String, Object> indexSettings = getIndexSettingsAsMap(searchableSnapMountedIndexName);
@@ -1086,6 +1097,8 @@ public void testSearchableSnapshotReplicateFor() throws Exception {
10861097
Integer numberOfReplicas = Integer.valueOf((String) indexSettings.get(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey()));
10871098
assertThat(numberOfReplicas, is(1));
10881099
}
1100+
// Wait for the original index to be deleted, to ensure ILM has finished
1101+
awaitIndexDoesNotExist(backingIndexName);
10891102

10901103
// tweak the policy to replicate_for hardly any time at all
10911104
createPolicy(

0 commit comments

Comments
 (0)