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() }
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)
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}
def deactivate_nodes(): environment = conftest.environment() __execute_command_in_nodes(environment, MYSQL_STOP_CMD)
def activate_nodes(): environment = conftest.environment() __execute_command_in_nodes(environment, MYSQL_RESTART_CMD)