From d0e7371077281c00073edb0d33c89da208aa49db Mon Sep 17 00:00:00 2001 From: airborne12 Date: Tue, 29 Oct 2024 13:33:02 +0800 Subject: [PATCH] [Test](bloom filter) add retry and retry timeout for bloom filter test case #42609 (#42672) cherry pick from #42609 --- .../test_bloom_filter_drop_column.groovy | 29 ++++++++++++++++--- ...loom_filter_hit_with_renamed_column.groovy | 4 +-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy b/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy index a2de2426832854..39c4cdb6141de1 100644 --- a/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy +++ b/regression-test/suites/bloom_filter_p0/test_bloom_filter_drop_column.groovy @@ -50,6 +50,29 @@ suite("test_bloom_filter_drop_column") { } assertTrue(useTime <= OpTimeout, "wait_for_latest_op_on_table_finish timeout") } + + def assertShowCreateTableWithRetry = { tableName, expectedCondition, maxRetries, waitSeconds -> + int attempt = 0 + while (attempt < maxRetries) { + def res = sql """SHOW CREATE TABLE ${tableName}""" + log.info("Attempt ${attempt + 1}: show table: ${res}") + if (res && res.size() > 0 && res[0][1].contains(expectedCondition)) { + logger.info("Attempt ${attempt + 1}: Condition met.") + return + } else { + logger.warn("Attempt ${attempt + 1}: Condition not met. Retrying after ${waitSeconds} second(s)...") + } + attempt++ + if (attempt < maxRetries) { + sleep(waitSeconds * 1000) + } + } + def finalRes = sql """SHOW CREATE TABLE ${tableName}""" + log.info("Final attempt: show table: ${finalRes}") + assertTrue(finalRes && finalRes.size() > 0, "SHOW CREATE TABLE return empty or null") + assertTrue(finalRes[0][1].contains(expectedCondition), "expected\"${expectedCondition}\",actural: ${finalRes[0][1]}") + } + sql """INSERT INTO ${table_name} values ('1', '1')""" qt_select """select * from ${table_name} order by a""" @@ -58,10 +81,8 @@ suite("test_bloom_filter_drop_column") { sql """ALTER TABLE ${table_name} DROP COLUMN c1""" wait_for_latest_op_on_table_finish(table_name, timeout) - // show create table - def res = sql """SHOW CREATE TABLE ${table_name}""" - log.info("show table:{}", res); - assert res[0][1].contains("\"bloom_filter_columns\" = \"\"") + // show create table with retry logic + assertShowCreateTableWithRetry(table_name, "\"bloom_filter_columns\" = \"\"", 3, 30) // add new column c1 sql """ALTER TABLE ${table_name} ADD COLUMN c1 ARRAY""" diff --git a/regression-test/suites/bloom_filter_p0/test_bloom_filter_hit_with_renamed_column.groovy b/regression-test/suites/bloom_filter_p0/test_bloom_filter_hit_with_renamed_column.groovy index 46d2e766109174..c86be96d4b1505 100644 --- a/regression-test/suites/bloom_filter_p0/test_bloom_filter_hit_with_renamed_column.groovy +++ b/regression-test/suites/bloom_filter_p0/test_bloom_filter_hit_with_renamed_column.groovy @@ -123,7 +123,7 @@ suite("test_bloom_filter_hit_with_renamed_column") { while (attempt < maxRetries) { profiles = httpGet(profileUrl) - log.debug("profiles attempt ${attempt + 1}: {}", profiles) + log.info("profiles attempt ${attempt + 1}: {}", profiles) if (profiles == null) { log.warn("Failed to fetch profiles on attempt ${attempt + 1}") } else { @@ -156,7 +156,7 @@ suite("test_bloom_filter_hit_with_renamed_column") { } def query = """select C_COMMENT_NEW from ${tableName} where C_COMMENT_NEW='OK'""" - def profileId = getProfileIdWithRetry(query, 3, 1) + def profileId = getProfileIdWithRetry(query, 3, 30) log.info("profileId:{}", profileId) def profileDetail = httpGet("/rest/v1/query_profile/" + profileId) log.info("profileDetail:{}", profileDetail)