当前位置: 首页>>代码示例>>C++>>正文


C++ TestConnections::add_result方法代码示例

本文整理汇总了C++中TestConnections::add_result方法的典型用法代码示例。如果您正苦于以下问题:C++ TestConnections::add_result方法的具体用法?C++ TestConnections::add_result怎么用?C++ TestConnections::add_result使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestConnections的用法示例。


在下文中一共展示了TestConnections::add_result方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(100);
    Test->repl->connect();

    const int TestConnNum = 100;
    MYSQL *conn[TestConnNum];
    int i;
    int conn_num;

    Test->tprintf("Creating %d connections to ReadConnRouter in 'slave' mode\n", TestConnNum);
    for (i = 0; i < TestConnNum; i++)
    {
        conn[i] = Test->open_readconn_slave_connection();
    }
    Test->tprintf("Waiting 5 seconds\n");
    sleep(5);

    int ConnFloor = floor((float)TestConnNum / (Test->repl->N - 1));
    int ConnCell = ceil((float)TestConnNum / (Test->repl->N - 1));
    int TotalConn = 0;

    Test->tprintf("Checking connections to Master: should be 0\n");
    conn_num = get_conn_num(Test->repl->nodes[0], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
    Test->add_result(conn_num, "number of connections to Master is %d\n", conn_num);

    Test->tprintf("Number of connections to each slave should be between %d and %d\n", ConnFloor, ConnCell);
    Test->tprintf("Checking connections to each node\n");
    for (int i = 1; i < Test->repl->N; i++)
    {
        conn_num = get_conn_num(Test->repl->nodes[i], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
        TotalConn += conn_num;
        printf("Connections to node %d (%s):\t%d\n", i, Test->repl->IP[i], conn_num);
        if ((conn_num > ConnCell) || (conn_num < ConnFloor))
        {
            Test->add_result(1, "wrong number of connectiosn to mode %d\n", i);
        }
    }

    Test->tprintf("Total number of connections %d\n", TotalConn);
    if (TotalConn != TestConnNum)
    {
        Test->add_result(1, "total number of connections is wrong\n");
    }

    for (i = 0; i < TestConnNum; i++)
    {
        mysql_close(conn[i]);
    }

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:55,代码来源:readconnrouter_slave.cpp

示例2: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(30);

    Test->tprintf("Connecting to RWSplit\n");
    Test->conn_rwsplit = open_conn_no_db(Test->rwsplit_port, Test->maxscale_IP, Test->maxscale_user,
                                         Test->maxscale_password, Test->ssl);
    if (Test->conn_rwsplit == NULL)
    {
        Test->add_result(1, "Error connecting to MaxScale\n");
        delete Test;
        return 1;
    }
    Test->tprintf("Removing 'test' DB\n");
    execute_query(Test->conn_rwsplit, (char *) "DROP DATABASE IF EXISTS test;");
    Test->tprintf("Closing connections and waiting 5 seconds\n");
    Test->close_rwsplit();
    sleep(5);

    Test->tprintf("Connection to non-existing DB (all routers)\n");
    Test->connect_maxscale();
    Test->close_maxscale_connections();

    Test->tprintf("Connecting to RWSplit again to recreate 'test' db\n");
    Test->conn_rwsplit = open_conn_no_db(Test->rwsplit_port, Test->maxscale_IP, Test->maxscale_user,
                                         Test->maxscale_password, Test->ssl);
    if (Test->conn_rwsplit == NULL)
    {
        printf("Error connecting to MaxScale\n");
        delete Test;
        return 1;
    }

    Test->tprintf("Creating and selecting 'test' DB\n");
    Test->try_query(Test->conn_rwsplit, (char *) "CREATE DATABASE test; USE test");
    Test->tprintf("Creating 't1' table\n");
    Test->add_result(create_t1(Test->conn_rwsplit), "Error creation 't1'\n");
    Test->close_rwsplit();

    Test->tprintf("Reconnectiong\n");
    Test->add_result(Test->connect_maxscale(), "error connection to Maxscale\n");
    Test->tprintf("Trying simple operations with t1 \n");
    Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
    Test->set_timeout(240);
    Test->add_result(execute_select_query_and_check(Test->conn_rwsplit, (char *) "SELECT * FROM t1;", 1),
                     "Error execution SELECT * FROM t1;\n");

    Test->close_maxscale_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:54,代码来源:connect_to_nonexisting_db.cpp

示例3: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(30);
    MYSQL * conn_found_rows;
    my_ulonglong rows;


    Test->repl->connect();
    Test->connect_maxscale();

    conn_found_rows = open_conn_db_flags(Test->rwsplit_port, Test->maxscale_IP, (char *) "test",
                                         Test->maxscale_user, Test->maxscale_password, CLIENT_FOUND_ROWS, Test->ssl);

    Test->set_timeout(30);
    execute_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1");
    execute_query(Test->conn_rwsplit, "CREATE TABLE t1(id INT PRIMARY KEY, val INT, msg VARCHAR(100))");
    execute_query(Test->conn_rwsplit,
                  "INSERT INTO t1 VALUES (1, 1, 'foo'), (2, 1, 'bar'), (3, 2, 'baz'), (4, 2, 'abc')");

    Test->set_timeout(30);
    execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
    Test->tprintf("update #1: %ld (expeced value is 2)\n", (long) rows);
    if (rows != 2)
    {
        Test->add_result(1, "Affected rows is not 2\n");
    }

    Test->set_timeout(30);
    execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
    Test->tprintf("update #2: %ld  (expeced value is 0)\n", (long) rows);
    if (rows != 0)
    {
        Test->add_result(1, "Affected rows is not 0\n");
    }

    Test->set_timeout(30);
    execute_query_affected_rows(conn_found_rows, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
    Test->tprintf("update #3: %ld  (expeced value is 2)\n", (long) rows);
    if (rows != 2)
    {
        Test->add_result(1, "Affected rows is not 2\n");
    }

    Test->close_maxscale_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;

}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:51,代码来源:bug565.cpp

示例4: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(100);

    Test->repl->connect();

    Test->tprintf("Connecting to ReadConnnRouter in 'master' mode\n");
    Test->connect_readconn_master();
    printf("Sleeping 10 seconds\n");
    Test->stop_timeout();
    sleep(10);
    Test->set_timeout(50);
    Test->add_result(check_connnections_only_to_master(Test, 0), "connections are not only to Master\n");
    Test->close_readconn_master();
    Test->tprintf("Changing master to node 1\n");
    Test->set_timeout(50);
    Test->repl->change_master(1, 0);
    printf("Sleeping 10 seconds\n");
    Test->stop_timeout();
    sleep(10);
    Test->set_timeout(50);
    printf("Connecting to ReadConnnRouter in 'master' mode\n");
    Test->connect_readconn_master();
    printf("Sleeping 10 seconds\n");
    Test->stop_timeout();
    sleep(10);
    Test->set_timeout(50);
    Test->add_result(check_connnections_only_to_master(Test, 1), "connections are not only to master");
    Test->close_readconn_master();
    Test->set_timeout(50);
    printf("Changing master back to node 0\n");
    Test->repl->change_master(0, 1);

    Test->check_log_err((char *) "The service 'CLI' is missing a definition of the servers", false);

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:40,代码来源:readconnrouter_master.cpp

示例5: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(20);
    Test->repl->connect();

    Test->tprintf("Connecting to RWSplit %s\n", Test->maxscale_ip());
    Test->connect_rwsplit();

    unsigned int conn_num;
    unsigned int all_conn = 0;
    Test->tprintf("Sleeping 5 seconds\n");
    sleep(5);
    Test->tprintf("Checking number of connections ot backend servers\n");
    for (int i = 0; i < Test->repl->N; i++)
    {
        conn_num = get_conn_num(Test->repl->nodes[i], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
        Test->tprintf("connections: %u\n", conn_num);
        if ((i == 0) && (conn_num != 1))
        {
            Test->add_result(1, " Master should have only 1 connection, but it has %d connection(s)\n", conn_num);
        }
        all_conn += conn_num;
    }
    if (all_conn != 2)
    {
        Test->add_result(1,
                         "there should be two connections in total: one to master and one to one of slaves, but number of connections is %d\n",
                         all_conn);
    }

    Test->close_rwsplit();
    Test->repl->close_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:38,代码来源:rwsplit_connect.cpp

示例6: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(30);

    Test->galera->connect();

    tolerance = 0;

    // connect to the MaxScale server (rwsplit)
    Test->connect_rwsplit();

    Test->execute_maxadmin_command((char *) "shutdown monitor \"Galera Monitor\"");

    if (Test->conn_rwsplit == NULL )
    {
        Test->add_result(1, "Can't connect to MaxScale\n");
        int rval = Test->global_result;
        delete Test;
        exit(1);
    }
    else
    {

        Test->try_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1;");
        Test->try_query(Test->conn_rwsplit, "create table t1 (x1 int);");

        get_global_status_allnodes(&selects[0], &inserts[0], Test->galera, silent);
        Test->try_query(Test->conn_rwsplit, "select * from t1;");
        get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
        print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);

        Test->try_query(Test->conn_rwsplit, "insert into t1 values(1);");
        get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
        print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);

        // close connections
        Test->close_rwsplit();
    }
    Test->galera->close_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:45,代码来源:rw_galera_select_insert.cpp

示例7: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(20);
    int i, j;
    MYSQL * conn;

    int N_cmd = 2;
    char * fail_cmd[N_cmd - 1];

    int N_ports = 3;
    int ports[N_ports];

    fail_cmd[0] = (char *) "fail backendfd";
    fail_cmd[1] = (char *) "fail clientfd";

    ports[0] = Test->rwsplit_port;
    ports[1] = Test->readconn_master_port;
    ports[2] = Test->readconn_slave_port;

    for (i = 0; i < N_cmd; i++)
    {
        for (j = 0; j < N_ports; j++)
        {
            Test->tprintf("Executing MaxAdmin command '%s'\n", fail_cmd[i]);
            if (execute_maxadmin_command(Test->maxscale_IP, (char *) "admin", Test->maxadmin_password, fail_cmd[i]) != 0)
            {
                Test->add_result(1, "MaxAdmin command failed\n");
            }
            else
            {
                printf("Trying query against %d\n", ports[j]);
                conn = open_conn(ports[j], Test->maxscale_IP, Test->maxscale_user, Test->maxscale_user, Test->ssl);
                Test->try_query(conn, (char *) "show processlist;");
            }
        }
    }

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:43,代码来源:bug539.cpp

示例8: main

int main(int argc, char *argv[])
{

    TestConnections * Test = new TestConnections(argc, argv);
    int master;
    long int q;
    int threads_num = 25;

    long int selects[256];
    long int inserts[256];
    long int new_selects[256];
    long int new_inserts[256];
    long int i1, i2;

    Test->set_timeout(20);
    master = Test->find_master_maxadmin(Test->galera);

    if (master >= 0)
    {
        Test->tprintf("Master node is %d (server%d)\n", master, master + 1);
        Test->set_timeout(20);

        if (Test->smoke)
        {
            threads_num = 15;
        }
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 300;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connect_errors = 100000;");
        }
        Test->galera->close_connections();

        Test->set_timeout(1200);
        load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], threads_num, Test, &i1, &i2, 1, true, true);

        long int avr = (i1 + i2 ) / (Test->galera->N);
        Test->tprintf("average number of quries per node %ld\n", avr);
        long int min_q = avr / 3;
        long int max_q = avr * 3;
        Test->tprintf("Acceplable value for every node from %ld until %ld\n", min_q, max_q);

        for (int i = 0; i < Test->galera->N; i++)
        {
            if ( i != master)
            {
                q = new_selects[i] - selects[i];
                if ((q > max_q) || (q < min_q))
                {
                    Test->add_result(1, "number of queries for node %d is %ld\n", i + 1, q);
                }
            }
        }

        if ((new_selects[master] - selects[master]) > avr / 3 )
        {
            Test->add_result(1,
                             "number of queries for master greater then 30%% of averange number of queries per node\n");
        }

        Test->tprintf("Restoring nodes\n");
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "flush hosts;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 151;");
        }
        Test->galera->close_connections();

        Test->check_maxscale_alive();
    }
    else
    {
        Test->add_result(1, "Master is not found\n");
    }

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:81,代码来源:load_balancing_galera.cpp

