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


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

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


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

示例1: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    int global_result = 0;

    Test->read_env();
    Test->print_env();

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

    printf("Setup firewall to block mysql on master\n"); fflush(stdout);
    Test->repl->block_node(0);

    printf("Trying query to RWSplit, expecting failure, but not a crash\n"); fflush(stdout);
    execute_query(Test->conn_rwsplit, (char *) "show processlist;");

    printf("Setup firewall back to allow mysql\n"); fflush(stdout);
    Test->repl->unblock_node(0);

    sleep(10);

    global_result += check_maxscale_alive();

    Test->close_rwsplit();


    printf("Reconnecting and trying query to RWSplit\n"); fflush(stdout);
    Test->connect_rwsplit();
    global_result += execute_query(Test->conn_rwsplit, (char *) "show processlist;");
    Test->close_rwsplit();

    Test->copy_all_logs(); return(global_result);
}
开发者ID:Robert-Xie,项目名称:maxscale-system-test,代码行数:34,代码来源:kill_master.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);

    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

示例4: 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


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