github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/tests/lightning_checkpoint_engines_order/run.sh (about) 1 #!/bin/sh 2 # 3 # Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. 4 5 set -eux 6 7 check_cluster_version 4 0 0 'local backend' || exit 0 8 9 run_sql 'DROP DATABASE IF EXISTS disk_quota_checkpoint;' 10 run_sql 'DROP DATABASE IF EXISTS tidb_lightning_checkpoint;' 11 rm -rf "$TEST_DIR/$TEST_NAME.sorted" 12 13 # force crash when anything is written... 14 export GO_FAILPOINTS='github.com/pingcap/br/pkg/lightning/restore/FailAfterWriteRows=panic' 15 16 # ensure only 2 engines (index + one data) are open all the time no matter 17 # how many times we restart from beginning, since nothing was written. 18 for i in $(seq 5); do 19 set +e 20 run_lightning --enable-checkpoint=1 2> /dev/null 21 [ $? -ne 0 ] || exit 1 22 set -e 23 # engine sorted kv dir name is 36 length (UUID4). 24 [ $(ls -1q "$TEST_DIR/$TEST_NAME.sorted" | grep -E "^\S{36}$" | wc -l) -eq 2 ] 25 # load all engines into tmp file (will repeat) 26 ls -1q "$TEST_DIR/$TEST_NAME.sorted" | grep -E "^\S{36}$" >> $TEST_DIR/$TEST_NAME.sorted/engines_name 27 done 28 29 # allow one file to be written at a time, 30 export GO_FAILPOINTS='github.com/pingcap/br/pkg/lightning/restore/FailAfterWriteRows=1*return->panic' 31 32 # and now we should have 3 engines since one engine will be successfully imported. 33 set +e 34 run_lightning --enable-checkpoint=1 2> /dev/null 35 [ $? -ne 0 ] || exit 1 36 set -e 37 # engine sorted kv dir name is 36 length (UUID4). 38 ls -1q "$TEST_DIR/$TEST_NAME.sorted" | grep -E "^\S{36}$" >> $TEST_DIR/$TEST_NAME.sorted/engines_name 39 if [ ! $(cat $TEST_DIR/$TEST_NAME.sorted/engines_name | sort -n | uniq | wc -l) -eq 3 ]; then 40 ls -al "$TEST_DIR/$TEST_NAME.sorted" 41 exit 1 42 fi 43 44 # allow everything to be written, 45 export GO_FAILPOINTS='' 46 # to import everything, 47 run_lightning --enable-checkpoint=1 48 # simple check. 49 run_sql 'select concat(a, b) from disk_quota_checkpoint.t;' 50 check_contains '1one' 51 check_contains '5five' 52 check_contains '9nine'