This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
test: add online ddl test in integration test #84
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b0910c3
test: intergration test script tuning
amyangfei 8318a7b
test: add online ddl test
amyangfei 40ba707
*: fix mysql port
amyangfei 2debe90
*: simplify sql file in online ddl test
amyangfei 132e93a
test: add pt-osc test. refine scripts
amyangfei 3a0eb43
test: enable both gh-ost and pt-osc in online ddl test
amyangfei ea0a039
test: fix cleanup target db
amyangfei 6cabb4c
*: fix parameter sequence in run_sql_file
amyangfei 7d13afd
test: update test readme
amyangfei e9d5aad
test: remove unused interface in online_ddl.
amyangfei 1d5e6ac
Update tests/README.md
csuzhangxc 8747c6e
*: DDL typo
amyangfei 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
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#!/bin/sh | ||
# parameter 1: sql file | ||
# parameter 2: port | ||
# parameter 2: host | ||
# parameter 3: port | ||
|
||
set -eu | ||
|
||
echo "[$(date)] Executing SQL: $1" > "$TEST_DIR/sql_res.$TEST_NAME.txt" | ||
mysql -uroot -h127.0.0.1 -P$2 --default-character-set utf8 -vv < "$1" >> "$TEST_DIR/sql_res.$TEST_NAME.txt" | ||
mysql -uroot -h$2 -P$3 --default-character-set utf8 -vv < "$1" >> "$TEST_DIR/sql_res.$TEST_NAME.txt" |
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,49 @@ | ||
#!/bin/bash | ||
# parameter 1: sql file | ||
# parameter 2: host | ||
# parameter 3: port | ||
# parameter 4: db | ||
# parameter 5: online ddl tool, pt or gh-ost | ||
|
||
set -eu | ||
|
||
sql_file=$1 | ||
host=$2 | ||
port=$3 | ||
schema=$4 | ||
ghost_bin=${GHOST_BINARY:-gh-ost} | ||
ptosc_bin=${PTOSC_BINARY:-pt-online-schema-change} | ||
|
||
echo "[$(date)] Executing SQL: $sql_file" > "$TEST_DIR/sql_res.$TEST_NAME.txt" | ||
|
||
# we use lower case `alter table` in test sql, if want case insensetive, | ||
# just set `shopt -s nocasematch` | ||
ddl_regex="^alter table.*" | ||
while IFS= read -r line | ||
do | ||
if [[ "$line" =~ $ddl_regex ]]; then | ||
table=$(echo $line | cut -d " " -f3) | ||
alter=$(echo $line | cut -d " " -f4-) | ||
# gh-ost check connection port whether equals to `select @@global.port`. | ||
# if we have test MySQL in container and port mapping, these two ports | ||
# may different. So we cheat gh-ost that we are running on aliyun rds, | ||
# on which will disable the port check. | ||
if [ "$5" == "gh-ost" ]; then | ||
$ghost_bin --user=root --host=$host --port=$port \ | ||
--database=$schema --table=$table --alter="$alter" \ | ||
--serve-socket-file="$TEST_DIR/gh-ost.$schema.$table.$port.sock" \ | ||
--allow-on-master --allow-master-master --initially-drop-ghost-table \ | ||
--initially-drop-old-table -ok-to-drop-table -aliyun-rds -execute \ | ||
>> $TEST_DIR/gh-ost.log | ||
elif [ "$5" == "pt" ]; then | ||
$ptosc_bin --user=root --host=$host --port=$port \ | ||
--alter="$alter" D=$schema,t=$table \ | ||
--recursion-method=none --print --execute \ | ||
>> $TEST_DIR/pt-osc.log | ||
else | ||
mysql -uroot -h$host -P$port --default-character-set utf8 -E -e "use $schema; $line" >> "$TEST_DIR/sql_res.$TEST_NAME.txt" | ||
fi | ||
else | ||
mysql -uroot -h$host -P$port --default-character-set utf8 -E -e "use $schema; $line" >> "$TEST_DIR/sql_res.$TEST_NAME.txt" | ||
fi | ||
done <"$sql_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,23 @@ | ||
MYSQL_HOST1=${MYSQL_HOST1:-127.0.0.1} | ||
MYSQL_HOST2=${MYSQL_HOST2:-127.0.0.1} | ||
MYSQL_PORT1=${MYSQL_PORT1:-3306} | ||
MYSQL_PORT2=${MYSQL_PORT2:-3307} | ||
TIDB_PORT=4000 | ||
MASTER_PORT=8261 | ||
WORKER1_PORT=8262 | ||
WORKER2_PORT=8263 | ||
|
||
# we do clean staff at beginning of each run, so we can keep logs of the latset run | ||
function cleanup1() { | ||
rm -rf $WORK_DIR | ||
mkdir $WORK_DIR | ||
for target_db in "$@"; do | ||
run_sql "drop database if exists ${target_db}" $TIDB_PORT | ||
done | ||
run_sql "drop database if exists dm_meta" $TIDB_PORT | ||
} | ||
|
||
function cleanup2() { | ||
pkill -hup dm-worker.test 2>/dev/null || true | ||
pkill -hup dm-master.test 2>/dev/null || true | ||
} |
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,57 @@ | ||
# 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 = "online_ddl" | ||
tables = ["t_target"] | ||
|
||
[[table-config]] | ||
schema = "online_ddl" | ||
table = "t_target" | ||
ignore-columns = ["id"] | ||
is-online_ddl = true | ||
index-field = "uid" | ||
|
||
[[table-config.source-tables]] | ||
instance-id = "source-1" | ||
schema = "online_ddl" | ||
table = "~t.*" | ||
|
||
[[table-config.source-tables]] | ||
instance-id = "source-2" | ||
schema = "online_ddl" | ||
table = "~t.*" | ||
|
||
[[source-db]] | ||
host = "127.0.0.1" | ||
port = 3306 | ||
user = "root" | ||
password = "" | ||
instance-id = "source-1" | ||
|
||
[[source-db]] | ||
host = "127.0.0.1" | ||
port = 3307 | ||
user = "root" | ||
password = "" | ||
instance-id = "source-2" | ||
|
||
[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,9 @@ | ||
# Master Configuration. | ||
|
||
[[deploy]] | ||
source-id = "mysql-replica-01" | ||
dm-worker = "127.0.0.1:8262" | ||
|
||
[[deploy]] | ||
source-id = "mysql-replica-02" | ||
dm-worker = "127.0.0.1:8263" |
Oops, something went wrong.
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.
@GregoryIan what's your opinion about removing these unused interfaces.
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.
It doesn't matter, add it back when you need it.