_get_ip_flow_range: fix bug with single IP ranges 25/40525/3
authorRoss Brattain <ross.b.brattain@intel.com>
Wed, 23 Aug 2017 22:27:01 +0000 (15:27 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Wed, 30 Aug 2017 22:54:44 +0000 (15:54 -0700)
If we have a /32 or for some reason find a range of IPs
to use, we can default to the single IP specified on the interface.

Change-Id: Ieaa1d57b04e1d57e8cef344d5a53bbca05e7887f
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
yardstick/benchmark/scenarios/networking/vnf_generic.py

index df5047a..fe7b6a5 100644 (file)
@@ -362,7 +362,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
     def test__get_ip_flow_range(self):
         self.scenario_cfg["traffic_options"]["flow"] = \
             self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml")
-        result = '152.16.100.1-152.16.100.254'
+        result = '152.16.100.2-152.16.100.254'
         self.assertEqual(result, self.s._get_ip_flow_range({"tg__1": 'xe0'}))
 
     def test___get_traffic_flow(self):
@@ -384,8 +384,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
               'public_ip': ['1.1.1.1'],
             },
         }
-        result = {'flow': {'dst_ip0': '152.16.40.1-152.16.40.254',
-                           'src_ip0': '152.16.100.1-152.16.100.254'}}
+        result = {'flow': {'dst_ip0': '152.16.40.2-152.16.40.254',
+                           'src_ip0': '152.16.100.2-152.16.100.254'}}
 
         self.assertEqual(result, self.s._get_traffic_flow())
 
index 4510bcf..7ae6f08 100644 (file)
@@ -150,7 +150,13 @@ class NetworkServiceTestCase(base.Scenario):
 
             ipaddr = ipaddress.ip_network(six.text_type('{}/{}'.format(ip, mask)), strict=False)
             hosts = list(ipaddr.hosts())
-            ip_addr_range = "{}-{}".format(hosts[0], hosts[-1])
+            if len(hosts) > 2:
+                # skip the first host in case of gateway
+                ip_addr_range = "{}-{}".format(hosts[1], hosts[-1])
+            else:
+                LOG.warning("Only single IP in range %s", ipaddr)
+                # fall back to single IP range
+                ip_addr_range = ip
         else:
             # we are manually specifying the range
             ip_addr_range = range_or_interface