Пример #1
0
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'
Пример #2
0
def test_can_fail_without_write(environment, capsys):
    node = test_utils.set_read_only(environment.master, capsys)
    assert node['mode'] == 'read_only'

    node = test_utils.failed_node(environment.master, capsys)
    assert node['status'] == 'failed'

    node = test_utils.failed_node(environment.replication, capsys)
    assert node['status'] == 'failed'
Пример #3
0
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'
Пример #4
0
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'
Пример #5
0
def test_can_change_node_to_read_write(environment, capsys):
    node = test_utils.set_read_only(environment.master, capsys)
    assert node['mode'] == 'read_only'

    node = test_utils.set_read_write(environment.replication, capsys)
    assert node['mode'] == 'read_write'
Пример #6
0
def test_cannot_change_to_read_when_already_is_read(environment, capsys):
    node = test_utils.set_read_only(environment.replication, capsys)
    assert node['mode'] == 'read_only'