diff --git a/_utils/terror_gen/errors_release.txt b/_utils/terror_gen/errors_release.txt index 0472b37382..df87734676 100644 --- a/_utils/terror_gen/errors_release.txt +++ b/_utils/terror_gen/errors_release.txt @@ -451,4 +451,5 @@ ErrSchedulerSubTaskExist,[code=46014:class=scheduler:scope=internal:level=medium ErrSchedulerSubTaskStageInvalidUpdate,[code=46015:class=dm-master:scope=internal:level=medium], "Message: invalid new expectant subtask stage %s" ErrSchedulerSubTaskOpTaskNotExist,[code=46016:class=dm-master:scope=internal:level=medium], "Message: subtasks with name %s need to be operate not exist" ErrSchedulerSubTaskOpSourceNotExist,[code=46017:class=dm-master:scope=internal:level=medium], "Message: sources %v need to be operate not exist" -ErrNotSet,[code=48001:class=not-set:scope=not-set:level=high] +ErrCtlGRPCCreateConn,[code=48001:class=dmctl:scope=internal:level=high], "Message: can not create grpc connection, Workaround: Please check your network connection." +ErrNotSet,[code=50000:class=not-set:scope=not-set:level=high] diff --git a/cmd/dm-ctl/main.go b/cmd/dm-ctl/main.go index 8efc4d0b75..0040c3b43d 100644 --- a/cmd/dm-ctl/main.go +++ b/cmd/dm-ctl/main.go @@ -28,6 +28,7 @@ import ( "github.com/pingcap/dm/dm/ctl" "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/pkg/log" + "github.com/pingcap/dm/pkg/terror" "github.com/pingcap/dm/pkg/utils" ) @@ -148,7 +149,7 @@ func main() { err = ctl.Init(cfg) if err != nil { - fmt.Printf("init control error %v", errors.ErrorStack(err)) + common.PrintLines("%v", terror.Message(err)) os.Exit(2) } if lenCmdArgs > 0 { diff --git a/dm/ctl/common/util.go b/dm/ctl/common/util.go index a497088719..39a047b5b2 100644 --- a/dm/ctl/common/util.go +++ b/dm/ctl/common/util.go @@ -22,6 +22,7 @@ import ( "github.com/pingcap/dm/dm/pb" parserpkg "github.com/pingcap/dm/pkg/parser" + "github.com/pingcap/dm/pkg/terror" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" @@ -45,9 +46,9 @@ func InitUtils(cfg *Config) error { // InitClient initializes dm-master client func InitClient(addr string) error { - conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithBackoffMaxDelay(3*time.Second)) + conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithBackoffMaxDelay(3*time.Second), grpc.WithBlock(), grpc.WithTimeout(3*time.Second)) if err != nil { - return errors.Trace(err) + return terror.ErrCtlGRPCCreateConn.AnnotateDelegate(err, "can't connect to %s", addr) } masterClient = pb.NewMasterClient(conn) return nil diff --git a/errors.toml b/errors.toml index 89c56c422e..31c56c5508 100644 --- a/errors.toml +++ b/errors.toml @@ -2716,7 +2716,13 @@ description = "" workaround = "" tags = ["internal", "medium"] -[error.DM-not-set-48001] +[error.DM-dmctl-48001] +message = "can not create grpc connection" +description = "" +workaround = "Please check your network connection." +tags = ["internal", "high"] + +[error.DM-not-set-50000] message = "" description = "" workaround = "" diff --git a/pkg/terror/error_list.go b/pkg/terror/error_list.go index c1847ee68f..b6c606cc43 100644 --- a/pkg/terror/error_list.go +++ b/pkg/terror/error_list.go @@ -546,8 +546,14 @@ const ( codeSchedulerSubTaskOpSourceNotExist ) +// dmctl error code const ( - codeNotSet ErrCode = iota + 48001 + codeCtlGRPCCreateConn ErrCode = iota + 48001 +) + +// default error code +const ( + codeNotSet ErrCode = iota + 50000 ) // Error instances @@ -1062,6 +1068,9 @@ var ( ErrSchedulerSubTaskOpTaskNotExist = New(codeSchedulerSubTaskOpTaskNotExist, ClassDMMaster, ScopeInternal, LevelMedium, "subtasks with name %s need to be operate not exist", "") ErrSchedulerSubTaskOpSourceNotExist = New(codeSchedulerSubTaskOpSourceNotExist, ClassDMMaster, ScopeInternal, LevelMedium, "sources %v need to be operate not exist", "") - // default error code + // dmctl + ErrCtlGRPCCreateConn = New(codeCtlGRPCCreateConn, ClassDMCtl, ScopeInternal, LevelHigh, "can not create grpc connection", "Please check your network connection.") + + // default error ErrNotSet = New(codeNotSet, ClassNotSet, ScopeNotSet, LevelHigh, "", "") ) diff --git a/pkg/terror/terror.go b/pkg/terror/terror.go index f5c2f6f7f3..42419c556f 100644 --- a/pkg/terror/terror.go +++ b/pkg/terror/terror.go @@ -48,6 +48,7 @@ const ( ClassDMTracer ClassSchemaTracker ClassScheduler + ClassDMCtl ClassNotSet ) @@ -68,6 +69,7 @@ var errClass2Str = map[ErrClass]string{ ClassDMTracer: "dm-tracer", ClassSchemaTracker: "schema-tracker", ClassScheduler: "scheduler", + ClassDMCtl: "dmctl", ClassNotSet: "not-set", } diff --git a/tests/dmctl_advance/check_list/migrate_relay.sh b/tests/dmctl_advance/check_list/migrate_relay.sh index 8063283c3b..62c802b4fd 100644 --- a/tests/dmctl_advance/check_list/migrate_relay.sh +++ b/tests/dmctl_advance/check_list/migrate_relay.sh @@ -12,9 +12,3 @@ function migrate_relay_without_worker() { "migrate-relay $SOURCE_ID1 bin-000001 $binlog_pos" \ "strconv.Atoi: parsing \"$binlog_pos\": invalid syntax" 1 } - -function migrate_relay_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "migrate-relay $SOURCE_ID1 bin-000001 194" \ - "can not migrate relay" 1 -} diff --git a/tests/dmctl_advance/check_list/query_error.sh b/tests/dmctl_advance/check_list/query_error.sh index d9f8506b63..bbf2b3a49b 100644 --- a/tests/dmctl_advance/check_list/query_error.sh +++ b/tests/dmctl_advance/check_list/query_error.sh @@ -6,8 +6,3 @@ function query_error_wrong_arg() { "query-error \[-s source ...\] \[task-name\]" 1 } -function query_error_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "query-error -s $SOURCE_ID1 test-task" \ - "query error failed" 1 -} diff --git a/tests/dmctl_advance/check_list/sql_replace.sh b/tests/dmctl_advance/check_list/sql_replace.sh index cd64382c0b..bf4a1d4858 100644 --- a/tests/dmctl_advance/check_list/sql_replace.sh +++ b/tests/dmctl_advance/check_list/sql_replace.sh @@ -18,9 +18,3 @@ function sql_replace_non_sharding_without_one_worker() { "sql-replace test-task --source $SOURCE_ID1,$SOURCE_ID2 --binlog-pos mysql-bin:13426 sql1" \ "should only specify one source, but got \[$SOURCE_ID1 $SOURCE_ID2\]" 1 } - -function sql_replace_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "sql-replace test-task --sharding --sql-pattern ~(?i)ALTER\\s+TABLE\\s+ ALTER TABLE tbl DROP COLUMN col" \ - "can not replace SQL:" 1 -} diff --git a/tests/dmctl_advance/check_list/sql_skip.sh b/tests/dmctl_advance/check_list/sql_skip.sh index a240093d44..db439a466e 100644 --- a/tests/dmctl_advance/check_list/sql_skip.sh +++ b/tests/dmctl_advance/check_list/sql_skip.sh @@ -37,9 +37,3 @@ function sql_skip_non_sharding_without_one_worker() { "sql-skip test-task --source $SOURCE_ID1,$SOURCE_ID2 --binlog-pos mysql-bin:13426" \ "should only specify one source, but got \[$SOURCE_ID1 $SOURCE_ID2\]" 1 } - -function sql_skip_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "sql-skip test-task --sharding --sql-pattern ~(?i)ALTER\\s+TABLE\\s+" \ - "can not skip SQL:" 1 -} diff --git a/tests/dmctl_advance/check_list/switch_relay_master.sh b/tests/dmctl_advance/check_list/switch_relay_master.sh index ecd4b1428d..8370554e83 100644 --- a/tests/dmctl_advance/check_list/switch_relay_master.sh +++ b/tests/dmctl_advance/check_list/switch_relay_master.sh @@ -11,9 +11,3 @@ function switch_relay_master_without_worker() { "switch-relay-master" \ "must specify at least one source (\`-s\` \/ \`--source\`)" 1 } - -function switch_relay_master_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "switch-relay-master -s $SOURCE_ID1" \ - "can not switch relay's master server (in sources \[$SOURCE_ID1\]):" 1 -} diff --git a/tests/dmctl_advance/check_list/unlock_ddl_lock.sh b/tests/dmctl_advance/check_list/unlock_ddl_lock.sh index 52557a50bd..3d08bcf438 100644 --- a/tests/dmctl_advance/check_list/unlock_ddl_lock.sh +++ b/tests/dmctl_advance/check_list/unlock_ddl_lock.sh @@ -12,9 +12,3 @@ function unlock_ddl_lock_invalid_force_remove() { "unlock-ddl-lock lock_id --force-remove=$force_remove_val" \ "Error: invalid argument \"$force_remove_val\" for \"-f, --force-remove\"" 1 } -function unlock_ddl_lock_while_master_down() { - lock_id="test-\`shard_db\`.\`shard_table\`" - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "unlock-ddl-lock $lock_id" \ - "can not unlock DDL lock $lock_id" 1 -} diff --git a/tests/dmctl_advance/conf/dm-master.toml b/tests/dmctl_advance/conf/dm-master.toml new file mode 100644 index 0000000000..14ac020290 --- /dev/null +++ b/tests/dmctl_advance/conf/dm-master.toml @@ -0,0 +1,4 @@ +# Master Configuration. + +master-addr = ":8261" +advertise-addr = "127.0.0.1:8261" diff --git a/tests/dmctl_advance/run.sh b/tests/dmctl_advance/run.sh index ef12dac1f8..2ea516b0a8 100755 --- a/tests/dmctl_advance/run.sh +++ b/tests/dmctl_advance/run.sh @@ -14,19 +14,14 @@ SQL_RESULT_FILE="$TEST_DIR/sql_res.$TEST_NAME.txt" function usage_and_arg_test() { migrate_relay_wrong_arg migrate_relay_without_worker - # todo: no sense to fix - #migrate_relay_while_master_down switch_relay_master_wrong_arg switch_relay_master_without_worker - switch_relay_master_while_master_down unlock_ddl_lock_wrong_arg unlock_ddl_lock_invalid_force_remove - unlock_ddl_lock_while_master_down query_error_wrong_arg - query_error_while_master_down sql_skip_wrong_arg sql_skip_binlogpos_sqlpattern_conflict @@ -34,13 +29,11 @@ function usage_and_arg_test() { sql_skip_invalid_regex sql_skip_sharding_with_binlogpos sql_skip_non_sharding_without_one_worker - sql_skip_while_master_down sql_replace_wrong_arg sql_replace_invalid_binlog_pos sql_replace_non_sharding_without_one_worker # TODO: check SQLs error test - sql_replace_while_master_down } function run() { @@ -50,6 +43,8 @@ function run() { done cd - + 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 usage_and_arg_test } diff --git a/tests/dmctl_basic/check_list/check_task.sh b/tests/dmctl_basic/check_list/check_task.sh index 944197a477..2d969f99e4 100644 --- a/tests/dmctl_basic/check_list/check_task.sh +++ b/tests/dmctl_basic/check_list/check_task.sh @@ -12,14 +12,6 @@ function check_task_wrong_config_file() { "get file content error" 1 } -# run this check if DM-master is not available -function check_task_while_master_down() { - 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" \ diff --git a/tests/dmctl_basic/check_list/operate_source.sh b/tests/dmctl_basic/check_list/operate_source.sh index a6fb4002d1..4da3f83b3d 100644 --- a/tests/dmctl_basic/check_list/operate_source.sh +++ b/tests/dmctl_basic/check_list/operate_source.sh @@ -12,13 +12,6 @@ function operate_source_wrong_config_file() { "get file content error" 1 } -function operate_source_while_master_down() { - source_conf=$1 - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "operate-source create $source_conf" \ - "can not update task" 1 -} - function operate_source_stop_not_created_config() { source_conf=$1 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ diff --git a/tests/dmctl_basic/check_list/pause_relay.sh b/tests/dmctl_basic/check_list/pause_relay.sh index ead2568398..c3cc018d8d 100644 --- a/tests/dmctl_basic/check_list/pause_relay.sh +++ b/tests/dmctl_basic/check_list/pause_relay.sh @@ -12,12 +12,6 @@ function pause_relay_wihout_worker() { "must specify at least one source" 1 } -function pause_relay_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "pause-relay -s $SOURCE_ID1 -s $SOURCE_ID2" \ - "can not pause relay unit:" 1 -} - function pause_relay_success() { run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "pause-relay -s $SOURCE_ID1 -s $SOURCE_ID2" \ diff --git a/tests/dmctl_basic/check_list/pause_task.sh b/tests/dmctl_basic/check_list/pause_task.sh index b2c93589a3..0440b906f7 100644 --- a/tests/dmctl_basic/check_list/pause_task.sh +++ b/tests/dmctl_basic/check_list/pause_task.sh @@ -6,13 +6,6 @@ function pause_task_wrong_arg() { "pause-task \[-s source ...\] \[flags\]" 1 } -function pause_task_while_master_down() { - task_name="any_task_name" - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "pause-task $task_name" \ - "can not pause task $task_name:" 1 -} - function pause_task_success() { task_name=$1 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ diff --git a/tests/dmctl_basic/check_list/purge_relay.sh b/tests/dmctl_basic/check_list/purge_relay.sh index 29f766772e..9dd9965a5d 100644 --- a/tests/dmctl_basic/check_list/purge_relay.sh +++ b/tests/dmctl_basic/check_list/purge_relay.sh @@ -18,12 +18,6 @@ function purge_relay_filename_with_multi_workers() { "for --filename, can only specify one source per time" 1 } -function purge_relay_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "purge-relay --filename bin-000001 -s $SOURCE_ID1" \ - "can not purge relay log files:" 1 -} - function purge_relay_success() { binlog_file=$1 source_id=$2 diff --git a/tests/dmctl_basic/check_list/query_status.sh b/tests/dmctl_basic/check_list/query_status.sh index 5d105def95..43171a8bb4 100644 --- a/tests/dmctl_basic/check_list/query_status.sh +++ b/tests/dmctl_basic/check_list/query_status.sh @@ -9,7 +9,7 @@ function query_status_wrong_arg() { function query_status_wrong_params() { run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "query-status -s source-x task-y" \ - "can not query task-y task's status(in sources \[source-x\]):" 1 + "source-x relevant worker-client not found" 1 } function query_status_with_no_tasks() { diff --git a/tests/dmctl_basic/check_list/resume_task.sh b/tests/dmctl_basic/check_list/resume_task.sh index 4a9536db14..aa52a6988e 100644 --- a/tests/dmctl_basic/check_list/resume_task.sh +++ b/tests/dmctl_basic/check_list/resume_task.sh @@ -6,13 +6,6 @@ function resume_task_wrong_arg() { "resume-task \[-s source ...\] \[flags\]" 1 } -function resume_task_while_master_down() { - task_name="any_task_name" - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "resume-task $task_name" \ - "can not resume task $task_name:" 1 -} - function resume_task_success() { task_name=$1 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ diff --git a/tests/dmctl_basic/check_list/show_ddl_locks.sh b/tests/dmctl_basic/check_list/show_ddl_locks.sh index 65483000c5..4f00d3e89f 100644 --- a/tests/dmctl_basic/check_list/show_ddl_locks.sh +++ b/tests/dmctl_basic/check_list/show_ddl_locks.sh @@ -6,12 +6,6 @@ function show_ddl_locks_wrong_arg() { "show-ddl-locks \[-s source ...\] \[task-name\] \[flags\]" 1 } -function show_ddl_locks_while_master_down() { - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "show-ddl-locks task-name -s $SOURCE_ID1" \ - "can not show DDL locks for task task-name and sources \[$SOURCE_ID1\]" 1 -} - function show_ddl_locks_no_locks() { task_name=$1 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ diff --git a/tests/dmctl_basic/check_list/start_task.sh b/tests/dmctl_basic/check_list/start_task.sh index 5f0efe7550..ce7bfc60b7 100644 --- a/tests/dmctl_basic/check_list/start_task.sh +++ b/tests/dmctl_basic/check_list/start_task.sh @@ -11,10 +11,3 @@ function start_task_wrong_config_file() { "start-task not_exists_config_file" \ "get file content error" 1 } - -function start_task_while_master_down() { - task_conf=$1 - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "start-task $task_conf" \ - "can not start task:" 1 -} diff --git a/tests/dmctl_basic/check_list/stop_task.sh b/tests/dmctl_basic/check_list/stop_task.sh index eaca8b6eaa..87dfc10777 100644 --- a/tests/dmctl_basic/check_list/stop_task.sh +++ b/tests/dmctl_basic/check_list/stop_task.sh @@ -5,10 +5,3 @@ function stop_task_wrong_arg() { "stop-task" \ "stop-task \[-s source ...\] \[flags\]" 1 } - -function stop_task_while_master_down() { - task_name="any_task_name" - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "stop-task $task_name" \ - "can not stop task $task_name:" 1 -} diff --git a/tests/dmctl_basic/check_list/update_master_config.sh b/tests/dmctl_basic/check_list/update_master_config.sh index 7fdbb62216..21fd0d1157 100644 --- a/tests/dmctl_basic/check_list/update_master_config.sh +++ b/tests/dmctl_basic/check_list/update_master_config.sh @@ -12,13 +12,6 @@ function update_master_config_wrong_config_file() { "get file content error" 1 } -function update_master_config_while_master_down() { - master_conf=$1 - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "update-master-config $master_conf" \ - "can not update master config:" 1 -} - function update_master_config_success() { master_conf=$1 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ diff --git a/tests/dmctl_basic/check_list/update_relay.sh b/tests/dmctl_basic/check_list/update_relay.sh index 9ace24cae3..609d89f8d9 100644 --- a/tests/dmctl_basic/check_list/update_relay.sh +++ b/tests/dmctl_basic/check_list/update_relay.sh @@ -19,13 +19,6 @@ function update_relay_should_specify_one_dm_worker() { "must specify one source (\`-s\` \/ \`--source\`)" 1 } -function update_relay_while_master_down() { - task_conf=$1 - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "update-relay $task_conf -s $SOURCE_ID1" \ - "can not update relay config:" 1 -} - function update_relay_success() { task_conf=$1 source_id=$2 diff --git a/tests/dmctl_basic/check_list/update_task.sh b/tests/dmctl_basic/check_list/update_task.sh index b28c7b1fac..e99fd2eb86 100644 --- a/tests/dmctl_basic/check_list/update_task.sh +++ b/tests/dmctl_basic/check_list/update_task.sh @@ -12,13 +12,6 @@ function update_task_wrong_config_file() { "get file content error" 1 } -function update_task_while_master_down() { - task_conf=$1 - run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ - "update-task $task_conf" \ - "can not update task:" 1 -} - function update_task_worker_not_found() { task_conf=$1 not_found_source_id=$2 diff --git a/tests/dmctl_basic/run.sh b/tests/dmctl_basic/run.sh index 1c40e23b46..43f46f2917 100755 --- a/tests/dmctl_basic/run.sh +++ b/tests/dmctl_basic/run.sh @@ -15,25 +15,20 @@ function usage_and_arg_test() { echo "check_task_wrong_arg" check_task_wrong_arg check_task_wrong_config_file - check_task_while_master_down $TASK_CONF echo "pause_relay_wrong_arg" pause_relay_wrong_arg pause_relay_wihout_worker - pause_relay_while_master_down echo "resume_relay_wrong_arg" resume_relay_wrong_arg resume_relay_wihout_worker - resume_relay_while_master_down echo "pause_task_wrong_arg" pause_task_wrong_arg - pause_task_while_master_down echo "resume_task_wrong_arg" resume_task_wrong_arg - resume_task_while_master_down echo "query_status_wrong_arg" query_status_wrong_arg @@ -42,42 +37,34 @@ function usage_and_arg_test() { echo "start_task_wrong_arg" start_task_wrong_arg start_task_wrong_config_file - start_task_while_master_down $TASK_CONF echo "stop_task_wrong_arg" stop_task_wrong_arg - stop_task_while_master_down echo "show_ddl_locks_wrong_arg" show_ddl_locks_wrong_arg - show_ddl_locks_while_master_down echo "update_relay_wrong_arg" update_relay_wrong_arg update_relay_wrong_config_file update_relay_should_specify_one_dm_worker $MYSQL1_CONF - update_relay_while_master_down $MYSQL1_CONF # echo "update_task_wrong_arg" # update_task_wrong_arg # update_task_wrong_config_file - # update_task_while_master_down $TASK_CONF echo "update_master_config_wrong_arg" update_master_config_wrong_arg update_master_config_wrong_config_file - update_master_config_while_master_down $cur/conf/dm-master.toml echo "purge_relay_wrong_arg" purge_relay_wrong_arg purge_relay_wihout_worker purge_relay_filename_with_multi_workers - purge_relay_while_master_down echo "operate_source_empty_arg" operate_source_empty_arg operate_source_wrong_config_file - operate_source_while_master_down $MYSQL1_CONF } function recover_max_binlog_size() { @@ -106,8 +93,6 @@ function run() { done cd - - usage_and_arg_test - mkdir -p $WORK_DIR/master $WORK_DIR/worker1 $WORK_DIR/worker2 dm_master_conf="$WORK_DIR/master/dm-master.toml" dm_worker1_conf="$WORK_DIR/worker1/dm-worker.toml" @@ -116,8 +101,16 @@ function run() { cp $cur/conf/dm-worker2.toml $dm_worker2_conf cp $cur/conf/dm-master.toml $dm_master_conf + # start dmctl when master have not started + run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" "any command"\ + "can't connect to 127.0.0.1:8261" 1 \ + "Please check your network connection\." 1 + run_dm_master $WORK_DIR/master $MASTER_PORT $dm_master_conf check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT + + usage_and_arg_test + run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $dm_worker1_conf check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $dm_worker2_conf diff --git a/tests/dmctl_command/run.sh b/tests/dmctl_command/run.sh index e34d06c4f0..8bcb530155 100644 --- a/tests/dmctl_command/run.sh +++ b/tests/dmctl_command/run.sh @@ -51,6 +51,8 @@ function run() { exit 1 fi + 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 # check dmctl command start-task output with master-addr # it should usage for start-task $PWD/bin/dmctl.test DEVEL --master-addr=:$MASTER_PORT start-task > $WORK_DIR/help.log @@ -83,8 +85,6 @@ function run() { run_sql_file $cur/data/db2.prepare.sql $MYSQL_HOST2 $MYSQL_PORT2 $MYSQL_PASSWORD2 check_contains 'Query OK, 3 rows affected' - 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 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