Permalink
Browse files

Regression test for issue 417 (memory leak when replicating to DB wit…

…h id >= 10)
  • Loading branch information...
1 parent f1e38b3 commit 0f51e3c5640c2f5be2766f10660f668bc71c7dd9 @antirez committed Mar 30, 2012
Showing with 65 additions and 0 deletions.
  1. +10 −0 tests/helpers/bg_complex_data.tcl
  2. +54 −0 tests/integration/replication-4.tcl
  3. +1 −0 tests/test_helper.tcl
@@ -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]
@@ -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]
+ }
+ }
+}
@@ -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

0 comments on commit 0f51e3c

Please sign in to comment.