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 <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
mch2 authored and shiv0408 committed Apr 25, 2024
1 parent 4ccba11 commit c61b713
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 c61b713

Please sign in to comment.