Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-2.1: [regression-test](case) audit log case #47456 #47485

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions regression-test/suites/audit/test_audit_log_behavior.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,33 @@ suite("test_audit_log_behavior") {

qt_audit_log_schema """desc internal.__internal_schema.audit_log"""

for (def on : [true, false]) {
sql "set enable_nereids_planner=${on}"
sql "truncate table __internal_schema.audit_log"
// run queries
for (int i = 0; i < cnt; i++) {
def tuple2 = sqls.get(i)
sql tuple2[0]
}
sql "truncate table __internal_schema.audit_log"
// run queries
for (int i = 0; i < cnt; i++) {
def tuple2 = sqls.get(i)
sql tuple2[0]
}

if (on == true) {
// only new planner supports call flush_audit_log
// make sure audit event is created.
// see WorkloadRuntimeStatusMgr.getQueryNeedAudit()
Thread.sleep(6000)
sql """call flush_audit_log()"""
}
// check result
for (int i = 0; i < cnt; i++) {
def tuple2 = sqls.get(i)
def retry = 180
def query = "select stmt from __internal_schema.audit_log where stmt like 'insert%3F6B9A_${i}%' order by time asc limit 1"
def res = sql "${query}"
while (res.isEmpty()) {
if (retry-- < 0) {
logger.warn("It has retried a few but still failed, you need to check it")
return
}
sleep(1000)
res = sql "${query}"
Thread.sleep(6000)
sql """call flush_audit_log()"""

// check result
for (int i = 0; i < cnt; i++) {
def tuple2 = sqls.get(i)
def retry = 180
def query = "select stmt from __internal_schema.audit_log where stmt like 'insert%3F6B9A_${i}%' order by time asc limit 1"
def res = sql "${query}"
while (res.isEmpty()) {
if (retry-- < 0) {
logger.warn("It has retried a few but still failed, you need to check it")
return
}
assertEquals(res[0][0].toString(), tuple2[1].toString())
sleep(1000)
res = sql "${query}"
}
assertEquals(res[0][0].toString(), tuple2[1].toString())
}

// do not turn off
sql "set global enable_audit_plugin = false"
sql "set global audit_plugin_max_sql_length = 4096"
Expand Down