From 0cce2819d798b5365d15dc174f6b4e6d06c18fbf Mon Sep 17 00:00:00 2001 From: Oleksandr Naumets Date: Tue, 12 Feb 2019 18:40:26 +0000 Subject: Extend TRex RFC2544 test case collected stats Added new fields into Yardstick NSB TRex RFC2544 test case results: - Iteration - PktSize - Status JIRA: YARDSTICK-1592 Change-Id: Id746b537a0ef55a891653719cc1db29ef7e994fc Signed-off-by: Oleksandr Naumets --- .../libs/ixia_libs/ixnet/ixnet_api.py | 6 ++- .../traffic_profile/ixia_rfc2544.py | 17 ++----- .../network_services/traffic_profile/rfc2544.py | 11 +++- .../traffic_profile/trex_traffic_profile.py | 15 ++++++ .../vnf_generic/vnf/tg_rfc2544_ixia.py | 16 +++--- .../libs/ixia_libs/test_ixnet_api.py | 7 ++- .../traffic_profile/test_ixia_rfc2544.py | 59 +++++++++++----------- .../traffic_profile/test_rfc2544.py | 11 +++- .../vnf_generic/vnf/test_tg_rfc2544_ixia.py | 12 +++-- 9 files changed, 91 insertions(+), 63 deletions(-) (limited to 'yardstick') 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 cb8ba1771..ebef7fd9a 100644 --- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py +++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py @@ -477,7 +477,8 @@ class IxNextgen(object): # pragma: no cover self._create_flow_groups(uplink_endpoints, downlink_endpoints) self._setup_config_elements(traffic_profile=traffic_profile) - def create_ipv4_traffic_model(self, uplink_endpoints, downlink_endpoints): + def create_ipv4_traffic_model(self, uplink_endpoints, downlink_endpoints, + traffic_profile): """Create a traffic item and the needed flow groups Each flow group inside the traffic item (only one is present) @@ -490,7 +491,8 @@ class IxNextgen(object): # pragma: no cover """ self._create_traffic_item('ipv4') self._create_flow_groups(uplink_endpoints, downlink_endpoints) - self._setup_config_elements(False) + self._setup_config_elements(traffic_profile=traffic_profile, + add_default_proto=False) def _update_frame_mac(self, ethernet_descriptor, field, mac_address): """Set the MAC address in a config element stack Ethernet field diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py index aded2d347..5a9c06aba 100644 --- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py +++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py @@ -35,6 +35,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): super(IXIARFC2544Profile, self).__init__(yaml_data) self.rate = self.config.frame_rate self.rate_unit = self.config.rate_unit + self.iteration = 0 self.full_profile = {} def _get_ip_and_mask(self, ip_range): @@ -170,19 +171,6 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): self.ports = [port for port in port_generator()] - def _get_framesize(self): - framesizes = [] - traffic = self._get_ixia_traffic_profile(self.full_profile) - for v in traffic.values(): - framesize = v['outer_l2']['framesize'] - for size in (s for s, w in framesize.items() if int(w) != 0): - framesizes.append(size) - if len(set(framesizes)) == 0: - return '' - elif len(set(framesizes)) == 1: - return framesizes[0] - return 'IMIX' - def execute_traffic(self, traffic_generator, ixia_obj=None, mac=None): mac = {} if mac is None else mac first_run = self.first_run @@ -194,6 +182,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): else: self.rate = self._get_next_rate() + self.iteration = traffic_generator.rfc_helper.iteration.value traffic = self._get_ixia_traffic_profile(self.full_profile, mac) self._ixia_traffic_generate(traffic, ixia_obj, traffic_generator) return first_run @@ -278,6 +267,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile): samples['latency_ns_max'] = latency_ns_max samples['Rate'] = last_rate samples['PktSize'] = self._get_framesize() + samples['Iteration'] = self.iteration return completed, samples @@ -401,6 +391,7 @@ class IXIARFC2544PppoeScenarioProfile(IXIARFC2544Profile): samples['priority'] = priority_stats samples['Rate'] = last_rate samples['PktSize'] = self._get_framesize() + samples['Iteration'] = self.iteration samples.update(summary_subs_stats) if tc_rfc2544_opts: diff --git a/yardstick/network_services/traffic_profile/rfc2544.py b/yardstick/network_services/traffic_profile/rfc2544.py index b838bf814..4225f31b7 100644 --- a/yardstick/network_services/traffic_profile/rfc2544.py +++ b/yardstick/network_services/traffic_profile/rfc2544.py @@ -72,10 +72,13 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): """TRex RFC2544 traffic profile""" TOLERANCE_LIMIT = 0.01 + STATUS_SUCCESS = "Success" + STATUS_FAIL = "Failure" def __init__(self, traffic_generator): super(RFC2544Profile, self).__init__(traffic_generator) self.generator = None + self.iteration = 0 self.rate = self.config.frame_rate self.max_rate = self.config.frame_rate self.min_rate = 0 @@ -126,6 +129,7 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): self.generator.client.start(ports=ports, duration=self.config.duration, force=True) + self.iteration = self.generator.rfc2544_helper.iteration.value return ports, port_pg_id def _create_profile(self, profile_data, rate, port_pg_id, enable_latency): @@ -274,6 +278,7 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): correlated_traffic, resolution): """Calculate the drop percentage and run the traffic""" completed = False + status = self.STATUS_FAIL out_pkt_end = sum(port['out_packets'] for port in samples[-1].values()) in_pkt_end = sum(port['in_packets'] for port in samples[-1].values()) out_pkt_ini = sum(port['out_packets'] for port in samples[0].values()) @@ -304,6 +309,7 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): elif drop_percent < tol_low: self.min_rate = self.rate else: + status = self.STATUS_SUCCESS completed = True last_rate = self.rate @@ -332,6 +338,9 @@ class RFC2544Profile(trex_traffic_profile.TrexProfile): 'Throughput': throughput, 'DropPercentage': self.drop_percent_max, 'Rate': last_rate, - 'Latency': latency + 'Latency': latency, + 'PktSize': self._get_framesize(), + 'Iteration': self.iteration, + 'Status': status } return completed, output diff --git a/yardstick/network_services/traffic_profile/trex_traffic_profile.py b/yardstick/network_services/traffic_profile/trex_traffic_profile.py index 2d2c2d8b6..cf538d488 100644 --- a/yardstick/network_services/traffic_profile/trex_traffic_profile.py +++ b/yardstick/network_services/traffic_profile/trex_traffic_profile.py @@ -344,6 +344,21 @@ class TrexProfile(base.TrafficProfile): rate = round(float(self.max_rate + self.min_rate)/2.0, self.RATE_ROUND) return rate + def _get_framesize(self): + framesizes = [] + for traffickey, value in self.params.items(): + if not traffickey.startswith((self.UPLINK, self.DOWNLINK)): + continue + for _, data in value.items(): + framesize = data['outer_l2']['framesize'] + for size in (s for s, w in framesize.items() if int(w) != 0): + framesizes.append(size) + if len(set(framesizes)) == 0: + return '' + elif len(set(framesizes)) == 1: + return framesizes[0] + return 'IMIX' + @classmethod def _count_ip(cls, start_ip, end_ip): start = ipaddress.ip_address(six.u(start_ip)) diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py index 5d69fc8c8..5d64a8cba 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py @@ -54,13 +54,13 @@ class IxiaBasicScenario(object): def stop_protocols(self): pass - def create_traffic_model(self, traffic_profile=None): - # pylint: disable=unused-argument + def create_traffic_model(self, traffic_profile): vports = self.client.get_vports() self._uplink_vports = vports[::2] self._downlink_vports = vports[1::2] self.client.create_traffic_model(self._uplink_vports, - self._downlink_vports, traffic_profile) + self._downlink_vports, + traffic_profile) def _get_stats(self): return self.client.get_statistics() @@ -169,8 +169,7 @@ class IxiaL3Scenario(IxiaBasicScenario): self._add_interfaces() self._add_static_ips() - def create_traffic_model(self, traffic_profile=None): - # pylint: disable=unused-argument + def create_traffic_model(self, traffic_profile): vports = self.client.get_vports() self._uplink_vports = vports[::2] self._downlink_vports = vports[1::2] @@ -181,7 +180,8 @@ class IxiaL3Scenario(IxiaBasicScenario): for port in self._downlink_vports] self.client.create_ipv4_traffic_model(uplink_endpoints, - downlink_endpoints) + downlink_endpoints, + traffic_profile) class IxiaPppoeClientScenario(object): @@ -220,7 +220,8 @@ class IxiaPppoeClientScenario(object): uplink_endpoints = self._access_topologies downlink_endpoints = self._core_topologies self.client.create_ipv4_traffic_model(uplink_endpoints, - downlink_endpoints) + downlink_endpoints, + traffic_profile) def run_protocols(self): LOG.info('PPPoE Scenario - Start Protocols') @@ -816,7 +817,6 @@ class IxiaResourceHelper(ClientResourceHelper): completed, samples = traffic_profile.get_drop_percentage( samples, min_tol, max_tol, precision, resolution, first_run=first_run) - samples['Iteration'] = self.rfc_helper.iteration.value self._queue.put(samples) if completed: 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 270d342fd..a20592dc7 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 @@ -589,12 +589,15 @@ class TestIxNextgen(unittest.TestCase): mock__create_traffic_item): uplink_topologies = ['up1', 'up3'] downlink_topologies = ['down2', 'down4'] + traffic_profile = 'fake_profile' self.ixnet_gen.create_ipv4_traffic_model(uplink_topologies, - downlink_topologies) + downlink_topologies, + traffic_profile) mock__create_traffic_item.assert_called_once_with('ipv4') mock__create_flow_groups.assert_called_once_with(uplink_topologies, downlink_topologies) - mock__setup_config_elements.assert_called_once_with(False) + mock__setup_config_elements.assert_called_once_with( + traffic_profile='fake_profile', add_default_proto=False) def test_flows_settings(self): cfg = {'uplink_0': { diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py index 7b5165c39..426d6b21b 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py @@ -517,60 +517,56 @@ class TestIXIARFC2544Profile(unittest.TestCase): def test__get_framesize(self): traffic_profile = { - 'uplink_0': {'outer_l2': {'framesize': {'64B': 100}}}, - 'downlink_0': {'outer_l2': {'framesize': {'64B': 100}}}, - 'uplink_1': {'outer_l2': {'framesize': {'64B': 100}}}, - 'downlink_1': {'outer_l2': {'framesize': {'64B': 100}}} + 'uplink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 100}}}}, + 'downlink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 100}}}}, + 'uplink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 100}}}}, + 'downlink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 100}}}} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) - with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \ - as mock_get_tp: - mock_get_tp.return_value = traffic_profile - result = rfc2544_profile._get_framesize() + rfc2544_profile.params = traffic_profile + result = rfc2544_profile._get_framesize() self.assertEqual(result, '64B') def test__get_framesize_IMIX_traffic(self): traffic_profile = { - 'uplink_0': {'outer_l2': {'framesize': {'64B': 50, - '128B': 50}}}, - 'downlink_0': {'outer_l2': {'framesize': {'64B': 50, - '128B': 50}}}, - 'uplink_1': {'outer_l2': {'framesize': {'64B': 50, - '128B': 50}}}, - 'downlink_1': {'outer_l2': {'framesize': {'64B': 50, - '128B': 50}}} + 'uplink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 50, + '128B': 50}}}}, + 'downlink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 50, + '128B': 50}}}}, + 'uplink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 50, + '128B': 50}}}}, + 'downlink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 50, + '128B': 50}}}} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) - with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \ - as mock_get_tp: - mock_get_tp.return_value = traffic_profile - result = rfc2544_profile._get_framesize() + rfc2544_profile.params = traffic_profile + result = rfc2544_profile._get_framesize() self.assertEqual(result, 'IMIX') def test__get_framesize_zero_pkt_size_weight(self): traffic_profile = { - 'uplink_0': {'outer_l2': {'framesize': {'64B': 0}}}, - 'downlink_0': {'outer_l2': {'framesize': {'64B': 0}}}, - 'uplink_1': {'outer_l2': {'framesize': {'64B': 0}}}, - 'downlink_1': {'outer_l2': {'framesize': {'64B': 0}}} + 'uplink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 0}}}}, + 'downlink_0': {'ipv4': {'outer_l2': {'framesize': {'64B': 0}}}}, + 'uplink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 0}}}}, + 'downlink_1': {'ipv4': {'outer_l2': {'framesize': {'64B': 0}}}} } rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) - with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \ - as mock_get_tp: - mock_get_tp.return_value = traffic_profile - result = rfc2544_profile._get_framesize() + rfc2544_profile.params = traffic_profile + result = rfc2544_profile._get_framesize() self.assertEqual(result, '') def test_execute_traffic_first_run(self): rfc2544_profile = ixia_rfc2544.IXIARFC2544Profile(self.TRAFFIC_PROFILE) rfc2544_profile.first_run = True rfc2544_profile.rate = 50 + traffic_gen = mock.Mock() + traffic_gen.rfc_helper.iteration.value = 0 with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \ as mock_get_tp, \ mock.patch.object(rfc2544_profile, '_ixia_traffic_generate') \ as mock_tgenerate: mock_get_tp.return_value = 'fake_tprofile' - output = rfc2544_profile.execute_traffic(mock.ANY, + output = rfc2544_profile.execute_traffic(traffic_gen, ixia_obj=mock.ANY) self.assertTrue(output) @@ -585,13 +581,15 @@ class TestIXIARFC2544Profile(unittest.TestCase): rfc2544_profile.first_run = False rfc2544_profile.max_rate = 70 rfc2544_profile.min_rate = 0 + traffic_gen = mock.Mock() + traffic_gen.rfc_helper.iteration.value = 0 with mock.patch.object(rfc2544_profile, '_get_ixia_traffic_profile') \ as mock_get_tp, \ mock.patch.object(rfc2544_profile, '_ixia_traffic_generate') \ as mock_tgenerate: mock_get_tp.return_value = 'fake_tprofile' rfc2544_profile.full_profile = mock.ANY - output = rfc2544_profile.execute_traffic(mock.ANY, + output = rfc2544_profile.execute_traffic(traffic_gen, ixia_obj=mock.ANY) self.assertFalse(output) @@ -817,6 +815,7 @@ class TestIXIARFC2544PppoeScenarioProfile(unittest.TestCase): self.TRAFFIC_PROFILE) self.ixia_tp.rate = 100.0 self.ixia_tp._get_next_rate = mock.Mock(return_value=50.0) + self.ixia_tp._get_framesize = mock.Mock(return_value='64B') def test___init__(self): self.assertIsInstance(self.ixia_tp.full_profile, diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py index c72a72d3d..6c86bf1cb 100644 --- a/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/yardstick/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -248,8 +248,12 @@ class TestRFC2544Profile(base.BaseUnitTestCase): mock.call(percentage=float(25 * 35) / 100), mock.call(percentage=float(75 * 35) / 100)], any_order=True) - def test_get_drop_percentage(self): + @mock.patch.object(rfc2544.RFC2544Profile, '_get_framesize') + def test_get_drop_percentage(self, mock_get_framesize): rfc2544_profile = rfc2544.RFC2544Profile(self.TRAFFIC_PROFILE) + rfc2544_profile.iteration = 1 + mock_get_framesize.return_value = '64B' + samples = [ {'xe1': {'tx_throughput_fps': 110, 'rx_throughput_fps': 101, @@ -292,7 +296,10 @@ class TestRFC2544Profile(base.BaseUnitTestCase): 'TxThroughputBps': 128000000.0, 'CurrentDropPercentage': 50.0, 'Rate': 100.0, - 'Throughput': 1000000.0} + 'Throughput': 1000000.0, + 'Iteration': 1, + 'PktSize': '64B', + 'Status': 'Failure'} self.assertEqual(expected, output) self.assertFalse(completed) diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py index d84fda789..51a379cee 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py @@ -115,7 +115,7 @@ class TestIxiaResourceHelper(unittest.TestCase): mock_tprofile = mock.Mock() mock_tprofile.config.duration = 10 mock_tprofile.get_drop_percentage.return_value = \ - True, {'test': 'fake_samples'} + True, {'test': 'fake_samples', 'Iteration': 1} ixia_rhelper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock()) tasks_queue = mock.Mock() tasks_queue.get.return_value = 'RUN_TRAFFIC' @@ -649,11 +649,13 @@ class TestIxiaL3Scenario(TestIxiaBasicScenario): def test_create_traffic_model(self): self.mock_IxNextgen.get_vports.return_value = ['1', '2'] - self.scenario.create_traffic_model() + traffic_profile = 'fake_profile' + self.scenario.create_traffic_model(traffic_profile) self.scenario.client.get_vports.assert_called_once() self.scenario.client.create_ipv4_traffic_model.\ assert_called_once_with(['1/protocols/static'], - ['2/protocols/static']) + ['2/protocols/static'], + 'fake_profile') def test_apply_config(self): self.scenario._add_interfaces = mock.Mock() @@ -772,7 +774,7 @@ class TestIxiaPppoeClientScenario(unittest.TestCase): mock_id_pairs.assert_called_once_with(mock_tp.full_profile) mock_obj_pairs.assert_called_once_with(['xe0', 'xe1', 'xe0', 'xe1']) self.scenario.client.create_ipv4_traffic_model.assert_called_once_with( - uplink_endpoints, downlink_endpoints) + uplink_endpoints, downlink_endpoints, mock_tp) @mock.patch.object(tg_rfc2544_ixia.IxiaPppoeClientScenario, '_get_endpoints_src_dst_id_pairs') @@ -796,7 +798,7 @@ class TestIxiaPppoeClientScenario(unittest.TestCase): mock_id_pairs.assert_called_once_with(mock_tp.full_profile) mock_obj_pairs.assert_called_once_with([]) self.scenario.client.create_ipv4_traffic_model.assert_called_once_with( - uplink_topologies, downlink_topologies) + uplink_topologies, downlink_topologies, mock_tp) def test__get_endpoints_src_dst_id_pairs(self): full_tp = OrderedDict([ -- cgit 1.2.3-korg