From e532c95dfc3dd9f072b452db7b2d535cc2c12304 Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Mon, 21 Aug 2023 00:17:51 +0800 Subject: [PATCH] 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. --- tests/unit/introspection.tcl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 8132ee197..d551440ce 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -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= *}