Skip to content

Commit

Permalink
[fix](test)Fix unstable test drop index fault
Browse files Browse the repository at this point in the history
  • Loading branch information
qidaye committed Aug 2, 2024
1 parent 5edcbd7 commit 101ba6a
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
import org.codehaus.groovy.runtime.IOGroovyMethods

suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
def timeout = 60000
def delta_time = 1000
def alter_res = "null"
def useTime = 0
def wait_for_latest_op_on_table_finish = { table_name, OpTimeout ->
for(int t = delta_time; t <= OpTimeout; t += delta_time){
alter_res = sql """SHOW ALTER TABLE COLUMN WHERE TableName = "${table_name}" ORDER BY CreateTime DESC LIMIT 1;"""
alter_res = alter_res.toString()
if(alter_res.contains("FINISHED")) {
sleep(3000) // wait change table state to normal
logger.info(table_name + " latest alter job finished, detail: " + alter_res)
break
}
useTime = t
sleep(delta_time)
}
assertTrue(useTime <= OpTimeout, "wait_for_latest_op_on_table_finish timeout")
}
def runTest = { indexTbName ->
sql """ insert into ${indexTbName} values(1, "json love anny", "json", "anny",1); """
sql "sync"
Expand All @@ -33,6 +51,7 @@ suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
try {
GetDebugPoint().enableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index", [indexes_count: 3])
sql "DROP INDEX index_int ON ${indexTbName}"
wait_for_latest_op_on_table_finish(indexTbName, timeout)
show_result = sql_return_maparray "show index from ${indexTbName}"
logger.info("show index from " + indexTbName + " result: " + show_result)
assertEquals(show_result.size(), 3)
Expand All @@ -46,6 +65,7 @@ suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
try {
GetDebugPoint().enableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index", [indexes_count: 2])
sql "DROP INDEX index_str_k2 ON ${indexTbName}"
wait_for_latest_op_on_table_finish(indexTbName, timeout)
show_result = sql_return_maparray "show index from ${indexTbName}"
logger.info("show index from " + indexTbName + " result: " + show_result)
assertEquals(show_result.size(), 2)
Expand All @@ -58,6 +78,7 @@ suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
try {
GetDebugPoint().enableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index", [indexes_count: 1])
sql "DROP INDEX index_str_k4 ON ${indexTbName}"
wait_for_latest_op_on_table_finish(indexTbName, timeout)
show_result = sql_return_maparray "show index from ${indexTbName}"
logger.info("show index from " + indexTbName + " result: " + show_result)
assertEquals(show_result.size(), 1)
Expand All @@ -69,6 +90,7 @@ suite("test_index_builder_drop_index_fault_injection", "nonConcurrent") {
try {
GetDebugPoint().enableDebugPointForAllBEs("index_builder.update_inverted_index_info.drop_index", [indexes_count: 0])
sql "DROP INDEX index_k5 ON ${indexTbName}"
wait_for_latest_op_on_table_finish(indexTbName, timeout)
show_result = sql_return_maparray "show index from ${indexTbName}"
logger.info("show index from " + indexTbName + " result: " + show_result)
assertEquals(show_result.size(), 0)
Expand Down

0 comments on commit 101ba6a

Please sign in to comment.