Skip to content

Commit

Permalink
fix test not stable
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Nov 5, 2024
1 parent 76170a3 commit bd682b6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,8 @@ class Suite implements GroovyInterceptable {
}
}

def getMVJobState = { tableName, rollUpName ->
def jobStateResult = sql """ SHOW ALTER TABLE ROLLUP WHERE TableName='${tableName}' and IndexName = '${rollUpName}' ORDER BY CreateTime DESC limit 1"""
def getMVJobState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE ROLLUP WHERE TableName='${tableName}' ORDER BY CreateTime DESC limit 1"""
if (jobStateResult == null || jobStateResult.isEmpty()) {
logger.info("show alter table roll is empty" + jobStateResult)
return "NOT_READY"
Expand All @@ -1510,14 +1510,14 @@ class Suite implements GroovyInterceptable {
}
return "FINISHED";
}
def waitForRollUpJob = (tbName, rollUpName, timeoutMillisecond) -> {
def waitForRollUpJob = (tbName, timeoutMillisecond) -> {

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

String result
while (timeoutTimestamp > System.currentTimeMillis()){
result = getMVJobState(tbName, rollUpName)
result = getMVJobState(tbName)
if (result == "FINISHED") {
sleep(200)
return
Expand All @@ -1528,6 +1528,35 @@ class Suite implements GroovyInterceptable {
Assert.assertEquals("FINISHED", result)
}

def waitIndexVisible = (tbName, indexNames, timeoutMillisecond) -> {
def descAllResult = sql """ desc ${tbName} all"""
long startTime = System.currentTimeMillis()
long timeoutTimestamp = startTime + timeoutMillisecond
if (descAllResult == null || descAllResult.isEmpty()) {
logger.info("waitIndexVisible descAllResult is null")
Assert.assertTrue(false)
}
logger.info("waitIndexVisible descAllResult " + descAllResult)
Set<String> currentIndexSet = null;
while (timeoutTimestamp > System.currentTimeMillis()) {
currentIndexSet = new HashSet<>();
for (List<Object> row : descAllResult) {
if (row.size() < 1 || row.get(0) == null || row.get(0).toString().trim().size() == 0
|| Objects.equals(tbName, row.get(0).toString())) {
continue
}
currentIndexSet.add(String.valueOf(row.get(0)));
}
if (!Objects.equals(currentIndexSet, new HashSet(indexNames))) {
logger.info("waitIndexVisible currentIndexSet " + currentIndexSet)
sleep(200)
} else {
return
}
}
Assert.assertTrue(Objects.equals(currentIndexSet, new HashSet(indexNames)))
}

void testFoldConst(String foldSql) {
String openFoldConstant = "set debug_skip_fold_constant=false";
sql(openFoldConstant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,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", "r1", 60000)
waitForRollUpJob("mal_test_create_table_like", "r2", 60000)
waitIndexVisible("table_like_with_roll_up", ["ru1", "ru2"], 60000)
explain {
sql ("select sum(a) from table_like_with_roll_up group by a")
contains "ru1"
Expand All @@ -60,7 +59,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", "r1", 60000)
waitIndexVisible("table_like_with_partial_roll_up", ["ru1"], 60000)
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,7 +78,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", "r1", 60000)
waitIndexVisible("table_like_with_partial_roll_up_exists", ["ru1"], 60000)

sql "drop table if exists test_create_table_like_char_255"
sql """
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/nereids_p0/hint/test_use_mv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ suite("test_use_mv") {
);
"""
sql """ alter table t1 add rollup r1(k2, k1); """
waitForRollUpJob("t1", "r1", 15000)
waitForRollUpJob("t1", 150000)
sql """ alter table t1 add rollup r2(k2); """
waitForRollUpJob("t1", "r2", 15000)
waitForRollUpJob("t1", 150000)
createMV("create materialized view k1_k2_sumk3 as select k1, k2, sum(v1) from t1 group by k1, k2;")
explain {
sql """select /*+ no_use_mv */ k1 from t1;"""
Expand Down

0 comments on commit bd682b6

Please sign in to comment.