Esempio n. 1
0
def test_can_delete_added_node(default_connection, node, group):
    inner_logic.add_group(default_connection, group.name, group.description,
                          group.vip_address, group.mysql_user,
                          group.mysql_pass, group.relp_user, group.relp_pass)

    inner_logic.add_node(default_connection, node.group, node.name, node.ip,
                         node.port, node.mode, node.status)
    inner_logic.delete_node(default_connection, node.group, node.ip)

    with pytest.raises(NodeNotFoundError):
        inner_logic.get_node(node.group, node.ip, default_connection)
Esempio n. 2
0
def test_cannot_set_write_to_down_node(environment, default_connection):
    node = inner_logic.get_node(
        environment.group, environment.master, default_connection
    )
    shut_down_master_node(environment)

    with pytest.raises(NodeIsDownError):
        inner_logic.set_read_write(node, default_connection)
Esempio n. 3
0
def test_can_start_group(environment, default_connection):
    node_write = inner_logic.get_node(
        environment.group, environment.master, default_connection
    )
    node_write.node_connection.query(Query.SET_MODE % 'ON')
    assert node_write.mode != node_write.fox_mode

    assert inner_logic.start(environment.group, default_connection)
    assert node_write.mode == node_write.fox_mode
Esempio n. 4
0
def test_cannot_start_group_without_write(environment, default_connection):
    node_write = inner_logic.get_node(
        environment.group, environment.master, default_connection
    )
    node_write.fox_connection.query(
        Query.UPDATE_MODE % ('read_only', node_write.ip, node_write.group)
    )
    assert node_write.mode != node_write.fox_mode

    with pytest.raises(NoWriteNodeError):
        inner_logic.start(environment.group, default_connection)
Esempio n. 5
0
def test_can_add_node(default_connection, node, group):
    inner_logic.add_group(default_connection, group.name, group.description,
                          group.vip_address, group.mysql_user,
                          group.mysql_pass, group.relp_user, group.relp_pass)

    inner_logic.add_node(default_connection, node.group, node.name, node.ip,
                         node.port, node.mode, node.status)

    added_node = inner_logic.get_node(node.group, node.ip, default_connection)
    assert added_node.group == node.group
    assert added_node.ip == node.ip
    assert added_node.name == node.name
Esempio n. 6
0
def test_cannot_start_with_master_node_down(environment, default_connection):
    node_write = inner_logic.get_node(
        environment.group, environment.master, default_connection
    )
    assert node_write.is_mysql_status_up()

    test_utils.deactivate_node(environment.master_node)
    assert node_write.is_mysql_status_down()
    with pytest.raises(NodeIsDownError):
        inner_logic.start(environment.group, default_connection)

    test_utils.activate_node(environment.master_node)
Esempio n. 7
0
def test_cannot_start_group_with_many_write(environment, default_connection):
    node_repl = inner_logic.get_node(
        environment.group, environment.replication, default_connection
    )
    node_repl.fox_connection.query(
        Query.UPDATE_MODE % ('read_write', node_repl.ip, node_repl.group)
    )
    assert node_repl.mode != node_repl.fox_mode

    with pytest.raises(ManyWriteNodesError):
        inner_logic.start(environment.group, default_connection)

    node_repl.fox_connection.query(
        Query.UPDATE_MODE % ('read_only', node_repl.ip, node_repl.group)
    )
    assert node_repl.mode == node_repl.fox_mode
Esempio n. 8
0
def test_cannot_start_group_with_many_write(environment, capsys,
                                            default_connection,
                                            default_logger):
    node_repl = inner_logic.get_node(environment.group,
                                     environment.replication,
                                     default_connection)
    node_repl.fox_connection.query(
        Query.UPDATE_MODE % ('read_write', node_repl.ip, node_repl.group))
    assert node_repl.mode != node_repl.fox_mode

    formatter.start(environment.group, default_connection, default_logger)
    out, err = capsys.readouterr()
    assert 'There is many nodes with the "read_write" mode. ' \
           'Check your configuration!' in out

    node_repl.fox_connection.query(
        Query.UPDATE_MODE % ('read_only', node_repl.ip, node_repl.group))
    assert node_repl.mode == node_repl.fox_mode
Esempio n. 9
0
def test_cannot_set_write_without_replication(
        environment, default_connection, capsys
):
    test_utils.wait_for_replication_ok(environment, capsys)
    node_replication = inner_logic.get_node(
        environment.group, environment.replication, default_connection
    )
    assert node_replication.is_replication_running()

    node_replication.node_connection.query(Query.SQL_STOP_SLAVE)
    assert node_replication.is_replication_stopped()

    try:
        inner_logic.set_read_write(node_replication, default_connection)
    except ReplicationNotRunningError:
        assert True
    else:
        assert False, 'DO NOT RAISE ReplicationNotRunningError'
    finally:
        node_replication.node_connection.query(Query.SQL_START_SLAVE)
        test_utils.wait_for_replication_ok(environment, capsys)
        assert node_replication.is_replication_running()
Esempio n. 10
0
 def node_is_master(self, group_name, node_ip):
     node = inner_logic.get_node(group_name, node_ip, self.fox_connection)
     return node.is_fox_mode_read_write()
Esempio n. 11
0
def test_cannot_get_node_wrong_ip(environment, default_connection):
    with pytest.raises(NodeNotFoundError):
        inner_logic.get_node(
            environment.group, '111.222.333.444', default_connection
        )
Esempio n. 12
0
def test_cannot_get_node_wrong_group(environment, default_connection):
    with pytest.raises(NodeNotFoundError):
        inner_logic.get_node(
            'Strange_Group_Env', environment.master, default_connection
        )
Esempio n. 13
0
def test_cannot_get_node(environment, default_connection):
    with pytest.raises(NodeNotFoundError):
        inner_logic.get_node(
            'Strange_Group_Env', '111.222.333.444', default_connection
        )
Esempio n. 14
0
def test_can_get_node(environment, default_connection):
    node = inner_logic.get_node(
        environment.group, environment.master, default_connection
    )
    assert node.ip == environment.master
    assert node.group == environment.group