本文整理汇总了C++中TestConnections::set_timeout方法的典型用法代码示例。如果您正苦于以下问题:C++ TestConnections::set_timeout方法的具体用法?C++ TestConnections::set_timeout怎么用?C++ TestConnections::set_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestConnections
的用法示例。
在下文中一共展示了TestConnections::set_timeout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
char sql[10240];
Test->connect_maxscale();
create_t1(Test->conn_rwsplit);
Test->tprintf("INSERTing data\n");
for (int i = 0; i < 2000; i++)
{
Test->set_timeout(20);
create_insert_string(sql, 100, i);
Test->try_query(Test->conn_rwsplit, sql);
}
Test->tprintf("done, sleeping\n");
Test->stop_timeout();
sleep(20);
Test->tprintf("Trying SELECT\n");
Test->set_timeout(30);
Test->try_query(Test->conn_rwsplit, (char *) "SELECT * FROM t1");
Test->check_maxscale_alive();
int rval = Test->global_result;
delete Test;
return rval;
}
示例2: 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->tprintf("Trying USE db against RWSplit\n");
Test->try_query(Test->conn_rwsplit, (char *) "USE mysql");
Test->try_query(Test->conn_rwsplit, (char *) "USE test");
Test->set_timeout(10);
Test->tprintf("Trying USE db against ReadConn master\n");
Test->try_query(Test->conn_master, (char *) "USE mysql");
Test->try_query(Test->conn_master, (char *) "USE test");
Test->set_timeout(10);
Test->tprintf("Trying USE db against ReadConn slave\n");
Test->try_query(Test->conn_master, (char *) "USE mysql");
Test->try_query(Test->conn_slave, (char *) "USE test");
Test->set_timeout(10);
Test->close_maxscale_connections();
Test->check_maxscale_alive();
int rval = Test->global_result;
delete Test;
return rval;
}
示例3: 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;
}
示例4: 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;
}
示例5: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(3000);
int options_set = 3;
if (Test->smoke)
{
options_set = 1;
}
Test->repl->connect();
execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;");
Test->repl->close_connections();
sleep(5);
for (int option = 0; option < options_set; option++)
{
Test->binlog_cmd_option = option;
Test->start_binlog();
test_binlog(Test);
}
Test->check_log_err("SET NAMES utf8mb4", false);
Test->check_log_err("set autocommit=1", false);
Test->check_log_err("select USER()", false);
int rval = Test->global_result;
delete Test;
return rval;
}
示例6: 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;
}
示例7: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->check_log_err((char *) "Unexpected parameter 'укпоукц'", true);
Test->check_log_err((char *) "Unexpected parameter 'hren'", true);
Test->check_maxscale_processes(0);
int rval = Test->global_result;
delete Test;
return rval;
}
示例8: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(100);
Test->execute_maxadmin_command((char *) "show monitors");
sleep(5);
Test->check_log_err((char *) "Failed to start monitor", true);
Test->check_log_err((char *) "fatal signal 11", false);
Test->check_maxscale_processes(1);
int rval = Test->global_result;
delete Test;
return rval;
}
示例9: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->ssh_maxscale(true, "maxkeys");
Test->ssh_maxscale(true, "sudo chown maxscale:maxscale /var/lib/maxscale/.secrets");
try_password(Test, (char *) "aaa$aaa");
try_password(Test, (char *) "#¤&");
try_password(Test, (char *) "пароль");
Test->check_maxscale_alive();
int rval = Test->global_result;
delete Test;
return rval;
}
示例10: 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;
}
示例11: 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;
}
示例12: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(10);
int i;
Test->repl->connect();
Test->connect_maxscale();
Test->tprintf("Trying SHOW VARIABLES to different Maxscale services\n");
fflush(stdout);
Test->tprintf("RWSplit\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(5);
Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
}
Test->tprintf("ReadConn master\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(5);
Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
}
Test->tprintf("ReadConn slave\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(5);
Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
}
Test->tprintf("All in one loop\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(5);
Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
}
Test->set_timeout(10);
Test->close_maxscale_connections();
Test->repl->close_connections();
Test->check_maxscale_alive();
int rval = Test->global_result;
delete Test;
return rval;
}
示例13: 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;
}
示例14: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(20);
Test->connect_maxscale();
Test->tprintf("Trying query to ReadConn master\n");
fflush(stdout);
Test->try_query(Test->conn_master, "show processlist;");
Test->tprintf("Trying query to ReadConn slave\n");
Test->try_query(Test->conn_slave, "show processlist;");
Test->close_maxscale_connections();
Test->check_log_err((char *) "Creating client session for Tee filter failed. Terminating session.", true);
Test->check_log_err((char *) "Failed to create filter 'DuplicaFilter' for service 'RW_Router'", true);
int rval = Test->global_result;
delete Test;
return rval;
}
示例15: 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;
}