Unverified Commit 8a86bca5 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

Improve test suite to handle external servers better. (#9033)

This commit revives the improves the ability to run the test suite against
external servers, instead of launching and managing `redis-server` processes as
part of the test fixture.

This capability existed in the past, using the `--host` and `--port` options.
However, it was quite limited and mostly useful when running a specific tests.
Attempting to run larger chunks of the test suite experienced many issues:

* Many tests depend on being able to start and control `redis-server` themselves,
and there's no clear distinction between external server compatible and other
tests.
* Cluster mode is not supported (resulting with `CROSSSLOT` errors).

This PR cleans up many things and makes it possible to run the entire test suite
against an external server. It also provides more fine grained controls to
handle cases where the external server supports a subset of the Redis commands,
limited number of databases, cluster mode, etc.

The tests directory now contains a `README.md` file that describes how this
works.

This commit also includes additional cleanups and fixes:

* Tests can now be tagged.
* Tag-based selection is now unified across `start_server`, `tags` and `test`.
* More information is provided about skipped or ignored tests.
* Repeated patterns in tests have been extracted to common procedures, both at a
  global level and on a per-test file basis.
* Cleaned up some cases where test setup was based on a previous test executing
  (a major anti-pattern that repeats itself in many places).
* Cleaned up some cases where test teardown was not part of a test (in the
  future we should have dedicated teardown code that executes even when tests
  fail).
* Fixed some tests that were flaky running on external servers.
parent c396fd91
start_server {tags {"limits network"} overrides {maxclients 10}} { start_server {tags {"limits network external:skip"} overrides {maxclients 10}} {
if {$::tls} { if {$::tls} {
set expected_code "*I/O error*" set expected_code "*I/O error*"
} else { } else {
......
start_server {tags {"maxmemory"}} { start_server {tags {"maxmemory external:skip"}} {
test "Without maxmemory small integers are shared" { test "Without maxmemory small integers are shared" {
r config set maxmemory 0 r config set maxmemory 0
r set a 1 r set a 1
...@@ -144,7 +144,7 @@ start_server {tags {"maxmemory"}} { ...@@ -144,7 +144,7 @@ start_server {tags {"maxmemory"}} {
} }
proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} { proc test_slave_buffers {test_name cmd_count payload_len limit_memory pipeline} {
start_server {tags {"maxmemory"}} { start_server {tags {"maxmemory external:skip"}} {
start_server {} { start_server {} {
set slave_pid [s process_id] set slave_pid [s process_id]
test "$test_name" { test "$test_name" {
...@@ -241,7 +241,7 @@ test_slave_buffers {slave buffer are counted correctly} 1000000 10 0 1 ...@@ -241,7 +241,7 @@ test_slave_buffers {slave buffer are counted correctly} 1000000 10 0 1
# test again with fewer (and bigger) commands without pipeline, but with eviction # test again with fewer (and bigger) commands without pipeline, but with eviction
test_slave_buffers "replica buffer don't induce eviction" 100000 100 1 0 test_slave_buffers "replica buffer don't induce eviction" 100000 100 1 0
start_server {tags {"maxmemory"}} { start_server {tags {"maxmemory external:skip"}} {
test {Don't rehash if used memory exceeds maxmemory after rehash} { test {Don't rehash if used memory exceeds maxmemory after rehash} {
r config set maxmemory 0 r config set maxmemory 0
r config set maxmemory-policy allkeys-random r config set maxmemory-policy allkeys-random
...@@ -261,7 +261,7 @@ start_server {tags {"maxmemory"}} { ...@@ -261,7 +261,7 @@ start_server {tags {"maxmemory"}} {
} {4098} } {4098}
} }
start_server {tags {"maxmemory"}} { start_server {tags {"maxmemory external:skip"}} {
test {client tracking don't cause eviction feedback loop} { test {client tracking don't cause eviction feedback loop} {
r config set maxmemory 0 r config set maxmemory 0
r config set maxmemory-policy allkeys-lru r config set maxmemory-policy allkeys-lru
......
...@@ -21,7 +21,7 @@ proc test_memory_efficiency {range} { ...@@ -21,7 +21,7 @@ proc test_memory_efficiency {range} {
return $efficiency return $efficiency
} }
start_server {tags {"memefficiency"}} { start_server {tags {"memefficiency external:skip"}} {
foreach {size_range expected_min_efficiency} { foreach {size_range expected_min_efficiency} {
32 0.15 32 0.15
64 0.25 64 0.25
...@@ -37,7 +37,7 @@ start_server {tags {"memefficiency"}} { ...@@ -37,7 +37,7 @@ start_server {tags {"memefficiency"}} {
} }
run_solo {defrag} { run_solo {defrag} {
start_server {tags {"defrag"} overrides {appendonly yes auto-aof-rewrite-percentage 0 save ""}} { start_server {tags {"defrag external:skip"} overrides {appendonly yes auto-aof-rewrite-percentage 0 save ""}} {
if {[string match {*jemalloc*} [s mem_allocator]] && [r debug mallctl arenas.page] <= 8192} { if {[string match {*jemalloc*} [s mem_allocator]] && [r debug mallctl arenas.page] <= 8192} {
test "Active defrag" { test "Active defrag" {
r config set hz 100 r config set hz 100
......
proc wait_for_dbsize {size} {
set r2 [redis_client]
wait_for_condition 50 100 {
[$r2 dbsize] == $size
} else {
fail "Target dbsize not reached"
}
$r2 close
}
start_server {tags {"multi"}} { start_server {tags {"multi"}} {
test {MUTLI / EXEC basics} { test {MUTLI / EXEC basics} {
r del mylist r del mylist
...@@ -47,47 +57,47 @@ start_server {tags {"multi"}} { ...@@ -47,47 +57,47 @@ start_server {tags {"multi"}} {
} {*ERR WATCH*} } {*ERR WATCH*}
test {EXEC fails if there are errors while queueing commands #1} { test {EXEC fails if there are errors while queueing commands #1} {
r del foo1 foo2 r del foo1{t} foo2{t}
r multi r multi
r set foo1 bar1 r set foo1{t} bar1
catch {r non-existing-command} catch {r non-existing-command}
r set foo2 bar2 r set foo2{t} bar2
catch {r exec} e catch {r exec} e
assert_match {EXECABORT*} $e assert_match {EXECABORT*} $e
list [r exists foo1] [r exists foo2] list [r exists foo1{t}] [r exists foo2{t}]
} {0 0} } {0 0}
test {EXEC fails if there are errors while queueing commands #2} { test {EXEC fails if there are errors while queueing commands #2} {
set rd [redis_deferring_client] set rd [redis_deferring_client]
r del foo1 foo2 r del foo1{t} foo2{t}
r multi r multi
r set foo1 bar1 r set foo1{t} bar1
$rd config set maxmemory 1 $rd config set maxmemory 1
assert {[$rd read] eq {OK}} assert {[$rd read] eq {OK}}
catch {r lpush mylist myvalue} catch {r lpush mylist{t} myvalue}
$rd config set maxmemory 0 $rd config set maxmemory 0
assert {[$rd read] eq {OK}} assert {[$rd read] eq {OK}}
r set foo2 bar2 r set foo2{t} bar2
catch {r exec} e catch {r exec} e
assert_match {EXECABORT*} $e assert_match {EXECABORT*} $e
$rd close $rd close
list [r exists foo1] [r exists foo2] list [r exists foo1{t}] [r exists foo2{t}]
} {0 0} } {0 0} {needs:config-maxmemory}
test {If EXEC aborts, the client MULTI state is cleared} { test {If EXEC aborts, the client MULTI state is cleared} {
r del foo1 foo2 r del foo1{t} foo2{t}
r multi r multi
r set foo1 bar1 r set foo1{t} bar1
catch {r non-existing-command} catch {r non-existing-command}
r set foo2 bar2 r set foo2{t} bar2
catch {r exec} e catch {r exec} e
assert_match {EXECABORT*} $e assert_match {EXECABORT*} $e
r ping r ping
} {PONG} } {PONG}
test {EXEC works on WATCHed key not modified} { test {EXEC works on WATCHed key not modified} {
r watch x y z r watch x{t} y{t} z{t}
r watch k r watch k{t}
r multi r multi
r ping r ping
r exec r exec
...@@ -103,9 +113,9 @@ start_server {tags {"multi"}} { ...@@ -103,9 +113,9 @@ start_server {tags {"multi"}} {
} {} } {}
test {EXEC fail on WATCHed key modified (1 key of 5 watched)} { test {EXEC fail on WATCHed key modified (1 key of 5 watched)} {
r set x 30 r set x{t} 30
r watch a b x k z r watch a{t} b{t} x{t} k{t} z{t}
r set x 40 r set x{t} 40
r multi r multi
r ping r ping
r exec r exec
...@@ -119,7 +129,7 @@ start_server {tags {"multi"}} { ...@@ -119,7 +129,7 @@ start_server {tags {"multi"}} {
r multi r multi
r ping r ping
r exec r exec
} {} } {} {cluster:skip}
test {After successful EXEC key is no longer watched} { test {After successful EXEC key is no longer watched} {
r set x 30 r set x 30
...@@ -205,7 +215,7 @@ start_server {tags {"multi"}} { ...@@ -205,7 +215,7 @@ start_server {tags {"multi"}} {
r multi r multi
r ping r ping
r exec r exec
} {} } {} {singledb:skip}
test {SWAPDB is able to touch the watched keys that do not exist} { test {SWAPDB is able to touch the watched keys that do not exist} {
r flushall r flushall
...@@ -217,7 +227,7 @@ start_server {tags {"multi"}} { ...@@ -217,7 +227,7 @@ start_server {tags {"multi"}} {
r multi r multi
r ping r ping
r exec r exec
} {} } {} {singledb:skip}
test {WATCH is able to remember the DB a key belongs to} { test {WATCH is able to remember the DB a key belongs to} {
r select 5 r select 5
...@@ -232,7 +242,7 @@ start_server {tags {"multi"}} { ...@@ -232,7 +242,7 @@ start_server {tags {"multi"}} {
# Restore original DB # Restore original DB
r select 9 r select 9
set res set res
} {PONG} } {PONG} {singledb:skip}
test {WATCH will consider touched keys target of EXPIRE} { test {WATCH will consider touched keys target of EXPIRE} {
r del x r del x
...@@ -245,11 +255,15 @@ start_server {tags {"multi"}} { ...@@ -245,11 +255,15 @@ start_server {tags {"multi"}} {
} {} } {}
test {WATCH will consider touched expired keys} { test {WATCH will consider touched expired keys} {
r flushall
r del x r del x
r set x foo r set x foo
r expire x 1 r expire x 1
r watch x r watch x
after 1100
# Wait for the keys to expire.
wait_for_dbsize 0
r multi r multi
r ping r ping
r exec r exec
...@@ -288,7 +302,7 @@ start_server {tags {"multi"}} { ...@@ -288,7 +302,7 @@ start_server {tags {"multi"}} {
{exec} {exec}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
test {MULTI / EXEC is propagated correctly (empty transaction)} { test {MULTI / EXEC is propagated correctly (empty transaction)} {
set repl [attach_to_replication_stream] set repl [attach_to_replication_stream]
...@@ -300,7 +314,7 @@ start_server {tags {"multi"}} { ...@@ -300,7 +314,7 @@ start_server {tags {"multi"}} {
{set foo bar} {set foo bar}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
test {MULTI / EXEC is propagated correctly (read-only commands)} { test {MULTI / EXEC is propagated correctly (read-only commands)} {
r set foo value1 r set foo value1
...@@ -314,10 +328,11 @@ start_server {tags {"multi"}} { ...@@ -314,10 +328,11 @@ start_server {tags {"multi"}} {
{set foo value2} {set foo value2}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
test {MULTI / EXEC is propagated correctly (write command, no effect)} { test {MULTI / EXEC is propagated correctly (write command, no effect)} {
r del bar foo bar r del bar
r del foo
set repl [attach_to_replication_stream] set repl [attach_to_replication_stream]
r multi r multi
r del foo r del foo
...@@ -332,7 +347,7 @@ start_server {tags {"multi"}} { ...@@ -332,7 +347,7 @@ start_server {tags {"multi"}} {
{incr foo} {incr foo}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
test {DISCARD should not fail during OOM} { test {DISCARD should not fail during OOM} {
set rd [redis_deferring_client] set rd [redis_deferring_client]
...@@ -346,7 +361,7 @@ start_server {tags {"multi"}} { ...@@ -346,7 +361,7 @@ start_server {tags {"multi"}} {
assert {[$rd read] eq {OK}} assert {[$rd read] eq {OK}}
$rd close $rd close
r ping r ping
} {PONG} } {PONG} {needs:config-maxmemory}
test {MULTI and script timeout} { test {MULTI and script timeout} {
# check that if MULTI arrives during timeout, it is either refused, or # check that if MULTI arrives during timeout, it is either refused, or
...@@ -460,8 +475,8 @@ start_server {tags {"multi"}} { ...@@ -460,8 +475,8 @@ start_server {tags {"multi"}} {
# make sure that the INCR wasn't executed # make sure that the INCR wasn't executed
assert { $xx == 1} assert { $xx == 1}
$r1 config set min-replicas-to-write 0 $r1 config set min-replicas-to-write 0
$r1 close; $r1 close
} } {0} {needs:repl}
test {exec with read commands and stale replica state change} { test {exec with read commands and stale replica state change} {
# check that exec that contains read commands fails if server state changed since they were queued # check that exec that contains read commands fails if server state changed since they were queued
...@@ -491,8 +506,8 @@ start_server {tags {"multi"}} { ...@@ -491,8 +506,8 @@ start_server {tags {"multi"}} {
set xx [r exec] set xx [r exec]
# make sure that the INCR was executed # make sure that the INCR was executed
assert { $xx == 1 } assert { $xx == 1 }
$r1 close; $r1 close
} } {0} {needs:repl cluster:skip}
test {EXEC with only read commands should not be rejected when OOM} { test {EXEC with only read commands should not be rejected when OOM} {
set r2 [redis_client] set r2 [redis_client]
...@@ -511,7 +526,7 @@ start_server {tags {"multi"}} { ...@@ -511,7 +526,7 @@ start_server {tags {"multi"}} {
# releasing OOM # releasing OOM
$r2 config set maxmemory 0 $r2 config set maxmemory 0
$r2 close $r2 close
} } {0} {needs:config-maxmemory}
test {EXEC with at least one use-memory command should fail} { test {EXEC with at least one use-memory command should fail} {
set r2 [redis_client] set r2 [redis_client]
...@@ -530,20 +545,20 @@ start_server {tags {"multi"}} { ...@@ -530,20 +545,20 @@ start_server {tags {"multi"}} {
# releasing OOM # releasing OOM
$r2 config set maxmemory 0 $r2 config set maxmemory 0
$r2 close $r2 close
} } {0} {needs:config-maxmemory}
test {Blocking commands ignores the timeout} { test {Blocking commands ignores the timeout} {
r xgroup create s g $ MKSTREAM r xgroup create s{t} g $ MKSTREAM
set m [r multi] set m [r multi]
r blpop empty_list 0 r blpop empty_list{t} 0
r brpop empty_list 0 r brpop empty_list{t} 0
r brpoplpush empty_list1 empty_list2 0 r brpoplpush empty_list1{t} empty_list2{t} 0
r blmove empty_list1 empty_list2 LEFT LEFT 0 r blmove empty_list1{t} empty_list2{t} LEFT LEFT 0
r bzpopmin empty_zset 0 r bzpopmin empty_zset{t} 0
r bzpopmax empty_zset 0 r bzpopmax empty_zset{t} 0
r xread BLOCK 0 STREAMS s $ r xread BLOCK 0 STREAMS s{t} $
r xreadgroup group g c BLOCK 0 STREAMS s > r xreadgroup group g c BLOCK 0 STREAMS s{t} >
set res [r exec] set res [r exec]
list $m $res list $m $res
...@@ -564,7 +579,7 @@ start_server {tags {"multi"}} { ...@@ -564,7 +579,7 @@ start_server {tags {"multi"}} {
{exec} {exec}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl cluster:skip}
test {MULTI propagation of SCRIPT LOAD} { test {MULTI propagation of SCRIPT LOAD} {
set repl [attach_to_replication_stream] set repl [attach_to_replication_stream]
...@@ -582,7 +597,7 @@ start_server {tags {"multi"}} { ...@@ -582,7 +597,7 @@ start_server {tags {"multi"}} {
{exec} {exec}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
test {MULTI propagation of SCRIPT LOAD} { test {MULTI propagation of SCRIPT LOAD} {
set repl [attach_to_replication_stream] set repl [attach_to_replication_stream]
...@@ -600,7 +615,7 @@ start_server {tags {"multi"}} { ...@@ -600,7 +615,7 @@ start_server {tags {"multi"}} {
{exec} {exec}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
tags {"stream"} { tags {"stream"} {
test {MULTI propagation of XREADGROUP} { test {MULTI propagation of XREADGROUP} {
...@@ -624,7 +639,7 @@ start_server {tags {"multi"}} { ...@@ -624,7 +639,7 @@ start_server {tags {"multi"}} {
{exec} {exec}
} }
close_replication_stream $repl close_replication_stream $repl
} } {} {needs:repl}
} }
} }
...@@ -20,7 +20,7 @@ test {CONFIG SET port number} { ...@@ -20,7 +20,7 @@ test {CONFIG SET port number} {
$rd PING $rd PING
$rd close $rd close
} }
} } {} {external:skip}
test {CONFIG SET bind address} { test {CONFIG SET bind address} {
start_server {} { start_server {} {
...@@ -33,4 +33,4 @@ test {CONFIG SET bind address} { ...@@ -33,4 +33,4 @@ test {CONFIG SET bind address} {
$rd PING $rd PING
$rd close $rd close
} }
} } {} {external:skip}
start_server {tags {"obuf-limits"}} { start_server {tags {"obuf-limits external:skip"}} {
test {Client output buffer hard limit is enforced} { test {Client output buffer hard limit is enforced} {
r config set client-output-buffer-limit {pubsub 100000 0 0} r config set client-output-buffer-limit {pubsub 100000 0 0}
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
......
...@@ -2,7 +2,7 @@ set system_name [string tolower [exec uname -s]] ...@@ -2,7 +2,7 @@ set system_name [string tolower [exec uname -s]]
set user_id [exec id -u] set user_id [exec id -u]
if {$system_name eq {linux}} { if {$system_name eq {linux}} {
start_server {tags {"oom-score-adj"}} { start_server {tags {"oom-score-adj external:skip"}} {
proc get_oom_score_adj {{pid ""}} { proc get_oom_score_adj {{pid ""}} {
if {$pid == ""} { if {$pid == ""} {
set pid [srv 0 pid] set pid [srv 0 pid]
......
start_server {overrides {save ""} tags {"other"}} { start_server {tags {"other"}} {
if {$::force_failure} { if {$::force_failure} {
# This is used just for test suite development purposes. # This is used just for test suite development purposes.
test {Failing test} { test {Failing test} {
...@@ -17,7 +17,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -17,7 +17,7 @@ start_server {overrides {save ""} tags {"other"}} {
r zadd mytestzset 20 b r zadd mytestzset 20 b
r zadd mytestzset 30 c r zadd mytestzset 30 c
r save r save
} {OK} } {OK} {needs:save}
tags {slow} { tags {slow} {
if {$::accurate} {set iterations 10000} else {set iterations 1000} if {$::accurate} {set iterations 10000} else {set iterations 1000}
...@@ -47,65 +47,65 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -47,65 +47,65 @@ start_server {overrides {save ""} tags {"other"}} {
waitForBgsave r waitForBgsave r
r debug reload r debug reload
r get x r get x
} {10} } {10} {needs:save}
test {SELECT an out of range DB} { test {SELECT an out of range DB} {
catch {r select 1000000} err catch {r select 1000000} err
set _ $err set _ $err
} {*index is out of range*} } {*index is out of range*} {cluster:skip}
tags {consistency} { tags {consistency} {
if {true} { proc check_consistency {dumpname code} {
if {$::accurate} {set numops 10000} else {set numops 1000}
test {Check consistency of different data types after a reload} {
r flushdb
createComplexDataset r $numops
set dump [csvdump r] set dump [csvdump r]
set sha1 [r debug digest] set sha1 [r debug digest]
r debug reload
uplevel 1 $code
set sha1_after [r debug digest] set sha1_after [r debug digest]
if {$sha1 eq $sha1_after} { if {$sha1 eq $sha1_after} {
set _ 1 return 1
} else { }
# Failed
set newdump [csvdump r] set newdump [csvdump r]
puts "Consistency test failed!" puts "Consistency test failed!"
puts "You can inspect the two dumps in /tmp/repldump*.txt" puts "You can inspect the two dumps in /tmp/${dumpname}*.txt"
set fd [open /tmp/repldump1.txt w] set fd [open /tmp/${dumpname}1.txt w]
puts $fd $dump puts $fd $dump
close $fd close $fd
set fd [open /tmp/repldump2.txt w] set fd [open /tmp/${dumpname}2.txt w]
puts $fd $newdump puts $fd $newdump
close $fd close $fd
set _ 0 return 0
}
if {$::accurate} {set numops 10000} else {set numops 1000}
test {Check consistency of different data types after a reload} {
r flushdb
createComplexDataset r $numops usetag
if {$::ignoredigest} {
set _ 1
} else {
check_consistency {repldump} {
r debug reload
}
} }
} {1} } {1}
test {Same dataset digest if saving/reloading as AOF?} { test {Same dataset digest if saving/reloading as AOF?} {
if {$::ignoredigest} {
set _ 1
} else {
check_consistency {aofdump} {
r config set aof-use-rdb-preamble no r config set aof-use-rdb-preamble no
r bgrewriteaof r bgrewriteaof
waitForBgrewriteaof r waitForBgrewriteaof r
r debug loadaof r debug loadaof
set sha1_after [r debug digest]
if {$sha1 eq $sha1_after} {
set _ 1
} else {
set newdump [csvdump r]
puts "Consistency test failed!"
puts "You can inspect the two dumps in /tmp/aofdump*.txt"
set fd [open /tmp/aofdump1.txt w]
puts $fd $dump
close $fd
set fd [open /tmp/aofdump2.txt w]
puts $fd $newdump
close $fd
set _ 0
} }
} {1}
} }
} {1} {needs:debug}
} }
test {EXPIRES after a reload (snapshot + append only file rewrite)} { test {EXPIRES after a reload (snapshot + append only file rewrite)} {
...@@ -122,7 +122,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -122,7 +122,7 @@ start_server {overrides {save ""} tags {"other"}} {
set ttl [r ttl x] set ttl [r ttl x]
set e2 [expr {$ttl > 900 && $ttl <= 1000}] set e2 [expr {$ttl > 900 && $ttl <= 1000}]
list $e1 $e2 list $e1 $e2
} {1 1} } {1 1} {needs:debug needs:save}
test {EXPIRES after AOF reload (without rewrite)} { test {EXPIRES after AOF reload (without rewrite)} {
r flushdb r flushdb
...@@ -162,7 +162,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -162,7 +162,7 @@ start_server {overrides {save ""} tags {"other"}} {
set ttl [r ttl pz] set ttl [r ttl pz]
assert {$ttl > 2900 && $ttl <= 3000} assert {$ttl > 2900 && $ttl <= 3000}
r config set appendonly no r config set appendonly no
} } {OK} {needs:debug}
tags {protocol} { tags {protocol} {
test {PIPELINING stresser (also a regression for the old epoll bug)} { test {PIPELINING stresser (also a regression for the old epoll bug)} {
...@@ -237,18 +237,23 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -237,18 +237,23 @@ start_server {overrides {save ""} tags {"other"}} {
# Leave the user with a clean DB before to exit # Leave the user with a clean DB before to exit
test {FLUSHDB} { test {FLUSHDB} {
set aux {} set aux {}
if {$::singledb} {
r flushdb
lappend aux 0 [r dbsize]
} else {
r select 9 r select 9
r flushdb r flushdb
lappend aux [r dbsize] lappend aux [r dbsize]
r select 10 r select 10
r flushdb r flushdb
lappend aux [r dbsize] lappend aux [r dbsize]
}
} {0 0} } {0 0}
test {Perform a final SAVE to leave a clean DB on disk} { test {Perform a final SAVE to leave a clean DB on disk} {
waitForBgsave r waitForBgsave r
r save r save
} {OK} } {OK} {needs:save}
test {RESET clears client state} { test {RESET clears client state} {
r client setname test-client r client setname test-client
...@@ -258,7 +263,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -258,7 +263,7 @@ start_server {overrides {save ""} tags {"other"}} {
set client [r client list] set client [r client list]
assert_match {*name= *} $client assert_match {*name= *} $client
assert_match {*flags=N *} $client assert_match {*flags=N *} $client
} } {} {needs:reset}
test {RESET clears MONITOR state} { test {RESET clears MONITOR state} {
set rd [redis_deferring_client] set rd [redis_deferring_client]
...@@ -269,7 +274,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -269,7 +274,7 @@ start_server {overrides {save ""} tags {"other"}} {
assert_equal [$rd read] "RESET" assert_equal [$rd read] "RESET"
assert_no_match {*flags=O*} [r client list] assert_no_match {*flags=O*} [r client list]
} } {} {needs:reset}
test {RESET clears and discards MULTI state} { test {RESET clears and discards MULTI state} {
r multi r multi
...@@ -278,7 +283,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -278,7 +283,7 @@ start_server {overrides {save ""} tags {"other"}} {
r reset r reset
catch {r exec} err catch {r exec} err
assert_match {*EXEC without MULTI*} $err assert_match {*EXEC without MULTI*} $err
} } {} {needs:reset}
test {RESET clears Pub/Sub state} { test {RESET clears Pub/Sub state} {
r subscribe channel-1 r subscribe channel-1
...@@ -286,7 +291,7 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -286,7 +291,7 @@ start_server {overrides {save ""} tags {"other"}} {
# confirm we're not subscribed by executing another command # confirm we're not subscribed by executing another command
r set key val r set key val
} } {OK} {needs:reset}
test {RESET clears authenticated state} { test {RESET clears authenticated state} {
r acl setuser user1 on >secret +@all r acl setuser user1 on >secret +@all
...@@ -296,10 +301,10 @@ start_server {overrides {save ""} tags {"other"}} { ...@@ -296,10 +301,10 @@ start_server {overrides {save ""} tags {"other"}} {
r reset r reset
assert_equal [r acl whoami] default assert_equal [r acl whoami] default
} } {} {needs:reset}
} }
start_server {tags {"other"}} { start_server {tags {"other external:skip"}} {
test {Don't rehash if redis has child proecess} { test {Don't rehash if redis has child proecess} {
r config set save "" r config set save ""
r config set rdb-key-save-delay 1000000 r config set rdb-key-save-delay 1000000
...@@ -322,7 +327,7 @@ start_server {tags {"other"}} { ...@@ -322,7 +327,7 @@ start_server {tags {"other"}} {
# size is power of two and over 4098, so it is 8192 # size is power of two and over 4098, so it is 8192
r set k3 v3 r set k3 v3
assert_match "*table size: 8192*" [r debug HTSTATS 9] assert_match "*table size: 8192*" [r debug HTSTATS 9]
} } {} {needs:local-process}
} }
proc read_proc_title {pid} { proc read_proc_title {pid} {
...@@ -333,7 +338,7 @@ proc read_proc_title {pid} { ...@@ -333,7 +338,7 @@ proc read_proc_title {pid} {
return $cmdline return $cmdline
} }
start_server {tags {"other"}} { start_server {tags {"other external:skip"}} {
test {Process title set as expected} { test {Process title set as expected} {
# Test only on Linux where it's easy to get cmdline without relying on tools. # Test only on Linux where it's easy to get cmdline without relying on tools.
# Skip valgrind as it messes up the arguments. # Skip valgrind as it messes up the arguments.
......
...@@ -12,7 +12,7 @@ proc prepare_value {size} { ...@@ -12,7 +12,7 @@ proc prepare_value {size} {
return $_v return $_v
} }
start_server {tags {"wait"}} { start_server {tags {"wait external:skip"}} {
start_server {} { start_server {} {
set slave [srv 0 client] set slave [srv 0 client]
set slave_host [srv 0 host] set slave_host [srv 0 host]
......
start_server {tags {"pubsub network"}} { start_server {tags {"pubsub network"}} {
if {$::singledb} {
set db 0
} else {
set db 9
}
test "Pub/Sub PING" { test "Pub/Sub PING" {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
subscribe $rd1 somechannel subscribe $rd1 somechannel
...@@ -182,7 +188,7 @@ start_server {tags {"pubsub network"}} { ...@@ -182,7 +188,7 @@ start_server {tags {"pubsub network"}} {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r set foo bar r set foo bar
assert_equal {pmessage * __keyspace@9__:foo set} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:foo set" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -191,7 +197,7 @@ start_server {tags {"pubsub network"}} { ...@@ -191,7 +197,7 @@ start_server {tags {"pubsub network"}} {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r set foo bar r set foo bar
assert_equal {pmessage * __keyevent@9__:set foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:set foo" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -200,8 +206,8 @@ start_server {tags {"pubsub network"}} { ...@@ -200,8 +206,8 @@ start_server {tags {"pubsub network"}} {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r set foo bar r set foo bar
assert_equal {pmessage * __keyspace@9__:foo set} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:foo set" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:set foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:set foo" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -213,8 +219,8 @@ start_server {tags {"pubsub network"}} { ...@@ -213,8 +219,8 @@ start_server {tags {"pubsub network"}} {
r set foo bar r set foo bar
r lpush mylist a r lpush mylist a
# No notification for set, because only list commands are enabled. # No notification for set, because only list commands are enabled.
assert_equal {pmessage * __keyspace@9__:mylist lpush} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:mylist lpush" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:lpush mylist} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:lpush mylist" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -225,10 +231,10 @@ start_server {tags {"pubsub network"}} { ...@@ -225,10 +231,10 @@ start_server {tags {"pubsub network"}} {
r set foo bar r set foo bar
r expire foo 1 r expire foo 1
r del foo r del foo
assert_equal {pmessage * __keyspace@9__:foo expire} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:foo expire" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:expire foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:expire foo" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:foo del} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:foo del" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:del foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:del foo" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -240,12 +246,12 @@ start_server {tags {"pubsub network"}} { ...@@ -240,12 +246,12 @@ start_server {tags {"pubsub network"}} {
r lpush mylist a r lpush mylist a
r rpush mylist a r rpush mylist a
r rpop mylist r rpop mylist
assert_equal {pmessage * __keyspace@9__:mylist lpush} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:mylist lpush" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:lpush mylist} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:lpush mylist" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:mylist rpush} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:mylist rpush" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:rpush mylist} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:rpush mylist" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:mylist rpop} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:mylist rpop" [$rd1 read]
assert_equal {pmessage * __keyevent@9__:rpop mylist} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:rpop mylist" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -258,9 +264,9 @@ start_server {tags {"pubsub network"}} { ...@@ -258,9 +264,9 @@ start_server {tags {"pubsub network"}} {
r srem myset x r srem myset x
r sadd myset x y z r sadd myset x y z
r srem myset x r srem myset x
assert_equal {pmessage * __keyspace@9__:myset sadd} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myset sadd" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:myset sadd} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myset sadd" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:myset srem} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myset srem" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -273,9 +279,9 @@ start_server {tags {"pubsub network"}} { ...@@ -273,9 +279,9 @@ start_server {tags {"pubsub network"}} {
r zrem myzset x r zrem myzset x
r zadd myzset 3 x 4 y 5 z r zadd myzset 3 x 4 y 5 z
r zrem myzset x r zrem myzset x
assert_equal {pmessage * __keyspace@9__:myzset zadd} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myzset zadd" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:myzset zadd} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myzset zadd" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:myzset zrem} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myzset zrem" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -286,8 +292,8 @@ start_server {tags {"pubsub network"}} { ...@@ -286,8 +292,8 @@ start_server {tags {"pubsub network"}} {
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r hmset myhash yes 1 no 0 r hmset myhash yes 1 no 0
r hincrby myhash yes 10 r hincrby myhash yes 10
assert_equal {pmessage * __keyspace@9__:myhash hset} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myhash hset" [$rd1 read]
assert_equal {pmessage * __keyspace@9__:myhash hincrby} [$rd1 read] assert_equal "pmessage * __keyspace@${db}__:myhash hincrby" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -302,7 +308,7 @@ start_server {tags {"pubsub network"}} { ...@@ -302,7 +308,7 @@ start_server {tags {"pubsub network"}} {
} else { } else {
fail "Key does not expire?!" fail "Key does not expire?!"
} }
assert_equal {pmessage * __keyevent@9__:expired foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:expired foo" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -312,7 +318,7 @@ start_server {tags {"pubsub network"}} { ...@@ -312,7 +318,7 @@ start_server {tags {"pubsub network"}} {
set rd1 [redis_deferring_client] set rd1 [redis_deferring_client]
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r psetex foo 100 1 r psetex foo 100 1
assert_equal {pmessage * __keyevent@9__:expired foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:expired foo" [$rd1 read]
$rd1 close $rd1 close
} }
...@@ -324,10 +330,11 @@ start_server {tags {"pubsub network"}} { ...@@ -324,10 +330,11 @@ start_server {tags {"pubsub network"}} {
assert_equal {1} [psubscribe $rd1 *] assert_equal {1} [psubscribe $rd1 *]
r set foo bar r set foo bar
r config set maxmemory 1 r config set maxmemory 1
assert_equal {pmessage * __keyevent@9__:evicted foo} [$rd1 read] assert_equal "pmessage * __keyevent@${db}__:evicted foo" [$rd1 read]
r config set maxmemory 0 r config set maxmemory 0
$rd1 close $rd1 close
} r config set maxmemory-policy noeviction
} {OK} {needs:config-maxmemory}
test "Keyspace notifications: test CONFIG GET/SET of event flags" { test "Keyspace notifications: test CONFIG GET/SET of event flags" {
r config set notify-keyspace-events gKE r config set notify-keyspace-events gKE
......
start_server {tags {"scan network"}} { start_server {tags {"scan network"}} {
test "SCAN basic" { test "SCAN basic" {
r flushdb r flushdb
r debug populate 1000 populate 1000
set cur 0 set cur 0
set keys {} set keys {}
...@@ -19,7 +19,7 @@ start_server {tags {"scan network"}} { ...@@ -19,7 +19,7 @@ start_server {tags {"scan network"}} {
test "SCAN COUNT" { test "SCAN COUNT" {
r flushdb r flushdb
r debug populate 1000 populate 1000
set cur 0 set cur 0
set keys {} set keys {}
...@@ -37,7 +37,7 @@ start_server {tags {"scan network"}} { ...@@ -37,7 +37,7 @@ start_server {tags {"scan network"}} {
test "SCAN MATCH" { test "SCAN MATCH" {
r flushdb r flushdb
r debug populate 1000 populate 1000
set cur 0 set cur 0
set keys {} set keys {}
...@@ -56,7 +56,7 @@ start_server {tags {"scan network"}} { ...@@ -56,7 +56,7 @@ start_server {tags {"scan network"}} {
test "SCAN TYPE" { test "SCAN TYPE" {
r flushdb r flushdb
# populate only creates strings # populate only creates strings
r debug populate 1000 populate 1000
# Check non-strings are excluded # Check non-strings are excluded
set cur 0 set cur 0
...@@ -114,7 +114,7 @@ start_server {tags {"scan network"}} { ...@@ -114,7 +114,7 @@ start_server {tags {"scan network"}} {
r sadd set {*}$elements r sadd set {*}$elements
# Verify that the encoding matches. # Verify that the encoding matches.
assert {[r object encoding set] eq $enc} assert_encoding $enc set
# Test SSCAN # Test SSCAN
set cur 0 set cur 0
...@@ -148,7 +148,7 @@ start_server {tags {"scan network"}} { ...@@ -148,7 +148,7 @@ start_server {tags {"scan network"}} {
r hmset hash {*}$elements r hmset hash {*}$elements
# Verify that the encoding matches. # Verify that the encoding matches.
assert {[r object encoding hash] eq $enc} assert_encoding $enc hash
# Test HSCAN # Test HSCAN
set cur 0 set cur 0
...@@ -188,7 +188,7 @@ start_server {tags {"scan network"}} { ...@@ -188,7 +188,7 @@ start_server {tags {"scan network"}} {
r zadd zset {*}$elements r zadd zset {*}$elements
# Verify that the encoding matches. # Verify that the encoding matches.
assert {[r object encoding zset] eq $enc} assert_encoding $enc zset
# Test ZSCAN # Test ZSCAN
set cur 0 set cur 0
...@@ -214,7 +214,7 @@ start_server {tags {"scan network"}} { ...@@ -214,7 +214,7 @@ start_server {tags {"scan network"}} {
test "SCAN guarantees check under write load" { test "SCAN guarantees check under write load" {
r flushdb r flushdb
r debug populate 100 populate 100
# We start scanning here, so keys from 0 to 99 should all be # We start scanning here, so keys from 0 to 99 should all be
# reported at the end of the iteration. # reported at the end of the iteration.
......
...@@ -35,8 +35,8 @@ start_server {tags {"scripting"}} { ...@@ -35,8 +35,8 @@ start_server {tags {"scripting"}} {
} {1 2 3 ciao {1 2}} } {1 2 3 ciao {1 2}}
test {EVAL - Are the KEYS and ARGV arrays populated correctly?} { test {EVAL - Are the KEYS and ARGV arrays populated correctly?} {
r eval {return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}} 2 a b c d r eval {return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}} 2 a{t} b{t} c{t} d{t}
} {a b c d} } {a{t} b{t} c{t} d{t}}
test {EVAL - is Lua able to call Redis API?} { test {EVAL - is Lua able to call Redis API?} {
r set mykey myval r set mykey myval
...@@ -116,7 +116,7 @@ start_server {tags {"scripting"}} { ...@@ -116,7 +116,7 @@ start_server {tags {"scripting"}} {
r select 10 r select 10
r set mykey "this is DB 10" r set mykey "this is DB 10"
r eval {return redis.pcall('get',KEYS[1])} 1 mykey r eval {return redis.pcall('get',KEYS[1])} 1 mykey
} {this is DB 10} } {this is DB 10} {singledb:skip}
test {EVAL - SELECT inside Lua should not affect the caller} { test {EVAL - SELECT inside Lua should not affect the caller} {
# here we DB 10 is selected # here we DB 10 is selected
...@@ -125,7 +125,7 @@ start_server {tags {"scripting"}} { ...@@ -125,7 +125,7 @@ start_server {tags {"scripting"}} {
set res [r get mykey] set res [r get mykey]
r select 9 r select 9
set res set res
} {original value} } {original value} {singledb:skip}
if 0 { if 0 {
test {EVAL - Script can't run more than configured time limit} { test {EVAL - Script can't run more than configured time limit} {
...@@ -195,7 +195,7 @@ start_server {tags {"scripting"}} { ...@@ -195,7 +195,7 @@ start_server {tags {"scripting"}} {
} e } e
r debug lua-always-replicate-commands 1 r debug lua-always-replicate-commands 1
set e set e
} {*not allowed after*} } {*not allowed after*} {needs:debug}
test {EVAL - No arguments to redis.call/pcall is considered an error} { test {EVAL - No arguments to redis.call/pcall is considered an error} {
set e {} set e {}
...@@ -368,25 +368,25 @@ start_server {tags {"scripting"}} { ...@@ -368,25 +368,25 @@ start_server {tags {"scripting"}} {
set res [r eval {return redis.call('smembers',KEYS[1])} 1 myset] set res [r eval {return redis.call('smembers',KEYS[1])} 1 myset]
r debug lua-always-replicate-commands 1 r debug lua-always-replicate-commands 1
set res set res
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} } {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} {needs:debug}
test "SORT is normally not alpha re-ordered for the scripting engine" { test "SORT is normally not alpha re-ordered for the scripting engine" {
r del myset r del myset
r sadd myset 1 2 3 4 10 r sadd myset 1 2 3 4 10
r eval {return redis.call('sort',KEYS[1],'desc')} 1 myset r eval {return redis.call('sort',KEYS[1],'desc')} 1 myset
} {10 4 3 2 1} } {10 4 3 2 1} {cluster:skip}
test "SORT BY <constant> output gets ordered for scripting" { test "SORT BY <constant> output gets ordered for scripting" {
r del myset r del myset
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
r eval {return redis.call('sort',KEYS[1],'by','_')} 1 myset r eval {return redis.call('sort',KEYS[1],'by','_')} 1 myset
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} } {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} {cluster:skip}
test "SORT BY <constant> with GET gets ordered for scripting" { test "SORT BY <constant> with GET gets ordered for scripting" {
r del myset r del myset
r sadd myset a b c r sadd myset a b c
r eval {return redis.call('sort',KEYS[1],'by','_','get','#','get','_:*')} 1 myset r eval {return redis.call('sort',KEYS[1],'by','_','get','#','get','_:*')} 1 myset
} {a {} b {} c {}} } {a {} b {} c {}} {cluster:skip}
test "redis.sha1hex() implementation" { test "redis.sha1hex() implementation" {
list [r eval {return redis.sha1hex('')} 0] \ list [r eval {return redis.sha1hex('')} 0] \
...@@ -477,9 +477,9 @@ start_server {tags {"scripting"}} { ...@@ -477,9 +477,9 @@ start_server {tags {"scripting"}} {
r debug loadaof r debug loadaof
set res [r get foo] set res [r get foo]
r slaveof no one r slaveof no one
set res
} {102}
r config set aof-use-rdb-preamble yes r config set aof-use-rdb-preamble yes
set res
} {102} {external:skip}
test {EVAL timeout from AOF} { test {EVAL timeout from AOF} {
# generate a long running script that is propagated to the AOF as script # generate a long running script that is propagated to the AOF as script
...@@ -516,16 +516,16 @@ start_server {tags {"scripting"}} { ...@@ -516,16 +516,16 @@ start_server {tags {"scripting"}} {
if {$::verbose} { puts "loading took $elapsed milliseconds" } if {$::verbose} { puts "loading took $elapsed milliseconds" }
$rd close $rd close
r get x r get x
} {y} } {y} {external:skip}
test {We can call scripts rewriting client->argv from Lua} { test {We can call scripts rewriting client->argv from Lua} {
r del myset r del myset
r sadd myset a b c r sadd myset a b c
r mset a 1 b 2 c 3 d 4 r mset a{t} 1 b{t} 2 c{t} 3 d{t} 4
assert {[r spop myset] ne {}} assert {[r spop myset] ne {}}
assert {[r spop myset 1] ne {}} assert {[r spop myset 1] ne {}}
assert {[r spop myset] ne {}} assert {[r spop myset] ne {}}
assert {[r mget a b c d] eq {1 2 3 4}} assert {[r mget a{t} b{t} c{t} d{t}] eq {1 2 3 4}}
assert {[r spop myset] eq {}} assert {[r spop myset] eq {}}
} }
...@@ -539,7 +539,7 @@ start_server {tags {"scripting"}} { ...@@ -539,7 +539,7 @@ start_server {tags {"scripting"}} {
end end
redis.call('rpush','mylist',unpack(x)) redis.call('rpush','mylist',unpack(x))
return redis.call('lrange','mylist',0,-1) return redis.call('lrange','mylist',0,-1)
} 0 } 1 mylist
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100} } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100}
test {Number conversion precision test (issue #1118)} { test {Number conversion precision test (issue #1118)} {
...@@ -547,14 +547,14 @@ start_server {tags {"scripting"}} { ...@@ -547,14 +547,14 @@ start_server {tags {"scripting"}} {
local value = 9007199254740991 local value = 9007199254740991
redis.call("set","foo",value) redis.call("set","foo",value)
return redis.call("get","foo") return redis.call("get","foo")
} 0 } 1 foo
} {9007199254740991} } {9007199254740991}
test {String containing number precision test (regression of issue #1118)} { test {String containing number precision test (regression of issue #1118)} {
r eval { r eval {
redis.call("set", "key", "12039611435714932082") redis.call("set", "key", "12039611435714932082")
return redis.call("get", "key") return redis.call("get", "key")
} 0 } 1 key
} {12039611435714932082} } {12039611435714932082}
test {Verify negative arg count is error instead of crash (issue #1842)} { test {Verify negative arg count is error instead of crash (issue #1842)} {
...@@ -565,13 +565,13 @@ start_server {tags {"scripting"}} { ...@@ -565,13 +565,13 @@ start_server {tags {"scripting"}} {
test {Correct handling of reused argv (issue #1939)} { test {Correct handling of reused argv (issue #1939)} {
r eval { r eval {
for i = 0, 10 do for i = 0, 10 do
redis.call('SET', 'a', '1') redis.call('SET', 'a{t}', '1')
redis.call('MGET', 'a', 'b', 'c') redis.call('MGET', 'a{t}', 'b{t}', 'c{t}')
redis.call('EXPIRE', 'a', 0) redis.call('EXPIRE', 'a{t}', 0)
redis.call('GET', 'a') redis.call('GET', 'a{t}')
redis.call('MGET', 'a', 'b', 'c') redis.call('MGET', 'a{t}', 'b{t}', 'c{t}')
end end
} 0 } 3 a{t} b{t} c{t}
} }
test {Functions in the Redis namespace are able to report errors} { test {Functions in the Redis namespace are able to report errors} {
...@@ -705,7 +705,7 @@ start_server {tags {"scripting"}} { ...@@ -705,7 +705,7 @@ start_server {tags {"scripting"}} {
assert_match {UNKILLABLE*} $e assert_match {UNKILLABLE*} $e
catch {r ping} e catch {r ping} e
assert_match {BUSY*} $e assert_match {BUSY*} $e
} } {} {external:skip}
# Note: keep this test at the end of this server stanza because it # Note: keep this test at the end of this server stanza because it
# kills the server. # kills the server.
...@@ -717,11 +717,11 @@ start_server {tags {"scripting"}} { ...@@ -717,11 +717,11 @@ start_server {tags {"scripting"}} {
# Make sure the server was killed # Make sure the server was killed
catch {set rd [redis_deferring_client]} e catch {set rd [redis_deferring_client]} e
assert_match {*connection refused*} $e assert_match {*connection refused*} $e
} } {} {external:skip}
} }
foreach cmdrepl {0 1} { foreach cmdrepl {0 1} {
start_server {tags {"scripting repl"}} { start_server {tags {"scripting repl needs:debug external:skip"}} {
start_server {} { start_server {} {
if {$cmdrepl == 1} { if {$cmdrepl == 1} {
set rt "(commands replication)" set rt "(commands replication)"
...@@ -817,12 +817,12 @@ foreach cmdrepl {0 1} { ...@@ -817,12 +817,12 @@ foreach cmdrepl {0 1} {
} else { } else {
fail "Master-Replica desync after Lua script using SELECT." fail "Master-Replica desync after Lua script using SELECT."
} }
} } {} {singledb:skip}
} }
} }
} }
start_server {tags {"scripting repl"}} { start_server {tags {"scripting repl external:skip"}} {
start_server {overrides {appendonly yes aof-use-rdb-preamble no}} { start_server {overrides {appendonly yes aof-use-rdb-preamble no}} {
test "Connect a replica to the master instance" { test "Connect a replica to the master instance" {
r -1 slaveof [srv 0 host] [srv 0 port] r -1 slaveof [srv 0 host] [srv 0 port]
...@@ -929,7 +929,7 @@ start_server {tags {"scripting repl"}} { ...@@ -929,7 +929,7 @@ start_server {tags {"scripting repl"}} {
} }
} }
start_server {tags {"scripting"}} { start_server {tags {"scripting external:skip"}} {
r script debug sync r script debug sync
r eval {return 'hello'} 0 r eval {return 'hello'} 0
r eval {return 'hello'} 0 r eval {return 'hello'} 0
......
start_server {tags {"shutdown"}} { start_server {tags {"shutdown external:skip"}} {
test {Temp rdb will be deleted if we use bg_unlink when shutdown} { test {Temp rdb will be deleted if we use bg_unlink when shutdown} {
for {set i 0} {$i < 20} {incr i} { for {set i 0} {$i < 20} {incr i} {
r set $i $i r set $i $i
...@@ -25,7 +25,7 @@ start_server {tags {"shutdown"}} { ...@@ -25,7 +25,7 @@ start_server {tags {"shutdown"}} {
} }
} }
start_server {tags {"shutdown"}} { start_server {tags {"shutdown external:skip"}} {
test {Temp rdb will be deleted in signal handle} { test {Temp rdb will be deleted in signal handle} {
for {set i 0} {$i < 20} {incr i} { for {set i 0} {$i < 20} {incr i} {
r set $i $i r set $i $i
......
start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
test {SLOWLOG - check that it starts with an empty log} { test {SLOWLOG - check that it starts with an empty log} {
if {$::external} {
r slowlog reset
}
r slowlog len r slowlog len
} {0} } {0}
...@@ -9,7 +12,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -9,7 +12,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert_equal [r slowlog len] 0 assert_equal [r slowlog len] 0
r debug sleep 0.2 r debug sleep 0.2
assert_equal [r slowlog len] 1 assert_equal [r slowlog len] 1
} } {} {needs:debug}
test {SLOWLOG - max entries is correctly handled} { test {SLOWLOG - max entries is correctly handled} {
r config set slowlog-log-slower-than 0 r config set slowlog-log-slower-than 0
...@@ -35,11 +38,13 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -35,11 +38,13 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r debug sleep 0.2 r debug sleep 0.2
set e [lindex [r slowlog get] 0] set e [lindex [r slowlog get] 0]
assert_equal [llength $e] 6 assert_equal [llength $e] 6
if {!$::external} {
assert_equal [lindex $e 0] 105 assert_equal [lindex $e 0] 105
}
assert_equal [expr {[lindex $e 2] > 100000}] 1 assert_equal [expr {[lindex $e 2] > 100000}] 1
assert_equal [lindex $e 3] {debug sleep 0.2} assert_equal [lindex $e 3] {debug sleep 0.2}
assert_equal {foobar} [lindex $e 5] assert_equal {foobar} [lindex $e 5]
} } {} {needs:debug}
test {SLOWLOG - Certain commands are omitted that contain sensitive information} { test {SLOWLOG - Certain commands are omitted that contain sensitive information} {
r config set slowlog-log-slower-than 0 r config set slowlog-log-slower-than 0
...@@ -57,7 +62,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -57,7 +62,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert_equal {config set masterauth (redacted)} [lindex [lindex [r slowlog get] 2] 3] assert_equal {config set masterauth (redacted)} [lindex [lindex [r slowlog get] 2] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex [r slowlog get] 1] 3] assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex [r slowlog get] 1] 3]
assert_equal {config set slowlog-log-slower-than 0} [lindex [lindex [r slowlog get] 0] 3] assert_equal {config set slowlog-log-slower-than 0} [lindex [lindex [r slowlog get] 0] 3]
} } {} {needs:repl}
test {SLOWLOG - Some commands can redact sensitive fields} { test {SLOWLOG - Some commands can redact sensitive fields} {
r config set slowlog-log-slower-than 0 r config set slowlog-log-slower-than 0
...@@ -72,7 +77,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -72,7 +77,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert_match {* key 9 5000} [lindex [lindex [r slowlog get] 2] 3] assert_match {* key 9 5000} [lindex [lindex [r slowlog get] 2] 3]
assert_match {* key 9 5000 AUTH (redacted)} [lindex [lindex [r slowlog get] 1] 3] assert_match {* key 9 5000 AUTH (redacted)} [lindex [lindex [r slowlog get] 1] 3]
assert_match {* key 9 5000 AUTH2 (redacted) (redacted)} [lindex [lindex [r slowlog get] 0] 3] assert_match {* key 9 5000 AUTH2 (redacted) (redacted)} [lindex [lindex [r slowlog get] 0] 3]
} } {} {needs:repl}
test {SLOWLOG - Rewritten commands are logged as their original command} { test {SLOWLOG - Rewritten commands are logged as their original command} {
r config set slowlog-log-slower-than 0 r config set slowlog-log-slower-than 0
...@@ -111,11 +116,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -111,11 +116,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
# blocked BLPOP is replicated as LPOP # blocked BLPOP is replicated as LPOP
set rd [redis_deferring_client] set rd [redis_deferring_client]
$rd blpop l 0 $rd blpop l 0
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
r multi r multi
r lpush l foo r lpush l foo
r slowlog reset r slowlog reset
...@@ -129,7 +130,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -129,7 +130,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r config set slowlog-log-slower-than 0 r config set slowlog-log-slower-than 0
r slowlog reset r slowlog reset
r sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 r sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
set e [lindex [r slowlog get] 0] set e [lindex [r slowlog get] end-1]
lindex $e 3 lindex $e 3
} {sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 {... (2 more arguments)}} } {sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 {... (2 more arguments)}}
...@@ -138,7 +139,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -138,7 +139,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r slowlog reset r slowlog reset
set arg [string repeat A 129] set arg [string repeat A 129]
r sadd set foo $arg r sadd set foo $arg
set e [lindex [r slowlog get] 0] set e [lindex [r slowlog get] end-1]
lindex $e 3 lindex $e 3
} {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}} } {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}}
...@@ -152,7 +153,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -152,7 +153,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert_equal [r slowlog len] 1 assert_equal [r slowlog len] 1
set e [lindex [r slowlog get] 0] set e [lindex [r slowlog get] 0]
assert_equal [lindex $e 3] {debug sleep 0.2} assert_equal [lindex $e 3] {debug sleep 0.2}
} } {} {needs:debug}
test {SLOWLOG - can clean older entries} { test {SLOWLOG - can clean older entries} {
r client setname lastentry_client r client setname lastentry_client
...@@ -161,7 +162,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -161,7 +162,7 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert {[llength [r slowlog get]] == 1} assert {[llength [r slowlog get]] == 1}
set e [lindex [r slowlog get] 0] set e [lindex [r slowlog get] 0]
assert_equal {lastentry_client} [lindex $e 5] assert_equal {lastentry_client} [lindex $e 5]
} } {} {needs:debug}
test {SLOWLOG - can be disabled} { test {SLOWLOG - can be disabled} {
r config set slowlog-max-len 1 r config set slowlog-max-len 1
...@@ -173,5 +174,5 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} { ...@@ -173,5 +174,5 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r slowlog reset r slowlog reset
r debug sleep 0.2 r debug sleep 0.2
assert_equal [r slowlog len] 0 assert_equal [r slowlog len] 0
} } {} {needs:debug}
} }
...@@ -47,28 +47,28 @@ start_server { ...@@ -47,28 +47,28 @@ start_server {
test "$title: SORT BY key" { test "$title: SORT BY key" {
assert_equal $result [r sort tosort BY weight_*] assert_equal $result [r sort tosort BY weight_*]
} } {} {cluster:skip}
test "$title: SORT BY key with limit" { test "$title: SORT BY key with limit" {
assert_equal [lrange $result 5 9] [r sort tosort BY weight_* LIMIT 5 5] assert_equal [lrange $result 5 9] [r sort tosort BY weight_* LIMIT 5 5]
} } {} {cluster:skip}
test "$title: SORT BY hash field" { test "$title: SORT BY hash field" {
assert_equal $result [r sort tosort BY wobj_*->weight] assert_equal $result [r sort tosort BY wobj_*->weight]
} } {} {cluster:skip}
} }
set result [create_random_dataset 16 lpush] set result [create_random_dataset 16 lpush]
test "SORT GET #" { test "SORT GET #" {
assert_equal [lsort -integer $result] [r sort tosort GET #] assert_equal [lsort -integer $result] [r sort tosort GET #]
} } {} {cluster:skip}
test "SORT GET <const>" { test "SORT GET <const>" {
r del foo r del foo
set res [r sort tosort GET foo] set res [r sort tosort GET foo]
assert_equal 16 [llength $res] assert_equal 16 [llength $res]
foreach item $res { assert_equal {} $item } foreach item $res { assert_equal {} $item }
} } {} {cluster:skip}
test "SORT GET (key and hash) with sanity check" { test "SORT GET (key and hash) with sanity check" {
set l1 [r sort tosort GET # GET weight_*] set l1 [r sort tosort GET # GET weight_*]
...@@ -78,21 +78,21 @@ start_server { ...@@ -78,21 +78,21 @@ start_server {
assert_equal $w1 [r get weight_$id1] assert_equal $w1 [r get weight_$id1]
assert_equal $w2 [r get weight_$id1] assert_equal $w2 [r get weight_$id1]
} }
} } {} {cluster:skip}
test "SORT BY key STORE" { test "SORT BY key STORE" {
r sort tosort BY weight_* store sort-res r sort tosort BY weight_* store sort-res
assert_equal $result [r lrange sort-res 0 -1] assert_equal $result [r lrange sort-res 0 -1]
assert_equal 16 [r llen sort-res] assert_equal 16 [r llen sort-res]
assert_encoding quicklist sort-res assert_encoding quicklist sort-res
} } {} {cluster:skip}
test "SORT BY hash field STORE" { test "SORT BY hash field STORE" {
r sort tosort BY wobj_*->weight store sort-res r sort tosort BY wobj_*->weight store sort-res
assert_equal $result [r lrange sort-res 0 -1] assert_equal $result [r lrange sort-res 0 -1]
assert_equal 16 [r llen sort-res] assert_equal 16 [r llen sort-res]
assert_encoding quicklist sort-res assert_encoding quicklist sort-res
} } {} {cluster:skip}
test "SORT extracts STORE correctly" { test "SORT extracts STORE correctly" {
r command getkeys sort abc store def r command getkeys sort abc store def
...@@ -188,21 +188,21 @@ start_server { ...@@ -188,21 +188,21 @@ start_server {
test "SORT with STORE returns zero if result is empty (github issue 224)" { test "SORT with STORE returns zero if result is empty (github issue 224)" {
r flushdb r flushdb
r sort foo store bar r sort foo{t} store bar{t}
} {0} } {0}
test "SORT with STORE does not create empty lists (github issue 224)" { test "SORT with STORE does not create empty lists (github issue 224)" {
r flushdb r flushdb
r lpush foo bar r lpush foo{t} bar
r sort foo alpha limit 10 10 store zap r sort foo{t} alpha limit 10 10 store zap{t}
r exists zap r exists zap{t}
} {0} } {0}
test "SORT with STORE removes key if result is empty (github issue 227)" { test "SORT with STORE removes key if result is empty (github issue 227)" {
r flushdb r flushdb
r lpush foo bar r lpush foo{t} bar
r sort emptylist store foo r sort emptylist{t} store foo{t}
r exists foo r exists foo{t}
} {0} } {0}
test "SORT with BY <constant> and STORE should still order output" { test "SORT with BY <constant> and STORE should still order output" {
...@@ -210,7 +210,7 @@ start_server { ...@@ -210,7 +210,7 @@ start_server {
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
r sort myset alpha by _ store mylist r sort myset alpha by _ store mylist
r lrange mylist 0 -1 r lrange mylist 0 -1
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} } {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} {cluster:skip}
test "SORT will complain with numerical sorting and bad doubles (1)" { test "SORT will complain with numerical sorting and bad doubles (1)" {
r del myset r del myset
...@@ -227,7 +227,7 @@ start_server { ...@@ -227,7 +227,7 @@ start_server {
set e {} set e {}
catch {r sort myset by score:*} e catch {r sort myset by score:*} e
set e set e
} {*ERR*double*} } {*ERR*double*} {cluster:skip}
test "SORT BY sub-sorts lexicographically if score is the same" { test "SORT BY sub-sorts lexicographically if score is the same" {
r del myset r del myset
...@@ -236,32 +236,32 @@ start_server { ...@@ -236,32 +236,32 @@ start_server {
set score:$ele 100 set score:$ele 100
} }
r sort myset by score:* r sort myset by score:*
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} } {a aa aaa azz b c d e f g h i l m n o p q r s t u v z} {cluster:skip}
test "SORT GET with pattern ending with just -> does not get hash field" { test "SORT GET with pattern ending with just -> does not get hash field" {
r del mylist r del mylist
r lpush mylist a r lpush mylist a
r set x:a-> 100 r set x:a-> 100
r sort mylist by num get x:*-> r sort mylist by num get x:*->
} {100} } {100} {cluster:skip}
test "SORT by nosort retains native order for lists" { test "SORT by nosort retains native order for lists" {
r del testa r del testa
r lpush testa 2 1 4 3 5 r lpush testa 2 1 4 3 5
r sort testa by nosort r sort testa by nosort
} {5 3 4 1 2} } {5 3 4 1 2} {cluster:skip}
test "SORT by nosort plus store retains native order for lists" { test "SORT by nosort plus store retains native order for lists" {
r del testa r del testa
r lpush testa 2 1 4 3 5 r lpush testa 2 1 4 3 5
r sort testa by nosort store testb r sort testa by nosort store testb
r lrange testb 0 -1 r lrange testb 0 -1
} {5 3 4 1 2} } {5 3 4 1 2} {cluster:skip}
test "SORT by nosort with limit returns based on original list order" { test "SORT by nosort with limit returns based on original list order" {
r sort testa by nosort limit 0 3 store testb r sort testa by nosort limit 0 3 store testb
r lrange testb 0 -1 r lrange testb 0 -1
} {5 3 4} } {5 3 4} {cluster:skip}
tags {"slow"} { tags {"slow"} {
set num 100 set num 100
...@@ -277,7 +277,7 @@ start_server { ...@@ -277,7 +277,7 @@ start_server {
puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds " puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
flush stdout flush stdout
} }
} } {} {cluster:skip}
test "SORT speed, $num element list BY hash field, 100 times" { test "SORT speed, $num element list BY hash field, 100 times" {
set start [clock clicks -milliseconds] set start [clock clicks -milliseconds]
...@@ -289,7 +289,7 @@ start_server { ...@@ -289,7 +289,7 @@ start_server {
puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds " puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
flush stdout flush stdout
} }
} } {} {cluster:skip}
test "SORT speed, $num element list directly, 100 times" { test "SORT speed, $num element list directly, 100 times" {
set start [clock clicks -milliseconds] set start [clock clicks -milliseconds]
...@@ -313,6 +313,6 @@ start_server { ...@@ -313,6 +313,6 @@ start_server {
puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds " puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
flush stdout flush stdout
} }
} } {} {cluster:skip}
} }
} }
...@@ -40,20 +40,20 @@ start_server {tags {"tracking network"}} { ...@@ -40,20 +40,20 @@ start_server {tags {"tracking network"}} {
} {*OK} } {*OK}
test {The other connection is able to get invalidations} { test {The other connection is able to get invalidations} {
r SET a 1 r SET a{t} 1
r SET b 1 r SET b{t} 1
r GET a r GET a{t}
r INCR b ; # This key should not be notified, since it wasn't fetched. r INCR b{t} ; # This key should not be notified, since it wasn't fetched.
r INCR a r INCR a{t}
set keys [lindex [$rd_redirection read] 2] set keys [lindex [$rd_redirection read] 2]
assert {[llength $keys] == 1} assert {[llength $keys] == 1}
assert {[lindex $keys 0] eq {a}} assert {[lindex $keys 0] eq {a{t}}}
} }
test {The client is now able to disable tracking} { test {The client is now able to disable tracking} {
# Make sure to add a few more keys in the tracking list # Make sure to add a few more keys in the tracking list
# so that we can check for leaks, as a side effect. # so that we can check for leaks, as a side effect.
r MGET a b c d e f g r MGET a{t} b{t} c{t} d{t} e{t} f{t} g{t}
r CLIENT TRACKING off r CLIENT TRACKING off
} {*OK} } {*OK}
...@@ -62,28 +62,28 @@ start_server {tags {"tracking network"}} { ...@@ -62,28 +62,28 @@ start_server {tags {"tracking network"}} {
} {*OK*} } {*OK*}
test {The connection gets invalidation messages about all the keys} { test {The connection gets invalidation messages about all the keys} {
r MSET a 1 b 2 c 3 r MSET a{t} 1 b{t} 2 c{t} 3
set keys [lsort [lindex [$rd_redirection read] 2]] set keys [lsort [lindex [$rd_redirection read] 2]]
assert {$keys eq {a b c}} assert {$keys eq {a{t} b{t} c{t}}}
} }
test {Clients can enable the BCAST mode with prefixes} { test {Clients can enable the BCAST mode with prefixes} {
r CLIENT TRACKING off r CLIENT TRACKING off
r CLIENT TRACKING on BCAST REDIRECT $redir_id PREFIX a: PREFIX b: r CLIENT TRACKING on BCAST REDIRECT $redir_id PREFIX a: PREFIX b:
r MULTI r MULTI
r INCR a:1 r INCR a:1{t}
r INCR a:2 r INCR a:2{t}
r INCR b:1 r INCR b:1{t}
r INCR b:2 r INCR b:2{t}
# we should not get this key # we should not get this key
r INCR c:1 r INCR c:1{t}
r EXEC r EXEC
# Because of the internals, we know we are going to receive # Because of the internals, we know we are going to receive
# two separated notifications for the two different prefixes. # two separated notifications for the two different prefixes.
set keys1 [lsort [lindex [$rd_redirection read] 2]] set keys1 [lsort [lindex [$rd_redirection read] 2]]
set keys2 [lsort [lindex [$rd_redirection read] 2]] set keys2 [lsort [lindex [$rd_redirection read] 2]]
set keys [lsort [list {*}$keys1 {*}$keys2]] set keys [lsort [list {*}$keys1 {*}$keys2]]
assert {$keys eq {a:1 a:2 b:1 b:2}} assert {$keys eq {a:1{t} a:2{t} b:1{t} b:2{t}}}
} }
test {Adding prefixes to BCAST mode works} { test {Adding prefixes to BCAST mode works} {
...@@ -96,16 +96,16 @@ start_server {tags {"tracking network"}} { ...@@ -96,16 +96,16 @@ start_server {tags {"tracking network"}} {
test {Tracking NOLOOP mode in standard mode works} { test {Tracking NOLOOP mode in standard mode works} {
r CLIENT TRACKING off r CLIENT TRACKING off
r CLIENT TRACKING on REDIRECT $redir_id NOLOOP r CLIENT TRACKING on REDIRECT $redir_id NOLOOP
r MGET otherkey1 loopkey otherkey2 r MGET otherkey1{t} loopkey{t} otherkey2{t}
$rd_sg SET otherkey1 1; # We should get this $rd_sg SET otherkey1{t} 1; # We should get this
r SET loopkey 1 ; # We should not get this r SET loopkey{t} 1 ; # We should not get this
$rd_sg SET otherkey2 1; # We should get this $rd_sg SET otherkey2{t} 1; # We should get this
# Because of the internals, we know we are going to receive # Because of the internals, we know we are going to receive
# two separated notifications for the two different keys. # two separated notifications for the two different keys.
set keys1 [lsort [lindex [$rd_redirection read] 2]] set keys1 [lsort [lindex [$rd_redirection read] 2]]
set keys2 [lsort [lindex [$rd_redirection read] 2]] set keys2 [lsort [lindex [$rd_redirection read] 2]]
set keys [lsort [list {*}$keys1 {*}$keys2]] set keys [lsort [list {*}$keys1 {*}$keys2]]
assert {$keys eq {otherkey1 otherkey2}} assert {$keys eq {otherkey1{t} otherkey2{t}}}
} }
test {Tracking NOLOOP mode in BCAST mode works} { test {Tracking NOLOOP mode in BCAST mode works} {
...@@ -220,16 +220,16 @@ start_server {tags {"tracking network"}} { ...@@ -220,16 +220,16 @@ start_server {tags {"tracking network"}} {
r CLIENT TRACKING on REDIRECT $redir_id r CLIENT TRACKING on REDIRECT $redir_id
$rd CLIENT TRACKING on REDIRECT $redir_id $rd CLIENT TRACKING on REDIRECT $redir_id
assert_equal OK [$rd read] ; # Consume the TRACKING reply assert_equal OK [$rd read] ; # Consume the TRACKING reply
$rd_sg MSET key1 1 key2 1 $rd_sg MSET key1{t} 1 key2{t} 1
r GET key1 r GET key1{t}
$rd GET key2 $rd GET key2{t}
assert_equal 1 [$rd read] ; # Consume the GET reply assert_equal 1 [$rd read] ; # Consume the GET reply
$rd_sg INCR key1 $rd_sg INCR key1{t}
$rd_sg INCR key2 $rd_sg INCR key2{t}
set res1 [lindex [$rd_redirection read] 2] set res1 [lindex [$rd_redirection read] 2]
set res2 [lindex [$rd_redirection read] 2] set res2 [lindex [$rd_redirection read] 2]
assert {$res1 eq {key1}} assert {$res1 eq {key1{t}}}
assert {$res2 eq {key2}} assert {$res2 eq {key2{t}}}
} }
test {Different clients using different protocols can track the same key} { test {Different clients using different protocols can track the same key} {
...@@ -356,9 +356,9 @@ start_server {tags {"tracking network"}} { ...@@ -356,9 +356,9 @@ start_server {tags {"tracking network"}} {
test {Tracking gets notification on tracking table key eviction} { test {Tracking gets notification on tracking table key eviction} {
r CLIENT TRACKING off r CLIENT TRACKING off
r CLIENT TRACKING on REDIRECT $redir_id NOLOOP r CLIENT TRACKING on REDIRECT $redir_id NOLOOP
r MSET key1 1 key2 2 r MSET key1{t} 1 key2{t} 2
# Let the server track the two keys for us # Let the server track the two keys for us
r MGET key1 key2 r MGET key1{t} key2{t}
# Force the eviction of all the keys but one: # Force the eviction of all the keys but one:
r config set tracking-table-max-keys 1 r config set tracking-table-max-keys 1
# Note that we may have other keys in the table for this client, # Note that we may have other keys in the table for this client,
...@@ -368,11 +368,11 @@ start_server {tags {"tracking network"}} { ...@@ -368,11 +368,11 @@ start_server {tags {"tracking network"}} {
# otherwise the test will die for timeout. # otherwise the test will die for timeout.
while 1 { while 1 {
set keys [lindex [$rd_redirection read] 2] set keys [lindex [$rd_redirection read] 2]
if {$keys eq {key1} || $keys eq {key2}} break if {$keys eq {key1{t}} || $keys eq {key2{t}}} break
} }
# We should receive an expire notification for one of # We should receive an expire notification for one of
# the two keys (only one must remain) # the two keys (only one must remain)
assert {$keys eq {key1} || $keys eq {key2}} assert {$keys eq {key1{t}} || $keys eq {key2{t}}}
} }
test {Invalidation message received for flushall} { test {Invalidation message received for flushall} {
......
...@@ -61,8 +61,8 @@ start_server {tags {"hash"}} { ...@@ -61,8 +61,8 @@ start_server {tags {"hash"}} {
set res [r hrandfield myhash 3] set res [r hrandfield myhash 3]
assert_equal [llength $res] 3 assert_equal [llength $res] 3
assert_equal [llength [lindex $res 1]] 1 assert_equal [llength [lindex $res 1]] 1
}
r hello 2 r hello 2
}
test "HRANDFIELD count of 0 is handled correctly" { test "HRANDFIELD count of 0 is handled correctly" {
r hrandfield myhash 0 r hrandfield myhash 0
...@@ -445,7 +445,7 @@ start_server {tags {"hash"}} { ...@@ -445,7 +445,7 @@ start_server {tags {"hash"}} {
test {Is a ziplist encoded Hash promoted on big payload?} { test {Is a ziplist encoded Hash promoted on big payload?} {
r hset smallhash foo [string repeat a 1024] r hset smallhash foo [string repeat a 1024]
r debug object smallhash r debug object smallhash
} {*hashtable*} } {*hashtable*} {needs:debug}
test {HINCRBY against non existing database key} { test {HINCRBY against non existing database key} {
r del htest r del htest
...@@ -709,7 +709,7 @@ start_server {tags {"hash"}} { ...@@ -709,7 +709,7 @@ start_server {tags {"hash"}} {
for {set i 0} {$i < 64} {incr i} { for {set i 0} {$i < 64} {incr i} {
r hset myhash [randomValue] [randomValue] r hset myhash [randomValue] [randomValue]
} }
assert {[r object encoding myhash] eq {hashtable}} assert_encoding hashtable myhash
} }
} }
...@@ -733,8 +733,8 @@ start_server {tags {"hash"}} { ...@@ -733,8 +733,8 @@ start_server {tags {"hash"}} {
test {Hash ziplist of various encodings} { test {Hash ziplist of various encodings} {
r del k r del k
r config set hash-max-ziplist-entries 1000000000 config_set hash-max-ziplist-entries 1000000000
r config set hash-max-ziplist-value 1000000000 config_set hash-max-ziplist-value 1000000000
r hset k ZIP_INT_8B 127 r hset k ZIP_INT_8B 127
r hset k ZIP_INT_16B 32767 r hset k ZIP_INT_16B 32767
r hset k ZIP_INT_32B 2147483647 r hset k ZIP_INT_32B 2147483647
...@@ -748,8 +748,8 @@ start_server {tags {"hash"}} { ...@@ -748,8 +748,8 @@ start_server {tags {"hash"}} {
set dump [r dump k] set dump [r dump k]
# will be converted to dict at RESTORE # will be converted to dict at RESTORE
r config set hash-max-ziplist-entries 2 config_set hash-max-ziplist-entries 2
r config set sanitize-dump-payload no config_set sanitize-dump-payload no mayfail
r restore kk 0 $dump r restore kk 0 $dump
set kk [r hgetall kk] set kk [r hgetall kk]
...@@ -765,7 +765,7 @@ start_server {tags {"hash"}} { ...@@ -765,7 +765,7 @@ start_server {tags {"hash"}} {
} {ZIP_INT_8B 127 ZIP_INT_16B 32767 ZIP_INT_32B 2147483647 ZIP_INT_64B 9223372036854775808 ZIP_INT_IMM_MIN 0 ZIP_INT_IMM_MAX 12} } {ZIP_INT_8B 127 ZIP_INT_16B 32767 ZIP_INT_32B 2147483647 ZIP_INT_64B 9223372036854775808 ZIP_INT_IMM_MIN 0 ZIP_INT_IMM_MAX 12}
test {Hash ziplist of various encodings - sanitize dump} { test {Hash ziplist of various encodings - sanitize dump} {
r config set sanitize-dump-payload yes config_set sanitize-dump-payload yes mayfail
r restore kk 0 $dump replace r restore kk 0 $dump replace
set k [r hgetall k] set k [r hgetall k]
set kk [r hgetall kk] set kk [r hgetall kk]
......
...@@ -63,7 +63,7 @@ start_server {tags {"incr"}} { ...@@ -63,7 +63,7 @@ start_server {tags {"incr"}} {
assert {[r object refcount foo] > 1} assert {[r object refcount foo] > 1}
r incr foo r incr foo
assert {[r object refcount foo] == 1} assert {[r object refcount foo] == 1}
} } {} {needs:debug}
test {INCR can modify objects in-place} { test {INCR can modify objects in-place} {
r set foo 20000 r set foo 20000
...@@ -75,7 +75,7 @@ start_server {tags {"incr"}} { ...@@ -75,7 +75,7 @@ start_server {tags {"incr"}} {
assert {[string range $old 0 2] eq "at:"} assert {[string range $old 0 2] eq "at:"}
assert {[string range $new 0 2] eq "at:"} assert {[string range $new 0 2] eq "at:"}
assert {$old eq $new} assert {$old eq $new}
} } {} {needs:debug}
test {INCRBYFLOAT against non existing key} { test {INCRBYFLOAT against non existing key} {
r del novar r del novar
......
start_server { start_server {
tags {list ziplist} tags {"list ziplist"}
overrides { overrides {
"list-max-ziplist-size" 16 "list-max-ziplist-size" 16
} }
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment