Example #1
0
def get_node_from_status(node_ip, capsys, group=None):
    if not group:
        group = conftest.environment().group
    formatter.status_nodes(
        group, conftest.default_logger(), conftest.default_connection()
    )

    out, err = capsys.readouterr()
    for line in out.split('\n'):

        if is_node_in_line(node_ip, line):
            data = line
            break

    group, address, status, mode, repl_status = data.split('|')[1:6]
    ip = __get_ip(address)
    name = __get_name(address)
    status = remove_ansi_format(status)

    return {
        'group': group.strip(),
        'name': name.strip(),
        'ip': ip.strip(),
        'status': status,
        'mode': mode.strip(),
        'repl_status': repl_status.strip()
    }
Example #2
0
def reset_database():
    environment = conftest.environment()

    fox.set('enabled', environment.group, environment.master)
    fox.set('enabled', environment.group, environment.replication)
    fox.set('read_only', environment.group, environment.replication)
    fox.set('read_write', environment.group, environment.master)
Example #3
0
def get_node_from_list(node_ip, capsys, group=None):
    if not group:
        group = conftest.environment().group

    with pytest.raises(SystemExit) as exec_info:
        formatter.list_nodes(group, conftest.default_connection())
    assert str(exec_info.value) == '0'

    out, err = capsys.readouterr()
    for line in out.split('\n'):
        if is_node_in_line(node_ip, line):
            data = line
            break

    group, address, status = data.split('|')[1:4]
    ip = __get_ip(address)
    name = __get_name(address)
    status = remove_ansi_format(status)

    return {'group': group.strip(), 'name': name.strip(),
            'ip': ip.strip(), 'status': status}
Example #4
0
def deactivate_nodes():
    environment = conftest.environment()
    __execute_command_in_nodes(environment, MYSQL_STOP_CMD)
Example #5
0
def activate_nodes():
    environment = conftest.environment()
    __execute_command_in_nodes(environment, MYSQL_RESTART_CMD)