From de32b1c1c4efa12954db2cedc1fd038e344629a3 Mon Sep 17 00:00:00 2001 From: hwware Date: Thu, 10 Feb 2022 15:25:51 +0000 Subject: [PATCH 1/6] Added tests for client commands --- tests/test_helper.tcl | 4 ++ tests/unit/client.tcl | 158 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 tests/unit/client.tcl diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 277fa38038b..a42c752c88f 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -93,7 +93,11 @@ set ::all_tests { unit/cluster unit/client-eviction unit/violations +<<<<<<< HEAD unit/replybufsize +======= + unit/client +>>>>>>> Added tests for client commands } # Index to the next test to run in the ::all_tests list. set ::next_test 0 diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl new file mode 100644 index 00000000000..f7f318fe485 --- /dev/null +++ b/tests/unit/client.tcl @@ -0,0 +1,158 @@ +start_server {tags {"Client Caching"}} { + test {CLIENT Caching wrong number of arguments} { + catch {r client caching} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT Caching wrong argument} { + catch {r client caching maybe} err + set _ $err + } {ERR*when the client is in tracking mode*} + + test {CLIENT Caching OFF without optout} { + catch {r client caching off} err + set _ $err + } {ERR*when the client is in tracking mode*} + + test {CLIENT Caching ON without optin} { + catch {r client caching on} err + set _ $err + } {ERR*when the client is in tracking mode*} + + test {CLIENT Caching ON with optout} { + r CLIENT TRACKING ON optout + catch {r client caching on} err + set _ $err + } {ERR*syntax*} + + test {CLIENT Caching OFF with optin} { + r CLIENT TRACKING off optout + catch {r client caching on} err + set _ $err + } {ERR*when the client is in tracking mode*} +} + +start_server {tags {"Client Kill"}} { + test {CLIENT kill wrong number of arguments} { + catch {r client kill} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT kill wrong address} { + catch {r client kill 000.123.321.567:0000} err + set _ $err + } {ERR*No such*} + + test {CLIENT kill no port} { + catch {r client kill 127.0.0.1:} err + set _ $err + } {ERR*No such*} +} + +start_server {tags {"Client No-evict"}} { + test {CLIENT no-evict wrong number of arguments} { + catch {r client no-evict ok x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT no-evict wrong argument} { + catch {r client no-evict wrongInput} err + set _ $err + } {ERR*syntax*} +} + + +start_server {tags {"Client pause"}} { + test {CLIENT pause wrong number of arguments} { + catch {r client pause} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT pause wrong timeout type} { + catch {r client pause abc} err + set _ $err + } {ERR*timeout is not an integer*} + + test {CLIENT pause negative timeout} { + catch {r client pause -1} err + set _ $err + } {ERR timeout is negative} +} + +start_server {tags {"Client reply"}} { + test {CLIENT reply wrong number of arguments} { + catch {r client reply on x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT reply wrong argument} { + catch {r client reply wrongInput} err + set _ $err + } {ERR*syntax*} +} + +start_server {tags {"Client tracking"}} { + test {CLIENT tracking wrong number of arguments} { + catch {r client tracking} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT tracking wrong argument} { + catch {r client tracking wrongInput} err + set _ $err + } {ERR*syntax*} + + test {CLIENT tracking wrong option} { + catch {r client tracking on wrongInput} err + set _ $err + } {ERR*syntax*} +} + +start_server {tags {"Client setname getname"}} { + test {CLIENT setname wrong number of arguments} { + catch {r client setname on x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT getname check if name set correctly} { + r client setname testName + r client getName + } {testName} +} + +start_server {tags {"Client _ wrong arguments"}} { + test {CLIENT getredir wrong number of arguments} { + catch {r client getredir x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT id wrong number of arguments} { + catch {r client id x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT info wrong number of arguments} { + catch {r client info x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT info wrong number of arguments} { + catch {r client info x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT list wrong number of arguments} { + catch {r client list x} err + set _ $err + } {ERR*syntax*} + + test {CLIENT trackinginfo wrong number of arguments} { + catch {r client trackinginfo x} err + set _ $err + } {ERR*wrong number of arguments*} + + test {CLIENT unpause wrong number of arguments} { + catch {r client unpause x} err + set _ $err + } {ERR*wrong number of arguments*} +} \ No newline at end of file From 8369121d5ee405d9bb36d0a2bb0d34e8a9f1dc6a Mon Sep 17 00:00:00 2001 From: hwware Date: Thu, 10 Feb 2022 15:34:24 +0000 Subject: [PATCH 2/6] Add new line --- tests/unit/client.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl index f7f318fe485..79827eb98df 100644 --- a/tests/unit/client.tcl +++ b/tests/unit/client.tcl @@ -155,4 +155,4 @@ start_server {tags {"Client _ wrong arguments"}} { catch {r client unpause x} err set _ $err } {ERR*wrong number of arguments*} -} \ No newline at end of file +} From ff4022081744766f36086b7d092b6f58eac8fe75 Mon Sep 17 00:00:00 2001 From: hwware Date: Tue, 15 Feb 2022 14:17:37 -0500 Subject: [PATCH 3/6] update test case --- tests/unit/client.tcl | 80 ++++--------------------------------------- 1 file changed, 7 insertions(+), 73 deletions(-) diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl index 79827eb98df..90f91f555a3 100644 --- a/tests/unit/client.tcl +++ b/tests/unit/client.tcl @@ -1,4 +1,4 @@ -start_server {tags {"Client Caching"}} { +start_server {tags {"client caching test suites"}} { test {CLIENT Caching wrong number of arguments} { catch {r client caching} err set _ $err @@ -32,12 +32,7 @@ start_server {tags {"Client Caching"}} { } {ERR*when the client is in tracking mode*} } -start_server {tags {"Client Kill"}} { - test {CLIENT kill wrong number of arguments} { - catch {r client kill} err - set _ $err - } {ERR*wrong number of arguments*} - +start_server {tags {"client kill test suites"}} { test {CLIENT kill wrong address} { catch {r client kill 000.123.321.567:0000} err set _ $err @@ -49,12 +44,7 @@ start_server {tags {"Client Kill"}} { } {ERR*No such*} } -start_server {tags {"Client No-evict"}} { - test {CLIENT no-evict wrong number of arguments} { - catch {r client no-evict ok x} err - set _ $err - } {ERR*wrong number of arguments*} - +start_server {tags {"client no-evict test suites"}} { test {CLIENT no-evict wrong argument} { catch {r client no-evict wrongInput} err set _ $err @@ -62,12 +52,7 @@ start_server {tags {"Client No-evict"}} { } -start_server {tags {"Client pause"}} { - test {CLIENT pause wrong number of arguments} { - catch {r client pause} err - set _ $err - } {ERR*wrong number of arguments*} - +start_server {tags {"client pause test suites"}} { test {CLIENT pause wrong timeout type} { catch {r client pause abc} err set _ $err @@ -79,23 +64,14 @@ start_server {tags {"Client pause"}} { } {ERR timeout is negative} } -start_server {tags {"Client reply"}} { - test {CLIENT reply wrong number of arguments} { - catch {r client reply on x} err - set _ $err - } {ERR*wrong number of arguments*} - +start_server {tags {"client reply test suites"}} { test {CLIENT reply wrong argument} { catch {r client reply wrongInput} err set _ $err } {ERR*syntax*} } -start_server {tags {"Client tracking"}} { - test {CLIENT tracking wrong number of arguments} { - catch {r client tracking} err - set _ $err - } {ERR*wrong number of arguments*} +start_server {tags {"client tracking test suites"}} { test {CLIENT tracking wrong argument} { catch {r client tracking wrongInput} err @@ -108,51 +84,9 @@ start_server {tags {"Client tracking"}} { } {ERR*syntax*} } -start_server {tags {"Client setname getname"}} { - test {CLIENT setname wrong number of arguments} { - catch {r client setname on x} err - set _ $err - } {ERR*wrong number of arguments*} - +start_server {tags {"client setname getname test suites"}} { test {CLIENT getname check if name set correctly} { r client setname testName r client getName } {testName} } - -start_server {tags {"Client _ wrong arguments"}} { - test {CLIENT getredir wrong number of arguments} { - catch {r client getredir x} err - set _ $err - } {ERR*wrong number of arguments*} - - test {CLIENT id wrong number of arguments} { - catch {r client id x} err - set _ $err - } {ERR*wrong number of arguments*} - - test {CLIENT info wrong number of arguments} { - catch {r client info x} err - set _ $err - } {ERR*wrong number of arguments*} - - test {CLIENT info wrong number of arguments} { - catch {r client info x} err - set _ $err - } {ERR*wrong number of arguments*} - - test {CLIENT list wrong number of arguments} { - catch {r client list x} err - set _ $err - } {ERR*syntax*} - - test {CLIENT trackinginfo wrong number of arguments} { - catch {r client trackinginfo x} err - set _ $err - } {ERR*wrong number of arguments*} - - test {CLIENT unpause wrong number of arguments} { - catch {r client unpause x} err - set _ $err - } {ERR*wrong number of arguments*} -} From 9bb56544a08c77fddb8d3ed9fbb87529c61024c8 Mon Sep 17 00:00:00 2001 From: hwware Date: Thu, 17 Feb 2022 11:01:00 -0500 Subject: [PATCH 4/6] remove tag from test case --- tests/unit/client.tcl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl index 90f91f555a3..b22a110ea25 100644 --- a/tests/unit/client.tcl +++ b/tests/unit/client.tcl @@ -1,4 +1,4 @@ -start_server {tags {"client caching test suites"}} { +start_server {} { test {CLIENT Caching wrong number of arguments} { catch {r client caching} err set _ $err @@ -32,7 +32,7 @@ start_server {tags {"client caching test suites"}} { } {ERR*when the client is in tracking mode*} } -start_server {tags {"client kill test suites"}} { +start_server {} { test {CLIENT kill wrong address} { catch {r client kill 000.123.321.567:0000} err set _ $err @@ -44,7 +44,7 @@ start_server {tags {"client kill test suites"}} { } {ERR*No such*} } -start_server {tags {"client no-evict test suites"}} { +start_server {} { test {CLIENT no-evict wrong argument} { catch {r client no-evict wrongInput} err set _ $err @@ -52,7 +52,7 @@ start_server {tags {"client no-evict test suites"}} { } -start_server {tags {"client pause test suites"}} { +start_server {} { test {CLIENT pause wrong timeout type} { catch {r client pause abc} err set _ $err @@ -64,14 +64,14 @@ start_server {tags {"client pause test suites"}} { } {ERR timeout is negative} } -start_server {tags {"client reply test suites"}} { +start_server {} { test {CLIENT reply wrong argument} { catch {r client reply wrongInput} err set _ $err } {ERR*syntax*} } -start_server {tags {"client tracking test suites"}} { +start_server {} { test {CLIENT tracking wrong argument} { catch {r client tracking wrongInput} err @@ -84,7 +84,7 @@ start_server {tags {"client tracking test suites"}} { } {ERR*syntax*} } -start_server {tags {"client setname getname test suites"}} { +start_server {} { test {CLIENT getname check if name set correctly} { r client setname testName r client getName From 3c4058335554b7876fae74ea86cb249e498cb84a Mon Sep 17 00:00:00 2001 From: hwware Date: Wed, 23 Feb 2022 09:45:19 -0500 Subject: [PATCH 5/6] remove multiple start server --- tests/test_helper.tcl | 3 --- tests/unit/client.tcl | 16 +--------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index a42c752c88f..5b7e6732844 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -93,11 +93,8 @@ set ::all_tests { unit/cluster unit/client-eviction unit/violations -<<<<<<< HEAD unit/replybufsize -======= unit/client ->>>>>>> Added tests for client commands } # Index to the next test to run in the ::all_tests list. set ::next_test 0 diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl index b22a110ea25..c016213d9db 100644 --- a/tests/unit/client.tcl +++ b/tests/unit/client.tcl @@ -30,9 +30,7 @@ start_server {} { catch {r client caching on} err set _ $err } {ERR*when the client is in tracking mode*} -} -start_server {} { test {CLIENT kill wrong address} { catch {r client kill 000.123.321.567:0000} err set _ $err @@ -42,17 +40,12 @@ start_server {} { catch {r client kill 127.0.0.1:} err set _ $err } {ERR*No such*} -} -start_server {} { test {CLIENT no-evict wrong argument} { catch {r client no-evict wrongInput} err set _ $err } {ERR*syntax*} -} - -start_server {} { test {CLIENT pause wrong timeout type} { catch {r client pause abc} err set _ $err @@ -62,16 +55,11 @@ start_server {} { catch {r client pause -1} err set _ $err } {ERR timeout is negative} -} -start_server {} { test {CLIENT reply wrong argument} { catch {r client reply wrongInput} err set _ $err } {ERR*syntax*} -} - -start_server {} { test {CLIENT tracking wrong argument} { catch {r client tracking wrongInput} err @@ -82,11 +70,9 @@ start_server {} { catch {r client tracking on wrongInput} err set _ $err } {ERR*syntax*} -} -start_server {} { test {CLIENT getname check if name set correctly} { r client setname testName r client getName } {testName} -} +} \ No newline at end of file From 55703941aea8eef9f77ef718984e7ac132525ea8 Mon Sep 17 00:00:00 2001 From: hwware Date: Wed, 9 Mar 2022 19:36:19 +0000 Subject: [PATCH 6/6] Remove redundant tests --- tests/unit/client.tcl | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/tests/unit/client.tcl b/tests/unit/client.tcl index c016213d9db..a66db58f73f 100644 --- a/tests/unit/client.tcl +++ b/tests/unit/client.tcl @@ -4,17 +4,9 @@ start_server {} { set _ $err } {ERR*wrong number of arguments*} - test {CLIENT Caching wrong argument} { - catch {r client caching maybe} err - set _ $err - } {ERR*when the client is in tracking mode*} - - test {CLIENT Caching OFF without optout} { - catch {r client caching off} err - set _ $err - } {ERR*when the client is in tracking mode*} - - test {CLIENT Caching ON without optin} { + test {CLIENT Caching test tracking} { + # Checks if the CLIENT_TRACKING flag is working as intended + r CLIENT TRACKING off optout catch {r client caching on} err set _ $err } {ERR*when the client is in tracking mode*} @@ -24,20 +16,9 @@ start_server {} { catch {r client caching on} err set _ $err } {ERR*syntax*} - - test {CLIENT Caching OFF with optin} { - r CLIENT TRACKING off optout - catch {r client caching on} err - set _ $err - } {ERR*when the client is in tracking mode*} - - test {CLIENT kill wrong address} { - catch {r client kill 000.123.321.567:0000} err - set _ $err - } {ERR*No such*} - test {CLIENT kill no port} { - catch {r client kill 127.0.0.1:} err + test {CLIENT kill wrong address or no port} { + catch {r client kill 999.999.999.000:} err set _ $err } {ERR*No such*} @@ -75,4 +56,4 @@ start_server {} { r client setname testName r client getName } {testName} -} \ No newline at end of file +}