Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
validate: fix debug meta test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Feb 4, 2020
1 parent 3863a3a commit 7feba3d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/br_debug_meta/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@

set -eu
DB="$TEST_NAME"
TABLE="usertable1"

run_sql "CREATE DATABASE $DB;"

run_sql "CREATE TABLE $DB.usertable1 ( \
run_sql "CREATE TABLE $DB.$TABLE( \
YCSB_KEY varchar(64) NOT NULL, \
FIELD0 varchar(1) DEFAULT NULL, \
PRIMARY KEY (YCSB_KEY) \
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"

run_sql "INSERT INTO $DB.usertable1 VALUES (\"a\", \"b\");"
run_sql "INSERT INTO $DB.usertable1 VALUES (\"aa\", \"b\");"
run_sql "INSERT INTO $DB.$TABLE VALUES (\"a\", \"b\");"
run_sql "INSERT INTO $DB.$TABLE VALUES (\"aa\", \"b\");"

row_count_ori=$(run_sql "SELECT COUNT(*) FROM $DB$.$TAble;" | awk '/COUNT/{print $2}')

# backup table
echo "backup start..."
run_br --pd $PD_ADDR backup table --db $DB --table usertable1 -s "local://$TEST_DIR/$DB" --ratelimit 5 --concurrency 4

run_sql "DROP DATABASE $DB;"

# Test validate decode
run_br validate decode -s "local://$TEST_DIR/$DB"

Expand All @@ -49,9 +54,16 @@ if [ ! -f "$TEST_DIR/$DB/backupmeta_from_json" ]; then
exit 1
fi

DIFF=$(diff $TEST_DIR/$DB/backupmeta_from_json $TEST_DIR/$DB/backupmeta)
if [ "$DIFF" != "" ]
then
# replace backupmeta
mv "$TEST_DIR/$DB/backupmeta_from_json" "$TEST_DIR/$DB/backupmeta"

# restore table
echo "restore start..."
run_br --pd $PD_ADDR restore table --db $DB --table usertable1 -s "local://$TEST_DIR/$DB"

row_count_new=$(run_sql "SELECT COUNT(*) FROM $DB$.$TABLE;" | awk '/COUNT/{print $2}')

if [ "${row_count_ori}" != "${row_count_new}" ];then
echo "TEST: [$TEST_NAME] failed!"
exit 1
fi
Expand Down

0 comments on commit 7feba3d

Please sign in to comment.