diff options
author | antirez <antirez@gmail.com> | 2018-08-02 14:14:39 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-08-02 14:15:53 +0200 |
commit | d506334b678ea1f0ad2f28b1144365ac7751999a (patch) | |
tree | 7c4d445b269febf75d7f8bfd56498e4d4cefc800 /tests/unit | |
parent | 2f282aee0b8e500697b627254b170f21d93dd4a8 (diff) | |
download | redis-d506334b678ea1f0ad2f28b1144365ac7751999a.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/unit')
-rw-r--r-- | tests/unit/type/zset.tcl | 26 |
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 + } } |