forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tests: add e2e test * fix ci * Update tests/_utils/check_sync_diff Co-Authored-By: kennytm <kennytm@gmail.com> * fix ci * fix ci * remove pd-server * fix ci * fix ci * fix ci * fix ci * debug ci * debug ci * fix ci * leave TODO * Update tests/_utils/check_sync_diff Co-Authored-By: Ian <ArGregoryIan@gmail.com> Co-authored-by: kennytm <kennytm@gmail.com> Co-authored-by: Ian <ArGregoryIan@gmail.com>
- Loading branch information
1 parent
65b93cc
commit 6828e6a
Showing
13 changed files
with
234 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ bin/ | |
coverage.txt | ||
.idea | ||
var | ||
fix.sql |
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,21 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# FIXME: change to latest version after lightning fix issue | ||
# https://github.com/pingcap/tidb-lightning/issues/277 | ||
TAG="v3.1.0-beta.1" | ||
pwd=$(pwd) | ||
|
||
mkdir bin/ | ||
|
||
# download lightning and sync_diff_inspector | ||
wget http://download.pingcap.org/tidb-toolkit-$TAG-linux-amd64.tar.gz -O tools.tar.gz | ||
tar -xzvf tools.tar.gz | ||
mv tidb-toolkit-$TAG-linux-amd64/bin/* bin/ | ||
|
||
# download tidb-server | ||
git clone -b $TAG https://github.com/pingcap/tidb | ||
cd $pwd/tidb && make | ||
cd $pwd | ||
mv tidb/bin/tidb-server bin/ |
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,30 @@ | ||
#!/bin/bash | ||
# parameter 1: config file for sync_diff_inspector | ||
# parameter 2: max check times | ||
|
||
conf=$1 | ||
check_time=${2-10} | ||
|
||
LOG=$DUMPLING_OUTPUT_DIR/sync_diff_inspector.log | ||
|
||
i=0 | ||
while [ $i -lt $check_time ] | ||
do | ||
bin/sync_diff_inspector --config=$conf >> $LOG 2>&1 | ||
ret=$? | ||
if [ "$ret" == 0 ]; then | ||
echo "check diff successfully" | ||
break | ||
fi | ||
((i++)) | ||
echo "check diff failed $i-th time, retry later" | ||
sleep 2 | ||
done | ||
|
||
if [ $i -ge $check_time ]; then | ||
echo "check data failed, some data are different!!" | ||
# show \n and other blanks | ||
printf "$(cat $LOG)\n" | ||
exit 1 | ||
fi | ||
cd $PWD |
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,11 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
echo "[$(date)] Executing bin/tidb-lightning..." | ||
|
||
conf=$1 | ||
|
||
bin/tidb-lightning -c $1 | ||
|
||
echo "[$(date)] Executed bin/tidb-lightning" |
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,56 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
PD_ADDR="127.0.0.1:2379" | ||
TIDB_IP="127.0.0.1" | ||
TIDB_PORT="4000" | ||
TIDB_ADDR="127.0.0.1:4000" | ||
TIDB_STATUS_ADDR="127.0.0.1:10080" | ||
|
||
stop_services() { | ||
killall -9 tidb-server || true | ||
|
||
find "$DUMPLING_TEST_DIR" -maxdepth 1 -not -path "$DUMPLING_TEST_DIR" -not -name "*.log" | xargs rm -r || true | ||
} | ||
|
||
start_services() { | ||
stop_services | ||
echo "Ensure mysql can connected..." | ||
|
||
cat > "$DUMPLING_TEST_DIR/mysql.cnf" <<EOF | ||
[client] | ||
user = ${DUMPLING_TEST_USER} | ||
host = ${DUMPLING_TEST_HOST} | ||
port = ${DUMPLING_TEST_PORT} | ||
password = ${DUMPLING_TEST_PASSWORD} | ||
default-character-set = utf8mb4 | ||
EOF | ||
i=0 | ||
while ! run_sql 'select 0 limit 0' > /dev/null; do | ||
i=$((i+1)) | ||
if [ "$i" -gt 10 ]; then | ||
echo 'Failed to ping MySQL Server' | ||
exit 1 | ||
fi | ||
sleep 3 | ||
done | ||
|
||
bin/tidb-server \ | ||
-P 4000 \ | ||
--status 10080 \ | ||
--store mocktikv \ | ||
--log-file "$DUMPLING_TEST_DIR/tidb.log" & | ||
|
||
echo "Verifying TiDB is started..." | ||
i=0 | ||
while ! curl -o /dev/null -sf "http://$TIDB_IP:10080/status"; do | ||
i=$((i+1)) | ||
if [ "$i" -gt 10 ]; then | ||
echo 'Failed to start TiDB' | ||
exit 1 | ||
fi | ||
sleep 3 | ||
done | ||
} | ||
|
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,42 @@ | ||
# diff Configuration. | ||
|
||
log-level = "info" | ||
|
||
chunk-size = 1000 | ||
|
||
check-thread-count = 4 | ||
|
||
sample-percent = 100 | ||
|
||
use-rowid = false | ||
|
||
use-checksum = true | ||
|
||
fix-sql-file = "fix.sql" | ||
|
||
# tables need to check. | ||
[[check-tables]] | ||
schema = "e2e" | ||
tables = ["~t.*"] | ||
|
||
[[table-config]] | ||
schema = "e2e" | ||
table = "t" | ||
|
||
[[table-config.source-tables]] | ||
instance-id = "source-1" | ||
schema = "e2e" | ||
table = "t" | ||
|
||
[[source-db]] | ||
host = "127.0.0.1" | ||
port = 3306 | ||
user = "root" | ||
password = "" | ||
instance-id = "source-1" | ||
|
||
[target-db] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" |
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,20 @@ | ||
### tidb-lightning config | ||
|
||
[lightning] | ||
server-mode = false | ||
level = "error" | ||
check-requirements = false | ||
|
||
[tikv-importer] | ||
backend="tidb" | ||
on-duplicate = "error" | ||
|
||
[mydumper] | ||
data-source-dir = "/tmp/dumpling_test_result/sql_res.e2e" | ||
|
||
[tidb] | ||
host = "127.0.0.1" | ||
port = 4000 | ||
user = "root" | ||
password = "" | ||
status-port = 10080 |
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,35 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
cur=$(cd `dirname $0`; pwd) | ||
|
||
DB_NAME="e2e" | ||
TABLE_NAME="t" | ||
|
||
# drop database on tidb | ||
export DUMPLING_TEST_PORT=4000 | ||
run_sql "drop database if exists $DB_NAME;" | ||
|
||
# drop database on mysql | ||
export DUMPLING_TEST_PORT=3306 | ||
run_sql "drop database if exists $DB_NAME;" | ||
|
||
# build data on mysql | ||
run_sql "create database $DB_NAME;" | ||
run_sql "create table $DB_NAME.$TABLE_NAME (a int(255));" | ||
|
||
# insert 100 records | ||
run_sql "insert into $DB_NAME.$TABLE_NAME values $(seq -s, 100 | sed 's/,*$//g' | sed "s/[0-9]*/('1')/g");" | ||
|
||
# dumping | ||
export DUMPLING_TEST_DATABASE=$DB_NAME | ||
run_dumpling | ||
|
||
cat "$cur/conf/lightning.toml" | ||
# use lightning import data to tidb | ||
run_lightning $cur/conf/lightning.toml | ||
|
||
# check mysql and tidb data | ||
check_sync_diff $cur/conf/diff_config.toml | ||
|
||
|
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