]> git.saurik.com Git - redis.git/blob - tests/integration/replication.tcl
Fixed a memory leak in redis-cli.c
[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 {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 }
27 }
28
29 start_server {tags {"repl"}} {
30 r set mykey foo
31
32 start_server {} {
33 test {Second server should have role master at first} {
34 s role
35 } {master}
36
37 test {SLAVEOF should start with link status "down"} {
38 r slaveof [srv -1 host] [srv -1 port]
39 s master_link_status
40 } {down}
41
42 test {The role should immediately be changed to "slave"} {
43 s role
44 } {slave}
45
46 wait_for_sync r
47 test {Sync should have transferred keys from master} {
48 r get mykey
49 } {foo}
50
51 test {The link status should be up} {
52 s master_link_status
53 } {up}
54
55 test {SET on the master should immediately propagate} {
56 r -1 set mykey bar
57 if {$::valgrind} {after 2000}
58 r 0 get mykey
59 } {bar}
60
61 test {FLUSHALL should replicate} {
62 r -1 flushall
63 if {$::valgrind} {after 2000}
64 list [r -1 dbsize] [r 0 dbsize]
65 } {0 0}
66 }
67 }