This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new bc41e7163a [test] fix unstable test for weighted external-path (#7387)
bc41e7163a is described below
commit bc41e7163a69bc9ddb380bf6c94ac88d0d1bd7b3
Author: LsomeYeah <[email protected]>
AuthorDate: Tue Mar 10 12:00:45 2026 +0800
[test] fix unstable test for weighted external-path (#7387)
---
.../fs/WeightedExternalPathProviderTest.java | 18 +++++++--------
.../apache/paimon/flink/AppendOnlyTableITCase.java | 26 +++++++++++++---------
.../flink/PrimaryKeyFileStoreTableITCase.java | 20 ++++++++++-------
3 files changed, 36 insertions(+), 28 deletions(-)
diff --git
a/paimon-common/src/test/java/org/apache/paimon/fs/WeightedExternalPathProviderTest.java
b/paimon-common/src/test/java/org/apache/paimon/fs/WeightedExternalPathProviderTest.java
index 9d9ffb751b..11868cc629 100644
---
a/paimon-common/src/test/java/org/apache/paimon/fs/WeightedExternalPathProviderTest.java
+++
b/paimon-common/src/test/java/org/apache/paimon/fs/WeightedExternalPathProviderTest.java
@@ -37,35 +37,35 @@ public class WeightedExternalPathProviderTest {
@Test
public void testEqualWeights() {
- int fileNum = 3000;
+ int fileNum = 30000;
int[] weights = {10, 10, 10};
Map<String, Integer> pathCounts = generatePaths(fileNum, weights);
int expectedCount = fileNum / 3;
for (int count : pathCounts.values()) {
- assertThat(count).isBetween(expectedCount - 100, expectedCount +
100);
+ assertThat(count).isBetween(expectedCount - 1000, expectedCount +
1000);
}
}
@Test
public void testDifferentWeights() {
int[] weights = {10, 5, 15};
- int fileNum = 3000;
+ int fileNum = 30000;
Map<String, Integer> pathCounts = generatePaths(fileNum, weights);
int totalWeight = 30;
assertThat(pathCounts.get("s3://bucket1/data"))
.isBetween(
- (int) (fileNum * 10.0 / totalWeight) - 100,
- (int) (fileNum * 10.0 / totalWeight) + 100);
+ (int) (fileNum * 10.0 / totalWeight) - 1000,
+ (int) (fileNum * 10.0 / totalWeight) + 1000);
assertThat(pathCounts.get("oss://bucket2/data"))
.isBetween(
- (int) (fileNum * 5.0 / totalWeight) - 100,
- (int) (fileNum * 5.0 / totalWeight) + 100);
+ (int) (fileNum * 5.0 / totalWeight) - 1000,
+ (int) (fileNum * 5.0 / totalWeight) + 1000);
assertThat(pathCounts.get("hdfs://namenode/data"))
.isBetween(
- (int) (fileNum * 15.0 / totalWeight) - 100,
- (int) (fileNum * 15.0 / totalWeight) + 100);
+ (int) (fileNum * 15.0 / totalWeight) - 1000,
+ (int) (fileNum * 15.0 / totalWeight) + 1000);
}
@Test
diff --git
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/AppendOnlyTableITCase.java
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/AppendOnlyTableITCase.java
index 13e0825f69..9c1796fcf4 100644
---
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/AppendOnlyTableITCase.java
+++
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/AppendOnlyTableITCase.java
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
@@ -248,7 +249,7 @@ public class AppendOnlyTableITCase extends
CatalogITCaseBase {
+ "'write-only' = 'true'"
+ ")");
- int fileNum = 50;
+ int fileNum = 30;
for (int i = 1; i <= fileNum; i++) {
batchSql("INSERT INTO append_table VALUES (" + i + ", 'AAA')");
}
@@ -256,18 +257,21 @@ public class AppendOnlyTableITCase extends
CatalogITCaseBase {
List<Row> rows = batchSql("SELECT * FROM append_table");
assertThat(rows.size()).isEqualTo(fileNum);
- // Verify file distribution based on weights
- long filesInPath1 =
- Files.list(Paths.get(tempExternalPath1.toString() +
"/bucket-0")).count();
- long filesInPath2 =
- Files.list(Paths.get(tempExternalPath2.toString() +
"/bucket-0")).count();
+ long filesInPath1 = 0;
+ long filesInPath2 = 0;
+ try {
+ filesInPath1 =
+ Files.list(Paths.get(tempExternalPath1.toString() +
"/bucket-0")).count();
+ filesInPath2 =
+ Files.list(Paths.get(tempExternalPath2.toString() +
"/bucket-0")).count();
+
+ } catch (NoSuchFileException ignored) {
+ }
+
long totalFiles = filesInPath1 + filesInPath2;
- // Since the file sample size is small in IT case, we only verify that
higher-weighted path
- // has more files
- assertThat(filesInPath1).isGreaterThan(0);
- assertThat(filesInPath2).isGreaterThan(0);
- assertThat(filesInPath2).isGreaterThan(filesInPath1);
+ // Since the file sample size is small in IT case, we only verify the
writing and reading
+ // For tests on file distribution by weights, see
WeightedExternalPathProviderTest
assertThat(totalFiles).isEqualTo(fileNum);
}
diff --git
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java
index 5883c51716..06afcce3bb 100644
---
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java
+++
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PrimaryKeyFileStoreTableITCase.java
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
@@ -340,7 +341,7 @@ public class PrimaryKeyFileStoreTableITCase extends
AbstractTestBase {
CloseableIterator<Row> it = collect(sEnv.executeSql("SELECT * FROM
T2"));
- int fileNum = 50;
+ int fileNum = 30;
for (int i = 1; i <= fileNum; i++) {
sEnv.executeSql("INSERT INTO T2 VALUES (" + i + ", 'data" + i +
"')").await();
}
@@ -352,15 +353,18 @@ public class PrimaryKeyFileStoreTableITCase extends
AbstractTestBase {
// Verify all data is readable
assertThat(actual).hasSize(fileNum);
- long filesInPath1 = Files.list(Paths.get(externalPath1.toString() +
"/bucket-0")).count();
- long filesInPath2 = Files.list(Paths.get(externalPath2.toString() +
"/bucket-0")).count();
+ long filesInPath1 = 0;
+ long filesInPath2 = 0;
+ try {
+ filesInPath1 = Files.list(Paths.get(externalPath1.toString() +
"/bucket-0")).count();
+ filesInPath2 = Files.list(Paths.get(externalPath2.toString() +
"/bucket-0")).count();
+
+ } catch (NoSuchFileException ignored) {
+ }
long totalFiles = filesInPath1 + filesInPath2;
- // Since the file sample size is small in IT case, we only verify that
higher-weighted path
- // has more files
- assertThat(filesInPath1).isGreaterThan(0);
- assertThat(filesInPath2).isGreaterThan(0);
- assertThat(filesInPath1).isGreaterThan(filesInPath2);
+ // Since the file sample size is small in IT case, we only verify the
writing and reading
+ // For tests on file distribution by weights, see
WeightedExternalPathProviderTest
assertThat(totalFiles).isEqualTo(fileNum);
}