]>
Commit | Line | Data |
---|---|---|
8b654e54 | 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 | ||
c1c9d551 | 9 | test {BRPOPLPUSH replication, when blocking against empty list} { |
10 | set rd [redis_deferring_client] | |
11 | $rd brpoplpush a b 5 | |
12 | r lpush a foo | |
13 | after 1000 | |
14 | assert_equal [r debug digest] [r -1 debug digest] | |
15 | } | |
16 | ||
17 | test {BRPOPLPUSH replication, list exists} { | |
18 | set rd [redis_deferring_client] | |
19 | r lpush c 1 | |
20 | r lpush c 2 | |
21 | r lpush c 3 | |
22 | $rd brpoplpush c d 5 | |
23 | after 1000 | |
24 | assert_equal [r debug digest] [r -1 debug digest] | |
25 | } | |
26 | ||
8b654e54 | 27 | test {MASTER and SLAVE dataset should be identical after complex ops} { |
28 | createComplexDataset r 10000 | |
a0573260 | 29 | after 500 |
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" | |
6146329f | 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 | test {MASTER and SLAVE consistency with expire} { | |
46 | createComplexDataset r 50000 useexpire | |
47 | after 4000 ;# Make sure everything expired before taking the digest | |
70bc5f77 | 48 | r keys * ;# Force DEL syntesizing to slave |
27fee630 | 49 | after 1000 ;# Wait another second. Now everything should be fine. |
6146329f | 50 | if {[r debug digest] ne [r -1 debug digest]} { |
51 | set csv1 [csvdump r] | |
52 | set csv2 [csvdump {r -1}] | |
53 | set fd [open /tmp/repldump1.txt w] | |
54 | puts -nonewline $fd $csv1 | |
55 | close $fd | |
56 | set fd [open /tmp/repldump2.txt w] | |
57 | puts -nonewline $fd $csv2 | |
58 | close $fd | |
59 | puts "Master - Slave inconsistency" | |
a0573260 | 60 | puts "Run diff -u against /tmp/repldump*.txt for more info" |
61 | } | |
8b654e54 | 62 | assert_equal [r debug digest] [r -1 debug digest] |
63 | } | |
64 | } | |
65 | } | |
66 | ||
7f7499ee | 67 | start_server {tags {"repl"}} { |
85ecc65e PN |
68 | r set mykey foo |
69 | ||
9e5d2e8b | 70 | start_server {} { |
85ecc65e PN |
71 | test {Second server should have role master at first} { |
72 | s role | |
73 | } {master} | |
74 | ||
75 | test {SLAVEOF should start with link status "down"} { | |
76 | r slaveof [srv -1 host] [srv -1 port] | |
77 | s master_link_status | |
78 | } {down} | |
79 | ||
80 | test {The role should immediately be changed to "slave"} { | |
81 | s role | |
82 | } {slave} | |
83 | ||
84 | wait_for_sync r | |
85 | test {Sync should have transferred keys from master} { | |
86 | r get mykey | |
87 | } {foo} | |
88 | ||
89 | test {The link status should be up} { | |
90 | s master_link_status | |
91 | } {up} | |
92 | ||
93 | test {SET on the master should immediately propagate} { | |
94 | r -1 set mykey bar | |
95 | r 0 get mykey | |
96 | } {bar} | |
97 | } | |
98 | } |