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

Large diffs are not rendered by default.

71 changes: 18 additions & 53 deletions regression-test/suites/auth_call/test_ddl_restore_auth.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,34 @@
// specific language governing permissions and limitations
// under the License.

import org.junit.Assert;
import java.util.UUID

suite("test_ddl_restore_auth","p0,auth_call") {
UUID uuid = UUID.randomUUID()
String randomValue = uuid.toString()
int hashCode = randomValue.hashCode()
hashCode = hashCode > 0 ? hashCode : hashCode * (-1)
suite("test_ddl_restore_auth", "p0,auth_call") {
String label = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 8)
def syncer = getSyncer()

def waitingBackupTaskFinished = { def curDbName ->
Thread.sleep(2000)
def waitingBackupTaskFinished = { String curDbName ->
String showTasks = "SHOW BACKUP FROM ${curDbName};"
String status = "NULL"
List<List<Object>> result
long startTime = System.currentTimeMillis()
long timeoutTimestamp = startTime + 5 * 60 * 1000 // 5 min
do {
result = sql(showTasks)
logger.info("result: " + result.toString())
long timeoutTimestamp = System.currentTimeMillis() + 5 * 60 * 1000 // 5 min
while (timeoutTimestamp > System.currentTimeMillis()) {
List<List<Object>> result = sql(showTasks)
assertTrue(result.size() == 1)
if (!result.isEmpty()) {
status = result.last().get(3)
status = result.last().get(3)
if (status == "FINISHED") {
return
}
logger.info("The state of ${showTasks} is ${status}")
Thread.sleep(1000);
} while (timeoutTimestamp > System.currentTimeMillis() && (status != 'FINISHED'))
if (status != "FINISHED") {
logger.info("status is not success")
Thread.sleep(1000)
}
assertTrue(status == "FINISHED")
return result[0][1]
}

String user = 'test_ddl_restore_auth_user'
String pwd = 'C123_567p'
String dbName = 'test_ddl_restore_auth_db'
String dbName = "test_ddl_restore_auth_db_${label}"
String tableName = 'test_ddl_restore_auth_tb'
String repositoryName = 'test_ddl_restore_auth_rps'
String restoreLabelName = 'test_ddl_restore_auth_restore_label' + hashCode.toString()

String ak = getS3AK()
String sk = getS3SK()
String endpoint = getS3Endpoint()
String region = getS3Region()
String bucket = context.config.otherConfigs.get("s3BucketName");
String repositoryName = "test_ddl_restore_auth_rps_${label}"
String restoreLabelName = "test_ddl_restore_auth_restore_label_${label}"

//cloud-mode
if (isCloudMode()) {
Expand All @@ -68,7 +51,6 @@ suite("test_ddl_restore_auth","p0,auth_call") {

try_sql("DROP USER ${user}")
try_sql """drop database if exists ${dbName}"""
try_sql("""DROP REPOSITORY `${repositoryName}`;""")
sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'"""
sql """grant select_priv on regression_test to ${user}"""
sql """create database ${dbName}"""
Expand All @@ -88,31 +70,14 @@ suite("test_ddl_restore_auth","p0,auth_call") {
(3, "333");
"""

sql """CREATE REPOSITORY `${repositoryName}`
WITH S3
ON LOCATION "s3://${bucket}/${repositoryName}"
PROPERTIES
(
"s3.endpoint" = "http://${endpoint}",
"s3.region" = "${region}",
"s3.access_key" = "${ak}",
"s3.secret_key" = "${sk}",
"delete_if_exists" = "true"
)"""
syncer.createS3Repository(repositoryName)
sql """BACKUP SNAPSHOT ${dbName}.${restoreLabelName}
TO ${repositoryName}
ON (${tableName})
PROPERTIES ("type" = "full");"""
def real_label = waitingBackupTaskFinished(dbName)
def backup_timestamp = sql """SHOW SNAPSHOT ON ${repositoryName};"""
logger.info("backup_timestamp: " + backup_timestamp)
def real_timestamp
for (int i = 0; i < backup_timestamp.size(); i++) {
if (backup_timestamp[i][0] == real_label) {
real_timestamp = backup_timestamp[i][1]
break
}
}
waitingBackupTaskFinished(dbName)
def real_timestamp = syncer.getSnapshotTimestamp(repositoryName, restoreLabelName)
assertTrue(real_timestamp != null)

sql """truncate table ${dbName}.`${tableName}`"""

Expand Down
14 changes: 12 additions & 2 deletions regression-test/suites/nereids_p0/cache/mtmv_with_sql_cache.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,21 @@ suite("mtmv_with_sql_cache") {
}
}

// Direct scans on MTMV tables only need to verify cache hits here.
// The heavier cached-vs-uncached result comparison is reserved for rewrite SQLs.
def shouldJudgeRes = { String sqlStr ->
return !sqlStr.trim().toLowerCase().startsWith("select * from ")
}

def assertHasCache = { String sqlStr ->
explain {
sql ("physical plan ${sqlStr}")
contains("PhysicalSqlCache")
}

judge_res(sqlStr)
if (shouldJudgeRes(sqlStr)) {
judge_res(sqlStr)
}
}

def assertNoCache = { String sqlStr ->
Expand Down Expand Up @@ -129,8 +137,10 @@ suite("mtmv_with_sql_cache") {
}

String dbName = context.config.getDbNameByFile(context.file)
// Keep multiple rounds for flaky cache timing, but align the actual execution count with 3 retries.
int flakyRetryRounds = 3

for (def __ in 0..3) {
for (def __ in 0..<flakyRetryRounds) {
combineFutures(
extraThread("testRenameMtmv", {
retryTestSqlCache(3, 1000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import com.google.common.util.concurrent.Uninterruptibles

import java.util.concurrent.TimeUnit
import java.util.stream.Collectors

class CanRetryException extends IllegalStateException {
CanRetryException() {
}
Expand Down Expand Up @@ -81,8 +79,10 @@ suite("mv_with_sql_cache") {
}

String dbName = context.config.getDbNameByFile(context.file)
// Keep multiple rounds for flaky cache timing, but align the actual execution count with 3 retries.
int flakyRetryRounds = 3

for (def __ in 0..3) {
for (def __ in 0..<flakyRetryRounds) {
combineFutures(
extraThread("testRenameMv", {
retryTestSqlCache(3, 1000) {
Expand Down
Loading
Loading