aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-26 14:33:17 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-07-26 14:33:17 +0000
commitb7ce705c0662671983f034d99c01941af8bc5d68 (patch)
treed3af4b5c99f2db30e9ff3cb37b1e0d5fcb64640a
parentbc9601ba236447ea3003411e2a7f705545759340 (diff)
parent851419fe355e1e3323ec03a7bc8e3085094e4f86 (diff)
Merge "Make injection time configurable for IXIA RFC2544 test cases"
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py3
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py7
-rw-r--r--yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py4
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_base.py9
4 files changed, 15 insertions, 8 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
index a840feade..ba27d4d05 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -330,7 +330,7 @@ class IxNextgen(object): # pragma: no cover
'-valueType', 'singleValue')
self.ixnet.commit()
- def update_frame(self, traffic):
+ def update_frame(self, traffic, duration):
"""Update the L2 frame
This function updates the L2 frame options:
@@ -348,6 +348,7 @@ class IxNextgen(object): # pragma: no cover
:param traffic: list of traffic elements; each traffic element contains
the injection parameter for each flow group.
+ :param duration: (int) injection time in seconds.
"""
for traffic_param in traffic.values():
fg_id = str(traffic_param['id'])
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index c32e9d8c9..43455330f 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -100,7 +100,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
return result
def _ixia_traffic_generate(self, traffic, ixia_obj):
- ixia_obj.update_frame(traffic)
+ ixia_obj.update_frame(traffic, self.config.duration)
ixia_obj.update_ip_packet(traffic)
ixia_obj.start_traffic()
@@ -137,11 +137,12 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
self._ixia_traffic_generate(traffic, ixia_obj)
return first_run
- def get_drop_percentage(self, samples, tol_min, tolerance, duration=30.0,
+ def get_drop_percentage(self, samples, tol_min, tolerance,
first_run=False):
completed = False
drop_percent = 100
num_ifaces = len(samples)
+ duration = self.config.duration
in_packets_sum = sum(
[samples[iface]['in_packets'] for iface in samples])
out_packets_sum = sum(
@@ -169,7 +170,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
completed = True if drop_percent <= tolerance else False
if (first_run and
self.rate_unit == tp_base.TrafficProfileConfig.RATE_FPS):
- self.rate = out_packets_sum / duration / num_ifaces
+ self.rate = float(out_packets_sum) / duration / num_ifaces
if drop_percent > tolerance:
self.max_rate = self.rate
diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
index dd43a64a5..2327d1ac8 100644
--- a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
+++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
@@ -367,7 +367,7 @@ class TestIxNextgen(unittest.TestCase):
mock_get_stack_item:
mock_get_stack_item.side_effect = [['item1'], ['item2'],
['item3'], ['item4']]
- ixnet_gen.update_frame(TRAFFIC_PARAMETERS)
+ ixnet_gen.update_frame(TRAFFIC_PARAMETERS, 50)
self.assertEqual(6, len(ixnet_gen.ixnet.setMultiAttribute.mock_calls))
self.assertEqual(4, len(mock_update_frame.mock_calls))
@@ -385,7 +385,7 @@ class TestIxNextgen(unittest.TestCase):
ixnet_gen, '_get_config_element_by_flow_group_name',
return_value=None):
with self.assertRaises(exceptions.IxNetworkFlowNotPresent):
- ixnet_gen.update_frame(TRAFFIC_PARAMETERS)
+ ixnet_gen.update_frame(TRAFFIC_PARAMETERS, 40)
def test_get_statistics(self):
ixnet_gen = ixnet_api.IxNextgen()
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_base.py b/yardstick/tests/unit/network_services/traffic_profile/test_base.py
index 2a366fc94..0dc3e0579 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_base.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_base.py
@@ -80,12 +80,17 @@ class TrafficProfileConfigTestCase(unittest.TestCase):
tp_config = {'traffic_profile': {'packet_sizes': {'64B': 100}}}
tp_config_obj = base.TrafficProfileConfig(tp_config)
self.assertEqual({'64B': 100}, tp_config_obj.packet_sizes)
+ self.assertEqual(base.TrafficProfileConfig.DEFAULT_DURATION,
+ tp_config_obj.duration)
+
+ def test__init_set_duration(self):
+ tp_config = {'traffic_profile': {'duration': 15}}
+ tp_config_obj = base.TrafficProfileConfig(tp_config)
self.assertEqual(base.TrafficProfileConfig.DEFAULT_SCHEMA,
tp_config_obj.schema)
self.assertEqual(float(base.TrafficProfileConfig.DEFAULT_FRAME_RATE),
tp_config_obj.frame_rate)
- self.assertEqual(base.TrafficProfileConfig.DEFAULT_DURATION,
- tp_config_obj.duration)
+ self.assertEqual(15, tp_config_obj.duration)
def test__parse_rate(self):
tp_config = {'traffic_profile': {'packet_sizes': {'64B': 100}}}