Add maxinfo SQL interface test

Added a test for the maxinfo SQL interface.
This commit is contained in:
Markus Mäkelä 2018-04-13 13:12:01 +03:00
parent 7e29725050
commit 890902e338
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 156 additions and 0 deletions

View File

@ -381,6 +381,9 @@ add_test_executable(max_connections.cpp max_connections replication LABELS MySQL
# Test of Maxinfo interface (http)
#add_test_executable(maxinfo.cpp maxinfocpp maxinfo LABELS maxinfo UNSTABLE HEAVY REPL_BACKEND)
# Test of Maxinfo SQL interface
add_test_executable(maxinfo_sql.cpp maxinfo_sql maxinfo_sql LABELS maxinfo REPL_BACKEND)
# Test of Maxinfo interface (http), python impelemntation
add_test_script(maxinfo.py maxinfo.py maxinfo LABELS maxinfo LIGHT REPL_BACKEND)

View File

@ -0,0 +1,71 @@
[maxscale]
threads=4
[server1]
type=server
address=###node_server_IP_1###
port=###node_server_port_1###
protocol=MySQLBackend
[server2]
type=server
address=###node_server_IP_2###
port=###node_server_port_2###
protocol=MySQLBackend
[server3]
type=server
address=###node_server_IP_3###
port=###node_server_port_3###
protocol=MySQLBackend
[server4]
type=server
address=###node_server_IP_4###
port=###node_server_port_4###
protocol=MySQLBackend
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
monitor_interval=1000
[Maxinfo]
type=service
router=maxinfo
user=maxuser
passwd=maxpwd
# Added here to allow users to be fetched from the backend server
servers=server1
[Maxinfo-SQL-Listener]
type=listener
service=Maxinfo
protocol=MySQLClient
port=4008
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[CLI]
type=service
router=cli
[CLI-Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default

View File

@ -0,0 +1,82 @@
/**
* Test MaxInfo with the SQL interface
*/
#include "testconnections.h"
#include <string>
#include <thread>
#include <vector>
#include <atomic>
using namespace std;
int main(int argc, char** argv)
{
vector<string> commands(
{
"SET SERVER server1 master",
"CLEAR SERVER server1 master",
"FLUSH LOGS",
"SHOW VARIABLES",
"SHOW VARIABLES LIKE '%version%'",
"SHOW STATUS",
"SHOW SERVICES",
"SHOW LISTENERS",
"SHOW SESSIONS",
"SHOW CLIENTS",
"SHOW SERVERS",
"SHOW MODULES",
"SHOW MONITORS",
"SHOW EVENTTIMES"
});
TestConnections test(argc, argv);
vector<thread> threads;
atomic<bool> run(true);
atomic<bool> wait(true);
// Create some threads so that the SHOW SESSIONS will actually do something
for (int i = 0; i < 25; i++)
{
threads.emplace_back([&]()
{
while (wait)
{
sleep(1);
}
while (run)
{
MYSQL* conn = test.maxscales->open_rwsplit_connection();
for (int i = 0; i < 100; i++)
{
mysql_query(conn, "SELECT REPEAT('a', 10000), sleep(0.01) FROM dual");
}
mysql_close(conn);
}
});
}
wait = false;
MYSQL* conn = test.maxscales->open_readconn_master_connection();
for (int i = 0; i < 100; i++)
{
for (auto a : commands)
{
test.try_query(conn, "%s", a.c_str());
}
}
mysql_close(conn);
run = false;
for (auto& a : threads)
{
a.join();
}
return test.global_result;
}