[enhancement](MTMV) Add a timeout for regression tests (#18048)
MTMV regression tests may loop forever due to some potential bugs. Therefore, we add a timeout to avoid endless loop. The value of the timeout is hard coded 30 minutes now.
This commit is contained in:
@ -45,12 +45,11 @@ import java.util.concurrent.Future
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.stream.Collectors
|
||||
import java.util.stream.LongStream
|
||||
import java.math.BigDecimal;
|
||||
import static org.apache.doris.regression.util.DataUtils.sortByToString
|
||||
|
||||
import java.io.File
|
||||
import java.sql.PreparedStatement
|
||||
import java.sql.ResultSetMetaData
|
||||
import org.junit.Assert
|
||||
|
||||
@Slf4j
|
||||
class Suite implements GroovyInterceptable {
|
||||
@ -396,6 +395,29 @@ class Suite implements GroovyInterceptable {
|
||||
file.delete()
|
||||
}
|
||||
|
||||
void waitingMTMVTaskFinished(String mvName) {
|
||||
String showTasks = "SHOW MTMV TASK ON " + mvName
|
||||
List<List<String>> showTaskMetaResult = sql_meta(showTasks)
|
||||
int index = showTaskMetaResult.indexOf(['State', 'CHAR'])
|
||||
String status = "PENDING"
|
||||
List<List<Object>> result
|
||||
long startTime = System.currentTimeMillis()
|
||||
long timeoutTimestamp = startTime + 30 * 60 * 1000 // 30 min
|
||||
do {
|
||||
result = sql(showTasks)
|
||||
if (!result.isEmpty()) {
|
||||
status = result.last().get(index)
|
||||
}
|
||||
println "The state of ${showTasks} is ${status}"
|
||||
Thread.sleep(1000);
|
||||
} while (timeoutTimestamp > System.currentTimeMillis() && (status == 'PENDING' || status == 'RUNNING'))
|
||||
if (status != "SUCCESS") {
|
||||
println "status is not success"
|
||||
println result.toString()
|
||||
}
|
||||
Assert.assertEquals("SUCCESS", status)
|
||||
}
|
||||
|
||||
List<String> downloadExportFromHdfs(String label) {
|
||||
String dataDir = context.config.dataPath + "/" + group + "/"
|
||||
String hdfsFs = context.config.otherConfigs.get("hdfsFs")
|
||||
|
||||
@ -69,19 +69,7 @@ suite("test_alter_mtmv") {
|
||||
"""
|
||||
|
||||
// waiting the task to be finished.
|
||||
def show_task_meta = sql_meta "SHOW MTMV TASK ON ${mvName}"
|
||||
def index = show_task_meta.indexOf(['State', 'CHAR'])
|
||||
def query = "SHOW MTMV TASK ON ${mvName}"
|
||||
def show_task_result
|
||||
def state = "PENDING"
|
||||
do {
|
||||
show_task_result = sql "${query}"
|
||||
if (!show_task_result.isEmpty()) {
|
||||
state = show_task_result.last().get(index)
|
||||
}
|
||||
println "The state of ${query} is ${state}"
|
||||
Thread.sleep(1000);
|
||||
} while (state.equals('PENDING') || state.equals('RUNNING'))
|
||||
waitingMTMVTaskFinished(mvName)
|
||||
|
||||
// test alter mtmv
|
||||
sql """
|
||||
|
||||
@ -70,19 +70,7 @@ suite("test_create_both_mtmv") {
|
||||
SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
|
||||
"""
|
||||
// wait task to be finished to avoid task leak in suite.
|
||||
def show_task_meta = sql_meta "SHOW MTMV TASK ON ${mvName}"
|
||||
def index = show_task_meta.indexOf(['State', 'CHAR'])
|
||||
def query = "SHOW MTMV TASK ON ${mvName}"
|
||||
def show_task_result
|
||||
def state = "PENDING"
|
||||
do {
|
||||
show_task_result = sql "${query}"
|
||||
if (!show_task_result.isEmpty()) {
|
||||
state = show_task_result.last().get(index)
|
||||
}
|
||||
println "The state of ${query} is ${state}"
|
||||
Thread.sleep(1000);
|
||||
} while (state.equals('PENDING') || state.equals('RUNNING'))
|
||||
waitingMTMVTaskFinished(mvName)
|
||||
|
||||
def show_job_result = sql "SHOW MTMV JOB ON ${mvName}"
|
||||
assertEquals 1, show_job_result.size(), show_job_result.toString()
|
||||
|
||||
@ -68,21 +68,8 @@ suite("test_create_mtmv") {
|
||||
SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
|
||||
"""
|
||||
|
||||
def show_task_meta = sql_meta "SHOW MTMV TASK ON ${mvName}"
|
||||
def index = show_task_meta.indexOf(['State', 'CHAR'])
|
||||
def query = "SHOW MTMV TASK ON ${mvName}"
|
||||
def show_task_result
|
||||
def state = "PENDING"
|
||||
do {
|
||||
show_task_result = sql "${query}"
|
||||
if (!show_task_result.isEmpty()) {
|
||||
state = show_task_result.last().get(index)
|
||||
}
|
||||
println "The state of ${query} is ${state}"
|
||||
Thread.sleep(1000);
|
||||
} while (state.equals('PENDING') || state.equals('RUNNING'))
|
||||
waitingMTMVTaskFinished(mvName)
|
||||
|
||||
assertEquals 'SUCCESS', state, show_task_result.last().toString()
|
||||
order_qt_select "SELECT * FROM ${mvName}"
|
||||
|
||||
sql """
|
||||
|
||||
@ -69,38 +69,17 @@ suite("test_refresh_mtmv") {
|
||||
"""
|
||||
|
||||
// waiting the task to be finished.
|
||||
def show_task_meta = sql_meta "SHOW MTMV TASK ON ${mvName}"
|
||||
def index = show_task_meta.indexOf(['State', 'CHAR'])
|
||||
def query = "SHOW MTMV TASK ON ${mvName}"
|
||||
def show_task_result
|
||||
def state = "PENDING"
|
||||
do {
|
||||
show_task_result = sql "${query}"
|
||||
if (!show_task_result.isEmpty()) {
|
||||
state = show_task_result.last().get(index)
|
||||
}
|
||||
println "The state of ${query} is ${state}"
|
||||
Thread.sleep(1000);
|
||||
} while (state.equals('PENDING') || state.equals('RUNNING'))
|
||||
waitingMTMVTaskFinished(mvName)
|
||||
|
||||
assertEquals 'SUCCESS', state, show_task_result.last().toString()
|
||||
order_qt_select "SELECT * FROM ${mvName}"
|
||||
|
||||
// test REFRESH make sure only define one mv and already run a task.
|
||||
sql """
|
||||
REFRESH MATERIALIZED VIEW ${mvName} COMPLETE
|
||||
"""
|
||||
state = "PENDING"
|
||||
do {
|
||||
show_task_result = sql "${query}"
|
||||
if (!show_task_result.isEmpty()) {
|
||||
state = show_task_result.last().get(index)
|
||||
}
|
||||
println "The state of ${query} is ${state}"
|
||||
Thread.sleep(1000);
|
||||
} while (state.equals('PENDING') || state.equals('RUNNING'))
|
||||
waitingMTMVTaskFinished(mvName)
|
||||
|
||||
assertEquals 'SUCCESS', state, show_task_result.last().toString()
|
||||
def show_task_result = sql "SHOW MTMV TASK ON ${mvName}"
|
||||
assertEquals 2, show_task_result.size(), show_task_result.toString()
|
||||
|
||||
sql """
|
||||
|
||||
Reference in New Issue
Block a user