From fb062dfc9ae2ff644253829b6483bebd7dd92a26 Mon Sep 17 00:00:00 2001 From: Danny Chan Date: Tue, 28 Nov 2023 10:52:33 +0800 Subject: [PATCH] [Minor] Fix the flaky tests in TestRemoteHoodieTableFileSystemView (#10179) --- .../view/TestHoodieTableFileSystemView.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hudi-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java b/hudi-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java index 558dc59f40c9..2648d6e247d7 100644 --- a/hudi-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java +++ b/hudi-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java @@ -78,6 +78,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -365,15 +366,15 @@ public void testViewForGetAllFileGroupsStateless() throws Exception { fsView.sync(); // invokes the stateless API first then the normal API, assert the result equality with different file group objects - List actual1 = fsView.getAllFileGroupsStateless(partitionPath1).collect(Collectors.toList()); - List expected1 = fsView.getAllFileGroups(partitionPath1).collect(Collectors.toList()); + List actual1 = fsView.getAllFileGroupsStateless(partitionPath1).sorted(Comparator.comparing(HoodieFileGroup::getFileGroupId)).collect(Collectors.toList()); + List expected1 = fsView.getAllFileGroups(partitionPath1).sorted(Comparator.comparing(HoodieFileGroup::getFileGroupId)).collect(Collectors.toList()); for (int i = 0; i < expected1.size(); i++) { assertThat("The stateless API should return the same result", actual1.get(i).toString(), is(expected1.get(i).toString())); assertNotSame(actual1.get(i), expected1.get(i), "The stateless API does not cache"); } - List expected2 = fsView.getAllFileGroupsStateless(partitionPath2).collect(Collectors.toList()); - List actual2 = fsView.getAllFileGroups(partitionPath2).collect(Collectors.toList()); + List expected2 = fsView.getAllFileGroupsStateless(partitionPath2).sorted(Comparator.comparing(HoodieFileGroup::getFileGroupId)).collect(Collectors.toList()); + List actual2 = fsView.getAllFileGroups(partitionPath2).sorted(Comparator.comparing(HoodieFileGroup::getFileGroupId)).collect(Collectors.toList()); for (int i = 0; i < expected2.size(); i++) { assertThat("The stateless API should return the same result", actual2.get(i).toString(), is(expected2.get(i).toString())); assertNotSame(actual2.get(i), expected2.get(i), "The stateless API does not cache"); @@ -417,15 +418,15 @@ public void testViewForGetLatestFileSlicesStateless() throws Exception { fsView.sync(); // invokes the stateless API first then the normal API, assert the result equality with different file slice objects - List actual1 = fsView.getLatestFileSlicesStateless(partitionPath1).collect(Collectors.toList()); - List expected1 = fsView.getLatestFileSlices(partitionPath1).collect(Collectors.toList()); + List actual1 = fsView.getLatestFileSlicesStateless(partitionPath1).sorted(Comparator.comparing(FileSlice::getFileId)).collect(Collectors.toList()); + List expected1 = fsView.getLatestFileSlices(partitionPath1).sorted(Comparator.comparing(FileSlice::getFileId)).collect(Collectors.toList()); for (int i = 0; i < expected1.size(); i++) { assertThat("The stateless API should return the same result", actual1.get(i), is(expected1.get(i))); assertNotSame(actual1.get(i), expected1.get(i), "The stateless API does not cache"); } - List expected2 = fsView.getLatestFileSlicesStateless(partitionPath2).collect(Collectors.toList()); - List actual2 = fsView.getLatestFileSlices(partitionPath2).collect(Collectors.toList()); + List expected2 = fsView.getLatestFileSlicesStateless(partitionPath2).sorted(Comparator.comparing(FileSlice::getFileId)).collect(Collectors.toList()); + List actual2 = fsView.getLatestFileSlices(partitionPath2).sorted(Comparator.comparing(FileSlice::getFileId)).collect(Collectors.toList()); for (int i = 0; i < expected2.size(); i++) { assertThat("The stateless API should return the same result", actual2.get(i), is(expected2.get(i))); assertNotSame(actual2.get(i), expected2.get(i), "The stateless API does not cache");