|
1 | | -# Check the basic monitoring and failover capabilities. |
| 1 | +# Check the manual failover |
2 | 2 |
|
3 | 3 | source "../tests/includes/init-tests.tcl" |
4 | 4 |
|
@@ -93,3 +93,95 @@ test "Instance #0 gets converted into a slave" { |
93 | 93 | fail "Old master was not converted into slave" |
94 | 94 | } |
95 | 95 | } |
| 96 | + |
| 97 | +## Check that manual failover does not happen if we can't talk with the master. |
| 98 | + |
| 99 | +source "../tests/includes/init-tests.tcl" |
| 100 | + |
| 101 | +test "Create a 5 nodes cluster" { |
| 102 | + create_cluster 5 5 |
| 103 | +} |
| 104 | + |
| 105 | +test "Cluster is up" { |
| 106 | + assert_cluster_state ok |
| 107 | +} |
| 108 | + |
| 109 | +test "Cluster is writable" { |
| 110 | + cluster_write_test 0 |
| 111 | +} |
| 112 | + |
| 113 | +test "Instance #5 is a slave" { |
| 114 | + assert {[RI 5 role] eq {slave}} |
| 115 | +} |
| 116 | + |
| 117 | +test "Instance #5 synced with the master" { |
| 118 | + wait_for_condition 1000 50 { |
| 119 | + [RI 5 master_link_status] eq {up} |
| 120 | + } else { |
| 121 | + fail "Instance #5 master link status is not up" |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | +test "Make instance #0 unreachable without killing it" { |
| 126 | + R 0 deferred 1 |
| 127 | + R 0 DEBUG SLEEP 10 |
| 128 | +} |
| 129 | + |
| 130 | +test "Send CLUSTER FAILOVER to instance #5" { |
| 131 | + R 5 cluster failover |
| 132 | +} |
| 133 | + |
| 134 | +test "Instance #5 is still a slave after some time (no failover)" { |
| 135 | + after 5000 |
| 136 | + assert {[RI 5 role] eq {master}} |
| 137 | +} |
| 138 | + |
| 139 | +test "Wait for instance #0 to return back alive" { |
| 140 | + R 0 deferred 0 |
| 141 | + assert {[R 0 read] eq {OK}} |
| 142 | +} |
| 143 | + |
| 144 | +## Check with "force" failover happens anyway. |
| 145 | + |
| 146 | +source "../tests/includes/init-tests.tcl" |
| 147 | + |
| 148 | +test "Create a 5 nodes cluster" { |
| 149 | + create_cluster 5 5 |
| 150 | +} |
| 151 | + |
| 152 | +test "Cluster is up" { |
| 153 | + assert_cluster_state ok |
| 154 | +} |
| 155 | + |
| 156 | +test "Cluster is writable" { |
| 157 | + cluster_write_test 0 |
| 158 | +} |
| 159 | + |
| 160 | +test "Instance #5 is a slave" { |
| 161 | + assert {[RI 5 role] eq {slave}} |
| 162 | +} |
| 163 | + |
| 164 | +test "Instance #5 synced with the master" { |
| 165 | + wait_for_condition 1000 50 { |
| 166 | + [RI 5 master_link_status] eq {up} |
| 167 | + } else { |
| 168 | + fail "Instance #5 master link status is not up" |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +test "Make instance #0 unreachable without killing it" { |
| 173 | + R 0 deferred 1 |
| 174 | + R 0 DEBUG SLEEP 10 |
| 175 | +} |
| 176 | + |
| 177 | +test "Send CLUSTER FAILOVER to instance #5" { |
| 178 | + R 5 cluster failover force |
| 179 | +} |
| 180 | + |
| 181 | +test "Instance #5 is a master after some time" { |
| 182 | + wait_for_condition 1000 50 { |
| 183 | + [RI 5 role] eq {master} |
| 184 | + } else { |
| 185 | + fail "Instance #5 is not a master after some time regardless of FORCE" |
| 186 | + } |
| 187 | +} |
0 commit comments