2014-05-23 11:47:47 +02:00
|
|
|
# Check the basic monitoring and failover capabilities.
|
|
|
|
|
2024-05-09 10:14:47 +08:00
|
|
|
start_cluster 5 5 {tags {external:skip cluster}} {
|
2014-05-23 11:47:47 +02:00
|
|
|
|
|
|
|
test "Cluster is up" {
|
2024-05-09 10:14:47 +08:00
|
|
|
wait_for_cluster_state ok
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is writable" {
|
2024-05-09 10:14:47 +08:00
|
|
|
cluster_write_test [srv 0 port]
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #5 is a slave" {
|
2024-05-09 10:14:47 +08:00
|
|
|
assert {[s -5 role] eq {slave}}
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
2014-06-10 15:00:39 +02:00
|
|
|
test "Instance #5 synced with the master" {
|
|
|
|
wait_for_condition 1000 50 {
|
2024-05-09 10:14:47 +08:00
|
|
|
[s -5 master_link_status] eq {up}
|
2014-06-10 15:00:39 +02:00
|
|
|
} 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]
|
|
|
|
|
2024-05-09 10:14:47 +08:00
|
|
|
set paused_pid [srv 0 pid]
|
2014-05-23 11:47:47 +02:00
|
|
|
test "Killing one master node" {
|
2024-05-09 10:14:47 +08:00
|
|
|
pause_process $paused_pid
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
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" {
|
2024-05-09 10:14:47 +08:00
|
|
|
for {set j 0} {$j < [llength $::servers]} {incr j} {
|
2024-07-19 11:25:58 +08:00
|
|
|
if {[process_is_paused [srv -$j pid]]} continue
|
2024-05-09 10:14:47 +08:00
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[CI $j cluster_state] eq "ok"
|
|
|
|
} else {
|
|
|
|
fail "Cluster node $j cluster_state:[CI $j cluster_state]"
|
|
|
|
}
|
|
|
|
}
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is writable" {
|
2024-05-09 10:14:47 +08:00
|
|
|
cluster_write_test [srv -1 port]
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #5 is now a master" {
|
2024-05-09 10:14:47 +08:00
|
|
|
assert {[s -5 role] eq {master}}
|
2014-05-23 11:47:47 +02:00
|
|
|
}
|
2014-06-10 13:54:38 +02:00
|
|
|
|
|
|
|
test "Restarting the previously killed master node" {
|
2024-05-09 10:14:47 +08:00
|
|
|
resume_process $paused_pid
|
2014-06-10 13:54:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #0 gets converted into a slave" {
|
|
|
|
wait_for_condition 1000 50 {
|
2024-05-09 10:14:47 +08:00
|
|
|
[s 0 role] eq {slave}
|
2014-06-10 13:54:38 +02:00
|
|
|
} else {
|
|
|
|
fail "Old master was not converted into slave"
|
|
|
|
}
|
2024-05-23 02:51:41 +05:30
|
|
|
wait_for_cluster_propagation
|
2014-06-10 13:54:38 +02:00
|
|
|
}
|
2024-05-09 10:14:47 +08:00
|
|
|
|
|
|
|
} ;# start_cluster
|
2024-07-23 14:43:16 +08:00
|
|
|
|
|
|
|
start_cluster 3 6 {tags {external:skip cluster}} {
|
|
|
|
|
|
|
|
test "Cluster is up" {
|
|
|
|
wait_for_cluster_state ok
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster is writable" {
|
|
|
|
cluster_write_test [srv 0 port]
|
|
|
|
}
|
|
|
|
|
|
|
|
set current_epoch [CI 1 cluster_current_epoch]
|
|
|
|
|
|
|
|
set paused_pid [srv 0 pid]
|
|
|
|
test "Killing the first primary node" {
|
|
|
|
pause_process $paused_pid
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Wait for failover" {
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[CI 1 cluster_current_epoch] > $current_epoch
|
|
|
|
} else {
|
|
|
|
fail "No failover detected"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Cluster should eventually be up again" {
|
|
|
|
for {set j 0} {$j < [llength $::servers]} {incr j} {
|
|
|
|
if {[process_is_paused [srv -$j pid]]} continue
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[CI $j cluster_state] eq "ok"
|
|
|
|
} else {
|
|
|
|
fail "Cluster node $j cluster_state:[CI $j cluster_state]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Restarting the previously killed primary node" {
|
|
|
|
resume_process $paused_pid
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Instance #0 gets converted into a replica" {
|
|
|
|
wait_for_condition 1000 50 {
|
|
|
|
[s 0 role] eq {slave}
|
|
|
|
} else {
|
|
|
|
fail "Old primary was not converted into replica"
|
|
|
|
}
|
|
|
|
wait_for_cluster_propagation
|
|
|
|
}
|
|
|
|
|
|
|
|
test "Make sure the replicas always get the different ranks" {
|
|
|
|
if {[s -3 role] == "master"} {
|
|
|
|
verify_log_message -3 "*Start of election*rank #0*" 0
|
|
|
|
verify_log_message -6 "*Start of election*rank #1*" 0
|
|
|
|
} else {
|
|
|
|
verify_log_message -3 "*Start of election*rank #1*" 0
|
|
|
|
verify_log_message -6 "*Start of election*rank #0*" 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} ;# start_cluster
|