github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/dmctl_basic/check_list/config.sh (about) 1 #!/bin/bash 2 3 function config_wrong_arg() { 4 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 5 "config" \ 6 "Available Commands" 1 7 8 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 9 "config hihi haha" \ 10 "Available Commands" 1 11 12 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 13 "config task haha" \ 14 "task not found" 1 15 16 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 17 "config master haha" \ 18 "master not found" 1 19 20 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 21 "config worker haha" \ 22 "worker not found" 1 23 24 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 25 "config source haha" \ 26 "source not found" 1 27 28 # test alias 29 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 30 "get-config haha" \ 31 "get-config <task | master | worker | source> <name> \[--file filename\] \[flags\]" 1 32 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 33 "get-config haha hihi" \ 34 "invalid config type 'haha'" 1 35 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 36 "get-config master haha" \ 37 "master not found" 1 38 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 39 "get-config worker haha" \ 40 "worker not found" 1 41 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 42 "get-config source haha" \ 43 "source not found" 1 44 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 45 "get-config task haha" \ 46 "task not found" 1 47 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 48 "get-task-config haha" \ 49 "task not found" 1 50 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 51 "get-task-config haha hihi" \ 52 "get-config <task | master | worker | source> <name> \[--file filename\] \[flags\]" 1 53 } 54 55 function diff_get_config() { 56 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 57 "config task test --path $WORK_DIR/get_task.yaml" \ 58 "\"result\": true" 1 59 diff $WORK_DIR/get_task.yaml $cur/conf/get_task.yaml || exit 1 60 61 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 62 "config master master1 --path $dm_master_conf" \ 63 "\"result\": true" 1 64 diff $dm_master_conf $cur/conf/get_master1.toml || exit 1 65 66 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 67 "config worker worker1 --path $dm_worker1_conf" \ 68 "\"result\": true" 1 69 diff $dm_worker1_conf $cur/conf/get_worker1.toml || exit 1 70 71 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 72 "config worker worker2 --path $dm_worker2_conf" \ 73 "\"result\": true" 1 74 diff $dm_worker2_conf $cur/conf/get_worker2.toml || exit 1 75 76 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 77 "config source mysql-replica-01 --path $WORK_DIR/get_source1.yaml" \ 78 "\"result\": true" 1 79 diff -I '^case-sensitive*' $WORK_DIR/get_source1.yaml $cur/conf/get_source1.yaml || exit 1 80 81 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 82 "config source mysql-replica-02 --path $WORK_DIR/get_source2.yaml" \ 83 "\"result\": true" 1 84 diff -I '^case-sensitive*' $WORK_DIR/get_source2.yaml $cur/conf/get_source2.yaml || exit 1 85 } 86 87 function config_to_file() { 88 diff_get_config 89 90 sed -i "s/password: '\*\*\*\*\*\*'/password: ''/g" $WORK_DIR/get_task.yaml 91 sed -i "s/password: '\*\*\*\*\*\*'/password: '123456'/g" $WORK_DIR/get_source1.yaml 92 sed -i "s/password: '\*\*\*\*\*\*'/password: '123456'/g" $WORK_DIR/get_source2.yaml 93 94 # stop task 95 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 96 "stop-task test" \ 97 "\"result\": true" 3 98 99 # restart source with get config 100 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 101 "operate-source stop mysql-replica-01" \ 102 "\"result\": true" 2 \ 103 "\"msg\": \"\"" 2 104 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 105 "operate-source create $WORK_DIR/get_source1.yaml" \ 106 "\"result\": true" 2 107 108 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 109 "operate-source stop mysql-replica-02" \ 110 "\"result\": true" 2 111 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 112 "operate-source create $WORK_DIR/get_source2.yaml" \ 113 "\"result\": true" 2 114 115 # start task with get config 116 run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 117 "start-task $WORK_DIR/get_task.yaml" \ 118 "\"result\": true" 3 119 120 # restart master with get config 121 kill_process dm-master 122 check_master_port_offline 1 123 run_dm_master $WORK_DIR/master $MASTER_PORT $dm_master_conf 124 check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT 125 126 # restart worker with get config 127 kill_process worker1 128 check_port_offline $WORKER1_PORT 20 129 kill_process worker2 130 check_port_offline $WORKER2_PORT 20 131 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 132 "list-member --worker" \ 133 "offline" 2 134 135 run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $dm_worker1_conf 136 check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT 137 run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $dm_worker2_conf 138 check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT 139 run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ 140 "list-member --worker" \ 141 "bound" 2 142 143 diff_get_config 144 }