intset stress testing added, ziplist stress testing relocated in a more appropriate place

This commit is contained in:
antirez 2010-09-24 11:15:06 +02:00
parent ef27ba988b
commit 4610b0332c
2 changed files with 95 additions and 50 deletions

View File

@ -604,63 +604,72 @@ start_server {
assert_equal 3 [r llen myotherlist] assert_equal 3 [r llen myotherlist]
} }
test {Explicit regression for a list bug} { }
set mylist {49376042582 {BkG2o\pIC]4YYJa9cJ4GWZalG[4tin;1D2whSkCOW`mX;SFXGyS8sedcff3fQI^tgPCC@^Nu1J6o]meM@Lko]t_jRyo<xSJ1oObDYd`ppZuW6P@fS278YaOx=s6lvdFlMbP0[SbkI^Kr\HBXtuFaA^mDx:yzS4a[skiiPWhT<nNfAf=aQVfclcuwDrfe;iVuKdNvB9kbfq>tK?tH[\EvWqS]b`o2OCtjg:?nUTwdjpcUm]y:pg5q24q7LlCOwQE^}} }
r del l
r rpush l [lindex $mylist 0]
r rpush l [lindex $mylist 1]
assert_equal [r lindex l 0] [lindex $mylist 0]
assert_equal [r lindex l 1] [lindex $mylist 1]
}
tags {slow} { start_server {
test {ziplist implementation: value encoding and backlink} { tags {list ziplist}
for {set j 0} {$j < 100} {incr j} { overrides {
r del l "list-max-ziplist-value" 200000
set l {} "list-max-ziplist-entries" 256
for {set i 0} {$i < 200} {incr i} { }
randpath { } {
set data [string repeat x [randomInt 100000]] test {Explicit regression for a list bug} {
} { set mylist {49376042582 {BkG2o\pIC]4YYJa9cJ4GWZalG[4tin;1D2whSkCOW`mX;SFXGyS8sedcff3fQI^tgPCC@^Nu1J6o]meM@Lko]t_jRyo<xSJ1oObDYd`ppZuW6P@fS278YaOx=s6lvdFlMbP0[SbkI^Kr\HBXtuFaA^mDx:yzS4a[skiiPWhT<nNfAf=aQVfclcuwDrfe;iVuKdNvB9kbfq>tK?tH[\EvWqS]b`o2OCtjg:?nUTwdjpcUm]y:pg5q24q7LlCOwQE^}}
set data [randomInt 65536] r del l
} { r rpush l [lindex $mylist 0]
set data [randomInt 4294967296] r rpush l [lindex $mylist 1]
} { assert_equal [r lindex l 0] [lindex $mylist 0]
set data [randomInt 18446744073709551616] assert_equal [r lindex l 1] [lindex $mylist 1]
} }
lappend l $data
r rpush l $data tags {slow} {
test {ziplist implementation: value encoding and backlink} {
for {set j 0} {$j < 100} {incr j} {
r del l
set l {}
for {set i 0} {$i < 200} {incr i} {
randpath {
set data [string repeat x [randomInt 100000]]
} {
set data [randomInt 65536]
} {
set data [randomInt 4294967296]
} {
set data [randomInt 18446744073709551616]
} }
assert_equal [llength $l] [r llen l] lappend l $data
# Traverse backward r rpush l $data
for {set i 199} {$i >= 0} {incr i -1} { }
if {[lindex $l $i] ne [r lindex l $i]} { assert_equal [llength $l] [r llen l]
assert_equal [lindex $l $i] [r lindex l $i] # Traverse backward
} for {set i 199} {$i >= 0} {incr i -1} {
if {[lindex $l $i] ne [r lindex l $i]} {
assert_equal [lindex $l $i] [r lindex l $i]
} }
} }
} }
}
test {ziplist implementation: encoding stress testing} { test {ziplist implementation: encoding stress testing} {
for {set j 0} {$j < 200} {incr j} { for {set j 0} {$j < 200} {incr j} {
r del l r del l
set l {} set l {}
set len [randomInt 400] set len [randomInt 400]
for {set i 0} {$i < $len} {incr i} { for {set i 0} {$i < $len} {incr i} {
set rv [randomValue] set rv [randomValue]
randpath { randpath {
lappend l $rv lappend l $rv
r rpush l $rv r rpush l $rv
} { } {
set l [concat [list $rv] $l] set l [concat [list $rv] $l]
r lpush l $rv r lpush l $rv
}
} }
assert_equal [llength $l] [r llen l] }
for {set i 0} {$i < 200} {incr i} { assert_equal [llength $l] [r llen l]
if {[lindex $l $i] ne [r lindex l $i]} { for {set i 0} {$i < 200} {incr i} {
assert_equal [lindex $l $i] [r lindex l $i] if {[lindex $l $i] ne [r lindex l $i]} {
} assert_equal [lindex $l $i] [r lindex l $i]
} }
} }
} }

View File

@ -295,4 +295,40 @@ start_server {
r set x 10 r set x 10
assert_error "ERR*wrong kind*" {r smove myset2 x foo} assert_error "ERR*wrong kind*" {r smove myset2 x foo}
} }
tags {slow} {
test {intsets implementation stress testing} {
for {set j 0} {$j < 20} {incr j} {
unset -nocomplain s
array set s {}
r del s
set len [randomInt 1024]
for {set i 0} {$i < $len} {incr i} {
randpath {
set data [randomInt 65536]
} {
set data [randomInt 4294967296]
} {
set data [randomInt 18446744073709551616]
}
set s($data) {}
r sadd s $data
}
assert_equal [lsort [r smembers s]] [lsort [array names s]]
set len [array size s]
for {set i 0} {$i < $len} {incr i} {
set e [r spop s]
if {![info exists s($e)]} {
puts "Can't find '$e' on local array"
puts "Local array: [lsort [r smembers s]]"
puts "Remote array: [lsort [array names s]]"
error "exception"
}
array unset s $e
}
assert_equal [r scard s] 0
assert_equal [array size s] 0
}
}
}
} }