@@ -21,6 +21,7 @@ CUR=$(cd `dirname $0`; pwd)
21
21
# const value
22
22
PREFIX=" pitr_backup" # NOTICE: don't start with 'br' because `restart services` would remove file/directory br*.
23
23
res_file=" $TEST_DIR /sql_res.$TEST_NAME .txt"
24
+ TASK_NAME=" br_pitr"
24
25
25
26
# start a new cluster
26
27
echo " restart a services"
@@ -37,7 +38,7 @@ echo "prepare_delete_range_count: $prepare_delete_range_count"
37
38
38
39
# start the log backup task
39
40
echo " start log task"
40
- run_br --pd $PD_ADDR log start --task-name integration_test -s " local://$TEST_DIR /$PREFIX /log"
41
+ run_br --pd $PD_ADDR log start --task-name $TASK_NAME -s " local://$TEST_DIR /$PREFIX /log"
41
42
42
43
# run snapshot backup
43
44
echo " run snapshot backup"
@@ -53,39 +54,8 @@ incremental_delete_range_count=$(run_sql "select count(*) DELETE_RANGE_CNT from
53
54
echo " incremental_delete_range_count: $incremental_delete_range_count "
54
55
55
56
# wait checkpoint advance
56
- echo " wait checkpoint advance"
57
- sleep 10
58
- current_ts=$( echo $(( $(date +% s% 3 N) << 18 )) )
59
- echo " current ts: $current_ts "
60
- i=0
61
- while true ; do
62
- # extract the checkpoint ts of the log backup task. If there is some error, the checkpoint ts should be empty
63
- log_backup_status=$( unset BR_LOG_TO_TERM && run_br --pd $PD_ADDR log status --task-name integration_test --json 2> /dev/null)
64
- echo " log backup status: $log_backup_status "
65
- checkpoint_ts=$( echo " $log_backup_status " | head -n 1 | jq ' if .[0].last_errors | length == 0 then .[0].checkpoint else empty end' )
66
- echo " checkpoint ts: $checkpoint_ts "
67
-
68
- # check whether the checkpoint ts is a number
69
- if [ $checkpoint_ts -gt 0 ] 2> /dev/null; then
70
- # check whether the checkpoint has advanced
71
- if [ $checkpoint_ts -gt $current_ts ]; then
72
- echo " the checkpoint has advanced"
73
- break
74
- fi
75
- # the checkpoint hasn't advanced
76
- echo " the checkpoint hasn't advanced"
77
- i=$(( i+ 1 ))
78
- if [ " $i " -gt 50 ]; then
79
- echo ' the checkpoint lag is too large'
80
- exit 1
81
- fi
82
- sleep 10
83
- else
84
- # unknown status, maybe somewhere is wrong
85
- echo " TEST: [$TEST_NAME ] failed to wait checkpoint advance!"
86
- exit 1
87
- fi
88
- done
57
+ current_ts=$( python3 -c " import time; print(int(time.time() * 1000) << 18)" )
58
+ . " $CUR /../br_test_utils.sh" && wait_log_checkpoint_advance $TASK_NAME
89
59
90
60
# dump some info from upstream cluster
91
61
# ...
0 commit comments