diff options
Diffstat (limited to 'examples/redis-unstable/tests/unit/moduleapi/scan.tcl')
| -rw-r--r-- | examples/redis-unstable/tests/unit/moduleapi/scan.tcl | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/examples/redis-unstable/tests/unit/moduleapi/scan.tcl b/examples/redis-unstable/tests/unit/moduleapi/scan.tcl deleted file mode 100644 index c880477..0000000 --- a/examples/redis-unstable/tests/unit/moduleapi/scan.tcl +++ /dev/null | |||
| @@ -1,103 +0,0 @@ | |||
| 1 | set testmodule [file normalize tests/modules/scan.so] | ||
| 2 | |||
| 3 | start_server {tags {"modules external:skip"}} { | ||
| 4 | r module load $testmodule | ||
| 5 | |||
| 6 | test {Module scan keyspace} { | ||
| 7 | # the module create a scan command with filtering which also return values | ||
| 8 | r set x 1 | ||
| 9 | r set y 2 | ||
| 10 | r set z 3 | ||
| 11 | r hset h f v | ||
| 12 | lsort [r scan.scan_strings] | ||
| 13 | } {{x 1} {y 2} {z 3}} | ||
| 14 | |||
| 15 | test {Module scan hash listpack} { | ||
| 16 | r hmset hh f1 v1 f2 v2 | ||
| 17 | assert_encoding listpack hh | ||
| 18 | lsort [r scan.scan_key hh] | ||
| 19 | } {{f1 v1} {f2 v2}} | ||
| 20 | |||
| 21 | test {Module scan hash listpack with int value} { | ||
| 22 | r hmset hh1 f1 1 | ||
| 23 | assert_encoding listpack hh1 | ||
| 24 | lsort [r scan.scan_key hh1] | ||
| 25 | } {{f1 1}} | ||
| 26 | |||
| 27 | test {Module scan hash listpack with hexpire} { | ||
| 28 | r debug set-active-expire 0 | ||
| 29 | r hmset hh f1 v1 f2 v2 f3 v3 | ||
| 30 | r hexpire hh 100000 fields 1 f1 | ||
| 31 | r hpexpire hh 1 fields 1 f3 | ||
| 32 | after 10 | ||
| 33 | assert_range [r httl hh fields 1 f1] 10000 100000 | ||
| 34 | assert_encoding listpackex hh | ||
| 35 | r debug set-active-expire 1 | ||
| 36 | lsort [r scan.scan_key hh] | ||
| 37 | } {{f1 v1} {f2 v2}} {needs:debug} | ||
| 38 | |||
| 39 | test {Module scan hash dict} { | ||
| 40 | r config set hash-max-ziplist-entries 2 | ||
| 41 | r hmset hh f3 v3 | ||
| 42 | assert_encoding hashtable hh | ||
| 43 | lsort [r scan.scan_key hh] | ||
| 44 | } {{f1 v1} {f2 v2} {f3 v3}} | ||
| 45 | |||
| 46 | test {Module scan hash dict with hexpire} { | ||
| 47 | r config set hash-max-listpack-entries 1 | ||
| 48 | r del hh | ||
| 49 | r hmset hh f1 v1 f2 v2 f3 v3 | ||
| 50 | r hexpire hh 100000 fields 1 f2 | ||
| 51 | r hpexpire hh 5 fields 1 f3 | ||
| 52 | assert_range [r httl hh fields 1 f2] 10000 100000 | ||
| 53 | assert_encoding hashtable hh | ||
| 54 | after 10 | ||
| 55 | lsort [r scan.scan_key hh] | ||
| 56 | } {{f1 v1} {f2 v2}} | ||
| 57 | |||
| 58 | test {Module scan hash with hexpire can return no items} { | ||
| 59 | r del hh | ||
| 60 | r debug set-active-expire 0 | ||
| 61 | r hmset hh f1 v1 f2 v2 f3 v3 | ||
| 62 | r hpexpire hh 1 fields 3 f1 f2 f3 | ||
| 63 | after 10 | ||
| 64 | assert_equal [r scan.scan_key hh] {} | ||
| 65 | r debug set-active-expire 1 | ||
| 66 | } {OK} {needs:debug} | ||
| 67 | |||
| 68 | test {Module scan zset listpack} { | ||
| 69 | r zadd zz 1 f1 2 f2 | ||
| 70 | assert_encoding listpack zz | ||
| 71 | lsort [r scan.scan_key zz] | ||
| 72 | } {{f1 1} {f2 2}} | ||
| 73 | |||
| 74 | test {Module scan zset skiplist} { | ||
| 75 | r config set zset-max-ziplist-entries 2 | ||
| 76 | r zadd zz 3 f3 | ||
| 77 | assert_encoding skiplist zz | ||
| 78 | lsort [r scan.scan_key zz] | ||
| 79 | } {{f1 1} {f2 2} {f3 3}} | ||
| 80 | |||
| 81 | test {Module scan set intset} { | ||
| 82 | r sadd ss 1 2 | ||
| 83 | assert_encoding intset ss | ||
| 84 | lsort [r scan.scan_key ss] | ||
| 85 | } {{1 {}} {2 {}}} | ||
| 86 | |||
| 87 | test {Module scan set dict} { | ||
| 88 | r config set set-max-intset-entries 2 | ||
| 89 | r sadd ss 3 | ||
| 90 | assert_encoding hashtable ss | ||
| 91 | lsort [r scan.scan_key ss] | ||
| 92 | } {{1 {}} {2 {}} {3 {}}} | ||
| 93 | |||
| 94 | test {Module scan set listpack} { | ||
| 95 | r sadd ss1 a b c | ||
| 96 | assert_encoding listpack ss1 | ||
| 97 | lsort [r scan.scan_key ss1] | ||
| 98 | } {{a {}} {b {}} {c {}}} | ||
| 99 | |||
| 100 | test "Unload the module - scan" { | ||
| 101 | assert_equal {OK} [r module unload scan] | ||
| 102 | } | ||
| 103 | } \ No newline at end of file | ||
