From 1ad8da59859f72c97321c9cf8a4f048fc57addd1 Mon Sep 17 00:00:00 2001 From: John O Loughlin Date: Fri, 23 Nov 2018 11:38:14 +0000 Subject: Fix QnQ issue Currently if multiple tests are run with a QnQ section defined the QnQ segment gets appended to the frame. This leads to invalid frames when the test is run for more than 1 iteration. With this patch the QnQ is updated if the QnQ segment has already been created. JIRA: YARDSTICK-1513 Change-Id: I4ba6ef89380ccf1cb8a132ff5bf048935a87f0c9 Signed-off-by: John O Loughlin Signed-off-by: Oleksandr Naumets --- .../libs/ixia_libs/test_ixnet_api.py | 101 ++++++++++++++++++++- .../vnf_generic/vnf/test_tg_rfc2544_ixia.py | 9 +- 2 files changed, 105 insertions(+), 5 deletions(-) (limited to 'yardstick/tests/unit/network_services') 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 38ca26b08..dfd07d28c 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 @@ -22,11 +22,47 @@ from collections import OrderedDict from yardstick.common import exceptions from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api +from yardstick.network_services.traffic_profile import ixia_rfc2544 UPLINK = 'uplink' DOWNLINK = 'downlink' +TRAFFIC_PROFILE = { + 'uplink_0': { + 'ipv4': { + 'outer_l2': { + 'framesize': { + '128B': '0', + '1518B': '0', + '64B': '0', + '373b': '0', + '256B': '0', + '1400B': '0', + '570B': '0'}}, + 'id': 1}}, + 'description': 'Traffic profile to run RFC2544 latency', + 'name': 'rfc2544', + 'schema': 'isb:traffic_profile:0.1', + 'traffic_profile': { + 'injection_time': None, + 'enable_latency': True, + 'frame_rate': '100%', + 'traffic_type': 'IXIARFC2544Profile'}, + 'downlink_0': { + 'ipv4': { + 'outer_l2': { + 'framesize': { + '128B': '0', + '1518B': '0', + '64B': '0', + '373b': '0', + '256B': '0', + '1400B': '0', + '570B': '0'}}, + 'id': 2}}} + + TRAFFIC_PARAMETERS = { UPLINK: { 'id': 1, @@ -506,12 +542,17 @@ class TestIxNextgen(unittest.TestCase): 'my_root/traffic/protocolTemplate:"my_protocol"') def test__setup_config_elements(self): + # the config parsed from some_file + yaml_data = {'traffic_profile': {} + } + traffic_profile = ixia_rfc2544.IXIARFC2544Profile(yaml_data) + traffic_profile.params = TRAFFIC_PROFILE self.ixnet_gen.ixnet.getList.side_effect = [['traffic_item'], ['cfg_element']] with mock.patch.object(self.ixnet_gen, '_append_procotol_to_stack') as \ mock_append_proto: - self.ixnet_gen._setup_config_elements() - mock_append_proto.assert_has_calls([ + self.ixnet_gen._setup_config_elements(traffic_profile=traffic_profile) + mock_append_proto.assert_has_calls([ mock.call(ixnet_api.PROTO_UDP, 'cfg_element/stack:"ethernet-1"'), mock.call(ixnet_api.PROTO_IPV4, 'cfg_element/stack:"ethernet-1"')]) self.ixnet_gen.ixnet.setAttribute.assert_has_calls([ @@ -526,11 +567,15 @@ class TestIxNextgen(unittest.TestCase): def test_create_traffic_model(self, mock__setup_config_elements, mock__create_flow_groups, mock__create_traffic_item): + # the config parsed from some_file + yaml_data = {'traffic_profile': {}} + traffic_profile = ixia_rfc2544.IXIARFC2544Profile(yaml_data) uplink_ports = ['port1', 'port3'] downlink_ports = ['port2', 'port4'] uplink_endpoints = ['port1/protocols', 'port3/protocols'] downlink_endpoints = ['port2/protocols', 'port4/protocols'] - self.ixnet_gen.create_traffic_model(uplink_ports, downlink_ports) + self.ixnet_gen.create_traffic_model(uplink_ports, downlink_ports, + traffic_profile=traffic_profile) mock__create_traffic_item.assert_called_once_with('raw') mock__create_flow_groups.assert_called_once_with(uplink_endpoints, downlink_endpoints) @@ -551,6 +596,56 @@ class TestIxNextgen(unittest.TestCase): downlink_topologies) mock__setup_config_elements.assert_called_once_with(False) + def test_flows_settings(self): + cfg = {'uplink_0': { + 'ipv4': { + 'outer_l2': { + 'framesize': { + '128B': '0', + '1518B': '0', + '64B': '0', + '373b': '0', + '256B': '0', + '1400B': '0', + '570B': '0'}}, + 'id': 1}}} + + expected = [ + {'ipv4': { + 'id': 1, + 'outer_l2': { + 'framesize': { + '1518B': '0', + '1400B': '0', + '128B': '0', + '64B': '0', + '256B': '0', + '373b': '0', + '570B': '0'}}}}] + + self.assertEqual(expected, self.ixnet_gen._flows_settings(cfg=cfg)) + + def test_is_qinq(self): + flow_data = {'ipv4': { + 'outer_l2': {}, + 'id': 1}} + self.assertEqual(False, self.ixnet_gen.is_qinq(flow_data=flow_data)) + + flow_data = {'ipv4': { + 'outer_l2': { + 'QinQ': { + 'C-VLAN': { + 'priority': 0, + 'cfi': 0, + 'id': 512}, + 'S-VLAN': { + 'priority': 0, + 'cfi': 0, + 'id': 128}}, + }, + 'id': 1}} + self.assertEqual(True, self.ixnet_gen.is_qinq(flow_data=flow_data)) + def test__update_frame_mac(self): with mock.patch.object(self.ixnet_gen, '_get_field_in_stack_item') as \ mock_get_field: 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 9db8b7b00..e0397d948 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 @@ -28,6 +28,7 @@ from yardstick.benchmark.contexts import base as ctx_base from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api from yardstick.network_services.traffic_profile import base as tp_base from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_ixia +from yardstick.network_services.traffic_profile import ixia_rfc2544 TEST_FILE_YAML = 'nsb_test_case.yaml' @@ -526,9 +527,13 @@ class TestIxiaBasicScenario(unittest.TestCase): def test_create_traffic_model(self): self.mock_IxNextgen.get_vports.return_value = [1, 2, 3, 4] - self.scenario.create_traffic_model() + yaml_data = {'traffic_profile': {} + } + traffic_profile = ixia_rfc2544.IXIARFC2544Profile(yaml_data) + self.scenario.create_traffic_model(traffic_profile) self.scenario.client.get_vports.assert_called_once() - self.scenario.client.create_traffic_model.assert_called_once_with([1, 3], [2, 4]) + self.scenario.client.create_traffic_model.assert_called_once_with( + [1, 3], [2, 4], traffic_profile) def test_apply_config(self): self.assertIsNone(self.scenario.apply_config()) -- cgit 1.2.3-korg