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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,12 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
enum test_target
|
||||
{
|
||||
MXS_PRIMARY,
|
||||
MXS_SECONDARY
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class contains references to Master/Slave and Galera test setups
|
||||
* Test setup should consist of two setups: one Master/Slave and one Galera.
|
||||
@ -123,6 +129,12 @@ public:
|
||||
*/
|
||||
char maxscale_IP[1024];
|
||||
|
||||
/** IPv4 and IPv6 addresses for the primary and secondary instances */
|
||||
std::string primary_maxscale_IP;
|
||||
std::string primary_maxscale_IP6;
|
||||
std::string secondary_maxscale_IP;
|
||||
std::string secondary_maxscale_IP6;
|
||||
|
||||
/**
|
||||
* @brief Maxscale_IP6 Maxscale machine IP address (IPv6)
|
||||
*/
|
||||
@ -715,6 +727,13 @@ public:
|
||||
* @param dest Destination file name for actual configuration file
|
||||
*/
|
||||
void process_template(const char *src, const char *dest = "/etc/maxscale.cnf");
|
||||
|
||||
/**
|
||||
* @brief Change the target MaxScale
|
||||
*
|
||||
* @param target Either MXS_PRIMARY or MXS_SECONDARY
|
||||
*/
|
||||
void set_active_maxscale(enum test_target target);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user