summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-08-02 14:14:39 +0200
committerantirez <antirez@gmail.com>2018-08-02 18:34:34 +0200
commit70c4bcb7bc008213b823afcc5bad70c00694f7d5 (patch)
treeb0f1da52bd8a0a02368101e0c77f57126f4bb8a0 /tests
parent63addc5c1e39de160ae457c2566c779a55406641 (diff)
downloadredis-70c4bcb7bc008213b823afcc5bad70c00694f7d5.tar.gz
Test: new sorted set skiplist order consistency.
This should be able to find new bugs and regressions about the new sorted set update function when ZADD is used to update an element already existing. The test is able to find the bug fixed at 2f282aee immediately.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/type/zset.tcl26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl
index bebba96d9..cf54ae839 100644
--- a/tests/unit/type/zset.tcl
+++ b/tests/unit/type/zset.tcl
@@ -1185,4 +1185,30 @@ start_server {tags {"zset"}} {
stressers ziplist
stressers skiplist
}
+
+ test {ZSET skiplist order consistency when elements are moved} {
+ set original_max [lindex [r config get zset-max-ziplist-entries] 1]
+ r config set zset-max-ziplist-entries 0
+ for {set times 0} {$times < 10} {incr times} {
+ r del zset
+ for {set j 0} {$j < 1000} {incr j} {
+ r zadd zset [randomInt 50] ele-[randomInt 10]
+ }
+
+ # Make sure that element ordering is correct
+ set prev_element {}
+ set prev_score -1
+ foreach {element score} [r zrange zset 0 -1 WITHSCORES] {
+ # Assert that elements are in increasing ordering
+ assert {
+ $prev_score < $score ||
+ ($prev_score == $score &&
+ [string compare $prev_element $element] == -1)
+ }
+ set prev_element $element
+ set prev_score $score
+ }
+ }
+ r config set zset-max-ziplist-entries $original_max
+ }
}