Permalink
Browse files

tags for existing tests

  • Loading branch information...
1 parent 19b49c3 commit 0319bd1e9f24505b760c96d64a141560b66f0aff @pietern pietern committed Jun 2, 2010
View
@@ -22,59 +22,61 @@ proc start_server_aof {overrides code} {
kill_server $srv
}
-## Test the server doesn't start when the AOF contains an unfinished MULTI
-create_aof {
- append_to_aof [formatCommand set foo hello]
- append_to_aof [formatCommand multi]
- append_to_aof [formatCommand set bar world]
-}
+tags {"aof"} {
+ ## Test the server doesn't start when the AOF contains an unfinished MULTI
+ create_aof {
+ append_to_aof [formatCommand set foo hello]
+ append_to_aof [formatCommand multi]
+ append_to_aof [formatCommand set bar world]
+ }
-start_server_aof [list dir $server_path] {
- test {Unfinished MULTI: Server should not have been started} {
- is_alive $srv
- } {0}
+ start_server_aof [list dir $server_path] {
+ test {Unfinished MULTI: Server should not have been started} {
+ is_alive $srv
+ } {0}
- test {Unfinished MULTI: Server should have logged an error} {
- exec cat [dict get $srv stdout] | tail -n1
- } {*Unexpected end of file reading the append only file*}
-}
+ test {Unfinished MULTI: Server should have logged an error} {
+ exec cat [dict get $srv stdout] | tail -n1
+ } {*Unexpected end of file reading the append only file*}
+ }
-## Test that the server exits when the AOF contains a short read
-create_aof {
- append_to_aof [formatCommand set foo hello]
- append_to_aof [string range [formatCommand set bar world] 0 end-1]
-}
+ ## Test that the server exits when the AOF contains a short read
+ create_aof {
+ append_to_aof [formatCommand set foo hello]
+ append_to_aof [string range [formatCommand set bar world] 0 end-1]
+ }
-start_server_aof [list dir $server_path] {
- test {Short read: Server should not have been started} {
- is_alive $srv
- } {0}
+ start_server_aof [list dir $server_path] {
+ test {Short read: Server should not have been started} {
+ is_alive $srv
+ } {0}
- test {Short read: Server should have logged an error} {
- exec cat [dict get $srv stdout] | tail -n1
- } {*Bad file format reading the append only file*}
-}
+ test {Short read: Server should have logged an error} {
+ exec cat [dict get $srv stdout] | tail -n1
+ } {*Bad file format reading the append only file*}
+ }
-## Test that redis-check-aof indeed sees this AOF is not valid
-test {Short read: Utility should confirm the AOF is not valid} {
- catch {
- exec ./redis-check-aof $aof_path
- } str
- set _ $str
-} {*not valid*}
+ ## Test that redis-check-aof indeed sees this AOF is not valid
+ test {Short read: Utility should confirm the AOF is not valid} {
+ catch {
+ exec ./redis-check-aof $aof_path
+ } str
+ set _ $str
+ } {*not valid*}
-test {Short read: Utility should be able to fix the AOF} {
- exec echo y | ./redis-check-aof --fix $aof_path
-} {*Successfully truncated AOF*}
+ test {Short read: Utility should be able to fix the AOF} {
+ exec echo y | ./redis-check-aof --fix $aof_path
+ } {*Successfully truncated AOF*}
-## Test that the server can be started using the truncated AOF
-start_server_aof [list dir $server_path] {
- test {Fixed AOF: Server should have been started} {
- is_alive $srv
- } {1}
+ ## Test that the server can be started using the truncated AOF
+ start_server_aof [list dir $server_path] {
+ test {Fixed AOF: Server should have been started} {
+ is_alive $srv
+ } {1}
- test {Fixed AOF: Keyspace should contain values that were parsable} {
- set client [redis [dict get $srv host] [dict get $srv port]]
- list [$client get foo] [$client get bar]
- } {hello {}}
+ test {Fixed AOF: Keyspace should contain values that were parsable} {
+ set client [redis [dict get $srv host] [dict get $srv port]]
+ list [$client get foo] [$client get bar]
+ } {hello {}}
+ }
}
@@ -1,4 +1,4 @@
-start_server {} {
+start_server {tags {"repl"}} {
r set mykey foo
start_server {} {
View
@@ -1,4 +1,4 @@
-start_server {overrides {requirepass foobar}} {
+start_server {tags {"auth"} overrides {requirepass foobar}} {
test {AUTH fails when a wrong password is given} {
catch {r auth wrong!} err
format $err
View
@@ -1,4 +1,4 @@
-start_server {tags {basic}} {
+start_server {tags {"basic"}} {
test {DEL all keys to start with a clean DB} {
foreach key [r keys *] {r del $key}
r dbsize
@@ -52,47 +52,47 @@ start_server {tags {basic}} {
r get foo
} [string repeat "abcd" 1000000]
- tags {slow} {
- test {Very big payload random access} {
- set err {}
- array set payload {}
- for {set j 0} {$j < 100} {incr j} {
- set size [expr 1+[randomInt 100000]]
- set buf [string repeat "pl-$j" $size]
- set payload($j) $buf
- r set bigpayload_$j $buf
- }
- for {set j 0} {$j < 1000} {incr j} {
- set index [randomInt 100]
- set buf [r get bigpayload_$index]
- if {$buf != $payload($index)} {
- set err "Values differ: I set '$payload($index)' but I read back '$buf'"
- break
+ tags {"slow"} {
+ test {Very big payload random access} {
+ set err {}
+ array set payload {}
+ for {set j 0} {$j < 100} {incr j} {
+ set size [expr 1+[randomInt 100000]]
+ set buf [string repeat "pl-$j" $size]
+ set payload($j) $buf
+ r set bigpayload_$j $buf
}
- }
- unset payload
- set _ $err
- } {}
-
- test {SET 10000 numeric keys and access all them in reverse order} {
- set err {}
- for {set x 0} {$x < 10000} {incr x} {
- r set $x $x
- }
- set sum 0
- for {set x 9999} {$x >= 0} {incr x -1} {
- set val [r get $x]
- if {$val ne $x} {
- set err "Eleemnt at position $x is $val instead of $x"
- break
+ for {set j 0} {$j < 1000} {incr j} {
+ set index [randomInt 100]
+ set buf [r get bigpayload_$index]
+ if {$buf != $payload($index)} {
+ set err "Values differ: I set '$payload($index)' but I read back '$buf'"
+ break
+ }
}
- }
- set _ $err
- } {}
+ unset payload
+ set _ $err
+ } {}
+
+ test {SET 10000 numeric keys and access all them in reverse order} {
+ set err {}
+ for {set x 0} {$x < 10000} {incr x} {
+ r set $x $x
+ }
+ set sum 0
+ for {set x 9999} {$x >= 0} {incr x -1} {
+ set val [r get $x]
+ if {$val ne $x} {
+ set err "Eleemnt at position $x is $val instead of $x"
+ break
+ }
+ }
+ set _ $err
+ } {}
- test {DBSIZE should be 10101 now} {
- r dbsize
- } {10101}
+ test {DBSIZE should be 10101 now} {
+ r dbsize
+ } {10101}
}
test {INCR against non existing key} {
View
@@ -0,0 +1,114 @@
+start_server {tags {"cas"}} {
+ test {EXEC works on WATCHed key not modified} {
+ r watch x y z
+ r watch k
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {EXEC fail on WATCHed key modified (1 key of 1 watched)} {
+ r set x 30
+ r watch x
+ r set x 40
+ r multi
+ r ping
+ r exec
+ } {}
+
+ test {EXEC fail on WATCHed key modified (1 key of 5 watched)} {
+ r set x 30
+ r watch a b x k z
+ r set x 40
+ r multi
+ r ping
+ r exec
+ } {}
+
+ test {After successful EXEC key is no longer watched} {
+ r set x 30
+ r watch x
+ r multi
+ r ping
+ r exec
+ r set x 40
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {After failed EXEC key is no longer watched} {
+ r set x 30
+ r watch x
+ r set x 40
+ r multi
+ r ping
+ r exec
+ r set x 40
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {It is possible to UNWATCH} {
+ r set x 30
+ r watch x
+ r set x 40
+ r unwatch
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {UNWATCH when there is nothing watched works as expected} {
+ r unwatch
+ } {OK}
+
+ test {FLUSHALL is able to touch the watched keys} {
+ r set x 30
+ r watch x
+ r flushall
+ r multi
+ r ping
+ r exec
+ } {}
+
+ test {FLUSHALL does not touch non affected keys} {
+ r del x
+ r watch x
+ r flushall
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {FLUSHDB is able to touch the watched keys} {
+ r set x 30
+ r watch x
+ r flushdb
+ r multi
+ r ping
+ r exec
+ } {}
+
+ test {FLUSHDB does not touch non affected keys} {
+ r del x
+ r watch x
+ r flushdb
+ r multi
+ r ping
+ r exec
+ } {PONG}
+
+ test {WATCH is able to remember the DB a key belongs to} {
+ r select 5
+ r set x 30
+ r watch x
+ r select 1
+ r set x 10
+ r select 5
+ r multi
+ r ping
+ r exec
+ } {PONG}
+}
View
@@ -1,4 +1,4 @@
-start_server {} {
+start_server {tags {"expire"}} {
test {EXPIRE - don't set timeouts multiple times} {
r set x foobar
set v1 [r expire x 5]
Oops, something went wrong.

0 comments on commit 0319bd1

Please sign in to comment.