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.
This commit is contained in:
antirez 2018-08-02 14:14:39 +02:00
parent 2f282aee0b
commit d506334b67

View File

@ -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
}
}