Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -145,7 +148,6 @@ public void extractInsertRecord() throws Exception {
}
}

@Ignore // TODO unstable test
@Test
public void extractUpdateRecord() throws Exception {
AliyunRecordParser parser =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
+ "')");
Expand Down Expand Up @@ -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)
+ "')");
Expand Down Expand Up @@ -250,7 +252,7 @@ public void testMigrateDatabaseAction(String format, boolean forceStartFlinkJob)

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 =
Expand All @@ -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)
+ "')");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
+ "')");
Expand Down Expand Up @@ -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)
+ "')");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
+ "')");
Expand Down Expand Up @@ -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)
+ "')");
Expand Down Expand Up @@ -169,7 +171,7 @@ public void testMigrateAction(String format, boolean forceStartFlinkJob) throws
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 =
Expand All @@ -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)
+ "')");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
+ "')");
Expand All @@ -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<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);
Expand Down
Loading
Loading