| 1 |
""" |
| 2 |
redis command in `cluster` group parse test. |
| 3 |
""" |
| 4 |
|
| 5 |
|
| 6 |
def test_command_cluster_addslots(judge_command): |
| 7 |
judge_command("cluster addslots 1", {"command": "cluster addslots", "slots": "1"}) |
| 8 |
judge_command("CLUSTER ADDSLOTS 1", {"command": "CLUSTER ADDSLOTS", "slots": "1"}) |
| 9 |
judge_command( |
| 10 |
"cluster addslots 1 2 3 4", {"command": "cluster addslots", "slots": "1 2 3 4"} |
| 11 |
) |
| 12 |
judge_command("cluster addslots 1 a", None) |
| 13 |
judge_command("cluster addslots a", None) |
| 14 |
judge_command("cluster addslots a 4", None) |
| 15 |
judge_command("cluster addslots abc", None) |
| 16 |
|
| 17 |
|
| 18 |
def test_command_cluster_count_failure_reports(judge_command): |
| 19 |
judge_command( |
| 20 |
"cluster count-failure-reports 1", |
| 21 |
{"command": "cluster count-failure-reports", "node": "1"}, |
| 22 |
) |
| 23 |
judge_command( |
| 24 |
"CLUSTER COUNT-FAILURE-REPORTS 1", |
| 25 |
{"command": "CLUSTER COUNT-FAILURE-REPORTS", "node": "1"}, |
| 26 |
) |
| 27 |
judge_command("cluster count-failure-reports 1 2 3 4", None) |
| 28 |
judge_command("cluster count-failure-reports 1 a", None) |
| 29 |
judge_command( |
| 30 |
"cluster count-failure-reports a", |
| 31 |
{"command": "cluster count-failure-reports", "node": "a"}, |
| 32 |
) |
| 33 |
judge_command("cluster count-failure-reports a 2", None) |
| 34 |
judge_command( |
| 35 |
"cluster count-failure-reports abc", |
| 36 |
{"command": "cluster count-failure-reports", "node": "abc"}, |
| 37 |
) |
| 38 |
|
| 39 |
|
| 40 |
def test_command_cluster_countkeysinslot(judge_command): |
| 41 |
judge_command( |
| 42 |
"cluster countkeysinslot 1", {"command": "cluster countkeysinslot", "slot": "1"} |
| 43 |
) |
| 44 |
judge_command( |
| 45 |
"CLUSTER COUNTKEYSINSLOT 1", {"command": "CLUSTER COUNTKEYSINSLOT", "slot": "1"} |
| 46 |
) |
| 47 |
judge_command("cluster countkeysinslot 1 2 3 4", None) |
| 48 |
judge_command("cluster countkeysinslot 1 a", None) |
| 49 |
judge_command("cluster countkeysinslot a", None) |
| 50 |
judge_command("cluster countkeysinslot a 4", None) |
| 51 |
judge_command("cluster countkeysinslot abc", None) |
| 52 |
|
| 53 |
|
| 54 |
def test_command_cluster_delslots(judge_command): |
| 55 |
judge_command("cluster delslots 1", {"command": "cluster delslots", "slots": "1"}) |
| 56 |
judge_command("CLUSTER DELSLOTS 1", {"command": "CLUSTER DELSLOTS", "slots": "1"}) |
| 57 |
judge_command( |
| 58 |
"cluster delslots 1 2 3 4", {"command": "cluster delslots", "slots": "1 2 3 4"} |
| 59 |
) |
| 60 |
judge_command("cluster delslots 1 a", None) |
| 61 |
judge_command("cluster delslots a", None) |
| 62 |
judge_command("cluster delslots a 4", None) |
| 63 |
judge_command("cluster delslots abc", None) |
| 64 |
|
| 65 |
|
| 66 |
def test_command_cluster_failover(judge_command): |
| 67 |
judge_command( |
| 68 |
"cluster failover force", |
| 69 |
{"command": "cluster failover", "failoverchoice": "force"}, |
| 70 |
) |
| 71 |
judge_command( |
| 72 |
"cluster failover takeover", |
| 73 |
{"command": "cluster failover", "failoverchoice": "takeover"}, |
| 74 |
) |
| 75 |
judge_command( |
| 76 |
"CLUSTER FAILOVER FORCE", |
| 77 |
{"command": "CLUSTER FAILOVER", "failoverchoice": "FORCE"}, |
| 78 |
) |
| 79 |
judge_command( |
| 80 |
"CLUSTER FAILOVER takeover", |
| 81 |
{"command": "CLUSTER FAILOVER", "failoverchoice": "takeover"}, |
| 82 |
) |
| 83 |
judge_command( |
| 84 |
"CLUSTER FAILOVER TAKEOVER", |
| 85 |
{"command": "CLUSTER FAILOVER", "failoverchoice": "TAKEOVER"}, |
| 86 |
) |
| 87 |
|
| 88 |
|
| 89 |
def test_command_cluster_forget(judge_command): |
| 90 |
judge_command("cluster forget 1", {"command": "cluster forget", "node": "1"}) |
| 91 |
judge_command( |
| 92 |
"CLUSTER COUNT-FAILURE-REPORTS 1", |
| 93 |
{"command": "CLUSTER COUNT-FAILURE-REPORTS", "node": "1"}, |
| 94 |
) |
| 95 |
judge_command("cluster forget 1 2 3 4", None) |
| 96 |
judge_command("cluster forget 1 a", None) |
| 97 |
judge_command("cluster forget a", {"command": "cluster forget", "node": "a"}) |
| 98 |
judge_command("cluster forget a 2", None) |
| 99 |
judge_command( |
| 100 |
"cluster forget abc", |
| 101 |
{ |
| 102 |
"command": "cluster forget", |
| 103 |
"node": "abc", |
| 104 |
}, |
| 105 |
) |
| 106 |
judge_command( |
| 107 |
"cluster forget 07c37dfeb235213a872192d90877d0cd55635b91", |
| 108 |
{ |
| 109 |
"command": "cluster forget", |
| 110 |
"node": "07c37dfeb235213a872192d90877d0cd55635b91", |
| 111 |
}, |
| 112 |
) |
| 113 |
|
| 114 |
|
| 115 |
def test_command_cluster_getkeysinslot(judge_command): |
| 116 |
judge_command( |
| 117 |
"cluster getkeysinslot 1 1", |
| 118 |
{"command": "cluster getkeysinslot", "slot": "1", "count": "1"}, |
| 119 |
) |
| 120 |
judge_command( |
| 121 |
"CLUSTER GETKEYSINSLOT 1 1", |
| 122 |
{"command": "CLUSTER GETKEYSINSLOT", "slot": "1", "count": "1"}, |
| 123 |
) |
| 124 |
judge_command( |
| 125 |
"cluster getkeysinslot 1123 1121", |
| 126 |
{"command": "cluster getkeysinslot", "slot": "1123", "count": "1121"}, |
| 127 |
) |
| 128 |
judge_command("cluster getkeysinslot 1 2 3 4", None) |
| 129 |
judge_command("cluster getkeysinslot 1 a", None) |
| 130 |
judge_command("cluster getkeysinslot a", None) |
| 131 |
judge_command("cluster getkeysinslot a 4", None) |
| 132 |
judge_command("cluster getkeysinslot abc", None) |
| 133 |
|
| 134 |
|
| 135 |
def test_command_cluster_info(judge_command): |
| 136 |
judge_command("cluster info", {"command": "cluster info"}) |
| 137 |
judge_command("CLUSTER INFO", {"command": "CLUSTER INFO"}) |
| 138 |
judge_command("CLUSTER INFO 1", None) |
| 139 |
judge_command("Acluster info", "invalid") |
| 140 |
|
| 141 |
|
| 142 |
def test_command_cluster_keyslot(judge_command): |
| 143 |
judge_command( |
| 144 |
"cluster keyslot mykey", {"command": "cluster keyslot", "key": "mykey"} |
| 145 |
) |
| 146 |
judge_command( |
| 147 |
"cluster keyslot MYKEY", {"command": "cluster keyslot", "key": "MYKEY"} |
| 148 |
) |
| 149 |
judge_command( |
| 150 |
"CLUSTER KEYSLOT MYKEY", {"command": "CLUSTER KEYSLOT", "key": "MYKEY"} |
| 151 |
) |
| 152 |
|
| 153 |
|
| 154 |
def test_command_cluster_meet(judge_command): |
| 155 |
judge_command( |
| 156 |
"cluster meet 192.168.0.1 12200", |
| 157 |
{"command": "cluster meet", "ip": "192.168.0.1", "port": "12200"}, |
| 158 |
) |
| 159 |
judge_command( |
| 160 |
"CLUSTER MEET 192.168.0.1 12200", |
| 161 |
{"command": "CLUSTER MEET", "ip": "192.168.0.1", "port": "12200"}, |
| 162 |
) |
| 163 |
|
| 164 |
|
| 165 |
def test_command_cluster_nodes(judge_command): |
| 166 |
judge_command("cluster nodes", {"command": "cluster nodes"}) |
| 167 |
judge_command("CLUSTER NODES", {"command": "CLUSTER NODES"}) |
| 168 |
|
| 169 |
|
| 170 |
def test_command_cluster_reset(judge_command): |
| 171 |
judge_command( |
| 172 |
"cluster reset hard", {"command": "cluster reset", "resetchoice": "hard"} |
| 173 |
) |
| 174 |
judge_command( |
| 175 |
"cluster reset soft", {"command": "cluster reset", "resetchoice": "soft"} |
| 176 |
) |
| 177 |
judge_command( |
| 178 |
"CLUSTER RESET HARD", {"command": "CLUSTER RESET", "resetchoice": "HARD"} |
| 179 |
) |
| 180 |
judge_command( |
| 181 |
"CLUSTER RESET soft", {"command": "CLUSTER RESET", "resetchoice": "soft"} |
| 182 |
) |
| 183 |
judge_command( |
| 184 |
"CLUSTER RESET SOFT", {"command": "CLUSTER RESET", "resetchoice": "SOFT"} |
| 185 |
) |
| 186 |
judge_command("CLUSTER RESET SOFT1", None) |
| 187 |
judge_command("CLUSTER RESET SAOFT", None) |
| 188 |
|
| 189 |
|
| 190 |
def test_command_cluster_set_config_epoch(judge_command): |
| 191 |
judge_command("cluster set-config-epoch 123123 ad", None) |
| 192 |
judge_command( |
| 193 |
"cluster set-config-epoch 0 ", |
| 194 |
{"command": "cluster set-config-epoch", "epoch": "0"}, |
| 195 |
) |
| 196 |
judge_command( |
| 197 |
"cluster set-config-epoch 123123 ", |
| 198 |
{"command": "cluster set-config-epoch", "epoch": "123123"}, |
| 199 |
) |
| 200 |
|
| 201 |
|
| 202 |
def test_command_cluster_set_slot(judge_command): |
| 203 |
judge_command( |
| 204 |
"cluster setslot 123 importing 123123", |
| 205 |
{ |
| 206 |
"command": "cluster setslot", |
| 207 |
"slot": "123", |
| 208 |
"slotsubcmd": "importing", |
| 209 |
"node": "123123", |
| 210 |
}, |
| 211 |
) |
| 212 |
judge_command( |
| 213 |
"cluster setslot 123 migrating 123123", |
| 214 |
{ |
| 215 |
"command": "cluster setslot", |
| 216 |
"slot": "123", |
| 217 |
"slotsubcmd": "migrating", |
| 218 |
"node": "123123", |
| 219 |
}, |
| 220 |
) |
| 221 |
judge_command( |
| 222 |
"cluster setslot 123 node 123123", |
| 223 |
{ |
| 224 |
"command": "cluster setslot", |
| 225 |
"slot": "123", |
| 226 |
"slotsubcmd": "node", |
| 227 |
"node": "123123", |
| 228 |
}, |
| 229 |
) |
| 230 |
judge_command( |
| 231 |
"cluster setslot 123 node e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca", |
| 232 |
{ |
| 233 |
"command": "cluster setslot", |
| 234 |
"slot": "123", |
| 235 |
"slotsubcmd": "node", |
| 236 |
"node": "e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca", |
| 237 |
}, |
| 238 |
) |
| 239 |
judge_command( |
| 240 |
"cluster setslot 123 MIGRATING 123123", |
| 241 |
{ |
| 242 |
"command": "cluster setslot", |
| 243 |
"slot": "123", |
| 244 |
"slotsubcmd": "MIGRATING", |
| 245 |
"node": "123123", |
| 246 |
}, |
| 247 |
) |
| 248 |
judge_command( |
| 249 |
"cluster setslot 123 stable", |
| 250 |
{"command": "cluster setslot", "slot": "123", "slotsubcmd": "stable"}, |
| 251 |
) |
| 252 |
judge_command( |
| 253 |
"cluster setslot 123 STABLE", |
| 254 |
{"command": "cluster setslot", "slot": "123", "slotsubcmd": "STABLE"}, |
| 255 |
) |