summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modules/auth.c11
-rw-r--r--tests/modules/propagate.c11
-rw-r--r--tests/modules/subcommands.c21
-rw-r--r--tests/sentinel/tests/03-runtime-reconf.tcl2
-rw-r--r--tests/support/test.tcl6
-rw-r--r--tests/unit/acl.tcl22
-rw-r--r--tests/unit/expire.tcl22
-rw-r--r--tests/unit/functions.tcl4
-rw-r--r--tests/unit/info.tcl4
-rw-r--r--tests/unit/introspection-2.tcl57
-rw-r--r--tests/unit/introspection.tcl14
-rw-r--r--tests/unit/latency-monitor.tcl3
-rw-r--r--tests/unit/moduleapi/aclcheck.tcl4
-rw-r--r--tests/unit/moduleapi/auth.tcl5
-rw-r--r--tests/unit/moduleapi/basics.tcl5
-rw-r--r--tests/unit/moduleapi/blockedclient.tcl6
-rw-r--r--tests/unit/moduleapi/commandfilter.tcl4
-rw-r--r--tests/unit/moduleapi/eventloop.tcl4
-rw-r--r--tests/unit/moduleapi/fork.tcl3
-rw-r--r--tests/unit/moduleapi/getkeys.tcl4
-rw-r--r--tests/unit/moduleapi/hash.tcl4
-rw-r--r--tests/unit/moduleapi/infotest.tcl4
-rw-r--r--tests/unit/moduleapi/infra.tcl4
-rw-r--r--tests/unit/moduleapi/keyspace_events.tcl6
-rw-r--r--tests/unit/moduleapi/keyspecs.tcl4
-rw-r--r--tests/unit/moduleapi/list.tcl4
-rw-r--r--tests/unit/moduleapi/misc.tcl5
-rw-r--r--tests/unit/moduleapi/propagate.tcl6
-rw-r--r--tests/unit/moduleapi/reply.tcl4
-rw-r--r--tests/unit/moduleapi/scan.tcl4
-rw-r--r--tests/unit/moduleapi/stream.tcl4
-rw-r--r--tests/unit/moduleapi/subcommands.tcl26
-rw-r--r--tests/unit/moduleapi/timer.tcl4
-rw-r--r--tests/unit/moduleapi/zset.tcl4
-rw-r--r--tests/unit/pause.tcl2
-rw-r--r--tests/unit/type/hash.tcl8
-rw-r--r--tests/unit/type/list.tcl11
-rw-r--r--tests/unit/type/set.tcl4
-rw-r--r--tests/unit/type/stream.tcl10
-rw-r--r--tests/unit/type/string.tcl10
-rw-r--r--tests/unit/type/zset.tcl22
41 files changed, 301 insertions, 61 deletions
diff --git a/tests/modules/auth.c b/tests/modules/auth.c
index 959fb14f2..040a447ec 100644
--- a/tests/modules/auth.c
+++ b/tests/modules/auth.c
@@ -1,5 +1,7 @@
#include "redismodule.h"
+#define UNUSED(V) ((void) V)
+
// A simple global user
static RedisModuleUser *global = NULL;
static long long client_change_delta = 0;
@@ -87,3 +89,12 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
return REDISMODULE_OK;
}
+
+int RedisModule_OnUnload(RedisModuleCtx *ctx) {
+ UNUSED(ctx);
+
+ if (global)
+ RedisModule_FreeModuleUser(global);
+
+ return REDISMODULE_OK;
+}
diff --git a/tests/modules/propagate.c b/tests/modules/propagate.c
index 7560e94d2..d5132a5b4 100644
--- a/tests/modules/propagate.c
+++ b/tests/modules/propagate.c
@@ -41,6 +41,8 @@
#include <pthread.h>
#include <errno.h>
+#define UNUSED(V) ((void) V)
+
RedisModuleCtx *detached_ctx = NULL;
static int KeySpace_NotificationGeneric(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) {
@@ -390,3 +392,12 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
return REDISMODULE_OK;
}
+
+int RedisModule_OnUnload(RedisModuleCtx *ctx) {
+ UNUSED(ctx);
+
+ if (detached_ctx)
+ RedisModule_FreeThreadSafeContext(detached_ctx);
+
+ return REDISMODULE_OK;
+}
diff --git a/tests/modules/subcommands.c b/tests/modules/subcommands.c
index 783414a36..f0cc6ffaf 100644
--- a/tests/modules/subcommands.c
+++ b/tests/modules/subcommands.c
@@ -16,6 +16,15 @@ int cmd_get(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
return REDISMODULE_OK;
}
+int cmd_get_fullname(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
+ UNUSED(argv);
+ UNUSED(argc);
+
+ const char *command_name = RedisModule_GetCurrentCommandName(ctx);
+ RedisModule_ReplyWithSimpleString(ctx, command_name);
+ return REDISMODULE_OK;
+}
+
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
@@ -51,6 +60,18 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
if (RedisModule_SetCommandKeySpecFindKeysRange(subcmd,spec_id,0,1,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
+ /* Get the name of the command currently running. */
+ if (RedisModule_CreateCommand(ctx,"subcommands.parent_get_fullname",cmd_get_fullname,"",0,0,0) == REDISMODULE_ERR)
+ return REDISMODULE_ERR;
+
+ /* Get the name of the subcommand currently running. */
+ if (RedisModule_CreateCommand(ctx,"subcommands.sub",NULL,"",0,0,0) == REDISMODULE_ERR)
+ return REDISMODULE_ERR;
+
+ RedisModuleCommand *fullname_parent = RedisModule_GetCommand(ctx,"subcommands.sub");
+ if (RedisModule_CreateSubcommand(fullname_parent,"get_fullname",cmd_get_fullname,"",0,0,0) == REDISMODULE_ERR)
+ return REDISMODULE_ERR;
+
/* Sanity */
/* Trying to create the same subcommand fails */
diff --git a/tests/sentinel/tests/03-runtime-reconf.tcl b/tests/sentinel/tests/03-runtime-reconf.tcl
index 5e3a96039..ad9284e41 100644
--- a/tests/sentinel/tests/03-runtime-reconf.tcl
+++ b/tests/sentinel/tests/03-runtime-reconf.tcl
@@ -40,7 +40,7 @@ test "Sentinel Set with other error situations" {
assert_error "ERR Notification script seems non existing*" {S 0 SENTINEL SET mymaster notification-script test.txt}
# wrong parameter number
- assert_error "ERR wrong number of arguments for 'set' command or subcommand" {S 0 SENTINEL SET mymaster fakeoption}
+ assert_error "ERR wrong number of arguments for 'sentinel|set' command" {S 0 SENTINEL SET mymaster fakeoption}
# unknown parameter option
assert_error "ERR Unknown option or number of arguments for SENTINEL SET 'fakeoption'" {S 0 SENTINEL SET mymaster fakeoption fakevalue}
diff --git a/tests/support/test.tcl b/tests/support/test.tcl
index f3f7e132a..34c7986da 100644
--- a/tests/support/test.tcl
+++ b/tests/support/test.tcl
@@ -40,6 +40,12 @@ proc assert_failed {expected_err detail} {
error "assertion:$expected_err $detail"
}
+proc assert_not_equal {value expected {detail ""}} {
+ if {!($expected ne $value)} {
+ assert_failed "Expected '$value' not equal to '$expected'" $detail
+ }
+}
+
proc assert_equal {value expected {detail ""}} {
if {$expected ne $value} {
assert_failed "Expected '$value' to be equal to '$expected'" $detail
diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl
index 5c5592108..24f069313 100644
--- a/tests/unit/acl.tcl
+++ b/tests/unit/acl.tcl
@@ -476,6 +476,26 @@ start_server {tags {"acl external:skip"}} {
}
}
+ test "ACL CAT with illegal arguments" {
+ assert_error {*Unknown category 'NON_EXISTS'} {r ACL CAT NON_EXISTS}
+ assert_error {*Unknown subcommand or wrong number of arguments for 'CAT'*} {r ACL CAT NON_EXISTS NON_EXISTS2}
+ }
+
+ test "ACL CAT without category - list all categories" {
+ set categories [r acl cat]
+ assert_not_equal [lsearch $categories "keyspace"] -1
+ assert_not_equal [lsearch $categories "connection"] -1
+ }
+
+ test "ACL CAT category - list all commands/subcommands that belong to category" {
+ assert_not_equal [lsearch [r acl cat transaction] "multi"] -1
+ assert_not_equal [lsearch [r acl cat scripting] "function|list"] -1
+
+ # Negative check to make sure it doesn't actually return all commands.
+ assert_equal [lsearch [r acl cat keyspace] "set"] -1
+ assert_equal [lsearch [r acl cat stream] "get"] -1
+ }
+
test {ACL #5998 regression: memory leaks adding / removing subcommands} {
r AUTH default ""
r ACL setuser newuser reset -debug +debug|a +debug|b +debug|c
@@ -632,7 +652,7 @@ start_server {tags {"acl external:skip"}} {
test {ACL HELP should not have unexpected options} {
catch {r ACL help xxx} e
- assert_match "*wrong number of arguments*" $e
+ assert_match "*wrong number of arguments for 'acl|help' command" $e
}
test {Delete a user that the client doesn't use} {
diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl
index b853df035..d85d59e7a 100644
--- a/tests/unit/expire.tcl
+++ b/tests/unit/expire.tcl
@@ -244,35 +244,35 @@ start_server {tags {"expire"}} {
test {SET with EX with big integer should report an error} {
catch {r set foo bar EX 10000000000000000} e
set e
- } {ERR invalid expire time in set}
+ } {ERR invalid expire time in 'set' command}
test {SET with EX with smallest integer should report an error} {
catch {r SET foo bar EX -9999999999999999} e
set e
- } {ERR invalid expire time in set}
+ } {ERR invalid expire time in 'set' command}
test {GETEX with big integer should report an error} {
r set foo bar
catch {r GETEX foo EX 10000000000000000} e
set e
- } {ERR invalid expire time in getex}
+ } {ERR invalid expire time in 'getex' command}
test {GETEX with smallest integer should report an error} {
r set foo bar
catch {r GETEX foo EX -9999999999999999} e
set e
- } {ERR invalid expire time in getex}
+ } {ERR invalid expire time in 'getex' command}
test {EXPIRE with big integer overflows when converted to milliseconds} {
r set foo bar
# Hit `when > LLONG_MAX - basetime`
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo 9223370399119966}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo 9223370399119966}
# Hit `when > LLONG_MAX / 1000`
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo 9223372036854776}
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo 10000000000000000}
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo 18446744073709561}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo 9223372036854776}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo 10000000000000000}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo 18446744073709561}
assert_equal {-1} [r ttl foo]
}
@@ -281,14 +281,14 @@ start_server {tags {"expire"}} {
r set foo bar
catch {r PEXPIRE foo 9223372036854770000} e
set e
- } {ERR invalid expire time in pexpire}
+ } {ERR invalid expire time in 'pexpire' command}
test {EXPIRE with big negative integer} {
r set foo bar
# Hit `when < LLONG_MIN / 1000`
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo -9223372036854776}
- assert_error "ERR invalid expire time in expire" {r EXPIRE foo -9999999999999999}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo -9223372036854776}
+ assert_error "ERR invalid expire time in 'expire' command" {r EXPIRE foo -9999999999999999}
r ttl foo
} {-1}
diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl
index fe4ce5ad7..016bbb1e1 100644
--- a/tests/unit/functions.tcl
+++ b/tests/unit/functions.tcl
@@ -209,7 +209,7 @@ start_server {tags {"scripting"}} {
test {FUNCTION - test function restore with wrong number of arguments} {
catch {r function restore arg1 args2 arg3} e
set _ $e
- } {*wrong number of arguments*}
+ } {*Unknown subcommand or wrong number of arguments for 'restore'. Try FUNCTION HELP.}
test {FUNCTION - test fcall_ro with write command} {
r function load lua test REPLACE [get_no_writes_function_code test {return redis.call('set', 'x', '1')}]
@@ -302,7 +302,7 @@ start_server {tags {"scripting"}} {
assert_match {*only supports SYNC|ASYNC*} $e
catch {r function flush sync extra_arg} e
- assert_match {*wrong number of arguments*} $e
+ assert_match {*Unknown subcommand or wrong number of arguments for 'flush'. Try FUNCTION HELP.} $e
}
}
diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl
index 9439c0fc8..b211e6c91 100644
--- a/tests/unit/info.tcl
+++ b/tests/unit/info.tcl
@@ -197,7 +197,7 @@ start_server {tags {"info" "external:skip"}} {
assert_match {} [errorstat ERR]
r multi
catch {r set} e
- assert_match {ERR wrong number of arguments*} $e
+ assert_match {ERR wrong number of arguments for 'set' command} $e
catch {r exec} e
assert_match {EXECABORT*} $e
assert_match {*count=1*} [errorstat ERR]
@@ -216,7 +216,7 @@ start_server {tags {"info" "external:skip"}} {
assert_equal [s total_error_replies] 0
assert_match {} [errorstat ERR]
catch {r set k} e
- assert_match {ERR wrong number of arguments*} $e
+ assert_match {ERR wrong number of arguments for 'set' command} $e
assert_match {*count=1*} [errorstat ERR]
assert_match {*calls=0,*,rejected_calls=1,failed_calls=0} [cmdstat set]
# ensure that after a rejected command, valid ones are counted properly
diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl
index 457ac6bc4..40124e035 100644
--- a/tests/unit/introspection-2.tcl
+++ b/tests/unit/introspection-2.tcl
@@ -101,14 +101,59 @@ start_server {tags {"introspection"}} {
assert_equal {key1 key2} [r command getkeys lcs key1 key2]
}
- test "COMMAND LIST FILTERBY ACLCAT" {
- set reply [r command list filterby aclcat hyperloglog]
- assert_equal [lsort $reply] {pfadd pfcount pfdebug pfmerge pfselftest}
+ test "COMMAND LIST syntax error" {
+ assert_error "ERR syntax error*" {r command list bad_arg}
+ assert_error "ERR syntax error*" {r command list filterby bad_arg}
+ assert_error "ERR syntax error*" {r command list filterby bad_arg bad_arg2}
}
- test "COMMAND LIST FILTERBY PATTERN" {
- set reply [r command list filterby pattern pf*]
- assert_equal [lsort $reply] {pfadd pfcount pfdebug pfmerge pfselftest}
+ test "COMMAND LIST WITHOUT FILTERBY" {
+ set commands [r command list]
+ assert_not_equal [lsearch $commands "set"] -1
+ assert_not_equal [lsearch $commands "client|list"] -1
+ }
+
+ test "COMMAND LIST FILTERBY ACLCAT against non existing category" {
+ assert_equal {} [r command list filterby aclcat non_existing_category]
+ }
+
+ test "COMMAND LIST FILTERBY ACLCAT - list all commands/subcommands" {
+ set commands [r command list filterby aclcat scripting]
+ assert_not_equal [lsearch $commands "eval"] -1
+ assert_not_equal [lsearch $commands "script|kill"] -1
+
+ # Negative check, a command that should not be here
+ assert_equal [lsearch $commands "set"] -1
+ }
+
+ test "COMMAND LIST FILTERBY PATTERN - list all commands/subcommands" {
+ # Exact command match.
+ assert_equal {set} [r command list filterby pattern set]
+ assert_equal {get} [r command list filterby pattern get]
+
+ # Return the parent command and all the subcommands below it.
+ set commands [r command list filterby pattern config*]
+ assert_not_equal [lsearch $commands "config"] -1
+ assert_not_equal [lsearch $commands "config|get"] -1
+
+ # We can filter subcommands under a parent command.
+ set commands [r command list filterby pattern config|*re*]
+ assert_not_equal [lsearch $commands "config|resetstat"] -1
+ assert_not_equal [lsearch $commands "config|rewrite"] -1
+
+ # We can filter subcommands across parent commands.
+ set commands [r command list filterby pattern cl*help]
+ assert_not_equal [lsearch $commands "client|help"] -1
+ assert_not_equal [lsearch $commands "cluster|help"] -1
+
+ # Negative check, command that doesn't exist.
+ assert_equal {} [r command list filterby pattern non_exists]
+ assert_equal {} [r command list filterby pattern non_exists*]
+ }
+
+ test "COMMAND LIST FILTERBY MODULE against non existing module" {
+ # This should be empty, the real one is in subcommands.tcl
+ assert_equal {} [r command list filterby module non_existing_module]
}
test {COMMAND INFO of invalid subcommands} {
diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl
index 29d881372..33a41ee50 100644
--- a/tests/unit/introspection.tcl
+++ b/tests/unit/introspection.tcl
@@ -1,20 +1,26 @@
start_server {tags {"introspection"}} {
+ test "PING" {
+ assert_equal {PONG} [r ping]
+ assert_equal {redis} [r ping redis]
+ assert_error {*wrong number of arguments for 'ping' command} {r ping hello redis}
+ }
+
test {CLIENT LIST} {
r client list
- } {*addr=*:* fd=* age=* idle=* flags=N db=* sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=* argv-mem=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client*}
+ } {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=2*}
test {CLIENT LIST with IDs} {
set myid [r client id]
set cl [split [r client list id $myid] "\r\n"]
- assert_match "id=$myid*" [lindex $cl 0]
+ assert_match "id=$myid * cmd=client|list *" [lindex $cl 0]
}
test {CLIENT INFO} {
r client info
- } {*addr=*:* fd=* age=* idle=* flags=N db=* sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=* argv-mem=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client*}
+ } {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=2*}
test {CLIENT KILL with illegal arguments} {
- assert_error "ERR wrong number*" {r client kill}
+ assert_error "ERR wrong number of arguments for 'client|kill' command" {r client kill}
assert_error "ERR syntax error*" {r client kill id 10 wrong_arg}
assert_error "ERR*greater than 0*" {r client kill id str}
diff --git a/tests/unit/latency-monitor.tcl b/tests/unit/latency-monitor.tcl
index 79de0883c..39d404d55 100644
--- a/tests/unit/latency-monitor.tcl
+++ b/tests/unit/latency-monitor.tcl
@@ -8,6 +8,7 @@ start_server {tags {"latency-monitor needs:latency"}} {
set histo [dict create {*}[r latency histogram]]
# Config resetstat is recorded
assert_equal [dict size $histo] 1
+ assert_match {*config|resetstat*} $histo
}
test {LATENCY HISTOGRAM all commands} {
@@ -141,6 +142,6 @@ start_server {tags {"latency-monitor needs:latency"}} {
test {LATENCY HELP should not have unexpected options} {
catch {r LATENCY help xxx} e
- assert_match "*wrong number of arguments*" $e
+ assert_match "*wrong number of arguments for 'latency|help' command" $e
}
}
diff --git a/tests/unit/moduleapi/aclcheck.tcl b/tests/unit/moduleapi/aclcheck.tcl
index 3fa3ed43f..ad55eb160 100644
--- a/tests/unit/moduleapi/aclcheck.tcl
+++ b/tests/unit/moduleapi/aclcheck.tcl
@@ -72,4 +72,8 @@ start_server {tags {"modules acl"}} {
assert {[dict get $entry context] eq {module}}
assert {[dict get $entry object] eq {set}}
}
+
+ test "Unload the module - aclcheck" {
+ assert_equal {OK} [r module unload aclcheck]
+ }
}
diff --git a/tests/unit/moduleapi/auth.tcl b/tests/unit/moduleapi/auth.tcl
index 906ab0beb..6d8c3bd6a 100644
--- a/tests/unit/moduleapi/auth.tcl
+++ b/tests/unit/moduleapi/auth.tcl
@@ -68,4 +68,7 @@ start_server {tags {"modules"}} {
assert_equal [r acl whoami] "default"
}
-} \ No newline at end of file
+ test "Unload the module - testacl" {
+ assert_equal {OK} [r module unload testacl]
+ }
+}
diff --git a/tests/unit/moduleapi/basics.tcl b/tests/unit/moduleapi/basics.tcl
index be8b697f0..b858c344a 100644
--- a/tests/unit/moduleapi/basics.tcl
+++ b/tests/unit/moduleapi/basics.tcl
@@ -1,6 +1,5 @@
set testmodule [file normalize tests/modules/basics.so]
-
start_server {tags {"modules"}} {
r module load $testmodule
@@ -30,7 +29,9 @@ start_server {tags {"modules"}} {
assert_equal $reply 3
}
- r module unload test
+ test "Unload the module - test" {
+ assert_equal {OK} [r module unload test]
+ }
}
start_server {tags {"modules external:skip"} overrides {enable-module-command no}} {
diff --git a/tests/unit/moduleapi/blockedclient.tcl b/tests/unit/moduleapi/blockedclient.tcl
index c8651aabd..523d7ba69 100644
--- a/tests/unit/moduleapi/blockedclient.tcl
+++ b/tests/unit/moduleapi/blockedclient.tcl
@@ -1,5 +1,3 @@
-# source tests/support/util.tcl
-
set testmodule [file normalize tests/modules/blockedclient.so]
start_server {tags {"modules"}} {
@@ -181,4 +179,8 @@ start_server {tags {"modules"}} {
set clients [r client list]
assert_no_match "*name=myclient*" $clients
}
+
+ test "Unload the module - blockedclient" {
+ assert_equal {OK} [r module unload blockedclient]
+ }
}
diff --git a/tests/unit/moduleapi/commandfilter.tcl b/tests/unit/moduleapi/commandfilter.tcl
index 112846058..723dd1409 100644
--- a/tests/unit/moduleapi/commandfilter.tcl
+++ b/tests/unit/moduleapi/commandfilter.tcl
@@ -91,4 +91,8 @@ start_server {tags {"modules"}} {
r eval "redis.call('commandfilter.ping')" 0
assert_equal {} [r lrange log-key 0 -1]
}
+
+ test "Unload the module - commandfilter" {
+ assert_equal {OK} [r module unload commandfilter]
+ }
}
diff --git a/tests/unit/moduleapi/eventloop.tcl b/tests/unit/moduleapi/eventloop.tcl
index 44d28dfb9..81e01cae0 100644
--- a/tests/unit/moduleapi/eventloop.tcl
+++ b/tests/unit/moduleapi/eventloop.tcl
@@ -21,4 +21,8 @@ start_server {tags {"modules"}} {
test "Module eventloop oneshot" {
r test.oneshot
}
+
+ test "Unload the module - eventloop" {
+ assert_equal {OK} [r module unload eventloop]
+ }
}
diff --git a/tests/unit/moduleapi/fork.tcl b/tests/unit/moduleapi/fork.tcl
index 64184d01e..d6a2db9a9 100644
--- a/tests/unit/moduleapi/fork.tcl
+++ b/tests/unit/moduleapi/fork.tcl
@@ -39,4 +39,7 @@ start_server {tags {"modules"}} {
assert {[count_log_message "Can't fork for module: File exists"] eq "1"}
}
+ test "Unload the module - fork" {
+ assert_equal {OK} [r module unload fork]
+ }
}
diff --git a/tests/unit/moduleapi/getkeys.tcl b/tests/unit/moduleapi/getkeys.tcl
index 8ceb2b386..6061fe8cf 100644
--- a/tests/unit/moduleapi/getkeys.tcl
+++ b/tests/unit/moduleapi/getkeys.tcl
@@ -41,4 +41,8 @@ start_server {tags {"modules"}} {
catch {r getkeys.introspect set key} e
set _ $e
} {*EINVAL*}
+
+ test "Unload the module - getkeys" {
+ assert_equal {OK} [r module unload getkeys]
+ }
}
diff --git a/tests/unit/moduleapi/hash.tcl b/tests/unit/moduleapi/hash.tcl
index 89bb6c63a..116b1c512 100644
--- a/tests/unit/moduleapi/hash.tcl
+++ b/tests/unit/moduleapi/hash.tcl
@@ -20,4 +20,8 @@ start_server {tags {"modules"}} {
assert_equal 1 [r hash.set k "" sushi :delete: none :delete:]
r hgetall k
} {squirrel ofcourse banana no what nothing something nice}
+
+ test "Unload the module - hash" {
+ assert_equal {OK} [r module unload hash]
+ }
}
diff --git a/tests/unit/moduleapi/infotest.tcl b/tests/unit/moduleapi/infotest.tcl
index 1ad2ee6fc..0d07aaa7e 100644
--- a/tests/unit/moduleapi/infotest.tcl
+++ b/tests/unit/moduleapi/infotest.tcl
@@ -90,5 +90,9 @@ start_server {tags {"modules"}} {
assert_match {*infotest_unsafe_field:value=1*} $info
}
+ test "Unload the module - infotest" {
+ assert_equal {OK} [r module unload infotest]
+ }
+
# TODO: test crash report.
}
diff --git a/tests/unit/moduleapi/infra.tcl b/tests/unit/moduleapi/infra.tcl
index 077487457..7bfa7d4b3 100644
--- a/tests/unit/moduleapi/infra.tcl
+++ b/tests/unit/moduleapi/infra.tcl
@@ -12,11 +12,11 @@ test {modules config rewrite} {
assert_equal [lindex [lindex [r module list] 0] 1] infotest
- r module unload infotest
+ assert_equal {OK} [r module unload infotest]
r config rewrite
restart_server 0 true false
assert_equal [llength [r module list]] 0
}
-}
+}
diff --git a/tests/unit/moduleapi/keyspace_events.tcl b/tests/unit/moduleapi/keyspace_events.tcl
index 60800bbff..39350e518 100644
--- a/tests/unit/moduleapi/keyspace_events.tcl
+++ b/tests/unit/moduleapi/keyspace_events.tcl
@@ -82,5 +82,9 @@ tags "modules" {
assert_equal {pmessage * __keyspace@9__:x notify} [$rd1 read]
$rd1 close
}
- }
+
+ test "Unload the module - testkeyspace" {
+ assert_equal {OK} [r module unload testkeyspace]
+ }
+ }
}
diff --git a/tests/unit/moduleapi/keyspecs.tcl b/tests/unit/moduleapi/keyspecs.tcl
index b1b6da9db..cbd3aba83 100644
--- a/tests/unit/moduleapi/keyspecs.tcl
+++ b/tests/unit/moduleapi/keyspecs.tcl
@@ -48,4 +48,8 @@ start_server {tags {"modules"}} {
set reply [r command list filterby module keyspecs]
assert_equal [lsort $reply] {kspec.complex1 kspec.complex2 kspec.legacy}
}
+
+ test "Unload the module - keyspecs" {
+ assert_equal {OK} [r module unload keyspecs]
+ }
}
diff --git a/tests/unit/moduleapi/list.tcl b/tests/unit/moduleapi/list.tcl
index 6094a0354..34a19767c 100644
--- a/tests/unit/moduleapi/list.tcl
+++ b/tests/unit/moduleapi/list.tcl
@@ -63,4 +63,8 @@ start_server {tags {"modules"}} {
r list.edit k reverse rkr foo bar
r list.getall k
} {bar y foo}
+
+ test "Unload the module - list" {
+ assert_equal {OK} [r module unload list]
+ }
}
diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl
index 9aa191814..bc00b37d2 100644
--- a/tests/unit/moduleapi/misc.tcl
+++ b/tests/unit/moduleapi/misc.tcl
@@ -1,6 +1,5 @@
set testmodule [file normalize tests/modules/misc.so]
-
start_server {tags {"modules"}} {
r module load $testmodule
@@ -133,4 +132,8 @@ start_server {tags {"modules"}} {
set x [r test.monotonic_time]
assert { [r test.monotonic_time] >= $x }
}
+
+ test "Unload the module - misc" {
+ assert_equal {OK} [r module unload misc]
+ }
}
diff --git a/tests/unit/moduleapi/propagate.tcl b/tests/unit/moduleapi/propagate.tcl
index a95fbfd71..bbc9d3800 100644
--- a/tests/unit/moduleapi/propagate.tcl
+++ b/tests/unit/moduleapi/propagate.tcl
@@ -574,6 +574,11 @@ tags "modules" {
assert_equal [$replica ttl k1] -1
}
+ test "Unload the module - propagate-test/testkeyspace" {
+ assert_equal {OK} [r module unload propagate-test]
+ assert_equal {OK} [r module unload testkeyspace]
+ }
+
assert_equal [s -1 unexpected_error_replies] 0
}
}
@@ -598,6 +603,7 @@ tags "modules aof" {
# Load the AOF
r debug loadaof
+ assert_equal {OK} [r module unload propagate-test]
assert_equal [s 0 unexpected_error_replies] 0
}
}
diff --git a/tests/unit/moduleapi/reply.tcl b/tests/unit/moduleapi/reply.tcl
index 43d44707c..7fe8c8678 100644
--- a/tests/unit/moduleapi/reply.tcl
+++ b/tests/unit/moduleapi/reply.tcl
@@ -94,4 +94,8 @@ start_server {tags {"modules"}} {
assert_match "An error" $e
}
}
+
+ test "Unload the module - replywith" {
+ assert_equal {OK} [r module unload replywith]
+ }
}
diff --git a/tests/unit/moduleapi/scan.tcl b/tests/unit/moduleapi/scan.tcl
index 43a0c4d8a..66faf5eb8 100644
--- a/tests/unit/moduleapi/scan.tcl
+++ b/tests/unit/moduleapi/scan.tcl
@@ -49,4 +49,8 @@ start_server {tags {"modules"}} {
r sadd ss 3
lsort [r scan.scan_key ss]
} {{1 {}} {2 {}} {3 {}}}
+
+ test "Unload the module - scan" {
+ assert_equal {OK} [r module unload scan]
+ }
}
diff --git a/tests/unit/moduleapi/stream.tcl b/tests/unit/moduleapi/stream.tcl
index 15e97c183..80c24ff6c 100644
--- a/tests/unit/moduleapi/stream.tcl
+++ b/tests/unit/moduleapi/stream.tcl
@@ -152,4 +152,8 @@ start_server {tags {"modules"}} {
assert_equal 100 [r stream.trim mystream minid ~ +]
assert_equal 0 [r xlen mystream]
}
+
+ test "Unload the module - stream" {
+ assert_equal {OK} [r module unload stream]
+ }
}
diff --git a/tests/unit/moduleapi/subcommands.tcl b/tests/unit/moduleapi/subcommands.tcl
index bc890b77e..10c62d10d 100644
--- a/tests/unit/moduleapi/subcommands.tcl
+++ b/tests/unit/moduleapi/subcommands.tcl
@@ -21,9 +21,33 @@ start_server {tags {"modules"}} {
test "Module pure-container command fails on arity error" {
catch {r subcommands.bitarray} e
- assert_match {*wrong number of arguments*} $e
+ assert_match {*wrong number of arguments for 'subcommands.bitarray' command} $e
# Subcommands can be called
assert_equal [r subcommands.bitarray get k1] {OK}
}
+
+ test "Module get current command fullname" {
+ assert_equal [r subcommands.parent_get_fullname] {subcommands.parent_get_fullname}
+ }
+
+ test "Module get current subcommand fullname" {
+ assert_equal [r subcommands.sub get_fullname] {subcommands.sub|get_fullname}
+ }
+
+ test "COMMAND LIST FILTERBY MODULE" {
+ assert_equal {} [r command list filterby module non_existing]
+
+ set commands [r command list filterby module subcommands]
+ assert_not_equal [lsearch $commands "subcommands.bitarray"] -1
+ assert_not_equal [lsearch $commands "subcommands.bitarray|set"] -1
+ assert_not_equal [lsearch $commands "subcommands.parent_get_fullname"] -1
+ assert_not_equal [lsearch $commands "subcommands.sub|get_fullname"] -1
+
+ assert_equal [lsearch $commands "set"] -1
+ }
+
+ test "Unload the module - subcommands" {
+ assert_equal {OK} [r module unload subcommands]
+ }
}
diff --git a/tests/unit/moduleapi/timer.tcl b/tests/unit/moduleapi/timer.tcl
index 10a902276..c04f80b23 100644
--- a/tests/unit/moduleapi/timer.tcl
+++ b/tests/unit/moduleapi/timer.tcl
@@ -53,5 +53,9 @@ start_server {tags {"modules"}} {
# verify id does not exist
assert_equal {} [r test.gettimer $id]
}
+
+ test "Unload the module - timer" {
+ assert_equal {OK} [r module unload timer]
+ }
}
diff --git a/tests/unit/moduleapi/zset.tcl b/tests/unit/moduleapi/zset.tcl
index 998d20765..1c146eaf4 100644
--- a/tests/unit/moduleapi/zset.tcl
+++ b/tests/unit/moduleapi/zset.tcl
@@ -13,4 +13,8 @@ start_server {tags {"modules"}} {
assert_equal 1 [r zset.rem k world]
assert_equal 0 [r exists k]
}
+
+ test "Unload the module - zset" {
+ assert_equal {OK} [r module unload zset]
+ }
}
diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl
index 0f9bb4ae4..99fc7214d 100644
--- a/tests/unit/pause.tcl
+++ b/tests/unit/pause.tcl
@@ -104,7 +104,7 @@ start_server {tags {"pause network"}} {
test "Test clients with syntax errors will get responses immediately" {
r client PAUSE 100000 WRITE
catch {r set FOO} err
- assert_match "ERR wrong number of arguments for *" $err
+ assert_match "ERR wrong number of arguments for 'set' command" $err
r client unpause
}
diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl
index 6646ccc18..75ba29f77 100644
--- a/tests/unit/type/hash.tcl
+++ b/tests/unit/type/hash.tcl
@@ -310,10 +310,10 @@ start_server {tags {"hash"}} {
set _ $result
} {foo}
- test {HMSET wrong number of args} {
- catch {r hmset smallhash key1 val1 key2} err
- format $err
- } {*wrong number*}
+ test {HSET/HMSET wrong number of args} {
+ assert_error {*wrong number of arguments for 'hset' command} {r hset smallhash key1 val1 key2}
+ assert_error {*wrong number of arguments for 'hmset' command} {r hmset smallhash key1 val1 key2}
+ }
test {HMSET - small hash} {
set args {}
diff --git a/tests/unit/type/list.tcl b/tests/unit/type/list.tcl
index 3981d3f87..8cff56c6a 100644
--- a/tests/unit/type/list.tcl
+++ b/tests/unit/type/list.tcl
@@ -486,6 +486,11 @@ start_server {
assert_equal c [r lpop mylist2]
}
+ test "LPOP/RPOP with wrong number of arguments" {
+ assert_error {*wrong number of arguments for 'lpop' command} {r lpop key 1 1}
+ assert_error {*wrong number of arguments for 'rpop' command} {r rpop key 2 2}
+ }
+
test {RPOP/LPOP with the optional count argument} {
assert_equal 7 [r lpush listcount aa bb cc dd ee ff gg]
assert_equal {gg} [r lpop listcount 1]
@@ -1600,9 +1605,9 @@ foreach {pop} {BLPOP BLMPOP_LEFT} {
}
test {LMPOP with illegal argument} {
- assert_error "ERR wrong number of arguments*" {r lmpop}
- assert_error "ERR wrong number of arguments*" {r lmpop 1}
- assert_error "ERR wrong number of arguments*" {r lmpop 1 mylist{t}}
+ assert_error "ERR wrong number of arguments for 'lmpop' command" {r lmpop}
+ assert_error "ERR wrong number of arguments for 'lmpop' command" {r lmpop 1}
+ assert_error "ERR wrong number of arguments for 'lmpop' command" {r lmpop 1 mylist{t}}
assert_error "ERR numkeys*" {r lmpop 0 mylist{t} LEFT}
assert_error "ERR numkeys*" {r lmpop a mylist{t} LEFT}
diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl
index 587bd58f8..93f7311b1 100644
--- a/tests/unit/type/set.tcl
+++ b/tests/unit/type/set.tcl
@@ -144,8 +144,8 @@ start_server {
} {3}
test "SINTERCARD with illegal arguments" {
- assert_error "ERR wrong number of arguments*" {r sintercard}
- assert_error "ERR wrong number of arguments*" {r sintercard 1}
+ assert_error "ERR wrong number of arguments for 'sintercard' command" {r sintercard}
+ assert_error "ERR wrong number of arguments for 'sintercard' command" {r sintercard 1}
assert_error "ERR numkeys*" {r sintercard 0 myset{t}}
assert_error "ERR numkeys*" {r sintercard a myset{t}}
diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl
index 97d498258..7ba3ed116 100644
--- a/tests/unit/type/stream.tcl
+++ b/tests/unit/type/stream.tcl
@@ -52,6 +52,12 @@ set content {} ;# Will be populated with Tcl side copy of the stream content.
start_server {
tags {"stream"}
} {
+ test "XADD wrong number of args" {
+ assert_error {*wrong number of arguments for 'xadd' command} {r XADD mystream}
+ assert_error {*wrong number of arguments for 'xadd' command} {r XADD mystream *}
+ assert_error {*wrong number of arguments for 'xadd' command} {r XADD mystream * field}
+ }
+
test {XADD can add entries into a stream that XRANGE can fetch} {
r XADD mystream * item 1 value a
r XADD mystream * item 2 value b
@@ -797,11 +803,11 @@ start_server {tags {"stream needs:debug"} overrides {appendonly yes aof-use-rdb-
start_server {tags {"stream"}} {
test {XGROUP HELP should not have unexpected options} {
catch {r XGROUP help xxx} e
- assert_match "*wrong number of arguments*" $e
+ assert_match "*wrong number of arguments for 'xgroup|help' command" $e
}
test {XINFO HELP should not have unexpected options} {
catch {r XINFO help xxx} e
- assert_match "*wrong number of arguments*" $e
+ assert_match "*wrong number of arguments for 'xinfo|help' command" $e
}
}
diff --git a/tests/unit/type/string.tcl b/tests/unit/type/string.tcl
index a6b8fc1e9..d04bdff32 100644
--- a/tests/unit/type/string.tcl
+++ b/tests/unit/type/string.tcl
@@ -155,7 +155,7 @@ start_server {tags {"string"}} {
set ex {}
catch {r getex} ex
set ex
- } {*wrong number of arguments*}
+ } {*wrong number of arguments for 'getex' command}
test "GETDEL command" {
r del foo
@@ -221,10 +221,10 @@ start_server {tags {"string"}} {
r mget x{t} y{t} z{t}
} [list 10 {foo bar} "x x x x x x x\n\n\r\n"]
- test {MSET wrong number of args} {
- catch {r mset x{t} 10 y{t} "foo bar" z{t}} err
- format $err
- } {*wrong number*}
+ test {MSET/MSETNX wrong number of args} {
+ assert_error {*wrong number of arguments for 'mset' command} {r mset x{t} 10 y{t} "foo bar" z{t}}
+ assert_error {*wrong number of arguments for 'msetnx' command} {r msetnx x{t} 20 y{t} "foo bar" z{t}}
+ }
test {MSETNX with already existent key} {
list [r msetnx x1{t} xxx y2{t} yyy x{t} 20] [r exists x1{t}] [r exists y2{t}]
diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl
index f9d0c3a28..10945674e 100644
--- a/tests/unit/type/zset.tcl
+++ b/tests/unit/type/zset.tcl
@@ -1157,9 +1157,9 @@ start_server {tags {"zset"}} {
}
test "ZMPOP with illegal argument" {
- assert_error "ERR wrong number of arguments*" {r zmpop}
- assert_error "ERR wrong number of arguments*" {r zmpop 1}
- assert_error "ERR wrong number of arguments*" {r zmpop 1 myzset{t}}
+ assert_error "ERR wrong number of arguments for 'zmpop' command" {r zmpop}
+ assert_error "ERR wrong number of arguments for 'zmpop' command" {r zmpop 1}
+ assert_error "ERR wrong number of arguments for 'zmpop' command" {r zmpop 1 myzset{t}}
assert_error "ERR numkeys*" {r zmpop 0 myzset{t} MIN}
assert_error "ERR numkeys*" {r zmpop a myzset{t} MIN}
@@ -1475,6 +1475,16 @@ start_server {tags {"zset"}} {
assert_error "*not*float*" {r zadd myzset "" abc}
}
+ test "zunionInterDiffGenericCommand at least 1 input key" {
+ assert_error {*at least 1 input key * 'zunion' command} {r zunion 0 key{t}}
+ assert_error {*at least 1 input key * 'zunionstore' command} {r zunionstore dst_key{t} 0 key{t}}
+ assert_error {*at least 1 input key * 'zinter' command} {r zinter 0 key{t}}
+ assert_error {*at least 1 input key * 'zinterstore' command} {r zinterstore dst_key{t} 0 key{t}}
+ assert_error {*at least 1 input key * 'zdiff' command} {r zdiff 0 key{t}}
+ assert_error {*at least 1 input key * 'zdiffstore' command} {r zdiffstore dst_key{t} 0 key{t}}
+ assert_error {*at least 1 input key * 'zintercard' command} {r zintercard 0 key{t}}
+ }
+
proc stressers {encoding} {
set original_max_entries [lindex [r config get zset-max-ziplist-entries] 1]
set original_max_value [lindex [r config get zset-max-ziplist-value] 1]
@@ -1950,9 +1960,9 @@ start_server {tags {"zset"}} {
}
test "BZMPOP with illegal argument" {
- assert_error "ERR wrong number of arguments*" {r bzmpop}
- assert_error "ERR wrong number of arguments*" {r bzmpop 0 1}
- assert_error "ERR wrong number of arguments*" {r bzmpop 0 1 myzset{t}}
+ assert_error "ERR wrong number of arguments for 'bzmpop' command" {r bzmpop}
+ assert_error "ERR wrong number of arguments for 'bzmpop' command" {r bzmpop 0 1}
+ assert_error "ERR wrong number of arguments for 'bzmpop' command" {r bzmpop 0 1 myzset{t}}
assert_error "ERR numkeys*" {r bzmpop 1 0 myzset{t} MIN}
assert_error "ERR numkeys*" {r bzmpop 1 a myzset{t} MIN}