def test_status_is_down_after_crash(environment, capsys): node = test_utils.get_node_from_status(environment.master, capsys) assert node['status'] == 'Up' shut_down_master_node(environment) node = test_utils.get_node_from_status(environment.master, capsys) assert node['status'] == 'Down'
def test_status_after_restart(environment, capsys): shut_down_master_node(environment) node = test_utils.get_node_from_status(environment.master, capsys) assert node['status'] == 'Down' start_up_master_node(environment) node = test_utils.get_node_from_status(environment.master, capsys) assert node['status'] == 'Up'
def test_can_switch_between_nodes(environment, capsys): test_utils.wait_for_replication_ok(environment, capsys) fox.switchover(environment.group) sleep(15) node = test_utils.get_node_from_status(environment.master, capsys) assert node['mode'] == 'read_only' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_write'
def test_switchover_twice(environment, capsys): test_utils.wait_for_replication_ok(environment, capsys) fox.switchover(environment.group) node = test_utils.get_node_from_status(environment.master, capsys) assert node['mode'] == 'read_only' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_write' fox.switchover(environment.group) node = test_utils.get_node_from_status(environment.master, capsys) assert node['mode'] == 'read_write' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_only'
def test_cannot_change_to_write_when_replication_is_off(environment, capsys): node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_only' shut_down_master_node(environment) node = test_utils.set_read_only(environment.replication, capsys) assert node['mode'] == 'read_only'
def test_failover_when_write_node_failed(environment, capsys): node = test_utils.failed_node(environment.master, capsys) assert node['status'] == 'failed' node = test_utils.get_node_from_list(environment.replication, capsys) assert node['status'] == 'enabled' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_write'
def test_can_failover_node(environment, capsys): test_utils.wait_for_replication_ok(environment, capsys) fox.failover(environment.group) node = test_utils.get_node_from_list(environment.master, capsys) assert node['status'] == 'failed' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_write'
def test_cannot_switch_with_no_write_node(environment, capsys): node = test_utils.set_read_only(environment.master, capsys) assert node['mode'] == 'read_only' fox.switchover(environment.group) node = test_utils.get_node_from_list(environment.master, capsys) assert node['status'] == 'enabled' node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_only'
def test_cannot_change_to_write_with_heartbeat_delay(environment, capsys): node = test_utils.set_read_only(environment.master, capsys) assert node['mode'] == 'read_only' time.sleep(2) node = test_utils.set_read_write(environment.master, capsys) assert node['mode'] == 'read_write' fox.set('read_write', environment.group, environment.replication) delay_message = 'The node "%s" is (\d+.\d+) seconds delayed and ' \ 'cannot be set as read_write.' % environment.replication out, err = capsys.readouterr() assert re.findall(delay_message, out) node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_only'
def test_can_failover_with_node_write_down(environment, capsys): shut_down_master_node(environment) fox.failover(environment.group) node = test_utils.get_node_from_status(environment.replication, capsys) assert node['mode'] == 'read_write'
def test_cannot_disable_write_node(environment, capsys): node = test_utils.get_node_from_status(environment.master, capsys) assert node['mode'] == 'read_write' node = test_utils.disable_node(environment.master, capsys) assert node['status'] == 'enabled'