]> git.saurik.com Git - redis.git/commitdiff
Regression test for issue 417 (memory leak when replicating to DB with id >= 10)
authorantirez <antirez@gmail.com>
Fri, 30 Mar 2012 08:26:07 +0000 (10:26 +0200)
committerantirez <antirez@gmail.com>
Fri, 30 Mar 2012 08:39:56 +0000 (10:39 +0200)
tests/helpers/bg_complex_data.tcl [new file with mode: 0644]
tests/integration/replication-4.tcl [new file with mode: 0644]
tests/test_helper.tcl

diff --git a/tests/helpers/bg_complex_data.tcl b/tests/helpers/bg_complex_data.tcl
new file mode 100644 (file)
index 0000000..dffd7c6
--- /dev/null
@@ -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]
diff --git a/tests/integration/replication-4.tcl b/tests/integration/replication-4.tcl
new file mode 100644 (file)
index 0000000..69fcab3
--- /dev/null
@@ -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]
+        }
+    }
+}
index bef8231a71a0d020bd2cc5fabb3887ed3fe976bf..7978d8a4dee28639caaa763ddb30bcc0c35a8c40 100644 (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