From f3fd58eb4a0b2a2b5966e48c6b70c344f3bc248e Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 9 Jan 2015 11:06:38 +0100 Subject: [PATCH] Cluster test: also write from Lua script in resharding test. --- tests/cluster/tests/04-resharding.tcl | 13 +++++++++++-- tests/support/cluster.tcl | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/cluster/tests/04-resharding.tcl b/tests/cluster/tests/04-resharding.tcl index b9e772351..8811762c6 100644 --- a/tests/cluster/tests/04-resharding.tcl +++ b/tests/cluster/tests/04-resharding.tcl @@ -66,9 +66,18 @@ test "Cluster consistency during live resharding" { } # Write random data to random list. - set key "key:[randomInt $numkeys]" + set listid [randomInt $numkeys] + set key "key:$listid" set ele [randomValue] - $cluster rpush $key $ele + # We write both with Lua scripts and with plain commands. + # This way we are able to stress Lua -> Redis command invocation + # as well, that has tests to prevent Lua to write into wrong + # hash slots. + if {$listid % 2} { + $cluster rpush $key $ele + } else { + $cluster eval {redis.call("rpush",KEYS[1],ARGV[1])} 1 $key $ele + } lappend content($key) $ele if {($j % 1000) == 0} { diff --git a/tests/support/cluster.tcl b/tests/support/cluster.tcl index b007e3b05..d4e7d2e5d 100644 --- a/tests/support/cluster.tcl +++ b/tests/support/cluster.tcl @@ -226,6 +226,8 @@ proc ::redis_cluster::get_keys_from_command {cmd argv} { # Special handling for other commands switch -exact $cmd { mget {return $argv} + eval {return [lrange $argv 2 1+[lindex $argv 1]]} + evalsha {return [lrange $argv 2 1+[lindex $argv 1]]} } # All the remaining commands are not handled.