Skip to content

Commit 68d868a

Browse files
fix flaky test for file-based pull ingestion (#19735)
Signed-off-by: Varun Bharadwaj <varunbharadwaj1995@gmail.com>
1 parent 226e494 commit 68d868a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

plugins/ingestion-fs/src/test/java/org/opensearch/plugin/ingestion/fs/FileBasedIngestionSingleNodeTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public void setupIngestionFile() throws Exception {
7171
try (FileChannel channel = FileChannel.open(shardFile, StandardOpenOption.READ)) {
7272
channel.force(true);
7373
}
74+
75+
// Wait for file to be fully visible by reading it back
76+
// This prevents race conditions where tests start before file is ready
77+
assertBusy(() -> {
78+
java.util.List<String> lines = Files.readAllLines(shardFile, StandardCharsets.UTF_8);
79+
assertEquals("File should have exactly 2 lines", 2, lines.size());
80+
assertTrue("First line should contain alice", lines.get(0).contains("alice"));
81+
assertTrue("Second line should contain bob", lines.get(1).contains("bob"));
82+
});
7483
}
7584

7685
public void testFileIngestion() throws Exception {

0 commit comments

Comments
 (0)