]> git.saurik.com Git - redis.git/blame - tests/integration/replication.tcl
replication with expire test modified to produce no or less false failures
[redis.git] / tests / integration / replication.tcl
CommitLineData
8b654e54 1start_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
a0573260 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"
6146329f 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
70bc5f77 30 r keys * ;# Force DEL syntesizing to slave
31 after 1000 ;# Wait another second. Now everything should be file.
6146329f 32 if {[r debug digest] ne [r -1 debug digest]} {
33 set csv1 [csvdump r]
34 set csv2 [csvdump {r -1}]
35 set fd [open /tmp/repldump1.txt w]
36 puts -nonewline $fd $csv1
37 close $fd
38 set fd [open /tmp/repldump2.txt w]
39 puts -nonewline $fd $csv2
40 close $fd
41 puts "Master - Slave inconsistency"
a0573260 42 puts "Run diff -u against /tmp/repldump*.txt for more info"
43 }
8b654e54 44 assert_equal [r debug digest] [r -1 debug digest]
45 }
46 }
47}
48
7f7499ee 49start_server {tags {"repl"}} {
85ecc65e
PN
50 r set mykey foo
51
9e5d2e8b 52 start_server {} {
85ecc65e
PN
53 test {Second server should have role master at first} {
54 s role
55 } {master}
56
57 test {SLAVEOF should start with link status "down"} {
58 r slaveof [srv -1 host] [srv -1 port]
59 s master_link_status
60 } {down}
61
62 test {The role should immediately be changed to "slave"} {
63 s role
64 } {slave}
65
66 wait_for_sync r
67 test {Sync should have transferred keys from master} {
68 r get mykey
69 } {foo}
70
71 test {The link status should be up} {
72 s master_link_status
73 } {up}
74
75 test {SET on the master should immediately propagate} {
76 r -1 set mykey bar
77 r 0 get mykey
78 } {bar}
79 }
80}