This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
tests: add e2e test #34
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fe9e08a
tests: add e2e test
3pointer 5f72f07
fix ci
3pointer 44e2413
Update tests/_utils/check_sync_diff
3pointer 00e4a0d
fix ci
3pointer ae754e4
fix ci
3pointer 241bef3
remove pd-server
3pointer 51f6961
fix ci
3pointer 2c39281
fix ci
3pointer 593f30c
fix ci
3pointer 9533062
fix ci
3pointer 3e0f8fd
debug ci
3pointer 687fe48
debug ci
3pointer 4b4c77f
Merge branch 'master' into e2e_test
3pointer 70c14d6
fix ci
3pointer 412e79f
Merge branch 'e2e_test' of https://github.com/3pointer/dumpling into …
3pointer 7ca4268
leave TODO
3pointer 410504e
Merge branch 'master' into e2e_test
3pointer c969d17
Update tests/_utils/check_sync_diff
3pointer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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 | ||
kennytm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ run_sql "create table t (a varchar(255))" | |
chars_20="1111_0000_1111_0000_" | ||
|
||
# insert 100 records, each occupies 20 bytes | ||
run_sql "insert into t values $(seq -s, 100 | sed "s/[0-9]\+/('$chars_20')/g")" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this shell can not run on mac OS, so change it |
||
run_sql "insert into t values $(seq -s, 100 | sed 's/,*$//g' | sed "s/[0-9]*/('$chars_20')/g");" | ||
|
||
# dumping with file size = 200 bytes | ||
run_dumpling -F 200 | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better to always use latest lightning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an available lightning is enough, this test aimed to test dumpling not lightning