-
Notifications
You must be signed in to change notification settings - Fork 500
/
replica-redirect.tcl
36 lines (30 loc) · 1.1 KB
/
replica-redirect.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
start_server {tags {needs:repl external:skip}} {
start_server {} {
set master_host [srv -1 host]
set master_port [srv -1 port]
r replicaof $master_host $master_port
wait_for_condition 50 100 {
[s 0 master_link_status] eq {up}
} else {
fail "Replicas not replicating from master"
}
test {replica allow read command by default} {
r get foo
} {}
test {replica reply READONLY error for write command by default} {
assert_error {READONLY*} {r set foo bar}
}
test {replica redirect read and write command when enable replica-enable-redirect} {
r config set replica-enable-redirect yes
assert_error "REDIRECT $master_host:$master_port" {r set foo bar}
assert_error "REDIRECT $master_host:$master_port" {r get foo}
}
test {non-data access commands are not redirected} {
r ping
} {PONG}
test {replica allow read command in READONLY mode} {
r readonly
r get foo
} {}
}
}