Regression test for issue 417 (memory leak when replicating to DB with id >= 10)

This commit is contained in:
antirez 2012-03-30 10:26:07 +02:00
parent 4cba71e898
commit 22c9c4076b
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,10 @@
source tests/support/redis.tcl
source tests/support/util.tcl
proc bg_complex_data {host port db ops} {
set r [redis $host $port]
$r select $db
createComplexDataset $r $ops
}
bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3]

View File

@ -0,0 +1,54 @@
proc start_bg_complex_data {host port db ops} {
exec tclsh8.5 tests/helpers/bg_complex_data.tcl $host $port $db $ops &
}
proc stop_bg_complex_data {handle} {
catch {exec /bin/kill -9 $handle}
}
start_server {tags {"repl"}} {
start_server {} {
set master [srv 0 client]
set master_host [srv 0 host]
set master_port [srv 0 port]
set load_handle0 [start_bg_complex_data $master_host $master_port 9 100000]
set load_handle1 [start_bg_complex_data $master_host $master_port 11 100000]
set load_handle2 [start_bg_complex_data $master_host $master_port 12 100000]
test {First server should have role slave after SLAVEOF} {
r -1 slaveof [srv 0 host] [srv 0 port]
after 1000
s -1 role
} {slave}
test {Test replication with parallel clients writing in differnet DBs} {
lappend slave [srv 0 client]
after 5000
stop_bg_complex_data $load_handle0
stop_bg_complex_data $load_handle1
stop_bg_complex_data $load_handle2
set retry 10
while {$retry && ([$master debug digest] ne [$slave debug digest])}\
{
after 1000
incr retry -1
}
assert {[$master dbsize] > 0}
if {[r debug digest] ne [r -1 debug digest]} {
set csv1 [csvdump r]
set csv2 [csvdump {r -1}]
set fd [open /tmp/repldump1.txt w]
puts -nonewline $fd $csv1
close $fd
set fd [open /tmp/repldump2.txt w]
puts -nonewline $fd $csv2
close $fd
puts "Master - Slave inconsistency"
puts "Run diff -u against /tmp/repldump*.txt for more info"
}
assert_equal [r debug digest] [r -1 debug digest]
}
}
}

View File

@ -29,6 +29,7 @@ set ::all_tests {
integration/replication
integration/replication-2
integration/replication-3
integration/replication-4
integration/aof
integration/rdb
integration/convert-zipmap-hash-on-load