Skip to content

Commit

Permalink
[Test](bloom filter) add retry and retry timeout for bloom filter tes…
Browse files Browse the repository at this point in the history
…t case apache#42609 (apache#42672)

cherry pick from apache#42609
  • Loading branch information
airborne12 authored Oct 29, 2024
1 parent d5c43c5 commit d0e7371
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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<STRING>"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d0e7371

Please sign in to comment.