summaryrefslogtreecommitdiff
path: root/tests/integration/aof.tcl
diff options
context:
space:
mode:
authorAlon Diamant <diamant.alon@gmail.com>2014-03-11 15:38:55 +0100
committerAlon Diamant <alon@everything.me>2014-12-14 12:25:42 +0200
commit288028876f4428edfc044d8a1f1d6784b0dbe739 (patch)
treed5e4e55d9f639f2ab4dea25afb92b16e88618f3f /tests/integration/aof.tcl
parentc147cd848760c44791d73b03dbe2a4b8aa5b8c8e (diff)
downloadredis-288028876f4428edfc044d8a1f1d6784b0dbe739.tar.gz
Added <count> parameter to SPOP:
spopCommand() now runs spopWithCountCommand() in case the <count> param is found. Added intsetRandomMembers() to Intset: Copies N random members from the set into inputted 'values' array. Uses either the Knuth or Floyd sample algos depending on ratio count/size. Added setTypeRandomElements() to SET type: Returns a number of random elements from a non empty set. This is a version of setTypeRandomElement() that is modified in order to return multiple entries, using dictGetRandomKeys() and intsetRandomMembers(). Added tests for SPOP with <count>: unit/type/set, unit/scripting, integration/aof -- Cleaned up code a bit to match with required Redis coding style
Diffstat (limited to 'tests/integration/aof.tcl')
-rw-r--r--tests/integration/aof.tcl24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl
index 7ea70943c..01b928bb5 100644
--- a/tests/integration/aof.tcl
+++ b/tests/integration/aof.tcl
@@ -204,6 +204,30 @@ tags {"aof"} {
}
}
+ ## Test that SPOP with <count> (that modifies the client's argc/argv) is correctly free'd
+ create_aof {
+ append_to_aof [formatCommand sadd set foo]
+ append_to_aof [formatCommand sadd set bar]
+ append_to_aof [formatCommand sadd set gah]
+ append_to_aof [formatCommand spop set 2]
+ }
+
+ start_server_aof [list dir $server_path] {
+ test "AOF+SPOP: Server should have been started" {
+ assert_equal 1 [is_alive $srv]
+ }
+
+ test "AOF+SPOP: Set should have 1 member" {
+ set client [redis [dict get $srv host] [dict get $srv port]]
+ wait_for_condition 50 100 {
+ [catch {$client ping} e] == 0
+ } else {
+ fail "Loading DB is taking too much time."
+ }
+ assert_equal 1 [$client scard set]
+ }
+ }
+
## Test that EXPIREAT is loaded correctly
create_aof {
append_to_aof [formatCommand rpush list foo]