Files
MaxScale/maxscale-system-test/mxs244_prepared_stmt_loop.cpp
Timofey Turenko cd732ac14f MXS-2243 System tests brings VMs by themselves (#193)
maxscale-system-test changed in order to control test environment by itself.
Every test checks which machines are running, compare with list of needed machines
and start new VMs is they are missing in the running machines list.
Tests are executiong MDBCI commands, MDBCI executable should be in the PATH
2019-04-02 13:27:34 +03:00

63 lines
2.1 KiB
C++

/**
* @file mxs244_prepared_stmt_loop.cpp mxs244_prepared_stmt_loop executed following statements in the loop
* against all maxscales->routers[0]:
* @verbatim
* SET NAMES "UTF8";
* PREPARE s1 FROM 'SHOW GLOBAL STATUS WHERE variable_name = ?';
* SET @a = "Com_stmt_prepare";
* EXECUTE s1 USING @a;
* PREPARE s1 FROM 'SHOW GLOBAL STATUS WHERE variable_name = ?';
* SET @a = "Com_stmt_close";
* EXECUTE s1 USING @a;
* @endverbatim
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections::require_galera(true);
TestConnections* Test = new TestConnections(argc, argv);
long unsigned iterations = (Test->smoke) ? 1000 : 25000;
int r = (Test->smoke) ? 1 : 3;
Test->set_timeout(5);
Test->maxscales->connect_maxscale(0);
MYSQL* router[3];
router[0] = Test->maxscales->conn_rwsplit[0];
router[1] = Test->maxscales->conn_master[0];
router[2] = Test->maxscales->conn_slave[0];
for (int ir = 0; ir < r; ir++)
{
Test->tprintf("Trying simple prepared statements in the loop, router %d\n", ir);
for (long unsigned i = 0; i < iterations; i++)
{
Test->set_timeout(10);
Test->try_query(router[ir], (char*) "SET NAMES \"UTF8\"");
Test->try_query(router[ir],
(char*) "PREPARE s1 FROM 'SHOW GLOBAL STATUS WHERE variable_name = ?'");
Test->try_query(router[ir], (char*) "SET @a = \"Com_stmt_prepare\"");
Test->try_query(router[ir], (char*) "EXECUTE s1 USING @a");
Test->try_query(router[ir],
(char*) "PREPARE s1 FROM 'SHOW GLOBAL STATUS WHERE variable_name = ?'");
Test->try_query(router[ir], (char*) "SET @a = \"Com_stmt_close\"");
Test->try_query(router[ir], (char*) "EXECUTE s1 USING @a");
if ((( i / 100) * 100) == i)
{
Test->tprintf("Iterations = %lu\n", i);
}
}
}
Test->set_timeout(20);
Test->maxscales->close_maxscale_connections(0);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}