Add methods for changing the active MaxScale instance

The new function allows two MaxScale instances to be controlled via the
same TestConnections object. This will allow testing of Maxscale clusters.
This commit is contained in:
Markus Mäkelä
2017-10-04 10:57:12 +03:00
committed by Johan Wikman
parent 65b4612ff4
commit e58f6d6317
2 changed files with 63 additions and 0 deletions

View File

@ -278,6 +278,13 @@ TestConnections::TestConnections(int argc, char *argv[]):
if (maxscale_init)
{
init_maxscale();
if (!secondary_maxscale_IP.empty())
{
set_active_maxscale(MXS_SECONDARY);
init_maxscale();
set_active_maxscale(MXS_PRIMARY);
}
}
if (backend_ssl)
@ -372,12 +379,28 @@ int TestConnections::read_env()
if (env != NULL)
{
sprintf(maxscale_IP, "%s", env);
primary_maxscale_IP = env;
}
env = getenv("maxscale_network6");
if (env != NULL)
{
sprintf(maxscale_IP6, "%s", env);
primary_maxscale_IP6 = env;
}
env = getenv("maxscale2_IP");
if (env != NULL)
{
secondary_maxscale_IP = env;
}
env = getenv("maxscale2_network6");
if (env != NULL)
{
secondary_maxscale_IP = env;
}
env = getenv("maxscale_user");
if (env != NULL)
{
@ -2235,3 +2258,24 @@ char* TestConnections::maxscale_ip() const
{
return use_ipv6 ? (char*)maxscale_IP6 : (char*)maxscale_IP;
}
void TestConnections::set_active_maxscale(enum test_target target)
{
switch (target)
{
case MXS_PRIMARY:
strcpy(maxscale_IP, primary_maxscale_IP.c_str());
strcpy(maxscale_IP6, primary_maxscale_IP6.c_str());
break;
case MXS_SECONDARY:
strcpy(maxscale_IP, secondary_maxscale_IP.c_str());
strcpy(maxscale_IP6, secondary_maxscale_IP6.c_str());
break;
default:
tprintf("Wrong enum value for 'set_active_maxscale': 0x%02x", target);
exit(1);
break;
}
}