Skip to content

Commit

Permalink
This is an automated cherry-pick of #56799
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
Leavrth authored and ti-chi-bot committed Dec 17, 2024
1 parent d97f0ee commit 0056d81
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions br/tests/br_pitr/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ done
echo "restart a services"
restart_services

<<<<<<< HEAD
# PITR restore
echo "run pitr"
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" > $res_file 2>&1
Expand All @@ -109,3 +110,51 @@ run_sql "select * from mysql.gc_delete_range_done"
run_sql "select count(*) DELETE_RANGE_CNT from (select * from mysql.gc_delete_range union all select * from mysql.gc_delete_range_done) del_range group by ts order by DELETE_RANGE_CNT desc limit 1;"
expect_delete_range=$(($incremental_delete_range_count-$prepare_delete_range_count))
check_contains "DELETE_RANGE_CNT: $expect_delete_range"
=======
file_corruption() {
echo "corrupt the whole log files"
for filename in $(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta"); do
echo "corrupt the log file $filename"
filename_temp=$filename"_temp"
echo "corruption" > $filename_temp
cat $filename >> $filename_temp
mv $filename_temp $filename
truncate -s -11 $filename
done
}

# file corruption
file_corruption
export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/utils/set-import-attempt-to-one=return(true)"
restore_fail=0
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" || restore_fail=1
export GO_FAILPOINTS=""
if [ $restore_fail -ne 1 ]; then
echo 'pitr success on file corruption'
exit 1
fi

# start a new cluster for corruption
echo "restart a services"
restart_services

file_lost() {
echo "lost the whole log files"
for filename in $(find $TEST_DIR/$PREFIX/log -regex ".*\.log" | grep -v "schema-meta"); do
echo "lost the log file $filename"
filename_temp=$filename"_temp"
mv $filename $filename_temp
done
}

# file lost
file_lost
export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/utils/set-import-attempt-to-one=return(true)"
restore_fail=0
run_br --pd $PD_ADDR restore point -s "local://$TEST_DIR/$PREFIX/log" --full-backup-storage "local://$TEST_DIR/$PREFIX/full" || restore_fail=1
export GO_FAILPOINTS=""
if [ $restore_fail -ne 1 ]; then
echo 'pitr success on file lost'
exit 1
fi
>>>>>>> c7d09e6fa1e (br: fix br integration test file corruption (#56799))

0 comments on commit 0056d81

Please sign in to comment.