Skip to content

Commit 831f686

Browse files
authored
Fix testIdenticalSearchableSnapshotActionIsNoop (#69033) (#69056)
This fixes the flakiness in testIdenticalSearchableSnapshotActionIsNoop and testConvertingSearchableSnapshotFromFullToPartial caused by the fact that we enabled ILM for the index and *after that* indexed a document. If ILM runs very fast in CI the `indexDocument` call could fail, or in the case of testIdenticalSearchableSnapshotActionIsNoop all the assertions in the test will pass but the final one that checks there is one document indexed fails because the `indexDocument` call didn't execute. (cherry picked from commit 7d27d40) Signed-off-by: Andrei Dan <[email protected]>
1 parent 202e32a commit 831f686

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,14 @@ public void testIdenticalSearchableSnapshotActionIsNoop() throws Exception {
374374
null
375375
);
376376

377-
createIndex(index, Settings.builder()
378-
.put(LifecycleSettings.LIFECYCLE_NAME, policy)
379-
.build());
377+
createIndex(index, Settings.EMPTY);
380378
ensureGreen(index);
381379
indexDocument(client(), index, true);
382380

381+
// enable ILM after we indexed a document as otherwise ILM might sometimes run so fast the indexDocument call will fail with
382+
// `index_not_found_exception`
383+
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
384+
383385
final String searchableSnapMountedIndexName = (storage == MountSearchableSnapshotRequest.Storage.FULL_COPY ?
384386
SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX : SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX) + index;
385387

@@ -422,12 +424,14 @@ public void testConvertingSearchableSnapshotFromFullToPartial() throws Exception
422424
null
423425
);
424426

425-
createIndex(index, Settings.builder()
426-
.put(LifecycleSettings.LIFECYCLE_NAME, policy)
427-
.build());
427+
createIndex(index, Settings.EMPTY);
428428
ensureGreen(index);
429429
indexDocument(client(), index, true);
430430

431+
// enable ILM after we indexed a document as otherwise ILM might sometimes run so fast the indexDocument call will fail with
432+
// `index_not_found_exception`
433+
updateIndexSettings(index, Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy));
434+
431435
final String searchableSnapMountedIndexName = SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX +
432436
SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + index;
433437

0 commit comments

Comments
 (0)