Streams: modify tests to stress compression.

This commit is contained in:
antirez 2017-09-27 23:04:31 +02:00
parent 3f2d7e277e
commit 7d0d9693c1

View File

@ -83,13 +83,19 @@ start_server {
r DEL mystream r DEL mystream
r multi r multi
for {set j 0} {$j < 10000} {incr j} { for {set j 0} {$j < 10000} {incr j} {
r XADD mystream * item $j # From time to time insert a field with a different set
# of fields in order to stress the stream compression code.
if {rand() < 0.9} {
r XADD mystream * item $j
} else {
r XADD mystream * item $j otherfield foo
}
} }
r exec r exec
set items [r XRANGE mystream - +] set items [r XRANGE mystream - +]
for {set j 0} {$j < 10000} {incr j} { for {set j 0} {$j < 10000} {incr j} {
assert {[lindex $items $j 1] eq [list item $j]} assert {[lrange [lindex $items $j 1] 0 1] eq [list item $j]}
} }
assert {[r xlen mystream] == $j} assert {[r xlen mystream] == $j}
} }
@ -105,7 +111,7 @@ start_server {
set elements [r xrange mystream $last_id + COUNT 100] set elements [r xrange mystream $last_id + COUNT 100]
if {[llength $elements] == 0} break if {[llength $elements] == 0} break
foreach e $elements { foreach e $elements {
assert {[lindex $e 1] eq [list item $j]} assert {[lrange [lindex $e 1] 0 1] eq [list item $j]}
incr j; incr j;
} }
set last_id [streamNextID [lindex $elements end 0]] set last_id [streamNextID [lindex $elements end 0]]
@ -115,7 +121,7 @@ start_server {
test {XREAD with non empty stream} { test {XREAD with non empty stream} {
set res [r XREAD COUNT 1 STREAMS mystream 0.0] set res [r XREAD COUNT 1 STREAMS mystream 0.0]
assert {[lindex $res 0 1 0 1] eq {item 0}} assert {[lrange [lindex $res 0 1 0 1] 0 1] eq {item 0}}
} }
test {Non blocking XREAD with empty streams} { test {Non blocking XREAD with empty streams} {
@ -204,7 +210,6 @@ start_server {
} }
test {XRANGE fuzzing} { test {XRANGE fuzzing} {
# puts $items
set low_id [lindex $items 0 0] set low_id [lindex $items 0 0]
set high_id [lindex $items end 0] set high_id [lindex $items end 0]
for {set j 0} {$j < 100} {incr j} { for {set j 0} {$j < 100} {incr j} {