Do not fail local_address test if only one IP available

Instead do as much as possible.
This commit is contained in:
Johan Wikman 2018-02-08 13:15:12 +02:00
parent 458edb9b1d
commit 155fcd08df

View File

@ -256,10 +256,14 @@ void test_connecting(TestConnections& test,
}
}
void run_test(TestConnections& test, const string& ip1, const string& ip2)
void run_test(TestConnections& test, const vector<string>& ips)
{
test.connect_maxscale();
string ip1 = ips[0];
// If we do not have a proper second IP-address, we'll use an arbitrary one.
string ip2 = (ips.size() > 1) ? ips[1] : string("42.42.42.42");
string local_ip = get_local_ip(test);
const char* zUser1 = "alice";
@ -295,24 +299,34 @@ void run_test(TestConnections& test, const string& ip1, const string& ip2)
test.close_maxscale_connections();
test.stop_maxscale();
test.tprintf("\n");
test.tprintf("WARNING: Other IP-address not tested, as usable IP-address not available.");
if (ips.size() > 1)
{
#ifdef USABLE_SECOND_IP_ADDRESS_ON_MAXSCALE_NODE_IS_AVAILABLE
test.tprintf("\n");
test.tprintf("\nTesting with local_address=%s, bob should be able to access, alice not.",
ip2.c_str());
test.tprintf("\n");
test.tprintf("\nTesting with local_address=%s, bob should be able to access, alice not.",
ip2.c_str());
string local_address_ip2 = "local_address=" + ip2;
start_maxscale_with_local_address(test, local_address_ip1, local_address_ip2);
test.connect_maxscale();
string local_address_ip2 = "local_address=" + ip2;
start_maxscale_with_local_address(test, local_address_ip1, local_address_ip2);
test.connect_maxscale();
test_connecting(test, zUser1, zPassword1, ip1.c_str(), false);
test_connecting(test, zUser2, zPassword2, ip2.c_str(), true);
test_connecting(test, zUser1, zPassword1, ip1.c_str(), false);
test_connecting(test, zUser2, zPassword2, ip2.c_str(), true);
test.close_maxscale_connections();
test.stop_maxscale();
test.close_maxscale_connections();
test.stop_maxscale();
#else
test.tprintf("\n");
test.tprintf("WARNING: Other IP-address (%s) not tested, as IP-address currently "
"not usable on VM.", ip2.c_str());
#endif
}
else
{
test.tprintf("\n");
test.tprintf("WARNING: Only one IP-address found on MaxScale node, 'local_address' "
"not properly tested.");
}
}
}
@ -324,13 +338,13 @@ int main(int argc, char** argv)
vector<string> ips;
get_maxscale_ips(test, &ips);
if (ips.size() >= 2)
if (ips.size() >= 1)
{
run_test(test, ips[0], ips[1]);
run_test(test, ips);
}
else
{
test.assert(false, "MaxScale node does not have at least two IP-addresses.");
test.assert(false, "MaxScale node does not have at least one IP-address.");
}
return test.global_result;