From 7579c8365c06f5a59e15a3c8131e21ea1ab408e8 Mon Sep 17 00:00:00 2001 From: Yann Byron Date: Tue, 21 May 2024 15:52:49 +0800 Subject: [PATCH] [core] Fix FileStoreCommitTest.testIndexFiles flaky ut (#3358) --- .../paimon/operation/FileStoreCommitTest.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/paimon-core/src/test/java/org/apache/paimon/operation/FileStoreCommitTest.java b/paimon-core/src/test/java/org/apache/paimon/operation/FileStoreCommitTest.java index 26cb564caa64..d603eda41e68 100644 --- a/paimon-core/src/test/java/org/apache/paimon/operation/FileStoreCommitTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/operation/FileStoreCommitTest.java @@ -719,12 +719,14 @@ public void testIndexFiles() throws Exception { indexFileHandler.scan(snapshot.id(), HASH_INDEX, part1); assertThat(part1Index.size()).isEqualTo(2); - assertThat(part1Index.get(0).bucket()).isEqualTo(0); - assertThat(indexFileHandler.readHashIndexList(part1Index.get(0).indexFile())) + IndexManifestEntry indexManifestEntry = + part1Index.stream().filter(entry -> entry.bucket() == 0).findAny().get(); + assertThat(indexFileHandler.readHashIndexList(indexManifestEntry.indexFile())) .containsExactlyInAnyOrder(1, 2, 5); - assertThat(part1Index.get(1).bucket()).isEqualTo(1); - assertThat(indexFileHandler.readHashIndexList(part1Index.get(1).indexFile())) + indexManifestEntry = + part1Index.stream().filter(entry -> entry.bucket() == 1).findAny().get(); + assertThat(indexFileHandler.readHashIndexList(indexManifestEntry.indexFile())) .containsExactlyInAnyOrder(6, 8); // assert part2 @@ -744,12 +746,14 @@ public void testIndexFiles() throws Exception { part1Index = indexFileHandler.scan(snapshot.id(), HASH_INDEX, part1); assertThat(part1Index.size()).isEqualTo(2); - assertThat(part1Index.get(0).bucket()).isEqualTo(0); - assertThat(indexFileHandler.readHashIndexList(part1Index.get(0).indexFile())) + indexManifestEntry = + part1Index.stream().filter(entry -> entry.bucket() == 0).findAny().get(); + assertThat(indexFileHandler.readHashIndexList(indexManifestEntry.indexFile())) .containsExactlyInAnyOrder(1, 4); - assertThat(part1Index.get(1).bucket()).isEqualTo(1); - assertThat(indexFileHandler.readHashIndexList(part1Index.get(1).indexFile())) + indexManifestEntry = + part1Index.stream().filter(entry -> entry.bucket() == 1).findAny().get(); + assertThat(indexFileHandler.readHashIndexList(indexManifestEntry.indexFile())) .containsExactlyInAnyOrder(6, 8); // assert scan one bucket