示例9: main

int main(int argc, char *argv[])
{
    TestConnections::skip_maxscale_start(true);
    TestConnections * Test = new TestConnections(argc, argv);
    int local_result;
    char str[4096];
    char sql[4096];
    char pass_file[4096];
    char deny_file[4096];
    char rules_dir[4096];
    FILE* file;

    sprintf(rules_dir, "%s/fw/", test_dir);
    int N = 10;
    int i;

    for (i = 1; i < N + 1; i++)
    {
        Test->set_timeout(180);
        local_result = 0;

        Test->stop_maxscale();

        sprintf(str, "rules%d", i);
        copy_rules(Test, str, rules_dir);

        Test->start_maxscale();
        Test->connect_rwsplit();

        sprintf(pass_file, "%s/fw/pass%d", test_dir, i);
        sprintf(deny_file, "%s/fw/deny%d", test_dir, i);
        Test->tprintf("Pass file: %s\n", pass_file);
        Test->tprintf("Deny file: %s\n", deny_file);

        file = fopen(pass_file, "r");
        if (file != NULL)
        {
            Test->tprintf("********** Trying queries that should be OK ********** \n");
            while (fgets(sql, sizeof(sql), file))
            {
                if (strlen(sql) > 1)
                {
                    Test->tprintf("%s", sql);
                    local_result += execute_query(Test->conn_rwsplit, sql);
                }
            }
            fclose(file);
        }
        else
        {
            Test->add_result(1, "Error opening query file\n");
        }

        file = fopen(deny_file, "r");
        if (file != NULL)
        {
            Test->tprintf("********** Trying queries that should FAIL ********** \n");
            while (fgets(sql, sizeof(sql), file))
            {
                Test->set_timeout(180);
                if (strlen(sql) > 1)
                {
                    Test->tprintf("%s", sql);
                    execute_query(Test->conn_rwsplit, sql);
                    if (mysql_errno(Test->conn_rwsplit) != 1141)
                    {
                        Test->tprintf("Query succeded, but fail expected, errono is %d\n", mysql_errno(Test->conn_rwsplit));
                        local_result++;
                    }
                }
            }
            fclose(file);
        }
        else
        {
            Test->add_result(1, "Error opening query file\n");
        }
        if (local_result != 0)
        {
            Test->add_result(1, "********** rules%d test FAILED\n", i);
        }
        else
        {
            Test->tprintf("********** rules%d test PASSED\n", i);
        }

        mysql_close(Test->conn_rwsplit);
    }

    Test->set_timeout(180);
    Test->stop_maxscale();

    // Test for at_times clause
    Test->tprintf("Trying at_times clause\n");
    copy_rules(Test, (char *) "rules_at_time", rules_dir);

    Test->tprintf("DELETE quries without WHERE clause will be blocked during next 2 minutes\n");
    Test->tprintf("Put time to rules.txt: %s\n", str);
    Test->ssh_maxscale(false, "start_time=`date +%%T`; stop_time=` date --date "
                       "\"now +2 mins\" +%%T`; %s sed -i \"s/###time###/$start_time-$stop_time/\" %s/rules/rules.txt",
//.........这里部分代码省略.........
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:101,代码来源:fwf.cpp

示例10: main

int main(int argc, char **argv)
{
    TestConnections *test = new TestConnections(argc, argv);

    char server_id[test->repl->N][1024];

    test->repl->connect();
    /** Get server_id for each node */
    for (int i = 0; i < test->repl->N; i++)
    {
        sprintf(server_id[i], "%d", test->repl->get_server_id(i));
    }

    test->tprintf("Block the master and try a read query\n");
    test->repl->block_node(0);
    sleep(15);
    test->connect_readconn_slave();
    char first_slave[1024];
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", first_slave);

    int found = -1;

    for (int i = 0; i < test->repl->N; i++)
    {
        if (strcmp(server_id[i], first_slave) == 0)
        {
            found = i;
            break;
        }
    }

    test->add_result(found < 0, "No server with ID '%s' found.", first_slave);

    test->tprintf("Blocking node %d\n", found + 1);
    test->repl->block_node(found);
    sleep(15);

    test->tprintf("Blocked the slave that replied to us, expecting a different slave\n");
    test->connect_readconn_slave();
    char second_slave[1024];
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", second_slave);
    test->add_result(strcmp(first_slave, second_slave) == 0,
                     "Server IDs match when they shouldn't: %s - %s",
                     first_slave, second_slave);

    test->tprintf("Unblocking the slave that replied\n");
    test->repl->unblock_node(found);
    sleep(15);

    test->tprintf("Unblocked the slave, still expecting a different slave\n");
    test->connect_readconn_slave();
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", second_slave);
    test->add_result(strcmp(first_slave, second_slave) == 0,
                     "Server IDs match when they shouldn't: %s - %s",
                     first_slave, second_slave);

    test->tprintf("Unblocking all nodes\n");
    test->repl->unblock_all_nodes();
    sleep(15);

    test->tprintf("Unblocked all nodes, expecting the server ID of the first slave server\n");
    test->connect_readconn_slave();
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", second_slave);
    test->add_result(strcmp(first_slave, second_slave) != 0,
                     "Server IDs don't match when they should: %s - %s",
                     first_slave, second_slave);

    test->tprintf("Stopping replication on node %d\n", found + 1);
    execute_query(test->repl->nodes[found], "stop slave");
    sleep(15);

    test->tprintf("Stopped replication, expecting a different slave\n");
    test->connect_readconn_slave();
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", second_slave);
    test->add_result(strcmp(first_slave, second_slave) == 0,
                     "Server IDs match when they shouldn't: %s - %s",
                     first_slave, second_slave);

    test->tprintf("Starting replication on node %d\n", found + 1);
    execute_query(test->repl->nodes[found], "start slave");
    sleep(15);

    test->tprintf("Started replication, expecting the server ID of the first slave server\n");
    test->connect_readconn_slave();
    find_field(test->conn_slave, "SELECT @@server_id", "@@server_id", second_slave);
    test->add_result(strcmp(first_slave, second_slave) != 0,
                     "Server IDs don't match when they should: %s - %s",
                     first_slave, second_slave);

    int rval = test->global_result;
    delete test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:93,代码来源:stale_slaves.cpp

示例11: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(60);

    Test->repl->connect();
    Test->connect_maxscale();

    Test->tprintf("Creating user 'user' \n");

    execute_query(Test->conn_rwsplit, "DROP USER 'user'@'%%'");
    Test->try_query(Test->conn_rwsplit, (char *) "CREATE USER [email protected]'%%' identified by 'pass2'");
    Test->try_query(Test->conn_rwsplit, (char *) "GRANT SELECT ON test.* TO [email protected]'%%'");
    Test->try_query(Test->conn_rwsplit, (char *) "FLUSH PRIVILEGES;");
    Test->try_query(Test->conn_rwsplit, (char *) "DROP TABLE IF EXISTS t1");
    Test->try_query(Test->conn_rwsplit, (char *) "CREATE TABLE t1 (x1 int, fl int)");

    Test->tprintf("Changing user... \n");
    Test->add_result(mysql_change_user(Test->conn_rwsplit, (char *) "user", (char *) "pass2", (char *) "test") ,
                     "changing user failed \n");
    Test->tprintf("mysql_error is %s\n", mysql_error(Test->conn_rwsplit));

    Test->tprintf("Trying INSERT (expecting access denied)... \n");
    if ( execute_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 11);") == 0)
    {
        Test->add_result(1, "INSERT query succedded to user which does not have INSERT PRIVILEGES\n");
    }

    Test->tprintf("Changing user back... \n");
    Test->add_result(mysql_change_user(Test->conn_rwsplit, Test->repl->user_name, Test->repl->password,
                                       (char *) "test"), "changing user failed \n");

    Test->tprintf("Trying INSERT (expecting success)... \n");
    Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 12);");

    Test->tprintf("Changing user with wrong password... \n");
    if (mysql_change_user(Test->conn_rwsplit, (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
    {
        Test->add_result(1, "changing user with wrong password successed! \n");
    }
    Test->tprintf("%s\n", mysql_error(Test->conn_rwsplit));
    if ((strstr(mysql_error(Test->conn_rwsplit), "Access denied for user")) == NULL)
    {
        Test->add_result(1, "There is no proper error message\n");
    }

    Test->tprintf("Trying INSERT again (expecting success - use change should fail)... \n");
    Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 13);");


    Test->tprintf("Changing user with wrong password using ReadConn \n");
    if (mysql_change_user(Test->conn_slave, (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
    {
        Test->add_result(1, "FAILED: changing user with wrong password successed! \n");
    }
    Test->tprintf("%s\n", mysql_error(Test->conn_slave));
    if ((strstr(mysql_error(Test->conn_slave), "Access denied for user")) == NULL)
    {
        Test->add_result(1, "There is no proper error message\n");
    }

    Test->tprintf("Changing user for ReadConn \n");
    Test->add_result(mysql_change_user(Test->conn_slave, (char *) "user", (char *) "pass2", (char *) "test") ,
                     "changing user failed \n");

    Test->try_query(Test->conn_rwsplit, (char *) "DROP USER [email protected]'%%';");
    execute_query_silent(Test->conn_rwsplit, "DROP TABLE test.t1");

    Test->close_maxscale_connections();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:73,代码来源:change_user.cpp

示例12: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(10);

    Test->connect_maxscale();

    Test->set_timeout(10);
    Test->try_query(Test->conn_rwsplit, (char *) "SET @a=1");
    Test->stop_timeout();
    sleep(1);
    Test->set_timeout(20);
    Test->tprintf("Blocking first slave\n");
    Test->repl->block_node(1);
    Test->stop_timeout();
    sleep(5);
    Test->set_timeout(10);
    Test->tprintf("Unblocking first slave and blocking second slave\n");

    Test->repl->unblock_node(1);
    Test->stop_timeout();
    sleep(5);
    Test->repl->block_node(2);
    Test->stop_timeout();
    sleep(5);
    Test->set_timeout(20);

    int retries;

    for (retries = 0; retries < 10; retries++)
    {
        char server1_status[256];
        Test->get_maxadmin_param((char *) "show server server2", (char *) "Status", server1_status);
        if (strstr(server1_status, "Running"))
        {
            break;
        }
        sleep(1);
    }

    Test->add_result(retries == 10, "Slave is not recovered, slave status is not Running\n");

    Test->repl->connect();
    int real_id = Test->repl->get_server_id(1);

    char server_id[200] = "";
    find_field(Test->conn_rwsplit, "SELECT @@server_id", "@@server_id", server_id);
    int queried_id = atoi(server_id);

    Test->add_result(queried_id != real_id, "The query server ID '%d' does not match the one from server '%d'. "
                     "Slave was not recovered.", queried_id, real_id);

    char userval[200] = "";
    find_field(Test->conn_rwsplit, "SELECT @a", "@a", userval);

    Test->add_result(atoi(userval) != 1, "User variable @a is not 1, it is '%s'", userval);

    Test->tprintf("Unblocking second slave\n");
    Test->repl->unblock_node(2);

    Test->check_maxscale_alive();
    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:65,代码来源:mxs874_slave_recovery.cpp


注:本文中的TestConnections::add_result方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。