Skip to content

Commit

Permalink
Fix flaky pit/scroll tests in SegmentReplicationIT (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#10770)

This change adds an assertBusy to wait until files are cleared from disk as it is not
synchronous with the scroll/pit removal.

Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 authored Nov 6, 2023
1 parent 747f7d1 commit c1962cc
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,14 @@ public void testScrollCreatedOnReplica() throws Exception {

client(replica).prepareClearScroll().addScrollId(searchResponse.getScrollId()).get();

currentFiles = List.of(replicaShard.store().directory().listAll());
assertFalse("Files should be cleaned up post scroll clear request", currentFiles.containsAll(snapshottedSegments));
assertBusy(
() -> assertFalse(
"Files should be cleaned up post scroll clear request",
List.of(replicaShard.store().directory().listAll()).containsAll(snapshottedSegments)
)
);
assertEquals(100, scrollHits);

}

/**
Expand Down Expand Up @@ -1327,9 +1332,12 @@ public void testPitCreatedOnReplica() throws Exception {
// delete the PIT
DeletePitRequest deletePITRequest = new DeletePitRequest(pitResponse.getId());
client().execute(DeletePitAction.INSTANCE, deletePITRequest).actionGet();

currentFiles = List.of(replicaShard.store().directory().listAll());
assertFalse("Files should be cleaned up", currentFiles.containsAll(snapshottedSegments));
assertBusy(
() -> assertFalse(
"Files should be cleaned up",
List.of(replicaShard.store().directory().listAll()).containsAll(snapshottedSegments)
)
);
}

/**
Expand Down

0 comments on commit c1962cc

Please sign in to comment.