mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Improved regression test for #4906.
Removing the fix about 50% of the times the test will not be able to pass cleanly. It's very hard to write a test that will always fail, or actually, it is possible but then it's likely that it will consistently pass if we change some random bit, so better to use randomization here.
This commit is contained in:
parent
27beaf2f22
commit
00613bed06
@ -238,10 +238,16 @@ start_server {tags {"scan"}} {
|
||||
}
|
||||
|
||||
test "SCAN regression test for issue #4906" {
|
||||
for {set k 0} {$k < 100} {incr k} {
|
||||
r del set
|
||||
r sadd set x; # Make sure it's not intset encoded
|
||||
set toremove {}
|
||||
unset -nocomplain found
|
||||
array set found {}
|
||||
for {set j 0} {$j < 500} {incr j} {
|
||||
|
||||
# Populate the set
|
||||
set numele [expr {100+[randomInt 1000]}]
|
||||
for {set j 0} {$j < $numele} {incr j} {
|
||||
r sadd set $j
|
||||
if {$j >= 100} {
|
||||
lappend toremove $j
|
||||
@ -251,6 +257,7 @@ start_server {tags {"scan"}} {
|
||||
# Start scanning
|
||||
set cursor 0
|
||||
set iteration 0
|
||||
set del_iteration [randomInt 10]
|
||||
while {!($cursor == 0 && $iteration != 0)} {
|
||||
lassign [r sscan set $cursor] cursor items
|
||||
|
||||
@ -262,7 +269,7 @@ start_server {tags {"scan"}} {
|
||||
incr iteration
|
||||
# At some point remove most of the items to trigger the
|
||||
# rehashing to a smaller hash table.
|
||||
if {$iteration == 1} {
|
||||
if {$iteration == $del_iteration} {
|
||||
r srem set {*}$toremove
|
||||
}
|
||||
}
|
||||
@ -274,4 +281,5 @@ start_server {tags {"scan"}} {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user