summaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py')
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py225
1 files changed, 89 insertions, 136 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index 8f7f05772..f62a0fb3b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -16,68 +16,12 @@
#
from __future__ import absolute_import
+
import os
import unittest
import mock
-STL_MOCKS = {
- 'stl': mock.MagicMock(),
- 'stl.trex_stl_lib': mock.MagicMock(),
- 'stl.trex_stl_lib.base64': mock.MagicMock(),
- 'stl.trex_stl_lib.binascii': mock.MagicMock(),
- 'stl.trex_stl_lib.collections': mock.MagicMock(),
- 'stl.trex_stl_lib.copy': mock.MagicMock(),
- 'stl.trex_stl_lib.datetime': mock.MagicMock(),
- 'stl.trex_stl_lib.functools': mock.MagicMock(),
- 'stl.trex_stl_lib.imp': mock.MagicMock(),
- 'stl.trex_stl_lib.inspect': mock.MagicMock(),
- 'stl.trex_stl_lib.json': mock.MagicMock(),
- 'stl.trex_stl_lib.linecache': mock.MagicMock(),
- 'stl.trex_stl_lib.math': mock.MagicMock(),
- 'stl.trex_stl_lib.os': mock.MagicMock(),
- 'stl.trex_stl_lib.platform': mock.MagicMock(),
- 'stl.trex_stl_lib.pprint': mock.MagicMock(),
- 'stl.trex_stl_lib.random': mock.MagicMock(),
- 'stl.trex_stl_lib.re': mock.MagicMock(),
- 'stl.trex_stl_lib.scapy': mock.MagicMock(),
- 'stl.trex_stl_lib.socket': mock.MagicMock(),
- 'stl.trex_stl_lib.string': mock.MagicMock(),
- 'stl.trex_stl_lib.struct': mock.MagicMock(),
- 'stl.trex_stl_lib.sys': mock.MagicMock(),
- 'stl.trex_stl_lib.threading': mock.MagicMock(),
- 'stl.trex_stl_lib.time': mock.MagicMock(),
- 'stl.trex_stl_lib.traceback': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(),
- 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(),
- 'stl.trex_stl_lib.types': mock.MagicMock(),
- 'stl.trex_stl_lib.utils': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.collections': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.common': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.json': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.os': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.random': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.re': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.string': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.sys': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(),
- 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(),
- 'stl.trex_stl_lib.warnings': mock.MagicMock(),
- 'stl.trex_stl_lib.yaml': mock.MagicMock(),
- 'stl.trex_stl_lib.zlib': mock.MagicMock(),
- 'stl.trex_stl_lib.zmq': mock.MagicMock(),
-}
+
+from tests.unit import STL_MOCKS
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -91,13 +35,11 @@ if stl_patch:
TEST_FILE_YAML = 'nsb_test_case.yaml'
-
NAME = "tg__1"
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
class TestIxiaResourceHelper(unittest.TestCase):
-
def test___init___with_custom_rfc_helper(self, mock_ix_nextgen):
class MyRfcHelper(IxiaRfc2544Helper):
pass
@@ -118,71 +60,71 @@ class TestIxiaResourceHelper(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
class TestIXIATrafficGen(unittest.TestCase):
VNFD = {'vnfd:vnfd-catalog':
- {'vnfd':
- [{'short-name': 'VpeVnf',
- 'vdu':
- [{'routing_table':
- [{'network': '152.16.100.20',
- 'netmask': '255.255.255.0',
- 'gateway': '152.16.100.20',
- 'if': 'xe0'},
- {'network': '152.16.40.20',
- 'netmask': '255.255.255.0',
- 'gateway': '152.16.40.20',
- 'if': 'xe1'}],
- 'description': 'VPE approximation using DPDK',
- 'name': 'vpevnf-baremetal',
- 'nd_route_tbl':
- [{'network': '0064:ff9b:0:0:0:0:9810:6414',
- 'netmask': '112',
- 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
- 'if': 'xe0'},
- {'network': '0064:ff9b:0:0:0:0:9810:2814',
- 'netmask': '112',
- 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
- 'if': 'xe1'}],
- 'id': 'vpevnf-baremetal',
- 'external-interface':
- [{'virtual-interface':
- {'dst_mac': '00:00:00:00:00:04',
- 'vpci': '0000:05:00.0',
- 'local_ip': '152.16.100.19',
- 'type': 'PCI-PASSTHROUGH',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '0',
- 'bandwidth': '10 Gbps',
- 'driver': "i40e",
- 'dst_ip': '152.16.100.20',
- 'local_iface_name': 'xe0',
- 'local_mac': '00:00:00:00:00:02'},
- 'vnfd-connection-point-ref': 'xe0',
- 'name': 'xe0'},
- {'virtual-interface':
- {'dst_mac': '00:00:00:00:00:03',
- 'vpci': '0000:05:00.1',
- 'local_ip': '152.16.40.19',
- 'type': 'PCI-PASSTHROUGH',
- 'driver': "i40e",
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
- 'bandwidth': '10 Gbps',
- 'dst_ip': '152.16.40.20',
- 'local_iface_name': 'xe1',
- 'local_mac': '00:00:00:00:00:01'},
- 'vnfd-connection-point-ref': 'xe1',
- 'name': 'xe1'}]}],
- 'description': 'Vpe approximation using DPDK',
- 'mgmt-interface':
- {'vdu-id': 'vpevnf-baremetal',
- 'host': '1.1.1.1',
- 'password': 'r00t',
- 'user': 'root',
- 'ip': '1.1.1.1'},
- 'benchmark':
- {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
- 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
- {'type': 'VPORT', 'name': 'xe1'}],
- 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
+ {'vnfd':
+ [{'short-name': 'VpeVnf',
+ 'vdu':
+ [{'routing_table':
+ [{'network': '152.16.100.20',
+ 'netmask': '255.255.255.0',
+ 'gateway': '152.16.100.20',
+ 'if': 'xe0'},
+ {'network': '152.16.40.20',
+ 'netmask': '255.255.255.0',
+ 'gateway': '152.16.40.20',
+ 'if': 'xe1'}],
+ 'description': 'VPE approximation using DPDK',
+ 'name': 'vpevnf-baremetal',
+ 'nd_route_tbl':
+ [{'network': '0064:ff9b:0:0:0:0:9810:6414',
+ 'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:6414',
+ 'if': 'xe0'},
+ {'network': '0064:ff9b:0:0:0:0:9810:2814',
+ 'netmask': '112',
+ 'gateway': '0064:ff9b:0:0:0:0:9810:2814',
+ 'if': 'xe1'}],
+ 'id': 'vpevnf-baremetal',
+ 'external-interface':
+ [{'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.0',
+ 'local_ip': '152.16.100.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 0,
+ 'bandwidth': '10 Gbps',
+ 'driver': "i40e",
+ 'dst_ip': '152.16.100.20',
+ 'local_iface_name': 'xe0',
+ 'local_mac': '00:00:00:00:00:02'},
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'},
+ {'virtual-interface':
+ {'dst_mac': '00:00:00:00:00:03',
+ 'vpci': '0000:05:00.1',
+ 'local_ip': '152.16.40.19',
+ 'type': 'PCI-PASSTHROUGH',
+ 'driver': "i40e",
+ 'netmask': '255.255.255.0',
+ 'dpdk_port_num': 1,
+ 'bandwidth': '10 Gbps',
+ 'dst_ip': '152.16.40.20',
+ 'local_iface_name': 'xe1',
+ 'local_mac': '00:00:00:00:00:01'},
+ 'vnfd-connection-point-ref': 'xe1',
+ 'name': 'xe1'}]}],
+ 'description': 'Vpe approximation using DPDK',
+ 'mgmt-interface':
+ {'vdu-id': 'vpevnf-baremetal',
+ 'host': '1.1.1.1',
+ 'password': 'r00t',
+ 'user': 'root',
+ 'ip': '1.1.1.1'},
+ 'benchmark':
+ {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
+ 'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+ {'type': 'VPORT', 'name': 'xe1'}],
+ 'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
TRAFFIC_PROFILE = {
"schema": "isb:traffic_profile:0.1",
@@ -195,12 +137,12 @@ class TestIXIATrafficGen(unittest.TestCase):
"frame_size": 64}}
TC_YAML = {'scenarios': [{'tc_options':
- {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
+ {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
'runner': {'duration': 400,
'interval': 35, 'type': 'Duration'},
'traffic_options':
- {'flow': 'ipv4_1flow_Packets_vpe.yaml',
- 'imix': 'imix_voice.yaml'},
+ {'flow': 'ipv4_1flow_Packets_vpe.yaml',
+ 'imix': 'imix_voice.yaml'},
'vnf_options': {'vpe': {'cfg': 'vpe_config'}},
'traffic_profile': 'ipv4_throughput_vpe.yaml',
'type': 'NSPerf',
@@ -250,7 +192,7 @@ class TestIXIATrafficGen(unittest.TestCase):
'vnf_config': {'lb_config': 'SW',
'lb_count': 1,
'worker_config':
- '1C/1T',
+ '1C/1T',
'worker_threads': 1}}
}})
ixnet_traffic_gen.topology = ""
@@ -310,6 +252,8 @@ class TestIXIATrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
+ # traffic_profile.ports is standardized on port_num
+ mock_traffic_profile.ports = [0, 1]
mock_ssh_instance = mock.Mock(autospec=mock_ssh.SSH)
mock_ssh_instance.execute.return_value = 0, "", ""
@@ -361,11 +305,10 @@ class TestIXIATrafficGen(unittest.TestCase):
},
]
- mock_traffic_profile.execute.return_value = ['Completed', samples]
+ mock_traffic_profile.execute_traffic.return_value = ['Completed', samples]
mock_traffic_profile.get_drop_percentage.return_value = ['Completed', samples]
sut = IxiaTrafficGen(name, vnfd)
- sut.tg_port_pairs = [[[0], [1]]]
sut.vnf_port_pairs = [[[0], [1]]]
sut.tc_file_name = self._get_file_abspath(TEST_FILE_YAML)
sut.topology = ""
@@ -380,13 +323,15 @@ class TestIXIATrafficGen(unittest.TestCase):
sut.resource_helper.client = mock.MagicMock()
sut.resource_helper.client_started = mock.MagicMock()
sut.resource_helper.client_started.value = 1
+ sut.resource_helper.rfc_helper.iteration.value = 11
sut.scenario_helper.scenario_cfg = {
'options': {
'packetsize': 64,
'traffic_type': 4,
'rfc2544': {
- 'allowed_drop_rate': '0.8 - 1'
+ 'allowed_drop_rate': '0.8 - 1',
+ 'latency': True
},
'vnf__1': {
'rules': 'acl_1rule.yaml',
@@ -398,8 +343,16 @@ class TestIXIATrafficGen(unittest.TestCase):
},
},
},
- 'ixia_profile': {}
+ 'ixia_profile': '/path/to/profile',
+ 'task_path': '/path/to/task'
}
- result = sut._traffic_runner(mock_traffic_profile)
- self.assertIsNone(result)
+ @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.open',
+ mock.mock_open(), create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.LOG.exception')
+ def _traffic_runner(*args):
+ result = sut._traffic_runner(mock_traffic_profile)
+ self.assertIsNone(result)
+
+ _traffic_runner()