From 98ddae51934f1304abb32e4c77e69ab4d863330f Mon Sep 17 00:00:00 2001 From: airborne12 Date: Mon, 28 Oct 2024 20:35:02 +0800 Subject: [PATCH] [Test](build index) enhance build index case for finished state (#42630) ## Proposed changes Fix case error as below ``` Exception in fault_injection_p0/test_build_index_with_clone_fault.groovy(line 76): logger.warn("Attempt ${attempt + 1}: show_build_index is empty or null. Retrying after ${waitSeconds} second(s)...") } attempt++ if (attempt < maxRetries) { sleep(waitSeconds * 1000) } } def finalBuildIndex = sql_return_maparray("show build index where TableName = \"${tbl}\" ORDER BY JobId DESC LIMIT 1") assertTrue(finalBuildIndex && finalBuildIndex.size() > 0, "show_build_index is empty or null after ${maxRetries} attempts") assertEquals(expectedState, finalBuildIndex[0].State, "State does not match after ${maxRetries} attempts") ^^^^^^^^^^^^^^^^^^^^^^^^^^ERROR LINE^^^^^^^^^^^^^^^^^^^^^^^^^^ assertEquals(expectedMsg, finalBuildIndex[0].Msg, "Msg does not match after ${maxRetries} attempts") } def tbl = 'test_build_index_with_clone' try { GetDebugPoint().enableDebugPointForAllBEs("EngineCloneTask.wait_clone") logger.info("add debug point EngineCloneTask.wait_clone") sql """ DROP TABLE IF EXISTS ${tbl} """ sql """ CREATE TABLE ${tbl} ( Exception: org.opentest4j.AssertionFailedError: State does not match after 3 attempts ==> expected: but was: ``` --- .../test_build_index_with_clone_fault.groovy | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/regression-test/suites/fault_injection_p0/test_build_index_with_clone_fault.groovy b/regression-test/suites/fault_injection_p0/test_build_index_with_clone_fault.groovy index c1854b4066422a..0d73e4541b2427 100644 --- a/regression-test/suites/fault_injection_p0/test_build_index_with_clone_fault.groovy +++ b/regression-test/suites/fault_injection_p0/test_build_index_with_clone_fault.groovy @@ -57,8 +57,8 @@ suite("test_build_index_with_clone_fault_injection", "nonConcurrent"){ if (show_build_index && show_build_index.size() > 0) { def currentState = show_build_index[0].State def currentMsg = show_build_index[0].Msg - if (currentState == expectedState && currentMsg == expectedMsg) { - logger.info("Attempt ${attempt + 1}: State and Msg match expected values.") + if ((currentState == expectedState && currentMsg == expectedMsg) || currentState == "FINISHED") { + logger.info(currentState+" "+currentMsg) return } else { logger.warn("Attempt ${attempt + 1}: Expected State='${expectedState}' and Msg='${expectedMsg}', but got State='${currentState}' and Msg='${currentMsg}'. Retrying after ${waitSeconds} second(s)...") @@ -106,10 +106,8 @@ suite("test_build_index_with_clone_fault_injection", "nonConcurrent"){ // create index on table sql """ create index idx_k2 on ${tbl}(k2) using inverted """ sql """ build index idx_k2 on ${tbl} """ - // sleep 5s to wait for the build index job report table is unstable - sleep(5000) - assertShowBuildIndexWithRetry(tbl, 'WAITING_TXN', 'table is unstable', 3, 5) + assertShowBuildIndexWithRetry(tbl, 'WAITING_TXN', 'table is unstable', 3, 10) def state = wait_for_last_build_index_on_table_finish(tbl, timeout) assertEquals(state, "FINISHED")