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 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add import goroutine leak integration test
- Loading branch information
1 parent
fbf1fb3
commit b0daec2
Showing
6 changed files
with
203 additions
and
10 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
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" |
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 @@ | ||
--- | ||
name: test | ||
task-mode: full | ||
is-sharding: false | ||
meta-schema: "dm_meta" | ||
remove-meta: false | ||
enable-heartbeat: true | ||
timezone: "Asia/Shanghai" | ||
|
||
target-database: | ||
host: "127.0.0.1" | ||
port: 4000 | ||
user: "root" | ||
password: "" | ||
|
||
mysql-instances: | ||
- source-id: "mysql-replica-01" | ||
black-white-list: "instance" | ||
mydumper-config-name: "global" | ||
loader-config-name: "global" | ||
syncer-config-name: "global" | ||
|
||
- source-id: "mysql-replica-02" | ||
black-white-list: "instance" | ||
mydumper-config-name: "global" | ||
loader-config-name: "global" | ||
syncer-config-name: "global" | ||
|
||
black-white-list: | ||
instance: | ||
do-dbs: ["import_goroutine_leak"] | ||
|
||
mydumpers: | ||
global: | ||
mydumper-path: "./bin/mydumper" | ||
threads: 4 | ||
chunk-filesize: 0 | ||
skip-tz-utc: true | ||
extra-args: "--statement-size=100" | ||
|
||
loaders: | ||
global: | ||
pool-size: 16 | ||
dir: "./dumped_data" | ||
|
||
syncers: | ||
global: | ||
worker-count: 16 | ||
batch: 100 |
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,13 @@ | ||
# Worker Configuration. | ||
|
||
source-id = "mysql-replica-01" | ||
flavor = "" | ||
enable-gtid = false | ||
relay-binlog-name = "" | ||
relay-binlog-gtid = "" | ||
|
||
[from] | ||
host = "127.0.0.1" | ||
user = "root" | ||
password = "" | ||
port = 3306 |
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,13 @@ | ||
# Worker Configuration. | ||
|
||
source-id = "mysql-replica-02" | ||
flavor = "" | ||
enable-gtid = false | ||
relay-binlog-name = "" | ||
relay-binlog-gtid = "" | ||
|
||
[from] | ||
host = "127.0.0.1" | ||
user = "root" | ||
password = "" | ||
port = 3307 |
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,77 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
source $cur/../_utils/test_prepare | ||
WORK_DIR=$TEST_DIR/$TEST_NAME | ||
|
||
COUNT=200 | ||
function prepare_datafile() { | ||
for i in $(seq 2); do | ||
data_file="$WORK_DIR/db$i.prepare.sql" | ||
echo 'DROP DATABASE if exists import_goroutine_leak;' >> $data_file | ||
echo 'CREATE DATABASE import_goroutine_leak;' >> $data_file | ||
echo 'USE import_goroutine_leak;' >> $data_file | ||
echo "CREATE TABLE t$i(i TINYINT, j INT UNIQUE KEY);" >> $data_file | ||
for j in $(seq $COUNT); do | ||
echo "INSERT INTO t$i VALUES ($i,${j}000$i),($i,${j}001$i);" >> $data_file | ||
done | ||
done | ||
} | ||
|
||
function run() { | ||
prepare_datafile | ||
|
||
run_sql_file $WORK_DIR/db1.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1 | ||
run_sql_file $WORK_DIR/db2.prepare.sql $MYSQL_HOST2 $MYSQL_PORT2 | ||
|
||
|
||
# check workers of import unit exit | ||
inject_points=("github.com/pingcap/dm/loader/dispatchError=return(1)" | ||
"github.com/pingcap/dm/loader/LoadDataSlowDown=sleep(1000)" | ||
"github.com/pingcap/dm/loader/executeSQLError=return(1)" | ||
"github.com/pingcap/dm/loader/workerCantClose=return(1)" | ||
) | ||
export GO_FAILPOINTS="$(join_string \; ${inject_points[@]})" | ||
|
||
run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml | ||
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT | ||
run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml | ||
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT | ||
run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml | ||
check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT | ||
|
||
dmctl_start_task | ||
|
||
check_port_offline $WORKER1_PORT 20 | ||
check_port_offline $WORKER2_PORT 20 | ||
|
||
# dm-worker1 panics | ||
err_cnt=`grep "panic" $WORK_DIR/worker1/log/stdout.log | wc -l` | ||
if [ $err_cnt -ne 1 ]; then | ||
echo "dm-worker1 doesn't panic, panic count ${err_cnt}" | ||
exit 2 | ||
fi | ||
|
||
# check workers of import unit exit | ||
inject_points=("github.com/pingcap/dm/loader/dispatchError=return(1)" | ||
"github.com/pingcap/dm/loader/LoadDataSlowDown=sleep(1000)" | ||
"github.com/pingcap/dm/loader/executeSQLError=return(1)" | ||
) | ||
export GO_FAILPOINTS="$(join_string \; ${inject_points[@]})" | ||
run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml | ||
run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml | ||
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT | ||
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT | ||
|
||
export GO_FAILPOINTS='' | ||
} | ||
|
||
cleanup_data import_goroutine_leak | ||
# also cleanup dm processes in case of last run failed | ||
cleanup_process $* | ||
run $* | ||
cleanup_process $* | ||
|
||
echo "[$(date)] <<<<<< test case $TEST_NAME success! >>>>>>" |