diff --git a/regression-test/suites/rollup_p0/test_rollup_add_column.groovy b/regression-test/suites/rollup_p0/test_rollup_add_column.groovy index 944dd1d128f0888..cc31644db839bea 100644 --- a/regression-test/suites/rollup_p0/test_rollup_add_column.groovy +++ b/regression-test/suites/rollup_p0/test_rollup_add_column.groovy @@ -14,6 +14,9 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. +import org.awaitility.Awaitility +import static java.util.concurrent.TimeUnit.SECONDS + suite("test_rollup_add_column") { def tbName = "test_rollup_add_column" def rollupName = "test_rollup_add_column_index" @@ -41,38 +44,30 @@ suite("test_rollup_add_column") { """ sql """ALTER TABLE ${tbName} ADD ROLLUP ${rollupName}(k1, v1);""" - int max_try_secs = 60 - while (max_try_secs--) { + int max_try_secs = 120 + // if timeout testcase will fail same behaviour as old method. + Awaitility.await().atMost(max_try_secs, SECONDS).pollInterval(2, SECONDS).until{ String res = getJobRollupState(tbName) if (res == "FINISHED" || res == "CANCELLED") { assertEquals("FINISHED", res) sleep(3000) - break - } else { - Thread.sleep(2000) - if (max_try_secs < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } - } + return true; + } + return false; } + Thread.sleep(2000) sql "ALTER TABLE ${tbName} ADD COLUMN k3 INT KEY NOT NULL DEFAULT '3' AFTER k1 TO ${rollupName};" - max_try_secs = 60 - while (max_try_secs--) { + + Awaitility.await().atMost(max_try_secs, SECONDS).pollInterval(2, SECONDS).until{ String res = getJobColumnState(tbName) if (res == "FINISHED" || res == "CANCELLED") { assertEquals("FINISHED", res) sleep(3000) - break - } else { - Thread.sleep(2000) - if (max_try_secs < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } + return true; } + return false; } sql "insert into ${tbName} values(1, 2, 3, 4, 5);" diff --git a/regression-test/suites/rollup_p0/test_rollup_agg_date.groovy b/regression-test/suites/rollup_p0/test_rollup_agg_date.groovy index e17ae1075b5fecb..cacb0f33980e3cf 100644 --- a/regression-test/suites/rollup_p0/test_rollup_agg_date.groovy +++ b/regression-test/suites/rollup_p0/test_rollup_agg_date.groovy @@ -14,6 +14,9 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. +import org.awaitility.Awaitility +import static java.util.concurrent.TimeUnit.SECONDS + suite("test_rollup_agg_date", "rollup") { def tbName = "test_rollup_agg_date" @@ -41,38 +44,31 @@ suite("test_rollup_agg_date", "rollup") { DISTRIBUTED BY HASH(datek1) BUCKETS 5 properties("replication_num" = "1"); """ sql """ALTER TABLE ${tbName} ADD ROLLUP rollup_date(datek1,datetimek2,datetimek1,datetimek3,datev1,datetimev1,datetimev2,datetimev3);""" - int max_try_secs = 60 - while (max_try_secs--) { + int max_try_secs = 120 + // if timeout testcase will fail same behaviour as old nethod. + Awaitility.await().atMost(max_try_secs, SECONDS).pollInterval(2, SECONDS).until{ String res = getJobRollupState(tbName) if (res == "FINISHED" || res == "CANCELLED") { assertEquals("FINISHED", res) sleep(3000) - break - } else { - Thread.sleep(2000) - if (max_try_secs < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } + return true; } + return false; } + Thread.sleep(2000) sql "ALTER TABLE ${tbName} ADD COLUMN datetimev4 datetimev2(3) MAX NULL;" - max_try_secs = 60 - while (max_try_secs--) { + // if timeout testcase will fail same behaviour as old nethod. + Awaitility.await().atMost(max_try_secs, SECONDS).pollInterval(2, SECONDS).until{ String res = getJobColumnState(tbName) if (res == "FINISHED" || res == "CANCELLED") { assertEquals("FINISHED", res) sleep(3000) - break - } else { - Thread.sleep(2000) - if (max_try_secs < 1) { - println "test timeout," + "state:" + res - assertEquals("FINISHED",res) - } + return true; } + return false; } + sql "SHOW ALTER TABLE ROLLUP WHERE TableName='${tbName}';" qt_sql "DESC ${tbName} ALL;" sql "insert into ${tbName} values('2022-08-22', '2022-08-22 11:11:11.111111', '2022-08-22 11:11:11.111111', '2022-08-22 11:11:11.111111', '2022-08-22', '2022-08-22 11:11:11.111111', '2022-08-22 11:11:11.111111', '2022-08-22 11:11:11.111111', '2022-08-22 11:11:11.111111');" diff --git a/regression-test/suites/statistics/test_partition_stats.groovy b/regression-test/suites/statistics/test_partition_stats.groovy index 16cedb9889d82d4..96be61296eadf09 100644 --- a/regression-test/suites/statistics/test_partition_stats.groovy +++ b/regression-test/suites/statistics/test_partition_stats.groovy @@ -14,6 +14,8 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. +import org.awaitility.Awaitility +import static java.util.concurrent.TimeUnit.SECONDS suite("test_partition_stats") { @@ -36,33 +38,29 @@ suite("test_partition_stats") { sql """use ${db}""" result = sql """show frontends;""" logger.info("show frontends result master: " + result) - for (int i = 0; i < 120; i++) { - Thread.sleep(5000) + // in 300 sec its not matching, then timeout raised by awaited. + Awaitility.await().atMost(300, SECONDS).pollInterval(5, SECONDS).until{ result = sql """SHOW DATA FROM ${table};""" logger.info("result " + result) if (result[row][column] == expected) { - return; + return true; } + return false; } - throw new Exception("Row count report timeout.") } } def wait_mv_finish = { db, table -> - for (int loop = 0; loop < 300; loop++) { - Thread.sleep(1000) - boolean finished = true; + // in 300 sec its not matching, then timeout raised by awaited. + Awaitility.await().atMost(300, SECONDS).pollInterval(1, SECONDS).until{ def result = sql """SHOW ALTER TABLE MATERIALIZED VIEW FROM ${db} WHERE tableName="${table}";""" for (int i = 0; i < result.size(); i++) { if (result[i][8] != 'FINISHED') { - finished = false; - break; + return false; } } - if (finished) { - return; - } + return true; } throw new Exception("Wait mv finish timeout.") } @@ -116,15 +114,17 @@ suite("test_partition_stats") { // Test show cached partition stats. sql """analyze table part with sync;""" - for (int i = 0; i < 20; i++) { + // in 20 sec its not matching, then timeout raised by awaited. + Awaitility.await().atMost(20, SECONDS).pollInterval(1, SECONDS).until{ result = sql """show column cached stats part partition(*)""" if (result.size() == 27) { logger.info("cache is ready.") - break; + return true; } logger.info("cache is not ready yet.") - Thread.sleep(1000) + return false; } + result = sql """show column cached stats part(id) partition(p1)""" assertEquals("id", result[0][0]) assertEquals("p1", result[0][1]) @@ -479,13 +479,12 @@ suite("test_partition_stats") { result = sql """show auto analyze part4""" assertTrue(result.size() > 0) def index = result.size() - 1; - def finished = false; - for (int i = 0; i < 20; i++) { + // in 30 sec its not matching, then timeout raised by awaited. + Awaitility.await().atMost(30, SECONDS).pollInterval(1, SECONDS).until{ if (result[index][9].equals("FINISHED")) { - finished = true; - break; + return true; } - Thread.sleep(1000) + return false; } if (finished) { result = sql """show column stats part4""" @@ -667,13 +666,12 @@ suite("test_partition_stats") { sql """analyze table part7 properties("use.auto.analyzer"="true")""" result = sql """show auto analyze part7""" assertEquals(1, result.size()) - def finished = false; - for (int i = 0; i < 20; i++) { + // in 20 sec its not matching, then timeout raised by awaited. + Awaitility.await().atMost(20, SECONDS).pollInterval(1, SECONDS).until{ if (result[0][9].equals("FINISHED")) { - finished = true; - break; + return true; } - Thread.sleep(1000) + return false; } if (finished) { result = sql """show column stats part7""" diff --git a/regression-test/suites/variant_p0/compaction_sparse_column.groovy b/regression-test/suites/variant_p0/compaction_sparse_column.groovy index 57e6e6ef963c97e..3de2434795305c1 100644 --- a/regression-test/suites/variant_p0/compaction_sparse_column.groovy +++ b/regression-test/suites/variant_p0/compaction_sparse_column.groovy @@ -16,6 +16,7 @@ // under the License. import org.codehaus.groovy.runtime.IOGroovyMethods +import org.awaitility.Awaitility suite("test_compaction_sparse_column", "nonConcurrent") { def tableName = "test_compaction" @@ -125,9 +126,7 @@ suite("test_compaction_sparse_column", "nonConcurrent") { // wait for all compactions done for (def tablet in tablets) { - boolean running = true - do { - Thread.sleep(1000) + Awaitility.await().untilAsserted(() -> { String tablet_id = tablet.TabletId backend_id = tablet.BackendId (code, out, err) = be_get_compaction_status(backendId_to_backendIP.get(backend_id), backendId_to_backendHttpPort.get(backend_id), tablet_id) @@ -135,8 +134,8 @@ suite("test_compaction_sparse_column", "nonConcurrent") { assertEquals(code, 0) def compactionStatus = parseJson(out.trim()) assertEquals("success", compactionStatus.status.toLowerCase()) - running = compactionStatus.run_status - } while (running) + return compactionStatus.run_status; + }); } int rowCount = 0