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.
This commit is contained in:
Wen Hui 2023-08-21 00:17:51 +08:00 committed by GitHub
parent fe47c2027b
commit e532c95dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,6 +61,29 @@ start_server {tags {"introspection"}} {
$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" {
# Start a slow bgsave, trigger an active fork.
r flushall
@ -271,6 +294,11 @@ start_server {tags {"introspection"}} {
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} {
r client list
} {*name= *}