Unverified Commit e532c95d authored by Wen Hui's avatar Wen Hui Committed by GitHub
Browse files

Added tests for Client commands (#10276)

In our test case, now we missed some test coverage for client sub-commands.
This pr goal is to add some test coverage cases of the following commands:

Client caching
Client kill
Client no-evict
Client pause
Client reply
Client tracking
Client setname

At the very least, this is useful to make sure there are no leaks and crashes in these code paths.
parent fe47c202
...@@ -61,6 +61,29 @@ start_server {tags {"introspection"}} { ...@@ -61,6 +61,29 @@ start_server {tags {"introspection"}} {
$rd4 close $rd4 close
} }
test {CLIENT command unhappy path coverage} {
assert_error "ERR*wrong number of arguments*" {r client caching}
assert_error "ERR*when the client is in tracking mode*" {r client caching maybe}
assert_error "ERR*syntax*" {r client no-evict wrongInput}
assert_error "ERR*syntax*" {r client reply wrongInput}
assert_error "ERR*syntax*" {r client tracking wrongInput}
assert_error "ERR*syntax*" {r client tracking on wrongInput}
assert_error "ERR*when the client is in tracking mode*" {r client caching off}
assert_error "ERR*when the client is in tracking mode*" {r client caching on}
r CLIENT TRACKING ON optout
assert_error "ERR*syntax*" {r client caching on}
r CLIENT TRACKING off optout
assert_error "ERR*when the client is in tracking mode*" {r client caching on}
assert_error "ERR*No such*" {r client kill 000.123.321.567:0000}
assert_error "ERR*No such*" {r client kill 127.0.0.1:}
assert_error "ERR*timeout is not an integer*" {r client pause abc}
assert_error "ERR timeout is negative" {r client pause -1}
}
test "CLIENT KILL close the client connection during bgsave" { test "CLIENT KILL close the client connection during bgsave" {
# Start a slow bgsave, trigger an active fork. # Start a slow bgsave, trigger an active fork.
r flushall r flushall
...@@ -271,6 +294,11 @@ start_server {tags {"introspection"}} { ...@@ -271,6 +294,11 @@ start_server {tags {"introspection"}} {
r client getname r client getname
} {} } {}
test {CLIENT GETNAME check if name set correctly} {
r client setname testName
r client getName
} {testName}
test {CLIENT LIST shows empty fields for unassigned names} { test {CLIENT LIST shows empty fields for unassigned names} {
r client list r client list
} {*name= *} } {*name= *}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment