]> git.saurik.com Git - redis.git/blob - tests/integration/replication.tcl
replication asynchronous SYNC information in INFO output
[redis.git] / tests / integration / replication.tcl
1 start_server {tags {"repl"}} {
2 start_server {} {
3 test {First server should have role slave after SLAVEOF} {
4 r -1 slaveof [srv 0 host] [srv 0 port]
5 after 1000
6 s -1 role
7 } {slave}
8
9 test {MASTER and SLAVE dataset should be identical after complex ops} {
10 createComplexDataset r 10000
11 after 500
12 if {[r debug digest] ne [r -1 debug digest]} {
13 set csv1 [csvdump r]
14 set csv2 [csvdump {r -1}]
15 set fd [open /tmp/repldump1.txt w]
16 puts -nonewline $fd $csv1
17 close $fd
18 set fd [open /tmp/repldump2.txt w]
19 puts -nonewline $fd $csv2
20 close $fd
21 puts "Master - Slave inconsistency"
22 puts "Run diff -u against /tmp/repldump*.txt for more info"
23 }
24 assert_equal [r debug digest] [r -1 debug digest]
25 }
26
27 test {MASTER and SLAVE consistency with expire} {
28 createComplexDataset r 50000 useexpire
29 after 4000 ;# Make sure everything expired before taking the digest
30 if {[r debug digest] ne [r -1 debug digest]} {
31 set csv1 [csvdump r]
32 set csv2 [csvdump {r -1}]
33 set fd [open /tmp/repldump1.txt w]
34 puts -nonewline $fd $csv1
35 close $fd
36 set fd [open /tmp/repldump2.txt w]
37 puts -nonewline $fd $csv2
38 close $fd
39 puts "Master - Slave inconsistency"
40 puts "Run diff -u against /tmp/repldump*.txt for more info"
41 }
42 assert_equal [r debug digest] [r -1 debug digest]
43 }
44 }
45 }
46
47 start_server {tags {"repl"}} {
48 r set mykey foo
49
50 start_server {} {
51 test {Second server should have role master at first} {
52 s role
53 } {master}
54
55 test {SLAVEOF should start with link status "down"} {
56 r slaveof [srv -1 host] [srv -1 port]
57 s master_link_status
58 } {down}
59
60 test {The role should immediately be changed to "slave"} {
61 s role
62 } {slave}
63
64 wait_for_sync r
65 test {Sync should have transferred keys from master} {
66 r get mykey
67 } {foo}
68
69 test {The link status should be up} {
70 s master_link_status
71 } {up}
72
73 test {SET on the master should immediately propagate} {
74 r -1 set mykey bar
75 r 0 get mykey
76 } {bar}
77 }
78 }