diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-23 17:00:52 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-24 08:59:37 +0100 |
commit | abd5b952f42f429f6f1b59f3f7822cc92da0f6f6 (patch) | |
tree | 8a6519548f08650976ef4c31e16e30177905c39b /yardstick/tests/unit/common/test_utils.py | |
parent | 70eef8dd6ef160d3782984742fbc7958a35c03c7 (diff) |
Add IP mask to IxNetwork configuration
Assign the IP mask to IxNetwork configuration, depending on the IP range
provided by the user in the traffic profile. In case of single IP, a
default mask will be provided:
- IP_VERSION_4_MASK = 24
- IP_VERSION_6_MASK = 64
JIRA: YARDSTICK-1351
Change-Id: I029473ab8b9966a76cf559ffef53b34ca11462ad
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common/test_utils.py')
-rw-r--r-- | yardstick/tests/unit/common/test_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py index 446afdd38..bf0b5181a 100644 --- a/yardstick/tests/unit/common/test_utils.py +++ b/yardstick/tests/unit/common/test_utils.py @@ -1196,6 +1196,20 @@ class TestUtilsIpAddrMethods(ut_base.BaseUnitTestCase): for value in chain(value_iter, self.INVALID_IP_ADDRESS_STR_LIST): self.assertEqual(utils.ip_to_hex(value), value) + def test_get_mask_from_ip_range_ipv4(self): + ip_str = '1.1.1.1' + for mask in range(8, 30): + ip = ipaddress.ip_network(ip_str + '/' + str(mask), strict=False) + result = utils.get_mask_from_ip_range(ip[2], ip[-2]) + self.assertEqual(mask, result) + + def test_get_mask_from_ip_range_ipv6(self): + ip_str = '2001::1' + for mask in range(8, 120): + ip = ipaddress.ip_network(ip_str + '/' + str(mask), strict=False) + result = utils.get_mask_from_ip_range(ip[2], ip[-2]) + self.assertEqual(mask, result) + class SafeDecodeUtf8TestCase(ut_base.BaseUnitTestCase): |