proc start_server_aof {overrides code} {
upvar defaults defaults srv srv server_path server_path
set _defaults $defaults
- set srv [start_server default.conf [lappend _defaults $overrides]]
+ set srv [start_server {overrides [lappend _defaults $overrides]}]
uplevel 1 $code
kill_server $srv
}
-start_server default.conf {} {
+start_server {} {
r set mykey foo
- start_server default.conf {} {
+ start_server {} {
test {Second server should have role master at first} {
s role
} {master}
}
set ::global_overrides {}
-proc start_server {filename overrides {code undefined}} {
- set data [split [exec cat "tests/assets/$filename"] "\n"]
+proc start_server {options {code undefined}} {
+ # setup defaults
+ set baseconfig "default.conf"
+ set overrides {}
+
+ # parse options
+ foreach {option value} $options {
+ switch $option {
+ "config" { set baseconfig $value }
+ "overrides" { set overrides $value }
+ default { error "Unknown option $option" }
+ }
+ }
+
+ set data [split [exec cat "tests/assets/$baseconfig"] "\n"]
set config {}
foreach line $data {
if {[string length $line] > 0 && [string index $line 0] ne "#"} {
dict set config port [incr ::port]
# apply overrides from global space and arguments
- foreach override [concat $::global_overrides $overrides] {
- set directive [lrange $override 0 0]
- set arguments [lrange $override 1 end]
+ foreach {directive arguments} [concat $::global_overrides $overrides] {
dict set config $directive $arguments
}
-start_server default.conf {{requirepass foobar}} {
+start_server {overrides {requirepass foobar}} {
test {AUTH fails when a wrong password is given} {
catch {r auth wrong!} err
format $err
-start_server default.conf {} {
+start_server {} {
test {DEL all keys to start with a clean DB} {
foreach key [r keys *] {r del $key}
r dbsize
-start_server default.conf {} {
+start_server {} {
test {EXEC works on WATCHed key not modified} {
r watch x y z
r watch k
-start_server default.conf {} {
+start_server {} {
test {EXPIRE - don't set timeouts multiple times} {
r set x foobar
set v1 [r expire x 5]
-start_server default.conf {} {
+start_server {} {
test {SAVE - make sure there are all the types as values} {
# Wait for a background saving in progress to terminate
waitForBgsave r
-start_server default.conf {} {
+start_server {} {
test {Handle an empty query well} {
set fd [r channel]
puts -nonewline $fd "\r\n"
-start_server default.conf {} {
+start_server {} {
test {SORT ALPHA against integer encoded strings} {
r del mylist
r lpush mylist 2
-start_server default.conf {} {
+start_server {} {
test {HSET/HLEN - Small hash creation} {
array set smallhash {}
for {set i 0} {$i < 8} {incr i} {
-start_server default.conf {} {
+start_server {} {
test {Basic LPUSH, RPUSH, LLENGTH, LINDEX} {
set res [r lpush mylist a]
append res [r lpush mylist b]
-start_server default.conf {} {
+start_server {} {
test {SADD, SCARD, SISMEMBER, SMEMBERS basics} {
r sadd myset foo
r sadd myset bar
-start_server default.conf {} {
+start_server {} {
test {ZSET basic ZADD and score update} {
r zadd ztmp 10 x
r zadd ztmp 20 y