1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
def test_client_setname(judge_command):
judge_command(
"CLIENT SETNAME foobar", {"command": "CLIENT SETNAME", "value": "foobar"}
)
def test_client_unblock(judge_command):
judge_command(
"CLIENT UNBLOCK 33 TIMEOUT",
{"command": "CLIENT UNBLOCK", "clientid": "33", "error": "TIMEOUT"},
)
judge_command("CLIENT UNBLOCK 33", {"command": "CLIENT UNBLOCK", "clientid": "33"})
def test_flushdb(judge_command):
judge_command("FLUSHDB async", {"command": "FLUSHDB", "async": "async"})
judge_command("FLUSHDB", {"command": "FLUSHDB"})
judge_command("FLUSHDB ASYNC", {"command": "FLUSHDB", "async": "ASYNC"})
judge_command("FLUSHALL ASYNC", {"command": "FLUSHALL", "async": "ASYNC"})
def test_client_list(judge_command):
judge_command("client list", {"command": "client list"})
judge_command("client list TYPE REPLICA1", None)
judge_command(
"client list type master",
{"command": "client list", "type_const": "type", "conntype": "master"},
)
judge_command(
"client list TYPE REPLICA",
{"command": "client list", "type_const": "TYPE", "conntype": "REPLICA"},
)
judge_command(
"client list TYPE REPLICA id 1 2 3",
{
"command": "client list",
"type_const": "TYPE",
"conntype": "REPLICA",
"clientids": "1 2 3",
},
)
judge_command(
"client list ID 1 2 3",
{"command": "client list", "clientids": "1 2 3"},
)
def test_configset(judge_command):
judge_command(
"config set foo bar",
{"command": "config set", "parameter": "foo", "value": "bar"},
)
judge_command(
"config set requirepass ''",
{"command": "config set", "parameter": "requirepass", "value": "''"},
)
def test_shutdown(judge_command):
judge_command("shutdown save", {"command": "shutdown", "shutdown": "save"})
judge_command("shutdown NOSAVE", {"command": "shutdown", "shutdown": "NOSAVE"})
def test_clientpause(judge_command):
judge_command("client pause 3000", {"command": "client pause", "timeout": "3000"})
def test_client_reply(judge_command):
judge_command("client reply on", {"command": "client reply", "switch": "on"})
def test_client_kill(judge_command):
judge_command(
"CLIENT KILL addr 127.0.0.1:12345 type pubsub",
{
"command": "CLIENT KILL",
"addr": "addr",
"ip_port": "127.0.0.1:12345",
"type_const": "type",
"conntype": "pubsub",
},
)
judge_command(
"CLIENT KILL 127.0.0.1:12345 ",
{"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345"},
)
judge_command(
"CLIENT KILL ADDR 127.0.0.1:12345 ",
{"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345", "addr": "ADDR"},
)
judge_command(
"CLIENT KILL LADDR 127.0.0.1:12345 ",
{"command": "CLIENT KILL", "ip_port": "127.0.0.1:12345", "laddr": "LADDR"},
)
judge_command(
"CLIENT KILL USER myuser",
{"command": "CLIENT KILL", "const_user": "USER", "username": "myuser"},
)
judge_command(
"CLIENT KILL id 123455 type pubsub skipme no",
{
"command": "CLIENT KILL",
"const_id": "id",
"clientid": "123455",
"type_const": "type",
"conntype": "pubsub",
"skipme": "skipme",
"yes": "no",
},
)
def test_client_kill_username(judge_command):
"""since redis-server 6.0"""
judge_command(
"client kill USER default",
{"command": "client kill", "const_user": "USER", "username": "default"},
)
def test_client_kill_unordered_arguments(judge_command):
judge_command(
"CLIENT KILL type pubsub addr 127.0.0.1:12345",
{
"command": "CLIENT KILL",
"addr": "addr",
"ip_port": "127.0.0.1:12345",
"type_const": "type",
"conntype": "pubsub",
},
)
def test_psync(judge_command):
judge_command(
"PSYNC abc 123", {"command": "PSYNC", "replicationid": "abc", "offset": "123"}
)
judge_command("PSYNC", None)
def test_latency_graph(judge_command):
judge_command(
"latency graph command", {"command": "latency graph", "graphevent": "command"}
)
judge_command(
"latency graph fork", {"command": "latency graph", "graphevent": "fork"}
)
judge_command("latency graph", None)
def test_latency_reset(judge_command):
judge_command(
"latency reset command fork aof-fsync-always",
{"command": "latency reset", "graphevent": "aof-fsync-always"},
)
judge_command(
"latency reset fork", {"command": "latency reset", "graphevent": "fork"}
)
judge_command("latency reset", {"command": "latency reset"})
def test_lolwut(judge_command):
judge_command("lolwut", {"command": "lolwut"})
# only works before redis 6
judge_command("lolwut 5", {"command": "lolwut", "any": "5"})
judge_command("lolwut 5 1", {"command": "lolwut", "any": "5 1"})
# redis 6
judge_command(
"lolwut VERSION 5 5",
{"command": "lolwut", "version": "VERSION", "version_num": "5", "any": "5"},
)
def test_info(judge_command):
judge_command("info cpu", {"command": "info", "section": "cpu"})
judge_command("info", {"command": "info"})
judge_command("info all", {"command": "info", "section": "all"})
judge_command("info CPU", {"command": "info", "section": "CPU"})
def test_bgsave(judge_command):
judge_command("bgsave", {"command": "bgsave"})
judge_command("bgsave schedule", {"command": "bgsave", "schedule": "schedule"})
judge_command("BGSAVE SCHEDULE", {"command": "BGSAVE", "schedule": "SCHEDULE"})
def test_acl_cat(judge_command):
judge_command("acl cat", {"command": "acl cat"})
judge_command("acl CAT", {"command": "acl CAT"})
judge_command(
"ACL CAT scripting", {"command": "ACL CAT", "categoryname": "scripting"}
)
judge_command("ACL CAT WATCH", {"command": "ACL CAT", "categoryname": "WATCH"})
def test_acl_deluser(judge_command):
judge_command(
"acl deluser laixintao", {"command": "acl deluser", "username": "laixintao"}
)
judge_command(
"acl deluser laixintao antirez",
{"command": "acl deluser", "username": "antirez"},
)
def test_acl_log(judge_command):
judge_command("acl log 2", {"command": "acl log", "count": "2"})
judge_command("acl log reset", {"command": "acl log", "reset_const": "reset"})
judge_command("acl log ", {"command": "acl log"})
def test_acl_setuser(judge_command):
judge_command("ACL SETUSER alice", {"command": "ACL SETUSER", "username": "alice"})
judge_command(
"ACL SETUSER alice on >p1pp0 ~cached:* +get",
{"command": "ACL SETUSER", "username": "alice", "rule": "+get"},
)
judge_command(
"ACL SETUSER alan allkeys +@string +@set -SADD >alanpassword",
{"command": "ACL SETUSER", "username": "alan", "rule": ">alanpassword"},
)
def test_acl_getuser(judge_command):
judge_command("acl getuser alan", {"command": "acl getuser", "username": "alan"})
judge_command("acl getuser", None)
def test_failover(judge_command):
judge_command(
"failover to 10.0.0.5 7379 abort timeout 101",
{
"command": "failover",
"to_const": "to",
"host": "10.0.0.5",
"port": "7379",
"abort_const": "abort",
"timeout_const": "timeout",
"millisecond": "101",
},
)
judge_command(
"failover abort timeout 101",
{
"command": "failover",
"abort_const": "abort",
"timeout_const": "timeout",
"millisecond": "101",
},
)
judge_command(
"failover timeout 101",
{
"command": "failover",
"timeout_const": "timeout",
"millisecond": "101",
},
)
judge_command(
"failover to 10.0.0.5 7379 force abort timeout 101",
{
"command": "failover",
"to_const": "to",
"force": "force",
"host": "10.0.0.5",
"port": "7379",
"abort_const": "abort",
"timeout_const": "timeout",
"millisecond": "101",
},
)
|