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 974eea97665b..1715a18a0f02 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.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 void extractInsertRecord() throws Exception { } } - @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 9d29b0d99270..e6fe6b9870d6 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 @@ private static void setup() { 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 void start() { 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 void stop() throws Exception { 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 2dbed21acfbe..92ca7804bc14 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 void testMigrateOneNonPartitionedTable() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -251,7 +252,7 @@ public void testCloneWithTimestamp() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -325,7 +326,7 @@ public void testMigrateOnePartitionedTableImpl(boolean specificFilter) throws Ex "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -407,7 +408,7 @@ public void testMigrateOnePartitionedTableAndFilterNoPartition() throws Exceptio "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -471,7 +472,7 @@ public void testMigrateWholeDatabase() throws Exception { "--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 void testMigrateWholeDatabaseWithFilter() throws Exception { "--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 void testCloneWithExistedTable() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -650,7 +651,7 @@ public void testCloneWithNotExistedDatabase() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -729,7 +730,7 @@ public void testMigrateWholeCatalogWithExcludedTables() throws Exception { "--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 void testMigrateWholeCatalogWithIncludedTables() throws Exception { "--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 void testMigrateCsvTable() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -932,7 +933,7 @@ public void testMigrateJsonTable() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -993,7 +994,7 @@ public void testMigrateWithPreferFileFormat() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -1052,7 +1053,7 @@ public void testMigrateWithMetaOnly() throws Exception { "--catalog_conf", "metastore=hive", "--catalog_conf", - "uri=thrift://localhost:" + PORT, + "uri=thrift://localhost:" + port, "--target_database", "test", "--target_table", @@ -1108,7 +1109,7 @@ public void testCloneIfExistsEqualsFalse() throws Exception { "--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 65f62841c953..3d1ee6f384ee 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 void testMigrateDatabaseProcedure(String format, boolean isNamedArgument) 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 void testUpgradePartitionTable(String format, boolean isNamedArgument) th 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 void testUpgradeNonPartitionTable(String format, boolean isNamedArgument) 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 void testMigrateDatabaseAction(String format, boolean forceStartFlinkJob) Map 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 void testMigrateDatabaseAction(String format, boolean forceStartFlinkJob) 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 2ce9ede85782..ea5c4112f39d 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 void test(String format) throws Exception { 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 void testMigrateFileAction(String format) throws Exception { 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 91af09f1dc59..03f8918181ef 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 void testMigrateProcedure(String format) throws Exception { 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 void testUpgradePartitionTable(String format) throws Exception { 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 void testUpgradeNonPartitionTable(String format) throws Exception { 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 void testMigrateAction(String format, boolean forceStartFlinkJob) throws List r1 = ImmutableList.copyOf(tEnv.executeSql("SELECT * FROM hivetable").collect()); Map 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 void testMigrateAction(String format, boolean forceStartFlinkJob) throws 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 aaff92c55756..7f4afe3478f4 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 void testRepairTableAction(boolean forceStartFlinkJob) throws Exception { 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 void testRepairTableAction(boolean forceStartFlinkJob) throws Exception { tEnv.executeSql("INSERT INTO t_repair_hive VALUES(1, 'login', '2020-01-02', '09')").await(); Map 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 f71e5df3c08f..b6640884ff2d 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 @@ 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 @@ private SparkSession.Builder createSessionBuilder() { .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 af457ac63fe5..6b183cdc62ee 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 @@ 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 @@ private SparkSession.Builder createSparkSessionBuilder(Path warehousePath) { .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 void testChainTableWithGroupPartition(@TempDir java.nio.file.Path tempDir .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 void testHourlyChainTableWithGroupPartition(@TempDir java.nio.file.Path t .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 void testChainTableWithMultiGroupPartition(@TempDir java.nio.file.Path te .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 a8af1c10e6e3..d9a8c6c71164 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 @@ 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 @@ private SparkSession.Builder createSparkSessionBuilder(Path warehousePath) { .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 void testDataEvolution(@TempDir java.nio.file.Path tempDir) throws IOExce .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 8fc7d603b1eb..6166d257fc12 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 @@ 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 @@ private SparkSession.Builder createSparkSessionBuilder(Path warehousePath) { .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(