getting unit tests back to antirez verbatim

This commit is contained in:
Jonathan Pickett
2014-01-06 17:31:47 -08:00
parent 78b051a8be
commit f5a1b485c3
5 changed files with 108 additions and 117 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ tags {"aof"} {
set result [exec src/redis-check-aof --fix $aof_path << "y\n"]
assert_match "*Successfully truncated AOF*" $result
}
## 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" {
+22 -22
View File
@@ -67,29 +67,29 @@ start_server {tags {"dump"}} {
}
test {MIGRATE can correctly transfer large values} {
set first [srv 0 client]
r del key
for {set j 0} {$j < 5000} {incr j} {
r rpush key 1 2 3 4 5 6 7 8 9 10
r rpush key "item 1" "item 2" "item 3" "item 4" "item 5" \
"item 6" "item 7" "item 8" "item 9" "item 10"
}
assert {[string length [r dump key]] > (1024*64)}
start_server {tags {"repl"}} {
set second [srv 0 client]
set second_host [srv 0 host]
set second_port [srv 0 port]
set first [srv 0 client]
r del key
for {set j 0} {$j < 5000} {incr j} {
r rpush key 1 2 3 4 5 6 7 8 9 10
r rpush key "item 1" "item 2" "item 3" "item 4" "item 5" \
"item 6" "item 7" "item 8" "item 9" "item 10"
}
assert {[string length [r dump key]] > (1024*64)}
start_server {tags {"repl"}} {
set second [srv 0 client]
set second_host [srv 0 host]
set second_port [srv 0 port]
assert {[$first exists key] == 1}
assert {[$second exists key] == 0}
set ret [r -1 migrate $second_host $second_port key 9 10000]
assert {$ret eq {OK}}
assert {[$first exists key] == 0}
assert {[$second exists key] == 1}
assert {[$second ttl key] == -1}
assert {[$second llen key] == 5000*20}
}
}
assert {[$first exists key] == 1}
assert {[$second exists key] == 0}
set ret [r -1 migrate $second_host $second_port key 9 10000]
assert {$ret eq {OK}}
assert {[$first exists key] == 0}
assert {[$second exists key] == 1}
assert {[$second ttl key] == -1}
assert {[$second llen key] == 5000*20}
}
}
test {MIGRATE can correctly transfer hashes} {
set first [srv 0 client]
+13 -13
View File
@@ -12,13 +12,13 @@ start_server {tags {"introspection"}} {
} {*OK*"set" "foo"*"get" "foo"*}
test {MONITOR can log commands issued by the scripting engine} {
set rd [redis_deferring_client]
set rd [redis_deferring_client]
$rd monitor
r eval {redis.call('set',KEYS[1],ARGV[1])} 1 foo bar
$rd read ;# Discard the OK
assert_match {*eval*} [$rd read]
assert_match {*lua*"set"*"foo"*"bar"*} [$rd read]
}
}
test {CLIENT GETNAME should return NIL if name is not assigned} {
r client getname
@@ -44,16 +44,16 @@ start_server {tags {"introspection"}} {
} {*name=someothername*}
test {After CLIENT SETNAME, connection can still be closed} {
set rd [redis_deferring_client]
$rd client setname foobar
assert_equal [$rd read] "OK"
assert_match {*foobar*} [r client list]
$rd close
# Now the client should no longer be listed
wait_for_condition 50 100 {
[string match {*foobar*} [r client list]] == 0
} else {
fail "Client still listed in CLIENT LIST after SETNAME."
}
set rd [redis_deferring_client]
$rd client setname foobar
assert_equal [$rd read] "OK"
assert_match {*foobar*} [r client list]
$rd close
# Now the client should no longer be listed
wait_for_condition 50 100 {
[string match {*foobar*} [r client list]] == 0
} else {
fail "Client still listed in CLIENT LIST after SETNAME."
}
}
}
-2
View File
@@ -267,7 +267,6 @@ start_server {tags {"multi"}} {
close_replication_stream $repl
}
test {MULTI / EXEC is propagated correctly (empty transaction)} {
set repl [attach_to_replication_stream]
r multi
@@ -307,5 +306,4 @@ start_server {tags {"multi"}} {
}
close_replication_stream $repl
}
}
+72 -79
View File
@@ -122,22 +122,18 @@ start_server {tags {"scripting"}} {
r get mykey
} {this is DB 9}
# this test hangs in windows
test {EVAL - Script can't run more than configured time limit} {
if { $::tcl_platform(platform) != "windows" } {
r config set lua-time-limit 1
catch {
r eval {
local i = 0
while true do i=i+1 end
} 0
} e
set _ $e
} else {
fail "Win32: bypassing failing test"
}
} {*execution time*}
if 0 {
test {EVAL - Script can't run more than configured time limit} {
r config set lua-time-limit 1
catch {
r eval {
local i = 0
while true do i=i+1 end
} 0
} e
set _ $e
} {*execution time*}
}
test {EVAL - Scripts can't run certain commands} {
set e {}
@@ -286,25 +282,23 @@ start_server {tags {"scripting"}} {
assert {$rand2 ne $rand3}
}
# Win - COW killing redis - disabled replication
# test {EVAL processes writes from AOF in read-only slaves} {
# r flushall
# r config set appendonly yes
# r eval {redis.call("set","foo","100")} 0
# r eval {redis.call("incr","foo")} 0
# r eval {redis.call("incr","foo")} 0
# windows build needs a bit longer than the "50 100" specified
# wait_for_condition 100 1000 {
# [s aof_rewrite_in_progress] == 0
# } else {
# fail "AOF rewrite can't complete after CONFIG SET appendonly yes."
# }
# r config set slave-read-only yes
# r slaveof 127.0.0.1 0
# r debug loadaof
# r get foo
# } {102}
#}
test {EVAL processes writes from AOF in read-only slaves} {
r flushall
r config set appendonly yes
r eval {redis.call("set","foo","100")} 0
r eval {redis.call("incr","foo")} 0
r eval {redis.call("incr","foo")} 0
wait_for_condition 50 100 {
[s aof_rewrite_in_progress] == 0
} else {
fail "AOF rewrite can't complete after CONFIG SET appendonly yes."
}
r config set slave-read-only yes
r slaveof 127.0.0.1 0
r debug loadaof
r get foo
} {102}
}
# Start a new server since the last test in this stanza will kill the
# instance at all.
@@ -365,49 +359,48 @@ start_server {tags {"scripting repl"}} {
r eval {return redis.call('incr','x')} 0
} {2}
# Win - COW killing redis - disabled replication
# test {Connect a slave to the main instance} {
# r -1 slaveof [srv 0 host] [srv 0 port]
# wait_for_condition 50 100 {
# [s -1 role] eq {slave} &&
# [string match {*master_link_status:up*} [r -1 info replication]]
# } else {
# fail "Can't turn the instance into a slave"
# }
# }
#
# test {Now use EVALSHA against the master, with both SHAs} {
# # The server should replicate successful and unsuccessful
# # commands as EVAL instead of EVALSHA.
# catch {
# r evalsha 6e8bd6bdccbe78899e3cc06b31b6dbf4324c2e56 0
# }
# r evalsha ae3477e27be955de7e1bc9adfdca626b478d3cb2 0
# } {4}
#
# test {If EVALSHA was replicated as EVAL, 'x' should be '4'} {
# wait_for_condition 50 100 {
# [r -1 get x] eq {4}
# } else {
# fail "Expected 4 in x, but value is '[r -1 get x]'"
# }
# }
#
# test {Replication of script multiple pushes to list with BLPOP} {
# set rd [redis_deferring_client]
# $rd brpop a 0
# r eval {
# redis.call("lpush","a","1");
# redis.call("lpush","a","2");
# } 0
# set res [$rd read]
# $rd close
# wait_for_condition 50 100 {
# [r -1 lrange a 0 -1] eq [r lrange a 0 -1]
# } else {
# fail "Expected list 'a' in slave and master to be the same, but they are respectively '[r -1 lrange a 0 -1]' and '[r lrange a 0 -1]'"
# }
# set res
# } {a 1}
test {Connect a slave to the main instance} {
r -1 slaveof [srv 0 host] [srv 0 port]
wait_for_condition 50 100 {
[s -1 role] eq {slave} &&
[string match {*master_link_status:up*} [r -1 info replication]]
} else {
fail "Can't turn the instance into a slave"
}
}
test {Now use EVALSHA against the master, with both SHAs} {
# The server should replicate successful and unsuccessful
# commands as EVAL instead of EVALSHA.
catch {
r evalsha 6e8bd6bdccbe78899e3cc06b31b6dbf4324c2e56 0
}
r evalsha ae3477e27be955de7e1bc9adfdca626b478d3cb2 0
} {4}
test {If EVALSHA was replicated as EVAL, 'x' should be '4'} {
wait_for_condition 50 100 {
[r -1 get x] eq {4}
} else {
fail "Expected 4 in x, but value is '[r -1 get x]'"
}
}
test {Replication of script multiple pushes to list with BLPOP} {
set rd [redis_deferring_client]
$rd brpop a 0
r eval {
redis.call("lpush","a","1");
redis.call("lpush","a","2");
} 0
set res [$rd read]
$rd close
wait_for_condition 50 100 {
[r -1 lrange a 0 -1] eq [r lrange a 0 -1]
} else {
fail "Expected list 'a' in slave and master to be the same, but they are respectively '[r -1 lrange a 0 -1]' and '[r lrange a 0 -1]'"
}
set res
} {a 1}
}
}