From: antirez Date: Sun, 10 Jul 2011 22:46:25 +0000 (+0200) Subject: replication test split into three parts in order to improve test execution time.... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/569f84aa7cda1d47a27738906b1707741151521d?ds=inline replication test split into three parts in order to improve test execution time. Random fixes and improvements. --- diff --git a/tests/integration/replication-2.tcl b/tests/integration/replication-2.tcl new file mode 100644 index 00000000..5450bdd8 --- /dev/null +++ b/tests/integration/replication-2.tcl @@ -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 index 00000000..80140f20 --- /dev/null +++ b/tests/integration/replication-3.tcl @@ -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] + } + } +} diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl index 227356b2..4756b82c 100644 --- a/tests/integration/replication.tcl +++ b/tests/integration/replication.tcl @@ -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] - } } } diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 2bb18bc9..f96b68c6 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -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" }