github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/dmctl_basic/check_list/check_task.sh (about) 1 #!/bin/bash 2 3 function check_task_wrong_arg() { 4 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 5 "check-task" \ 6 "check-task <config-file> \[--error count\] \[--warn count\] \[flags\]" 1 7 } 8 9 function check_task_wrong_config_file() { 10 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 11 "check-task not_exists_config_file" \ 12 "error in get file content" 1 13 } 14 15 function check_task_pass() { 16 task_conf=$1 17 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 18 "check-task $task_conf" \ 19 "\"result\": true" 1 20 } 21 22 function check_task_not_pass() { 23 task_conf=$1 24 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 25 "check-task $task_conf" \ 26 "\"result\": false" 1 27 } 28 29 function check_task_not_pass_with_message() { 30 task_conf=$1 31 error_message=$2 32 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 33 "check-task $task_conf" \ 34 "$error_message" 1 35 } 36 37 function check_task_error_database_config() { 38 task_conf=$1 39 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 40 "check-task $task_conf" \ 41 "Access denied for user" 1 \ 42 "Please check the database connection and the database config in configuration file" 1 43 } 44 45 function check_task_wrong_start_time_format() { 46 task_conf=$1 47 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 48 "check-task $task_conf --start-time '20060102 150405'" \ 49 "error while parse start-time" 1 50 } 51 52 function check_task_error_count() { 53 task_conf=$1 54 # 10 errors 55 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 56 "check-task $task_conf" \ 57 "\"result\": false" 1 \ 58 "\"failed\": 2" 1 \ 59 "\"state\": \"fail\"" 2 60 61 # 1 error 62 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 63 "check-task $task_conf -e 1" \ 64 "\"result\": false" 1 \ 65 "\"failed\": 2" 1 \ 66 "\"state\": \"fail\"" 1 67 68 # 100 errors 69 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 70 "check-task $task_conf -e 100 -w 1" \ 71 "\"result\": false" 1 \ 72 "\"failed\": 2" 1 \ 73 "\"state\": \"fail\"" 2 74 75 # 0 error 76 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 77 "check-task $task_conf -e 0" \ 78 "\"result\": false" 1 \ 79 "\"failed\": 2" 1 \ 80 "\"state\": \"fail\"" 0 81 } 82 83 function check_task_only_warning() { 84 task_conf=$1 85 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 86 "check-task $task_conf" \ 87 "\"state\": \"warn\"" 1 88 } 89 90 function check_task_empty_dump_config() { 91 sed "/threads/d" $1 >/tmp/empty-dump.yaml 92 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 93 "check-task /tmp/empty-dump.yaml" \ 94 "pre-check is passed" 1 95 } 96 97 function check_task_empty_load_config() { 98 sed "/pool-size/d" $1 >/tmp/empty-load.yaml 99 cat /tmp/empty-load.yaml 100 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 101 "check-task /tmp/empty-load.yaml" \ 102 "pre-check is passed" 1 103 } 104 105 function check_task_empty_sync_config() { 106 sed "/worker-count/d" $1 >/tmp/empty-sync.yaml 107 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 108 "check-task /tmp/empty-sync.yaml" \ 109 "pre-check is passed" 1 110 } 111 112 function check_task_empty_config() { 113 check_task_empty_dump_config $1 114 check_task_empty_load_config $1 115 check_task_empty_sync_config $1 116 } 117 118 function check_task_wrong_no_source_meta() { 119 task_conf=$1 120 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 121 "check-task $task_conf" \ 122 "must specify \`binlog-name\` without GTID enabled for the source or specify \`binlog-gtid\` with GTID enabled for the source" 1 123 } 124 125 function check_task_no_source_meta_but_start_time() { 126 task_conf=$1 127 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 128 "check-task $task_conf --start-time '2006-01-02 15:04:05'" \ 129 "pre-check is passed" 1 130 }