github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/br_z_gc_safepoint/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2019 PingCAP, Inc. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 # Test whether BR fails fast when backup ts exceeds GC safe point. 17 # It is call br_*z*_gc_safepoint, because it brings lots of write and 18 # slows down other tests to changing GC safe point. Adding a z prefix to run 19 # the test last. 20 21 set -eux 22 23 DB="$TEST_NAME" 24 TABLE="usertable" 25 26 MAX_UINT64=9223372036854775807 27 28 run_sql "CREATE DATABASE $DB;" 29 30 go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_PORT -p mysql.user=root -p mysql.db=$DB 31 32 # Update GC safepoint to now + 5s after 10s seconds. 33 sleep 10 && bin/gc -pd $PD_ADDR \ 34 --ca "$TEST_DIR/certs/ca.pem" \ 35 --cert "$TEST_DIR/certs/br.pem" \ 36 --key "$TEST_DIR/certs/br.key" \ 37 -gc-offset "5s" -update-service true & 38 39 # total bytes is 1136000 40 # Set ratelimit to 40960 bytes/second, it will finish within 25s, 41 # so it won't trigger exceed GC safe point error. even It use updateServiceGCSafePoint to update GC safePoint. 42 backup_gc_fail=0 43 echo "backup start (won't fail)..." 44 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/1" --db $DB -t $TABLE --ratelimit 40960 --ratelimit-unit 1 || backup_gc_fail=1 45 46 if [ "$backup_gc_fail" -ne "0" ];then 47 echo "TEST: [$TEST_NAME] test check backup ts failed!" 48 exit 1 49 fi 50 51 # set safePoint otherwise the default safePoint is zero 52 bin/gc -pd $PD_ADDR \ 53 --ca "$TEST_DIR/certs/ca.pem" \ 54 --cert "$TEST_DIR/certs/br.pem" \ 55 --key "$TEST_DIR/certs/br.key" \ 56 -gc-offset "1s" 57 58 backup_gc_fail=0 59 echo "incremental backup start (expect fail)..." 60 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/2" --db $DB -t $TABLE --lastbackupts 1 --ratelimit 1 --ratelimit-unit 1 || backup_gc_fail=1 61 62 if [ "$backup_gc_fail" -ne "1" ];then 63 echo "TEST: [$TEST_NAME] test check last backup ts failed!" 64 exit 1 65 fi 66 67 backup_gc_fail=0 68 echo "incremental backup with max_uint64 start (expect fail)..." 69 run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/3" --db $DB -t $TABLE --lastbackupts $MAX_UINT64 --ratelimit 1 --ratelimit-unit 1 || backup_gc_fail=1 70 71 if [ "$backup_gc_fail" -ne "1" ];then 72 echo "TEST: [$TEST_NAME] test check max backup ts failed!" 73 exit 1 74 fi 75 76 run_sql "DROP DATABASE $DB;"