2014-05-23 11:47:47 +02:00
|
|
|
# Check the basic monitoring and failover capabilities.
|
|
|
|
|
|
|
|
source "../tests/includes/init-tests.tcl"
|
|
|
|
|
|
|
|
test "Create a 5 nodes cluster" {
|
|
|
|
create_cluster 5 5
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is up" {
|
|
|
|
assert_cluster_state ok
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is writable" {
|
|
|
|
cluster_write_test 0
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #5 is a slave" {
|
|
|
|
assert {[RI 5 role] eq {slave}}
|
|
|
|
}
|
|
|
|
|
2014-06-10 15:00:39 +02:00
|
|
|
test "Instance #5 synced with the master" {
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[RI 5 master_link_status] eq {up}
|
|
|
|
} else {
|
|
|
|
fail "Instance #5 master link status is not up"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-10 14:18:54 +02:00
|
|
|
set current_epoch [CI 1 cluster_current_epoch]
|
|
|
|
|
2014-05-23 11:47:47 +02:00
|
|
|
test "Killing one master node" {
|
|
|
|
kill_instance redis 0
|
|
|
|
}
|
|
|
|
|
2014-06-10 14:18:54 +02:00
|
|
|
test "Wait for failover" {
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[CI 1 cluster_current_epoch] > $current_epoch
|
|
|
|
} else {
|
|
|
|
fail "No failover detected"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 11:47:47 +02:00
|
|
|
test "Cluster should eventually be up again" {
|
|
|
|
assert_cluster_state ok
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is writable" {
|
|
|
|
cluster_write_test 1
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #5 is now a master" {
|
|
|
|
assert {[RI 5 role] eq {master}}
|
|
|
|
}
|
2014-06-10 13:54:38 +02:00
|
|
|
|
|
|
|
test "Restarting the previously killed master node" {
|
|
|
|
restart_instance redis 0
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #0 gets converted into a slave" {
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[RI 0 role] eq {slave}
|
|
|
|
} else {
|
|
|
|
fail "Old master was not converted into slave"
|
|
|
|
}
|
|
|
|
}
|