This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix incremental bug in llroad test (#199)
* restore: filter same table ddl * *: do not return error when backup/restore data is empty * fix create database double during incremental restore * add tests * fix ci * address comment
- Loading branch information
Showing
7 changed files
with
198 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2019 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
DB="$TEST_NAME" | ||
TABLE="usertable" | ||
ROW_COUNT=100 | ||
PATH="tests/$TEST_NAME:bin:$PATH" | ||
|
||
echo "load data..." | ||
# create database | ||
run_sql "CREATE DATABASE IF NOT EXISTS $DB;" | ||
# create table | ||
run_sql "CREATE TABLE IF NOT EXISTS ${DB}.${TABLE} (c1 INT);" | ||
# insert records | ||
for i in $(seq $ROW_COUNT); do | ||
run_sql "INSERT INTO ${DB}.${TABLE}(c1) VALUES ($i);" | ||
done | ||
|
||
# full backup | ||
echo "full backup start..." | ||
run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/full" --db $DB -t $TABLE --ratelimit 5 --concurrency 4 | ||
# run ddls | ||
echo "run ddls..." | ||
run_sql "RENAME TABLE ${DB}.${TABLE} to ${DB}.${TABLE}1;" | ||
run_sql "DROP TABLE ${DB}.${TABLE}1;" | ||
run_sql "DROP DATABASE ${DB};" | ||
run_sql "CREATE DATABASE ${DB};" | ||
run_sql "CREATE TABLE ${DB}.${TABLE}1 (c2 CHAR(255));" | ||
run_sql "RENAME TABLE ${DB}.${TABLE}1 to ${DB}.${TABLE};" | ||
run_sql "TRUNCATE TABLE ${DB}.${TABLE};" | ||
|
||
# incremental backup | ||
echo "incremental backup start..." | ||
last_backup_ts=$(br validate decode --field="end-version" -s "local://$TEST_DIR/$DB/full" | tail -n1) | ||
run_br --pd $PD_ADDR backup table -s "local://$TEST_DIR/$DB/inc" --db $DB -t $TABLE --ratelimit 5 --concurrency 4 --lastbackupts $last_backup_ts | ||
|
||
run_sql "DROP DATABASE $DB;" | ||
|
||
# full restore | ||
echo "full restore start..." | ||
run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB/full" --pd $PD_ADDR | ||
row_count_full=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') | ||
# check full restore | ||
if [ "${row_count_full}" != "${ROW_COUNT}" ];then | ||
echo "TEST: [$TEST_NAME] full restore fail on database $DB" | ||
exit 1 | ||
fi | ||
# incremental restore | ||
echo "incremental restore start..." | ||
fail=false | ||
run_br restore table --db $DB --table $TABLE -s "local://$TEST_DIR/$DB/inc" --pd $PD_ADDR || fail=true | ||
if $fail; then | ||
echo "TEST: [$TEST_NAME] incremental restore fail on database $DB" | ||
exit 1 | ||
else | ||
echo "TEST: [$TEST_NAME] successed!" | ||
fi | ||
|
||
run_sql "DROP DATABASE $DB;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2019 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
DB="$TEST_NAME" | ||
TABLE="usertable" | ||
ROW_COUNT=100 | ||
PATH="tests/$TEST_NAME:bin:$PATH" | ||
DB_COUNT=3 | ||
|
||
echo "load data..." | ||
|
||
# create database | ||
run_sql "CREATE DATABASE IF NOT EXISTS $DB;" | ||
# create table | ||
run_sql "CREATE TABLE IF NOT EXISTS ${DB}.${TABLE} (c1 INT);" | ||
# insert records | ||
for i in $(seq $ROW_COUNT); do | ||
run_sql "INSERT INTO ${DB}.${TABLE}(c1) VALUES ($i);" | ||
done | ||
|
||
# full backup | ||
echo "full backup start..." | ||
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB/full" --ratelimit 5 --concurrency 4 | ||
# run ddls | ||
|
||
# create 3 databases, each db has one table with same name | ||
for i in $(seq $DB_COUNT); do | ||
# create database | ||
run_sql "CREATE DATABASE $DB$i;" | ||
# create table | ||
run_sql "CREATE TABLE IF NOT EXISTS $DB$i.${TABLE} (c1 INT);" | ||
# insert records | ||
for j in $(seq $ROW_COUNT); do | ||
run_sql "INSERT INTO $DB$i.${TABLE}(c1) VALUES ($j);" | ||
done | ||
done | ||
|
||
# incremental backup | ||
echo "incremental backup start..." | ||
last_backup_ts=$(br validate decode --field="end-version" -s "local://$TEST_DIR/$DB/full" | tail -n1) | ||
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB/inc" --ratelimit 5 --concurrency 4 --lastbackupts $last_backup_ts | ||
|
||
# cleanup env | ||
run_sql "DROP DATABASE $DB;" | ||
for i in $(seq $DB_COUNT); do | ||
run_sql "DROP DATABASE $DB$i;" | ||
done | ||
|
||
# full restore | ||
echo "full restore start..." | ||
run_br restore full -s "local://$TEST_DIR/$DB/full" --pd $PD_ADDR | ||
row_count_full=$(run_sql "SELECT COUNT(*) FROM $DB.$TABLE;" | awk '/COUNT/{print $2}') | ||
# check full restore | ||
if [ "${row_count_full}" != "${ROW_COUNT}" ];then | ||
echo "TEST: [$TEST_NAME] full restore fail on database $DB" | ||
exit 1 | ||
fi | ||
|
||
# incremental restore only DB2.Table | ||
echo "incremental restore start..." | ||
run_br restore table --db ${DB}2 --table $TABLE -s "local://$TEST_DIR/$DB/inc" --pd $PD_ADDR | ||
row_count_inc=$(run_sql "SELECT COUNT(*) FROM ${DB}2.$TABLE;" | awk '/COUNT/{print $2}') | ||
# check full restore | ||
if [ "${row_count_inc}" != "${ROW_COUNT}" ];then | ||
echo "TEST: [$TEST_NAME] incremental restore fail on database $DB" | ||
exit 1 | ||
fi | ||
|
||
# cleanup env | ||
run_sql "DROP DATABASE $DB;" | ||
for i in $(seq $DB_COUNT); do | ||
run_sql "DROP DATABASE IF EXISTS $DB$i;" | ||
done |