Skip to content

Commit

Permalink
chore(ci): add log for flaky meta backup test (#8109)
Browse files Browse the repository at this point in the history
Add logs to troubleshoot flaky test in #7850

Approved-By: Li0k
  • Loading branch information
zwang28 committed Feb 22, 2023
1 parent fe9c5c5 commit 8a242fe
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/meta/src/backup_restore/restore.rs
Expand Up @@ -198,8 +198,8 @@ async fn restore_impl(
tracing::info!(
"snapshot {} after rewrite by snapshot {}:\n{}",
target_id,
newest_id,
target_snapshot,
newest_id
);
}
if opts.dry_run {
Expand Down
30 changes: 22 additions & 8 deletions src/storage/backup/integration_tests/common.sh
Expand Up @@ -14,11 +14,11 @@ function clean_all_data {
}

function clean_etcd_data() {
cargo make clean-etcd-data
cargo make clean-etcd-data 1>/dev/null 2>&1
}

function start_cluster() {
cargo make d ci-meta-backup-test
cargo make d ci-meta-backup-test 1>/dev/null 2>&1
}

function wait_cluster_ready() {
Expand All @@ -27,18 +27,18 @@ function wait_cluster_ready() {
}

function full_gc_sst() {
${BACKUP_TEST_RW_ALL_IN_ONE} risectl hummock trigger-full-gc -s 0
${BACKUP_TEST_RW_ALL_IN_ONE} risectl hummock trigger-full-gc -s 0 1>/dev/null 2>&1
# TODO #6482: wait full gc finish deterministically.
# Currently have to wait long enough.
sleep 30
}

function manual_compaction() {
${BACKUP_TEST_RW_ALL_IN_ONE} risectl hummock trigger-manual-compaction "$@"
${BACKUP_TEST_RW_ALL_IN_ONE} risectl hummock trigger-manual-compaction "$@" 1>/dev/null 2>&1
}

function start_etcd_minio() {
cargo make d ci-meta-backup-test-restore
cargo make d ci-meta-backup-test-restore 1>/dev/null 2>&1
}

function create_mvs() {
Expand Down Expand Up @@ -78,14 +78,28 @@ function restore() {
--meta-snapshot-id "${job_id}" \
--etcd-endpoints 127.0.0.1:2388 \
--storage-directory backup \
--storage-url minio://hummockadmin:hummockadmin@127.0.0.1:9301/hummock001
--storage-url minio://hummockadmin:hummockadmin@127.0.0.1:9301/hummock001 \
1>/dev/null
}

function execute_sql() {
local sql
sql=$1
echo "execute sql ${sql}"
echo "SET QUERY_MODE=distributed;${sql}" | psql -h localhost -p 4566 -d dev -U root 2>&1
echo "${sql}" | psql -h localhost -p 4566 -d dev -U root 2>&1
}

function execute_sql_and_expect() {
local sql
sql=$1
local expected
expected=$2

echo "execute SQL ${sql}"
echo "expected string in result: ${expected}"
query_result=$(execute_sql "${sql}")
printf "actual result:\n%s\n" "${query_result}"
result=$(echo "${query_result}" | grep "${expected}")
[ -n "${result}" ]
}

function get_max_committed_epoch() {
Expand Down
2 changes: 2 additions & 0 deletions src/storage/backup/integration_tests/run_all.sh
Expand Up @@ -11,3 +11,5 @@ for t in "${tests[@]}"
do
bash "${DIR}/${t}"
done

echo "all tests succeeded"
57 changes: 22 additions & 35 deletions src/storage/backup/integration_tests/test_query_backup.sh
Expand Up @@ -69,48 +69,35 @@ done
echo "safe epoch after compaction: ${safe_epoch}"

echo "QUERY_EPOCH=safe_epoch. It should fail because it's not covered by any backup"
result=$(
execute_sql "
SET QUERY_EPOCH TO ${safe_epoch};
select * from t1;
" | grep "Read backup error backup include epoch ${safe_epoch} not found"
)
[ -n "${result}" ]
execute_sql_and_expect \
"SET QUERY_EPOCH TO ${safe_epoch};
select * from t1;" \
"Read backup error backup include epoch ${safe_epoch} not found"

echo "QUERY_EPOCH=0 aka disabling query backup"
result=$(
execute_sql "
SET QUERY_EPOCH TO 0;
select * from t1;
" | grep "1 row"
)
[ -n "${result}" ]
execute_sql_and_expect \
"SET QUERY_EPOCH TO 0;
select * from t1;" \
"1 row"

echo "QUERY_EPOCH=backup_safe_epoch + 1, it's < safe_epoch but covered by backup"
[ $((backup_safe_epoch + 1)) -eq 1 ]
result=$(
execute_sql "
SET QUERY_EPOCH TO $((backup_safe_epoch + 1));
select * from t1;
" | grep "0 row"
)
[ -n "${result}" ]
execute_sql_and_expect \
"SET QUERY_EPOCH TO $((backup_safe_epoch + 1));
select * from t1;" \
"0 row"

echo "QUERY_EPOCH=backup_mce < safe_epoch, it's < safe_epoch but covered by backup"
result=$(
execute_sql "
SET QUERY_EPOCH TO $((backup_mce));
select * from t1;
" | grep "3 row"
)
[ -n "${result}" ]
execute_sql_and_expect \
"SET QUERY_EPOCH TO ${backup_mce};
select * from t1;" \
"3 row"

echo "QUERY_EPOCH=future epoch. It should fail because it's not covered by any backup"
future_epoch=18446744073709551615
result=$(
execute_sql "
SET QUERY_EPOCH TO ${future_epoch};
select * from t1;
" | grep "Read backup error backup include epoch ${future_epoch} not found"
)
[ -n "${result}" ]
execute_sql_and_expect \
"SET QUERY_EPOCH TO ${future_epoch};
select * from t1;" \
"Read backup error backup include epoch ${future_epoch} not found"

echo "test succeeded"

0 comments on commit 8a242fe

Please sign in to comment.