From 9790fe82a6c8817919776a179c1534b368aa59a0 Mon Sep 17 00:00:00 2001 From: zhouchangyue Date: Thu, 5 Dec 2024 13:23:40 +0800 Subject: [PATCH] add regression test Change-Id: I37e080786b56f5a12c7eac3a84e9301de66c6812 --- .../test_broker_load_with_partition.groovy | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/regression-test/suites/load_p0/broker_load/test_broker_load_with_partition.groovy b/regression-test/suites/load_p0/broker_load/test_broker_load_with_partition.groovy index 032b48baf6025ec..e20893a329e3119 100644 --- a/regression-test/suites/load_p0/broker_load/test_broker_load_with_partition.groovy +++ b/regression-test/suites/load_p0/broker_load/test_broker_load_with_partition.groovy @@ -54,6 +54,13 @@ suite("test_broker_load_with_partition", "load_p0") { assertTrue(result2.size() == 1) assertTrue(result2[0].size() == 1) assertTrue(result2[0][0] == 1, "Insert should update 1 rows") + + def result3 = sql """ + ALTER TABLE ${testTable} ADD TEMPORARY PARTITION tmp202309 VALUES LESS THAN ("2023-10-01"); + """ + assertTrue(result3.size() == 1) + assertTrue(result3[0].size() == 1) + assertTrue(result3[0][0] == 0, "Alter table should update 0 rows") } def load_from_hdfs_partition = {testTablex, label, hdfsFilePath, format, brokerName, hdfsUser, hdfsPasswd -> @@ -78,6 +85,28 @@ suite("test_broker_load_with_partition", "load_p0") { assertTrue(result1[0][0] == 0, "Query OK, 0 rows affected") } + def load_from_hdfs_temporary_partition = {testTablex, label, hdfsFilePath, format, brokerName, hdfsUser, hdfsPasswd -> + def result1= sql """ + LOAD LABEL ${label} ( + DATA INFILE("${hdfsFilePath}") + INTO TABLE ${testTablex} + TEMPORARY PARTITION (`tmp202309`) + COLUMNS TERMINATED BY "," + FORMAT as "${format}" + ) + with BROKER "${brokerName}" ( + "username"="${hdfsUser}", + "password"="${hdfsPasswd}") + PROPERTIES ( + "timeout"="1200", + "max_filter_ratio"="0.1"); + """ + + assertTrue(result1.size() == 1) + assertTrue(result1[0].size() == 1) + assertTrue(result1[0][0] == 0, "Query OK, 0 rows affected") + } + def check_load_result = {checklabel, testTablex -> max_try_milli_secs = 10000 while(max_try_milli_secs) { @@ -97,6 +126,25 @@ suite("test_broker_load_with_partition", "load_p0") { } } + def check_load_temporary_partition_result = {checklabel, testTablex -> + max_try_milli_secs = 10000 + while(max_try_milli_secs) { + result = sql "show load where label = '${checklabel}'" + log.info("result: ${result}") + if(result[0][2] == "FINISHED") { + //sql "sync" + qt_select "select * from ${testTablex} TEMPORARY PARTITION (`tmp202309`) order by k1" + break + } else { + sleep(1000) // wait 1 second every time + max_try_milli_secs -= 1000 + if(max_try_milli_secs <= 0) { + assertEquals(1, 2) + } + } + } + } + // if 'enableHdfs' in regression-conf.groovy has been set to true, // the test will run these case as below. if (enableHdfs()) { @@ -115,6 +163,12 @@ suite("test_broker_load_with_partition", "load_p0") { brokerName, hdfsUser, hdfsPasswd) check_load_result.call(test_load_label, testTable) + + def test_tmp_partition_load_label = UUID.randomUUID().toString().replaceAll("-", "") + load_from_hdfs_temporary_partition.call(testTable, test_tmp_partition_load_label, + hdfs_csv_file_path, "csv", brokerName, hdfsUser, hdfsPasswd) + + check_load_temporary_partition_result.call(test_tmp_partition_load_label, testTable) } finally { try_sql("DROP TABLE IF EXISTS ${testTable}") }