]> git.saurik.com Git - redis.git/blob - tests/integration/replication-4.tcl
Merge pull request #494 from quiver/init-fixes
[redis.git] / tests / integration / replication-4.tcl
1 proc start_bg_complex_data {host port db ops} {
2 exec tclsh8.5 tests/helpers/bg_complex_data.tcl $host $port $db $ops &
3 }
4
5 proc stop_bg_complex_data {handle} {
6 catch {exec /bin/kill -9 $handle}
7 }
8
9 start_server {tags {"repl"}} {
10 start_server {} {
11
12 set master [srv 0 client]
13 set master_host [srv 0 host]
14 set master_port [srv 0 port]
15 set load_handle0 [start_bg_complex_data $master_host $master_port 9 100000]
16 set load_handle1 [start_bg_complex_data $master_host $master_port 11 100000]
17 set load_handle2 [start_bg_complex_data $master_host $master_port 12 100000]
18
19 test {First server should have role slave after SLAVEOF} {
20 r -1 slaveof [srv 0 host] [srv 0 port]
21 after 1000
22 s -1 role
23 } {slave}
24
25 test {Test replication with parallel clients writing in differnet DBs} {
26 lappend slave [srv 0 client]
27 after 5000
28 stop_bg_complex_data $load_handle0
29 stop_bg_complex_data $load_handle1
30 stop_bg_complex_data $load_handle2
31 set retry 10
32 while {$retry && ([$master debug digest] ne [$slave debug digest])}\
33 {
34 after 1000
35 incr retry -1
36 }
37 assert {[$master dbsize] > 0}
38
39 if {[r debug digest] ne [r -1 debug digest]} {
40 set csv1 [csvdump r]
41 set csv2 [csvdump {r -1}]
42 set fd [open /tmp/repldump1.txt w]
43 puts -nonewline $fd $csv1
44 close $fd
45 set fd [open /tmp/repldump2.txt w]
46 puts -nonewline $fd $csv2
47 close $fd
48 puts "Master - Slave inconsistency"
49 puts "Run diff -u against /tmp/repldump*.txt for more info"
50 }
51 assert_equal [r debug digest] [r -1 debug digest]
52 }
53 }
54 }