Skip to content

Commit

Permalink
test(engine): add query job integration test (#7129)
Browse files Browse the repository at this point in the history
ref #6776
  • Loading branch information
lance6716 authored Sep 21, 2022
1 parent e529b0a commit 072f0a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions engine/test/integration_tests/dm_many_tables/conf/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ upstreams:
password: ''
source-id: mysql-01
block-allow-list: balist-01
loader-thread: 1
block-allow-list:
balist-01:
do-dbs:
Expand Down
12 changes: 7 additions & 5 deletions engine/test/integration_tests/dm_many_tables/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ function run() {
run_sql 'DROP DATABASE IF EXISTS dm_many_tables'
run_sql 'CREATE DATABASE dm_many_tables;'
for i in $(seq $TABLE_NUM); do
run_sql "CREATE TABLE dm_many_tables.t$i(i TINYINT, j INT UNIQUE KEY);"
run_sql --quiet "CREATE TABLE dm_many_tables.t$i(i TINYINT, j INT UNIQUE KEY);"
for j in $(seq 2); do
run_sql "INSERT INTO dm_many_tables.t$i VALUES ($j,${j}000$j),($j,${j}001$j);"
run_sql --quiet "INSERT INTO dm_many_tables.t$i VALUES ($j,${j}000$j),($j,${j}001$j);"
done
# to make the tables have odd number of lines before 'ALTER TABLE' command, for check_sync_diff to work correctly
run_sql "INSERT INTO dm_many_tables.t$i VALUES (9, 90009);"
run_sql --quiet "INSERT INTO dm_many_tables.t$i VALUES (9, 90009);"
done

# create job & wait for job finished
job_id=$(create_job "DM" "$CUR_DIR/conf/job.yaml" "dm_many_tables")
exec_with_retry --count 200 "curl \"http://127.0.0.1:10245/api/v1/jobs/$job_id/status\" | tee /dev/stderr | jq -e '.TaskStatus.\"mysql-01\".Status.Stage == \"Finished\"'"
# check progress is forwarded gradually, not jump to "finished"
exec_with_retry --count 200 "curl \"http://127.0.0.1:10245/api/v1/jobs/$job_id/status\" | tee /dev/stderr | jq -e '.task_status.\"mysql-01\".status.status | .finishedBytes > 0 and .finishedBytes < .totalBytes'"
exec_with_retry --count 50 "curl \"http://127.0.0.1:10245/api/v1/jobs/$job_id\" | tee /dev/stderr | jq -e '.state == \"Finished\"'"

# check data
check_sync_diff $WORK_DIR $CUR_DIR/conf/diff_config.toml 1
}

trap "stop_engine_cluster $WORK_DIR $CONFIG" EXIT
# run $*
run $*
echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"
8 changes: 7 additions & 1 deletion engine/test/utils/run_sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ password=""
sql=""
ssl_key=""
ssl_cert=""
quiet=0

while [[ ${1} ]]; do
case "${1}" in
Expand Down Expand Up @@ -35,6 +36,9 @@ while [[ ${1} ]]; do
ssl_cert=${2}
shift
;;
--quiet)
quiet=1
;;
*)
sql="$sql ${1}"
;;
Expand All @@ -58,5 +62,7 @@ if [[ -n ${ssl_cert} ]]; then
fi
cmd="${cmd} --default-character-set utf8mb4 -e \"${sql}\""

echo "will execute: $cmd" >&2
if [[ ${quiet} -ne 1 ]]; then
echo "will execute: $cmd" >&2
fi
eval $cmd

0 comments on commit 072f0a2

Please sign in to comment.