]> git.saurik.com Git - redis.git/commitdiff
replication test split into three parts in order to improve test execution time....
authorantirez <antirez@gmail.com>
Sun, 10 Jul 2011 22:46:25 +0000 (00:46 +0200)
committerantirez <antirez@gmail.com>
Sun, 10 Jul 2011 22:46:25 +0000 (00:46 +0200)
tests/integration/replication-2.tcl [new file with mode: 0644]
tests/integration/replication-3.tcl [new file with mode: 0644]
tests/integration/replication.tcl
tests/test_helper.tcl

diff --git a/tests/integration/replication-2.tcl b/tests/integration/replication-2.tcl
new file mode 100644 (file)
index 0000000..5450bdd
--- /dev/null
@@ -0,0 +1,27 @@
+start_server {tags {"repl"}} {
+    start_server {} {
+        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 {MASTER and SLAVE dataset should be identical after complex ops} {
+            createComplexDataset r 10000
+            after 500
+            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]
+        }
+    }
+}
diff --git a/tests/integration/replication-3.tcl b/tests/integration/replication-3.tcl
new file mode 100644 (file)
index 0000000..80140f2
--- /dev/null
@@ -0,0 +1,29 @@
+start_server {tags {"repl"}} {
+    start_server {} {
+        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 {MASTER and SLAVE consistency with expire} {
+            createComplexDataset r 50000 useexpire
+            after 4000 ;# Make sure everything expired before taking the digest
+            r keys *   ;# Force DEL syntesizing to slave
+            after 1000 ;# Wait another second. Now everything should be fine.
+            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 227356b24de6399f928e305058f942728d46e2e6..4756b82c83fab4b78fbfc539bd2ff6401d2b66e6 100644 (file)
@@ -23,44 +23,6 @@ start_server {tags {"repl"}} {
             after 1000
             assert_equal [r debug digest] [r -1 debug digest]
         }
-
-        test {MASTER and SLAVE dataset should be identical after complex ops} {
-            createComplexDataset r 10000
-            after 500
-            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]
-        }
-
-        test {MASTER and SLAVE consistency with expire} {
-            createComplexDataset r 50000 useexpire
-            after 4000 ;# Make sure everything expired before taking the digest
-            r keys *   ;# Force DEL syntesizing to slave
-            after 1000 ;# Wait another second. Now everything should be fine.
-            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 2bb18bc9ee14abb7bf74f8c925d32975a6b29ba1..f96b68c619c1da1a8423f176870c126ce663d23d 100644 (file)
@@ -24,6 +24,8 @@ set ::all_tests {
     unit/cas
     unit/quit
     integration/replication
+    integration/replication-2
+    integration/replication-3
     integration/aof
     unit/pubsub
     unit/slowlog
@@ -166,9 +168,11 @@ proc test_server_main {} {
     }
 
     # Start the client instances
+    set ::clients_pids {}
     for {set j 0} {$j < $::numclients} {incr j} {
-        exec tclsh8.5 [info script] {*}$::argv \
-            --client $port --port [expr {$::port+($j*10)}] &
+        set p [exec tclsh8.5 [info script] {*}$::argv \
+            --client $port --port [expr {$::port+($j*10)}] &]
+        lappend ::clients_pids $p
     }
 
     # Setup global state for the test server
@@ -215,13 +219,19 @@ proc read_from_test_client fd {
     } elseif {$status eq {done}} {
         set elapsed [expr {[clock seconds]-$::clients_start_time($fd)}]
         puts "\[[colorstr yellow $status]\]: $data ($elapsed seconds)"
-        puts "+++ [llength $::active_clients] units still in execution."
+        puts "+++ [expr {[llength $::active_clients]-1}] units still in execution."
         lappend ::clients_time_history $elapsed $data
         signal_idle_client $fd
     } elseif {$status eq {ok}} {
         puts "\[[colorstr green $status]\]: $data"
     } elseif {$status eq {err}} {
         puts "\[[colorstr red $status]\]: $data"
+    } elseif {$status eq {exception}} {
+        puts "\[[colorstr red $status]\]: $data"
+        foreach p $::clients_pids {
+            catch {exec kill -9 $p}
+        }
+        exit 1
     } else {
         puts "\[$status\]: $data"
     }