Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2431,8 +2431,21 @@ class Suite implements GroovyInterceptable {
origin.put(key, rows[0].Value as String)
}
}

try {
tempVars.each { key, value -> sql "set global ${key} = ${quote(value)}" }
} catch (Exception e) {
def err = e.getMessage()
log.warn("skip this case ${context.suiteName}, because ${err}")
if (err.toUpperCase().contains("ADMIN")) {
return
}

origin.each { key, value -> sql "set global ${key} = ${quote(value)}" }
throw e
}

try {
actionSupplier()
} finally {
origin.each { key, value -> sql "set global ${key} = ${quote(value)}" }
Expand Down
16 changes: 3 additions & 13 deletions regression-test/suites/audit/test_audit_log_behavior.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,8 @@
// under the License.

suite("test_audit_log_behavior","nonConcurrent") {
try {
sql "set global enable_audit_plugin = true"
sql "set global audit_plugin_max_sql_length = 58"
// sql "set global audit_plugin_max_batch_interval_sec = 1"
} catch (Exception e) {
log.warn("skip this case, because " + e.getMessage())
assertTrue(e.getMessage().toUpperCase().contains("ADMIN"))
return
}

setGlobalVarTemporary([enable_audit_plugin: true, audit_plugin_max_sql_length: 58], {
sql "drop table if exists audit_log_behavior"
sql """
CREATE TABLE `audit_log_behavior` (
Expand Down Expand Up @@ -99,8 +91,6 @@ suite("test_audit_log_behavior","nonConcurrent") {
assertEquals(tuple2[1].toString(), res[0][0].toString())
}

// do not turn off
sql "set global enable_audit_plugin = false"
sql "set global audit_plugin_max_sql_length = 4096"
sql "set global audit_plugin_max_batch_interval_sec = 60"
}

}
12 changes: 3 additions & 9 deletions regression-test/suites/audit/test_audit_log_queue_time.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@
// under the License.

suite("test_audit_log_queue_time", "nonConcurrent") {
// Check admin privilege
try {
sql "set global enable_audit_plugin = true"
} catch (Exception e) {
log.warn("skip this case, because " + e.getMessage())
assertTrue(e.getMessage().toUpperCase().contains("ADMIN"))
return
}

setGlobalVarTemporary([enable_audit_plugin: true], {

def tableName = "audit_queue_time_test"
def wgName = "test_queue_time_wg"
Expand Down Expand Up @@ -125,5 +119,5 @@ suite("test_audit_log_queue_time", "nonConcurrent") {
// Cleanup
sql "drop table if exists ${tableName}"
sql "drop workload group if exists ${wgName}"
sql "set global enable_audit_plugin = false"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ suite('test_audit_log_internal_query_failure', 'nonConcurrent') {
GetDebugPoint().clearDebugPointsForAllBEs()
}

def currentDb = (sql_return_maparray "select database() as db")[0].db.toString()
def fullTableName = "internal.${currentDb}.${tbl}"

// Force a flush so the failed internal query is queryable from
// __internal_schema.audit_log.
// The failed gather SQL reads from our user table and runs as an
// internal query; it must show up with state=ERR. Filter by start
// time to avoid matching stale entries from previous runs.
// Use queried_tables_and_views instead of stmt because stmt can be
// truncated by audit_plugin_max_sql_length when running in CI.
def query = """select state, error_code, error_message
from __internal_schema.audit_log
where is_internal = 1
and stmt like '%${tbl}%'
and array_contains(queried_tables_and_views, '${fullTableName}')
and state = 'ERR'
and `time` >= '${startTime}'
order by `time` desc limit 1"""
Expand Down
Loading