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

validate: fix debug meta test ci #153

Merged
merged 4 commits into from
Feb 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions tests/br_debug_meta/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,33 @@

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"

# should generate backupmeta.json
if [ ! -f "$TEST_DIR/$DB/backupmeta.json" ]; then
echo "TEST: [$TEST_NAME] failed!"
echo "TEST: [$TEST_NAME] decode failed!"
exit 1
fi

Expand All @@ -45,14 +50,21 @@ run_br validate encode -s "local://$TEST_DIR/$DB"

# should generate backupmeta_from_json
if [ ! -f "$TEST_DIR/$DB/backupmeta_from_json" ]; then
echo "TEST: [$TEST_NAME] failed!"
echo "TEST: [$TEST_NAME] encode failed!"
exit 1
fi

DIFF=$(diff $TEST_DIR/$DB/backupmeta_from_json $TEST_DIR/$DB/backupmeta)
if [ "$DIFF" != "" ]
then
echo "TEST: [$TEST_NAME] failed!"
# 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!, row count not equal after restore"
exit 1
fi

Expand Down