Skip to content

Commit

Permalink
maintain test case
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <zak.zhao@pingcap.com>
  • Loading branch information
joccau committed Mar 28, 2022
1 parent 4585e31 commit 9dcf0eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func CheckNewCollationEnable(
if CheckRequirements {
return errors.Annotatef(berrors.ErrUnknown,
"NewCollactionEnable not found in backupmeta. "+
"if you ensure the newCollactionEnable config is same as restore cluster, "+
"if you ensure the NewCollactionEnable config of backup cluster is as same as restore cluster, "+
"use --check-requirements=false to skip")
} else {
log.Warn("no NewCollactionEnable in backup")
Expand Down
27 changes: 20 additions & 7 deletions br/tests/br_check_new_collocation_enable/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
set -eu
DB="$TEST_NAME"

cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $cur/../_utils/run_services

PROGRESS_FILE="$TEST_DIR/progress_unit_file"
rm -rf $PROGRESS_FILE

Expand All @@ -40,7 +43,7 @@ run_sql "CREATE TABLE $DB.usertable2 ( \
run_sql "INSERT INTO $DB.usertable2 VALUES (\"c\", \"d\");"

# backup db
echo "backup start..."
echo "backup start ... with brv4.0.8 without NewCollactionEnable"
bin/brv4.0.8 backup db --db "$DB" -s "local://$TEST_DIR/$DB" \
--ca "$TEST_DIR/certs/ca.pem" \
--cert "$TEST_DIR/certs/br.pem" \
Expand All @@ -49,10 +52,11 @@ bin/brv4.0.8 backup db --db "$DB" -s "local://$TEST_DIR/$DB" \
--check-requirements=false

# restore db from v4.0.8 version without `newCollationEnable`
echo "restore start..."
echo "restore start ... without NewCollactionEnable in backupmeta"
restore_fail=0
error_str="NewCollactionEnable not found in backupmeta"
test_log="newCollotionEnabble_test.log"
test_log="new_collotion_enable_test.log"
unset BR_LOG_TO_TERM
run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --log-file $test_log || restore_fail=1
if [ $restore_fail -ne 1 ]; then
echo "TEST: [$TEST_NAME] test restore failed!"
Expand All @@ -61,29 +65,38 @@ fi

if ! grep -i "$error_str" $test_log; then
echo "${error_str} not found in log"
echo "TEST: [$TEST_NAME] test restore failed!"
exit 1
fi

rm -rf "$test_log"

# backup with NewCollationEable = false
echo "Restart cluster with new_collation_enable=false"
start_services --tidb-cfg $cur/config/new_collation_enable_false.toml
run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$TEST_DIR/$DB"

echo "backup start ... witch NewCollactionEnable=false in TiDB"
run_br --pd $PD_ADDR backup db --db "$DB" -s "local://$cur/${DB}_2"

echo "Restart cluster with new_collation_enable=true"
start_services --tidb-cfg $cur/config/new_collation_enable_true.toml

echo "restore start ... with NewCollactionEnable=True in TiDB"
restore_fail=0
test_log2="new_collotion_enable_test2.log"
error_str="newCollationEnable not match"
run_br restore db --db $DB -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --log-file $test_log2 || restore_fail=1
unset BR_LOG_TO_TERM
run_br restore db --db $DB -s "local://$cur/${DB}_2" --pd $PD_ADDR --log-file $test_log2 || restore_fail=1
if [ $restore_fail -ne 1 ]; then
echo "TEST: [$TEST_NAME] test restore failed!"
exit 1
fi

if ! grep -i "$error_str" $test_log2; then
echo "${error_str} not found in log"
echo "TEST: [$TEST_NAME] test restore failed!"
exit 1
fi

# drop database
run_sql "DROP DATABASE $DB;"
rm -rf "$test_log2"
rm -rf "$cur/${DB}_2"

0 comments on commit 9dcf0eb

Please sign in to comment.