Skip to content

Commit

Permalink
Regression test for issue 417 (memory leak when replicating to DB wit…
Browse files Browse the repository at this point in the history
…h id >= 10)
  • Loading branch information
antirez committed Mar 30, 2012
1 parent 4cba71e commit 22c9c40
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/helpers/bg_complex_data.tcl
Original file line number Diff line number Diff line change
@@ -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]
54 changes: 54 additions & 0 deletions tests/integration/replication-4.tcl
Original file line number Diff line number Diff line change
@@ -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]
}
}
}
1 change: 1 addition & 0 deletions tests/test_helper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22c9c40

Please sign in to comment.