Skip to content

Commit c61b713

Browse files
mch2shiv0408
authored andcommitted
Fix flaky pit/scroll tests in SegmentReplicationIT (opensearch-project#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> Signed-off-by: Shivansh Arora <hishiv@amazon.com>
1 parent 4ccba11 commit c61b713

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

server/src/internalClusterTest/java/org/opensearch/indices/replication/SegmentReplicationIT.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,14 @@ public void testScrollCreatedOnReplica() throws Exception {
10661066

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

1069-
currentFiles = List.of(replicaShard.store().directory().listAll());
1070-
assertFalse("Files should be cleaned up post scroll clear request", currentFiles.containsAll(snapshottedSegments));
1069+
assertBusy(
1070+
() -> assertFalse(
1071+
"Files should be cleaned up post scroll clear request",
1072+
List.of(replicaShard.store().directory().listAll()).containsAll(snapshottedSegments)
1073+
)
1074+
);
10711075
assertEquals(100, scrollHits);
1076+
10721077
}
10731078

10741079
/**
@@ -1327,9 +1332,12 @@ public void testPitCreatedOnReplica() throws Exception {
13271332
// delete the PIT
13281333
DeletePitRequest deletePITRequest = new DeletePitRequest(pitResponse.getId());
13291334
client().execute(DeletePitAction.INSTANCE, deletePITRequest).actionGet();
1330-
1331-
currentFiles = List.of(replicaShard.store().directory().listAll());
1332-
assertFalse("Files should be cleaned up", currentFiles.containsAll(snapshottedSegments));
1335+
assertBusy(
1336+
() -> assertFalse(
1337+
"Files should be cleaned up",
1338+
List.of(replicaShard.store().directory().listAll()).containsAll(snapshottedSegments)
1339+
)
1340+
);
13331341
}
13341342

13351343
/**

0 commit comments

Comments
 (0)