From 155fcd08df777dfbe21802bfdddb4980d6d22d40 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 8 Feb 2018 13:15:12 +0200 Subject: [PATCH] Do not fail local_address test if only one IP available Instead do as much as possible. --- maxscale-system-test/local_address.cpp | 48 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/maxscale-system-test/local_address.cpp b/maxscale-system-test/local_address.cpp index 071f43374..3795f78b0 100644 --- a/maxscale-system-test/local_address.cpp +++ b/maxscale-system-test/local_address.cpp @@ -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& 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 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;