1# Check that the no-failover option works
2
3source "../tests/includes/init-tests.tcl"
4
5test "Create a 5 nodes cluster" {
6    create_cluster 5 5
7}
8
9test "Cluster is up" {
10    assert_cluster_state ok
11}
12
13test "Cluster is writable" {
14    cluster_write_test 0
15}
16
17test "Instance #5 is a slave" {
18    assert {[RI 5 role] eq {slave}}
19
20    # Configure it to never failover the master
21    R 5 CONFIG SET cluster-slave-no-failover yes
22}
23
24test "Instance #5 synced with the master" {
25    wait_for_condition 1000 50 {
26        [RI 5 master_link_status] eq {up}
27    } else {
28        fail "Instance #5 master link status is not up"
29    }
30}
31
32test "The nofailover flag is propagated" {
33    set slave5_id [dict get [get_myself 5] id]
34
35    foreach_redis_id id {
36        wait_for_condition 1000 50 {
37            [has_flag [get_node_by_id $id $slave5_id] nofailover]
38        } else {
39            fail "Instance $id can't see the nofailover flag of slave"
40        }
41    }
42}
43
44set current_epoch [CI 1 cluster_current_epoch]
45
46test "Killing one master node" {
47    kill_instance redis 0
48}
49
50test "Cluster should be still down after some time" {
51    after 10000
52    assert_cluster_state fail
53}
54
55test "Instance #5 is still a slave" {
56    assert {[RI 5 role] eq {slave}}
57}
58
59test "Restarting the previously killed master node" {
60    restart_instance redis 0
61}
62