github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_checkpoint_dirty_tableid/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 set -eux 17 18 # clean env 19 rm -f "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" 20 run_sql 'DROP DATABASE IF EXISTS tidb_lightning_checkpoint' 21 22 export GO_FAILPOINTS="github.com/pingcap/br/pkg/lightning/restore/InitializeCheckpointExit=return(true)" 23 run_lightning --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" --config "tests/$TEST_NAME/mysql.toml" -d "tests/$TEST_NAME/data" 24 25 run_sql 'DROP DATABASE IF EXISTS cpdt' 26 27 export GO_FAILPOINTS="" 28 set +e 29 run_lightning --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" --config "tests/$TEST_NAME/mysql.toml" -d "tests/$TEST_NAME/data" 30 set -e 31 32 ILLEGAL_CP_COUNT=$(grep "TiDB Lightning has detected tables with illegal checkpoints. To prevent data mismatch, this run will stop now. Please remove these checkpoints first" "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" | wc -l) 33 TABLE_SUGGEST=$(grep "./tidb-lightning-ctl --checkpoint-remove=" "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" | wc -l) 34 35 [ $ILLEGAL_CP_COUNT -eq 1 ] 36 [ $TABLE_SUGGEST -eq 2 ] 37 38 # Try again with the file checkpoints 39 40 # clean env 41 run_sql 'DROP DATABASE IF EXISTS cpdt' 42 rm -f "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" 43 rm -f "/tmp/tidb_lightning_checkpoint.pb" 44 45 export GO_FAILPOINTS="github.com/pingcap/br/pkg/lightning/restore/InitializeCheckpointExit=return(true)" 46 run_lightning --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" --config "tests/$TEST_NAME/file.toml" -d "tests/$TEST_NAME/data" 47 48 run_sql 'DROP DATABASE IF EXISTS cpdt' 49 50 export GO_FAILPOINTS="" 51 set +e 52 run_lightning --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" --config "tests/$TEST_NAME/file.toml" -d "tests/$TEST_NAME/data" 53 set -e 54 55 ILLEGAL_CP_COUNT=$(grep "TiDB Lightning has detected tables with illegal checkpoints. To prevent data mismatch, this run will stop now. Please remove these checkpoints first" "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" | wc -l) 56 TABLE_SUGGEST=$(grep "./tidb-lightning-ctl --checkpoint-remove=" "$TEST_DIR/lightning-checkpoint-dirty-tableid.log" | wc -l) 57 58 [ $ILLEGAL_CP_COUNT -eq 1 ] 59 [ $TABLE_SUGGEST -eq 2 ]