
The SHOW DATABASES greatly slows down the test. By doing that only from time to time, the test time drops from roughly 160 seconds to 15 seconds. There's also no point in continuing the test after a failure has been seen. Also added a missing sync_slaves to the database creation to make sure they are created on all servers before the test starts.
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
/**
|
|
* MXS-1713: SchemaRouter unable to process SHOW DATABASES for a lot of schemas
|
|
*
|
|
* https://jira.mariadb.org/browse/MXS-1713
|
|
*/
|
|
#include "testconnections.h"
|
|
#include <vector>
|
|
#include <set>
|
|
#include <numeric>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
TestConnections test(argc, argv);
|
|
const int n_db = 2000;
|
|
std::vector<std::string> db_list;
|
|
|
|
for (int i = 0; i < n_db; i++)
|
|
{
|
|
db_list.push_back("db" + std::to_string(i));
|
|
}
|
|
|
|
test.tprintf("Create %lu databases...", db_list.size());
|
|
test.repl->connect();
|
|
for (auto db : db_list)
|
|
{
|
|
execute_query(test.repl->nodes[0], "CREATE DATABASE %s", db.c_str());
|
|
}
|
|
test.repl->sync_slaves();
|
|
test.tprintf("Done!");
|
|
|
|
test.tprintf("Opening a connection with each database as the default database...", db_list.size());
|
|
std::set<std::string> errors;
|
|
int i = 0;
|
|
|
|
for (auto db : db_list)
|
|
{
|
|
MYSQL* conn = open_conn_db(test.maxscales->port(),
|
|
test.maxscales->ip(),
|
|
db,
|
|
test.maxscales->user_name,
|
|
test.maxscales->password);
|
|
|
|
test.expect(execute_query(conn, "SELECT 1") == 0, "Query should work: %s", mysql_error(conn));
|
|
|
|
if (i++ % 300 == 0)
|
|
{
|
|
test.expect(execute_query(conn, "SHOW DATABASES") == 0, "Query should work: %s", mysql_error(conn));
|
|
}
|
|
|
|
mysql_close(conn);
|
|
|
|
if (test.global_result)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
test.tprintf("Done!");
|
|
|
|
test.tprintf("Dropping databases...");
|
|
for (auto db : db_list)
|
|
{
|
|
execute_query(test.repl->nodes[0], "DROP DATABASE %s", db.c_str());
|
|
}
|
|
test.tprintf("Done!");
|
|
|
|
return test.global_result;
|
|
}
|