Clean up mxs812_1
Use stack allocated objects, reduce the iteration count and the amount of sent data (now roughly 10MB in total).
This commit is contained in:
@ -6,77 +6,64 @@
|
|||||||
* - execute statement
|
* - execute statement
|
||||||
* - wait 5 seconds
|
* - wait 5 seconds
|
||||||
* - check "Current no. of conns" maxadmin output, expect 0
|
* - check "Current no. of conns" maxadmin output, expect 0
|
||||||
* - repeat test 10 times
|
* - repeat test 2 times
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "testconnections.h"
|
#include "testconnections.h"
|
||||||
|
|
||||||
void run_test(TestConnections *Test, size_t size, int chunks)
|
void run_test(TestConnections& test, size_t size, int chunks)
|
||||||
{
|
{
|
||||||
char *insert_stmt = (char *) "INSERT INTO long_blob_table(x, b) VALUES(1, ?)";
|
test.set_timeout(600);
|
||||||
MYSQL *conn = Test->maxscales->conn_rwsplit[0];
|
const char* insert_stmt = "INSERT INTO long_blob_table(x, b) VALUES(1, ?)";
|
||||||
MYSQL_STMT * stmt = mysql_stmt_init(conn);
|
MYSQL* conn = test.maxscales->conn_rwsplit[0];
|
||||||
|
MYSQL_STMT* stmt = mysql_stmt_init(conn);
|
||||||
|
|
||||||
Test->tprintf("Preparing statement");
|
test.add_result(mysql_stmt_prepare(stmt, insert_stmt, strlen(insert_stmt)),
|
||||||
Test->add_result(mysql_stmt_prepare(stmt, insert_stmt, strlen(insert_stmt)), "Error preparing stmt: %s\n",
|
"Error preparing stmt: %s", mysql_stmt_error(stmt));
|
||||||
mysql_stmt_error(stmt));
|
|
||||||
|
|
||||||
MYSQL_BIND param[1];
|
MYSQL_BIND param;
|
||||||
param[0].buffer_type = MYSQL_TYPE_STRING;
|
param.buffer_type = MYSQL_TYPE_STRING;
|
||||||
param[0].is_null = 0;
|
param.is_null = 0;
|
||||||
|
|
||||||
Test->add_result(mysql_stmt_bind_param(stmt, param), "Error parameter binding: %s\n", mysql_stmt_error(stmt));
|
test.add_result(mysql_stmt_bind_param(stmt, ¶m),
|
||||||
|
"Binding parameter failed: %s", mysql_stmt_error(stmt));
|
||||||
|
|
||||||
unsigned long *data = (unsigned long *) malloc(size * sizeof(long int));
|
std::string data(size, '.');
|
||||||
|
test.tprintf("Sending %d x %d bytes of data", size, chunks);
|
||||||
|
|
||||||
memset(data, '.', size * sizeof(long int));
|
|
||||||
|
|
||||||
Test->tprintf("Sending %d x %d bytes of data", size, chunks);
|
|
||||||
for (int i = 0; i < chunks; i++)
|
for (int i = 0; i < chunks; i++)
|
||||||
{
|
{
|
||||||
Test->set_timeout(600);
|
test.add_result(mysql_stmt_send_long_data(stmt, 0, data.c_str(), data.size()),
|
||||||
Test->tprintf("Chunk #%d\n", i);
|
"Error inserting data, iteration %d, error %s", i, mysql_stmt_error(stmt));
|
||||||
if (mysql_stmt_send_long_data(stmt, 0, (char *) data, size * sizeof(long int)) != 0)
|
|
||||||
{
|
|
||||||
Test->add_result(1, "Error inserting data, iteration %d, error %s\n", i, mysql_stmt_error(stmt));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Test->set_timeout(600);
|
test.set_timeout(600);
|
||||||
Test->tprintf("Executing statement");
|
test.add_result(mysql_stmt_execute(stmt), "Execute failed: %s", mysql_stmt_error(stmt));
|
||||||
Test->add_result(mysql_stmt_execute(stmt), "INSERT Statement with BLOB failed, error is %s\n",
|
|
||||||
mysql_stmt_error(stmt));
|
|
||||||
|
|
||||||
Test->stop_timeout();
|
test.stop_timeout();
|
||||||
sleep(5);
|
sleep(5);
|
||||||
Test->check_current_operations(0, 0);
|
test.check_current_operations(0, 0);
|
||||||
Test->tprintf("Closing statement");
|
test.add_result(mysql_stmt_close(stmt), "Closing statement failed: %s", mysql_stmt_error(stmt));
|
||||||
Test->add_result(mysql_stmt_close(stmt), "Error closing stmt\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
TestConnections * Test = new TestConnections(argc, argv);
|
TestConnections test(argc, argv);
|
||||||
Test->set_timeout(300);
|
test.repl->execute_query_all_nodes("set global max_allowed_packet=10000000");
|
||||||
int iter = 10;
|
|
||||||
|
|
||||||
Test->repl->execute_query_all_nodes( (char *) "set global max_allowed_packet=10000000");
|
test.repl->connect();
|
||||||
|
test.try_query(test.repl->nodes[0], "DROP TABLE IF EXISTS long_blob_table");
|
||||||
|
test.try_query(test.repl->nodes[0], "CREATE TABLE long_blob_table(x INT, b LONGBLOB)");
|
||||||
|
test.repl->sync_slaves();
|
||||||
|
|
||||||
/** Create test table */
|
test.maxscales->connect();
|
||||||
Test->repl->connect();
|
|
||||||
Test->try_query(Test->repl->nodes[0], (char*)"DROP TABLE IF EXISTS long_blob_table");
|
|
||||||
Test->try_query(Test->repl->nodes[0], (char*)"CREATE TABLE long_blob_table(x INT, b LONGBLOB)");
|
|
||||||
|
|
||||||
Test->maxscales->connect_maxscale(0);
|
for (int i = 0; i < 2; i++)
|
||||||
Test->tprintf("Starting test");
|
|
||||||
for (int i = 0; i < iter; i++)
|
|
||||||
{
|
{
|
||||||
run_test(Test, 500000, 10);
|
run_test(test, 500000, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rval = Test->global_result;
|
test.maxscales->disconnect();
|
||||||
delete Test;
|
|
||||||
return rval;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user