This is an automated email from the ASF dual-hosted git repository.

JingsongLi 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 9f0e06d0b8 [test] Fix unstable tests (#8820)
9f0e06d0b8 is described below

commit 9f0e06d0b8c906aa106293f326a53d2e7fde1516
Author: Juntao Zhang <[email protected]>
AuthorDate: Thu Jul 23 23:11:47 2026 +0800

    [test] Fix unstable tests (#8820)
---
 .../format/aliyun/AliyunJsonRecordParserTest.java  |  8 +++--
 .../org/apache/paimon/hive/TestHiveMetastore.java  |  7 ++++-
 .../paimon/hive/procedure/CloneActionITCase.java   | 35 +++++++++++-----------
 .../procedure/MigrateDatabaseProcedureITCase.java  | 16 +++++-----
 .../hive/procedure/MigrateFileProcedureITCase.java |  9 +++---
 .../procedure/MigrateTableProcedureITCase.java     | 16 +++++-----
 .../paimon/hive/procedure/RepairActionITCase.java  |  9 +++---
 .../paimon/spark/SparkCatalogWithHiveTest.java     |  9 +++---
 .../apache/paimon/spark/SparkChainTableITCase.java | 21 ++++++-------
 .../paimon/spark/SparkDataEvolutionITCase.java     | 13 ++++----
 .../apache/paimon/spark/SparkMultimodalITCase.java |  9 +++---
 11 files changed, 85 insertions(+), 67 deletions(-)

diff --git 
a/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/format/aliyun/AliyunJsonRecordParserTest.java
 
b/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/format/aliyun/AliyunJsonRecordParserTest.java
index 974eea9766..1715a18a0f 100644
--- 
a/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/format/aliyun/AliyunJsonRecordParserTest.java
+++ 
b/paimon-flink/paimon-flink-cdc/src/test/java/org/apache/paimon/flink/action/cdc/format/aliyun/AliyunJsonRecordParserTest.java
@@ -35,7 +35,6 @@ import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
 import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,7 +63,11 @@ public class AliyunJsonRecordParserTest extends 
KafkaActionITCaseBase {
 
     private static ObjectMapper objMapper = new ObjectMapper();
 
-    String dateTimeRegex = 
"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}";
+    // now() generates a timestamp with millisecond precision. 
LocalDateTime.toString() omits the
+    // whole :ss part when both seconds and milliseconds are zero (e.g. 
2026-07-23T12:34), omits
+    // .mmm when milliseconds are zero (e.g. ...:12:34:56), and keeps .mmm 
otherwise.
+    // Match all three forms: HH:mm, HH:mm:ss, HH:mm:ss.SSS.
+    String dateTimeRegex = 
"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{3})?)?";
 
     @Before
     public void setup() {
@@ -145,7 +148,6 @@ public class AliyunJsonRecordParserTest extends 
KafkaActionITCaseBase {
         }
     }
 
-    @Ignore // TODO unstable test
     @Test
     public void extractUpdateRecord() throws Exception {
         AliyunRecordParser parser =
diff --git 
a/paimon-hive/paimon-hive-common/src/test/java/org/apache/paimon/hive/TestHiveMetastore.java
 
b/paimon-hive/paimon-hive-common/src/test/java/org/apache/paimon/hive/TestHiveMetastore.java
index 9d29b0d992..e6fe6b9870 100644
--- 
a/paimon-hive/paimon-hive-common/src/test/java/org/apache/paimon/hive/TestHiveMetastore.java
+++ 
b/paimon-hive/paimon-hive-common/src/test/java/org/apache/paimon/hive/TestHiveMetastore.java
@@ -114,6 +114,7 @@ public class TestHiveMetastore {
     private ExecutorService executorService;
     private TServer server;
     private HiveMetaStore.HMSHandler baseHandler;
+    private int port;
 
     public void start(Configuration configuration, int port) {
         start(configuration, DEFAULT_POOL_SIZE, port);
@@ -144,7 +145,7 @@ public class TestHiveMetastore {
     public void start(Configuration conf, int poolSize, int portNum) {
         try {
             TServerSocket socket = new TServerSocket(portNum);
-            int port = socket.getServerSocket().getLocalPort();
+            this.port = socket.getServerSocket().getLocalPort();
             this.hiveConf = initConf(conf, port);
             this.server = newThriftServer(socket, poolSize, hiveConf);
             this.executorService = Executors.newSingleThreadExecutor();
@@ -177,6 +178,10 @@ public class TestHiveMetastore {
         System.clearProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname);
     }
 
+    public int getPort() {
+        return port;
+    }
+
     public void reset() throws Exception {
         setup();
         Path warehouseRoot = new Path(hiveLocalDir.getAbsolutePath());
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/CloneActionITCase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/CloneActionITCase.java
index 2dbed21acf..92ca7804bc 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/CloneActionITCase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/CloneActionITCase.java
@@ -63,11 +63,12 @@ public class CloneActionITCase extends ActionITCaseBase {
 
     private static final TestHiveMetastore TEST_HIVE_METASTORE = new 
TestHiveMetastore();
 
-    private static final int PORT = 9088;
+    private static int port;
 
     @BeforeAll
     public static void beforeAll() {
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     @AfterAll
@@ -198,7 +199,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_database",
                         "test",
                         "--target_table",
@@ -251,7 +252,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_database",
                         "test",
                         "--target_table",
@@ -325,7 +326,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -407,7 +408,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_database",
                         "test",
                         "--target_table",
@@ -471,7 +472,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_database",
                         "test",
                         "--target_catalog_conf",
@@ -531,7 +532,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_database",
                         "test",
                         "--target_catalog_conf",
@@ -590,7 +591,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -650,7 +651,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -729,7 +730,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_catalog_conf",
                         "warehouse=" + warehouse,
                         "--excluded_tables",
@@ -810,7 +811,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                         "--catalog_conf",
                         "metastore=hive",
                         "--catalog_conf",
-                        "uri=thrift://localhost:" + PORT,
+                        "uri=thrift://localhost:" + port,
                         "--target_catalog_conf",
                         "warehouse=" + warehouse,
                         "--included_tables",
@@ -872,7 +873,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -932,7 +933,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -993,7 +994,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -1052,7 +1053,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
@@ -1108,7 +1109,7 @@ public class CloneActionITCase extends ActionITCaseBase {
                                 "--catalog_conf",
                                 "metastore=hive",
                                 "--catalog_conf",
-                                "uri=thrift://localhost:" + PORT,
+                                "uri=thrift://localhost:" + port,
                                 "--target_database",
                                 "test",
                                 "--target_table",
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateDatabaseProcedureITCase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateDatabaseProcedureITCase.java
index 65f62841c9..3d1ee6f384 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateDatabaseProcedureITCase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateDatabaseProcedureITCase.java
@@ -48,11 +48,12 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
 
     private static final TestHiveMetastore TEST_HIVE_METASTORE = new 
TestHiveMetastore();
 
-    private static final int PORT = 9086;
+    private static int port;
 
     @BeforeEach
     public void beforeEach() {
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     @AfterEach
@@ -82,7 +83,8 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
     private void resetMetastore() throws Exception {
         TEST_HIVE_METASTORE.stop();
         TEST_HIVE_METASTORE.reset();
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     public void testUpgradePartitionTable(String format, boolean 
isNamedArgument) throws Exception {
@@ -120,7 +122,7 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -183,7 +185,7 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -250,7 +252,7 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
 
         Map<String, String> catalogConf = new HashMap<>();
         catalogConf.put("metastore", "hive");
-        catalogConf.put("uri", "thrift://localhost:" + PORT);
+        catalogConf.put("uri", "thrift://localhost:" + port);
         catalogConf.put(
                 "warehouse", 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname));
         MigrateDatabaseAction migrateDatabaseAction =
@@ -260,7 +262,7 @@ public class MigrateDatabaseProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateFileProcedureITCase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateFileProcedureITCase.java
index 2ce9ede857..ea5c4112f3 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateFileProcedureITCase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateFileProcedureITCase.java
@@ -43,11 +43,12 @@ public class MigrateFileProcedureITCase extends 
ActionITCaseBase {
 
     private static final TestHiveMetastore TEST_HIVE_METASTORE = new 
TestHiveMetastore();
 
-    private static final int PORT = 9085;
+    private static int port;
 
     @BeforeEach
     public void beforeEach() {
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     @AfterEach
@@ -84,7 +85,7 @@ public class MigrateFileProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -122,7 +123,7 @@ public class MigrateFileProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateTableProcedureITCase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateTableProcedureITCase.java
index 91af09f1dc..03f8918181 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateTableProcedureITCase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/MigrateTableProcedureITCase.java
@@ -46,11 +46,12 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
 
     private static final TestHiveMetastore TEST_HIVE_METASTORE = new 
TestHiveMetastore();
 
-    private static final int PORT = 9084;
+    private static int port;
 
     @BeforeEach
     public void beforeEach() {
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     @AfterEach
@@ -83,7 +84,8 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
     private void resetMetastore() throws Exception {
         TEST_HIVE_METASTORE.stop();
         TEST_HIVE_METASTORE.reset();
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     public void testUpgradePartitionTable(String format) throws Exception {
@@ -104,7 +106,7 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -135,7 +137,7 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -169,7 +171,7 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
         List<Row> r1 = ImmutableList.copyOf(tEnv.executeSql("SELECT * FROM 
hivetable").collect());
         Map<String, String> catalogConf = new HashMap<>();
         catalogConf.put("metastore", "hive");
-        catalogConf.put("uri", "thrift://localhost:" + PORT);
+        catalogConf.put("uri", "thrift://localhost:" + port);
         catalogConf.put(
                 "warehouse", 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname));
         MigrateTableAction migrateTableAction =
@@ -179,7 +181,7 @@ public class MigrateTableProcedureITCase extends 
ActionITCaseBase {
 
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/RepairActionITCase.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/RepairActionITCase.java
index aaff92c557..7f4afe3478 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/RepairActionITCase.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/procedure/RepairActionITCase.java
@@ -43,11 +43,12 @@ public class RepairActionITCase extends ActionITCaseBase {
 
     private static final TestHiveMetastore TEST_HIVE_METASTORE = new 
TestHiveMetastore();
 
-    private static final int PORT = 9082;
+    private static int port;
 
     @BeforeEach
     public void beforeEach() {
-        TEST_HIVE_METASTORE.start(PORT);
+        TEST_HIVE_METASTORE.start(0);
+        port = TEST_HIVE_METASTORE.getPort();
     }
 
     @AfterEach
@@ -61,7 +62,7 @@ public class RepairActionITCase extends ActionITCaseBase {
         TableEnvironment tEnv = tableEnvironmentBuilder().batchMode().build();
         tEnv.executeSql(
                 "CREATE CATALOG PAIMON WITH ('type'='paimon', 'metastore' = 
'hive', 'uri' = 'thrift://localhost:"
-                        + PORT
+                        + port
                         + "' , 'warehouse' = '"
                         + 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname)
                         + "')");
@@ -84,7 +85,7 @@ public class RepairActionITCase extends ActionITCaseBase {
         tEnv.executeSql("INSERT INTO t_repair_hive VALUES(1, 'login', 
'2020-01-02', '09')").await();
         Map<String, String> catalogConf = new HashMap<>();
         catalogConf.put("metastore", "hive");
-        catalogConf.put("uri", "thrift://localhost:" + PORT);
+        catalogConf.put("uri", "thrift://localhost:" + port);
         catalogConf.put(
                 "warehouse", 
System.getProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname));
         RepairAction repairAction = new RepairAction("test_db.t_repair_hive", 
catalogConf);
diff --git 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkCatalogWithHiveTest.java
 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkCatalogWithHiveTest.java
index f71e5df3c0..b6640884ff 100644
--- 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkCatalogWithHiveTest.java
+++ 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkCatalogWithHiveTest.java
@@ -42,13 +42,14 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 public class SparkCatalogWithHiveTest {
 
     private static TestHiveMetastore testHiveMetastore;
-    private static final int PORT = 9087;
+    private static int port;
     @TempDir java.nio.file.Path tempDir;
 
     @BeforeAll
     public static void startMetastore() {
         testHiveMetastore = new TestHiveMetastore();
-        testHiveMetastore.start(PORT);
+        testHiveMetastore.start(0);
+        port = testHiveMetastore.getPort();
     }
 
     @AfterAll
@@ -186,12 +187,12 @@ public class SparkCatalogWithHiveTest {
                 .config("spark.sql.warehouse.dir", warehousePath.toString())
                 // with hive metastore
                 .config("spark.sql.catalogImplementation", "hive")
-                .config("hive.metastore.uris", "thrift://localhost:" + PORT)
+                .config("hive.metastore.uris", "thrift://localhost:" + port)
                 .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                 .config("spark.sql.catalog.spark_catalog.metastore", "hive")
                 .config(
                         "spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                        "thrift://localhost:" + PORT)
+                        "thrift://localhost:" + port)
                 .config("spark.sql.catalog.spark_catalog.warehouse", 
warehousePath.toString())
                 .config(
                         "spark.sql.extensions",
diff --git 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkChainTableITCase.java
 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkChainTableITCase.java
index af457ac63f..6b183cdc62 100644
--- 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkChainTableITCase.java
+++ 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkChainTableITCase.java
@@ -40,12 +40,13 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 public class SparkChainTableITCase {
 
     private static TestHiveMetastore testHiveMetastore;
-    private static final int PORT = 9091;
+    private static int port;
 
     @BeforeAll
     public static void startMetastore() {
         testHiveMetastore = new TestHiveMetastore();
-        testHiveMetastore.start(PORT);
+        testHiveMetastore.start(0);
+        port = testHiveMetastore.getPort();
     }
 
     @AfterAll
@@ -58,12 +59,12 @@ public class SparkChainTableITCase {
                 .config("spark.sql.warehouse.dir", warehousePath.toString())
                 // with hive metastore
                 .config("spark.sql.catalogImplementation", "hive")
-                .config("hive.metastore.uris", "thrift://localhost:" + PORT)
+                .config("hive.metastore.uris", "thrift://localhost:" + port)
                 .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                 .config("spark.sql.catalog.spark_catalog.metastore", "hive")
                 .config(
                         "spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                        "thrift://localhost:" + PORT)
+                        "thrift://localhost:" + port)
                 
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                 .config("spark.sql.catalog.spark_catalog.warehouse", 
warehousePath.toString())
                 .config(
@@ -852,12 +853,12 @@ public class SparkChainTableITCase {
                         .config("spark.sql.warehouse.dir", 
warehousePath.toString())
                         // with hive metastore
                         .config("spark.sql.catalogImplementation", "hive")
-                        .config("hive.metastore.uris", "thrift://localhost:" + 
PORT)
+                        .config("hive.metastore.uris", "thrift://localhost:" + 
port)
                         .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                         .config("spark.sql.catalog.spark_catalog.metastore", 
"hive")
                         .config(
                                 
"spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                                "thrift://localhost:" + PORT)
+                                "thrift://localhost:" + port)
                         
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                         .config(
                                 "spark.sql.catalog.spark_catalog.warehouse",
@@ -1284,12 +1285,12 @@ public class SparkChainTableITCase {
                         .config("spark.sql.warehouse.dir", 
warehousePath.toString())
                         // with hive metastore
                         .config("spark.sql.catalogImplementation", "hive")
-                        .config("hive.metastore.uris", "thrift://localhost:" + 
PORT)
+                        .config("hive.metastore.uris", "thrift://localhost:" + 
port)
                         .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                         .config("spark.sql.catalog.spark_catalog.metastore", 
"hive")
                         .config(
                                 
"spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                                "thrift://localhost:" + PORT)
+                                "thrift://localhost:" + port)
                         
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                         .config(
                                 "spark.sql.catalog.spark_catalog.warehouse",
@@ -1741,12 +1742,12 @@ public class SparkChainTableITCase {
                         .config("spark.sql.warehouse.dir", 
warehousePath.toString())
                         // with hive metastore
                         .config("spark.sql.catalogImplementation", "hive")
-                        .config("hive.metastore.uris", "thrift://localhost:" + 
PORT)
+                        .config("hive.metastore.uris", "thrift://localhost:" + 
port)
                         .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                         .config("spark.sql.catalog.spark_catalog.metastore", 
"hive")
                         .config(
                                 
"spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                                "thrift://localhost:" + PORT)
+                                "thrift://localhost:" + port)
                         
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                         .config(
                                 "spark.sql.catalog.spark_catalog.warehouse",
diff --git 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkDataEvolutionITCase.java
 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkDataEvolutionITCase.java
index a8af1c10e6..d9a8c6c711 100644
--- 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkDataEvolutionITCase.java
+++ 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkDataEvolutionITCase.java
@@ -37,12 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class SparkDataEvolutionITCase {
 
     private static TestHiveMetastore testHiveMetastore;
-    private static final int PORT = 9094;
+    private static int port;
 
     @BeforeAll
     public static void startMetastore() {
         testHiveMetastore = new TestHiveMetastore();
-        testHiveMetastore.start(PORT);
+        testHiveMetastore.start(0);
+        port = testHiveMetastore.getPort();
     }
 
     @AfterAll
@@ -55,12 +56,12 @@ public class SparkDataEvolutionITCase {
                 .config("spark.sql.warehouse.dir", warehousePath.toString())
                 // with hive metastore
                 .config("spark.sql.catalogImplementation", "hive")
-                .config("hive.metastore.uris", "thrift://localhost:" + PORT)
+                .config("hive.metastore.uris", "thrift://localhost:" + port)
                 .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                 .config("spark.sql.catalog.spark_catalog.metastore", "hive")
                 .config(
                         "spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                        "thrift://localhost:" + PORT)
+                        "thrift://localhost:" + port)
                 
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                 .config("spark.sql.catalog.spark_catalog.warehouse", 
warehousePath.toString())
                 .config(
@@ -77,12 +78,12 @@ public class SparkDataEvolutionITCase {
                         .config("spark.sql.warehouse.dir", 
warehousePath.toString())
                         // with hive metastore
                         .config("spark.sql.catalogImplementation", "hive")
-                        .config("hive.metastore.uris", "thrift://localhost:" + 
PORT)
+                        .config("hive.metastore.uris", "thrift://localhost:" + 
port)
                         .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                         .config("spark.sql.catalog.spark_catalog.metastore", 
"hive")
                         .config(
                                 
"spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                                "thrift://localhost:" + PORT)
+                                "thrift://localhost:" + port)
                         
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                         .config(
                                 "spark.sql.catalog.spark_catalog.warehouse",
diff --git 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkMultimodalITCase.java
 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkMultimodalITCase.java
index 8fc7d603b1..6166d257fc 100644
--- 
a/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkMultimodalITCase.java
+++ 
b/paimon-spark/paimon-spark-ut/src/test/java/org/apache/paimon/spark/SparkMultimodalITCase.java
@@ -41,12 +41,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class SparkMultimodalITCase {
 
     private static TestHiveMetastore testHiveMetastore;
-    private static final int PORT = 9092;
+    private static int port;
 
     @BeforeAll
     public static void startMetastore() {
         testHiveMetastore = new TestHiveMetastore();
-        testHiveMetastore.start(PORT);
+        testHiveMetastore.start(0);
+        port = testHiveMetastore.getPort();
     }
 
     @AfterAll
@@ -59,12 +60,12 @@ public class SparkMultimodalITCase {
                 .config("spark.sql.warehouse.dir", warehousePath.toString())
                 // with hive metastore
                 .config("spark.sql.catalogImplementation", "hive")
-                .config("hive.metastore.uris", "thrift://localhost:" + PORT)
+                .config("hive.metastore.uris", "thrift://localhost:" + port)
                 .config("spark.sql.catalog.spark_catalog", 
SparkCatalog.class.getName())
                 .config("spark.sql.catalog.spark_catalog.metastore", "hive")
                 .config(
                         "spark.sql.catalog.spark_catalog.hive.metastore.uris",
-                        "thrift://localhost:" + PORT)
+                        "thrift://localhost:" + port)
                 
.config("spark.sql.catalog.spark_catalog.format-table.enabled", "true")
                 .config("spark.sql.catalog.spark_catalog.warehouse", 
warehousePath.toString())
                 .config(


Reply via email to