Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
add check_task api test
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei committed May 8, 2019
1 parent 3dd17f4 commit 94de8f1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
36 changes: 36 additions & 0 deletions tests/dmctl_basic/check_list/check_task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

function check_task_wrong_arg() {
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task" \
"check-task <config_file> \[flags\]" 1
}

function check_task_wrong_config_file() {
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task not_exists_config_file" \
"get file content error" 1
}

# run this check if DM-master is not available
function check_task_fail() {
task_conf=$1
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task $task_conf" \
"fail to check task" 1
}

function check_task_pass() {
task_conf=$1
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task $task_conf" \
"\"msg\": \"check pass!!!\"" 1 \
"\"result\": true" 1
}

function check_task_not_pass() {
task_conf=$1
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"check-task $task_conf" \
"\"result\": false" 1
}
2 changes: 2 additions & 0 deletions tests/dmctl_basic/conf/dm-task2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
description: "invalid task config"
18 changes: 16 additions & 2 deletions tests/dmctl_basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@ set -eu
cur=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $cur/../_utils/test_prepare
WORK_DIR=$TEST_DIR/$TEST_NAME
TASK_CONF=$cur/conf/dm-task.yaml

function run() {
run_sql_file $cur/data/db1.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1
run_sql_file $cur/data/db2.prepare.sql $MYSQL_HOST2 $MYSQL_PORT2

cd $cur
for file in "check_list"/*; do
source $file
done
cd -

check_task_wrong_arg
check_task_wrong_config_file
check_task_fail $TASK_CONF

run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status -w worker-x task-y" \
"can not query task-y task's status(in workers \[worker-x\]):" 1
Expand All @@ -31,17 +42,20 @@ function run() {
"\"result\": true" 3 \
"\"msg\": \"no sub task started\"" 2

check_task_pass $TASK_CONF
check_task_not_pass $cur/conf/dm-task2.yaml

# start DM task only
dmctl_start_task

check_sync_diff $WORK_DIR $cur/conf/diff_config.toml

run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status" \
"\"result\": true" 3 \
"\"unit\": \"Sync\"" 2 \
"\"stage\": \"Running\"" 4

check_sync_diff $WORK_DIR $cur/conf/diff_config.toml

run_sql_file $cur/data/db1.increment.sql $MYSQL_HOST1 $MYSQL_PORT1
run_sql_file $cur/data/db2.increment.sql $MYSQL_HOST2 $MYSQL_PORT2

Expand Down

0 comments on commit 94de8f1

Please sign in to comment.