Skip to content

Commit

Permalink
add regression test
Browse files Browse the repository at this point in the history
Change-Id: I37e080786b56f5a12c7eac3a84e9301de66c6812
  • Loading branch information
zxealous committed Dec 5, 2024
1 parent c271e6d commit 9790fe8
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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) {
Expand All @@ -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()) {
Expand All @@ -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}")
}
Expand Down

0 comments on commit 9790fe8

Please sign in to comment.