Skip to content

Commit

Permalink
[fix](mv) Fix test create table like test unstable (apache#39305)
Browse files Browse the repository at this point in the history
ddl_p0/test_create_table_like_nereids.groovy test result is unstable.
Should wait util rollup join finished then we can compare the explain
rollup result.
  • Loading branch information
seawinde committed Aug 28, 2024
1 parent ddf72ce commit a119d1c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,39 @@ class Suite implements GroovyInterceptable {
}
}

def getMVJobState = { tableName, limit ->
def jobStateResult = sql """ SHOW ALTER TABLE ROLLUP WHERE TableName='${tableName}' ORDER BY CreateTime DESC limit ${limit}"""
if (jobStateResult.size() != limit) {
logger.info("show alter table roll is empty" + jobStateResult)
return "NOT_READY"
}
for (int i = 0; i < jobStateResult.size(); i++) {
logger.info("getMVJobState is " + jobStateResult[i][8])
if (!jobStateResult[i][8].equals("FINISHED")) {
return "NOT_READY"
}
}
return "FINISHED";
}
def waitForRollUpJob = (tbName, timeoutMillisecond, limit) -> {

long startTime = System.currentTimeMillis()
long timeoutTimestamp = startTime + timeoutMillisecond

String result
// time out or has run exceed 10 minute, then break
while (timeoutTimestamp > System.currentTimeMillis() && System.currentTimeMillis() - startTime < 600000){
result = getMVJobState(tbName, limit)
if (result == "FINISHED") {
sleep(200)
return
} else {
sleep(200)
}
}
Assert.assertEquals("FINISHED", result)
}

String getJobName(String dbName, String mtmvName) {
String showMTMV = "select JobName from mv_infos('database'='${dbName}') where Name = '${mtmvName}'";
logger.info(showMTMV)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ suite("test_create_table_like_nereids") {
// with all rollup
sql "drop table if exists table_like_with_roll_up"
sql "CREATE TABLE table_like_with_roll_up LIKE mal_test_create_table_like with rollup;"
waitForRollUpJob("mal_test_create_table_like", 5000, 2)
explain {
sql ("select sum(a) from table_like_with_roll_up group by a")
contains "ru1"
Expand All @@ -60,6 +61,7 @@ suite("test_create_table_like_nereids") {
// with partial rollup
sql "drop table if exists table_like_with_partial_roll_up;"
sql "CREATE TABLE table_like_with_partial_roll_up LIKE mal_test_create_table_like with rollup (ru1);"
waitForRollUpJob("mal_test_create_table_like", 5000, 2)
sql "select * from table_like_with_partial_roll_up order by pk, a, b"
explain {
sql("select sum(a) from table_like_with_partial_roll_up group by a")
Expand All @@ -79,6 +81,7 @@ suite("test_create_table_like_nereids") {
sql "drop table if exists table_like_with_partial_roll_up_exists"
sql """CREATE TABLE if not exists table_like_with_partial_roll_up_exists
LIKE mal_test_create_table_like with rollup (ru1);"""
waitForRollUpJob("mal_test_create_table_like", 5000, 2)

sql "drop table if exists test_create_table_like_char_255"
sql """
Expand Down

0 comments on commit a119d1c

Please sign in to comment.