diff options
author | Martin Banszel <martinx.banszel@intel.com> | 2017-07-19 19:35:02 +0000 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-09-05 17:48:02 -0700 |
commit | d3ee35dc0015e073b7138f3b02508b40fc6288b1 (patch) | |
tree | d5350f427a7ba6dcea8d36b00ae217d0074f0511 /tests/unit/network_services/vnf_generic/vnf | |
parent | 79e811f096f8640189fc75862535f1f0cc4773c5 (diff) |
Add fixes for heat deployed UDP_Replay and TRex
- Added a PROTOCOL_MAP to map the protocol names to codes -- the scapy
requires the code, it fails if the proto is set e.g. to 'udp'
- ip addresses must be str, not unicode -- explicit conversion to str
added
- removed unittest for setup_vnf_environment in test_tg_trex.py as
it is the same function as already tested in test_sample_vnf.py
- traffic_profile refactored -- code repetition decreased, unittest
adapted
Known issues:
- there is a an attempt to stop already stopped trex. It fires an
exception that stop command is issued on the disconnected client.
Change-Id: I87e9029630f48b30e8f5b4f9d88ab3b25fd65f03
Signed-off-by: Martin Banszel <martinx.banszel@intel.com>
Diffstat (limited to 'tests/unit/network_services/vnf_generic/vnf')
3 files changed, 639 insertions, 374 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py index ad8c6494e..6f2a9445f 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py @@ -21,9 +21,9 @@ import unittest import mock from tests.unit import STL_MOCKS +SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' -SSH_HELPER = "yardstick.ssh.SSH" STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) @@ -252,6 +252,8 @@ class TestTrexTrafficGenRFC(unittest.TestCase): trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen._start_server = mock.Mock(return_value=0) trex_traffic_gen.resource_helper = mock.MagicMock() + trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() + scenario_cfg = { "tc": "tc_baremetal_rfc2544_ipv4_1flow_64B", "topology": 'nsb_test_case.yaml', @@ -286,6 +288,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase): trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) trex_traffic_gen.resource_helper = mock.MagicMock() + trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() scenario_cfg = { "tc": "tc_baremetal_rfc2544_ipv4_1flow_64B", "nodes": [ diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py index 65370dfa5..9d1ce1520 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py @@ -20,6 +20,8 @@ from __future__ import absolute_import import unittest import mock +SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' + from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh from tests.unit import STL_MOCKS @@ -112,16 +114,197 @@ class TestTrexTrafficGen(unittest.TestCase): "traffic_type": "FixedTraffic", "frame_rate": 100, # pps "flow_number": 10, - "frame_size": 64}} + "frame_size": 64 + }, + } + + SCENARIO_CFG = { + "options": { + "packetsize": 64, + "traffic_type": 4, + "rfc2544": { + "allowed_drop_rate": "0.8 - 1", + }, + "vnf__1": { + "rules": "acl_1rule.yaml", + "vnf_config": { + "lb_config": "SW", + "lb_count": 1, + "worker_config": "1C/1T", + "worker_threads": 1, + } + } + }, + "task_id": "a70bdf4a-8e67-47a3-9dc1-273c14506eb7", + "tc": "tc_ipv4_1Mflow_64B_packetsize", + "runner": { + "object": "NetworkServiceTestCase", + "interval": 35, + "output_filename": "/tmp/yardstick.out", + "runner_id": 74476, "duration": 400, + "type": "Duration" + }, + "traffic_profile": "ipv4_throughput_acl.yaml", + "traffic_options": { + "flow": "ipv4_Packets_acl.yaml", + "imix": "imix_voice.yaml" + }, + "type": "ISB", + "nodes": { + "tg__2": "trafficgen_2.yardstick", + "tg__1": "trafficgen_1.yardstick", + "vnf__1": "vnf.yardstick" + }, + "topology": "udpreplay-tg-topology-baremetal.yaml" + } + + CONTEXT_CFG = { + "nodes": { + "vnf__1": { + "vnfd-id-ref": "vnf__1", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens786f0", + "vld_id": "private", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.0", + "local_ip": "152.16.100.19", + "driver": "i40e", + "dst_ip": "152.16.100.20", + "local_mac": "00:00:00:00:00:02", + "dst_mac": "00:00:00:00:00:04", + "dpdk_port_num": 0 + }, + "xe1": { + "local_iface_name": "ens786f1", + "vld_id": "public", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.1", + "local_ip": "152.16.40.19", + "driver": "i40e", + "dst_ip": "152.16.40.20", + "local_mac": "00:00:00:00:00:01", + "dst_mac": "00:00:00:00:00:03", + "dpdk_port_num": 1 + } + }, + "host": "1.2.1.1", + "user": "root", + "nd_route_tbl": [ + { + "netmask": "112", + "if": "xe0", + "gateway": "0064:ff9b:0:0:0:0:9810:6414", + "network": "0064:ff9b:0:0:0:0:9810:6414" + }, + { + "netmask": "112", + "if": "xe1", + "gateway": "0064:ff9b:0:0:0:0:9810:2814", + "network": "0064:ff9b:0:0:0:0:9810:2814" + } + ], + "password": "r00t", + "VNF model": "udp_replay.yaml", + "name": "vnf.yardstick", + "member-vnf-index": "2", + "routing_table": [ + { + "netmask": "255.255.255.0", + "if": "xe0", + "gateway": "152.16.100.20", + "network": "152.16.100.20" + }, + { + "netmask": "255.255.255.0", + "if": "xe1", + "gateway": "152.16.40.20", + "network": "152.16.40.20" + } + ], + "role": "vnf" + }, + "trafficgen_2.yardstick": { + "member-vnf-index": "3", + "role": "TrafficGen", + "name": "trafficgen_2.yardstick", + "vnfd-id-ref": "tg__2", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens513f0", + "vld_id": "public", + "netmask": "255.255.255.0", + "vpci": "0000:02:00.0", + "local_ip": "152.16.40.20", + "driver": "ixgbe", + "dst_ip": "152.16.40.19", + "local_mac": "00:00:00:00:00:03", + "dst_mac": "00:00:00:00:00:01", + "dpdk_port_num": 0 + }, + "xe1": { + "local_iface_name": "ens513f1", + "netmask": "255.255.255.0", + "network": "202.16.100.0", + "local_ip": "202.16.100.20", + "driver": "ixgbe", + "local_mac": "00:1e:67:d0:60:5d", + "vpci": "0000:02:00.1", + "dpdk_port_num": 1 + } + }, + "password": "r00t", + "VNF model": "l3fwd_vnf.yaml", + "user": "root" + }, + "trafficgen_1.yardstick": { + "member-vnf-index": "1", + "role": "TrafficGen", + "name": "trafficgen_1.yardstick", + "vnfd-id-ref": "tg__1", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens785f0", + "vld_id": "private", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.0", + "local_ip": "152.16.100.20", + "driver": "i40e", + "dst_ip": "152.16.100.19", + "local_mac": "00:00:00:00:00:04", + "dst_mac": "00:00:00:00:00:02", + "dpdk_port_num": 0 + }, + "xe1": { + "local_ip": "152.16.100.21", + "driver": "i40e", + "vpci": "0000:05:00.1", + "dpdk_port_num": 1, + "local_iface_name": "ens785f1", + "netmask": "255.255.255.0", + "local_mac": "00:00:00:00:00:01" + } + }, + "password": "r00t", + "VNF model": "tg_rfc2544_tpl.yaml", + "user": "root" + } + } + } + + - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test___init__(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGen(NAME, vnfd) self.assertIsInstance(trex_traffic_gen.resource_helper, TrexResourceHelper) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_collect_kpi(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] @@ -130,14 +313,14 @@ class TestTrexTrafficGen(unittest.TestCase): result = trex_traffic_gen.collect_kpi() self.assertEqual({}, result) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_listen_traffic(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGen(NAME, vnfd) self.assertIsNone(trex_traffic_gen.listen_traffic({})) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_instantiate(self, ssh): mock_ssh(ssh) @@ -150,9 +333,11 @@ class TestTrexTrafficGen(unittest.TestCase): trex_traffic_gen._tg_process._is_alive = mock.Mock(return_value=1) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() - self.assertIsNone(trex_traffic_gen.instantiate({}, {})) + trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() - @mock.patch("yardstick.ssh.SSH") + self.assertIsNone(trex_traffic_gen.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG)) + + @mock.patch(SSH_HELPER) def test_instantiate_error(self, ssh): mock_ssh(ssh, exec_result=(1, "", "")) @@ -164,9 +349,10 @@ class TestTrexTrafficGen(unittest.TestCase): trex_traffic_gen._tg_process._is_alive = mock.Mock(return_value=0) trex_traffic_gen.ssh_helper = mock.MagicMock() trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() - self.assertIsNone(trex_traffic_gen.instantiate({}, {})) + trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock() + self.assertIsNone(trex_traffic_gen.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG)) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test__start_server(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] @@ -175,7 +361,7 @@ class TestTrexTrafficGen(unittest.TestCase): trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen._start_server()) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test__traffic_runner(self, ssh): mock_ssh(ssh) @@ -195,7 +381,7 @@ class TestTrexTrafficGen(unittest.TestCase): self.sut.resource_helper.QUEUE_WAIT_TIME = 0 self.sut._traffic_runner(mock_traffic_profile) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test__generate_trex_cfg(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] @@ -203,7 +389,7 @@ class TestTrexTrafficGen(unittest.TestCase): trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.resource_helper.generate_cfg()) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_run_traffic(self, ssh): mock_ssh(ssh) @@ -221,21 +407,14 @@ class TestTrexTrafficGen(unittest.TestCase): self.sut._traffic_process.terminate() self.assertIsNotNone(result) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_scale(self, ssh): mock_ssh(ssh, exec_result=(1, "", "")) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] trex_traffic_gen = TrexTrafficGen(NAME, vnfd) trex_traffic_gen.scale('') - @mock.patch("yardstick.ssh.SSH") - def test_setup_vnf_environment(self, ssh): - mock_ssh(ssh, exec_result=(1, "", "")) - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - trex_traffic_gen = TrexTrafficGen(NAME, vnfd) - self.assertIsNone(trex_traffic_gen.setup_helper.setup_vnf_environment()) - - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test_terminate(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] @@ -244,7 +423,7 @@ class TestTrexTrafficGen(unittest.TestCase): trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock() self.assertIsNone(trex_traffic_gen.terminate()) - @mock.patch("yardstick.ssh.SSH") + @mock.patch(SSH_HELPER) def test__connect_client(self, ssh): mock_ssh(ssh) vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py index f0d75d57b..c4ced30fe 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py @@ -22,6 +22,7 @@ import mock import os from tests.unit import STL_MOCKS +SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' STLClient = mock.MagicMock() @@ -30,269 +31,347 @@ stl_patch.start() if stl_patch: from yardstick.network_services.vnf_generic.vnf.udp_replay import UdpReplayApproxVnf - from yardstick.network_services.vnf_generic.vnf import udp_replay + from yardstick.network_services.vnf_generic.vnf.sample_vnf import ScenarioHelper + +from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh TEST_FILE_YAML = 'nsb_test_case.yaml' -NAME = "tg__1" +NAME = "vnf__1" @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Process") -class TestAclApproxVnf(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.2.1.1', - 'password': 'r00t', - 'user': 'root', - 'ip': '1.2.1.1'}, - 'benchmark': - {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']}, - 'connection-point': [{'type': 'VPORT', 'name': 'xe0'}, - {'type': 'VPORT', 'name': 'xe1'}], - 'id': 'UdpReplayApproxVnf', 'name': 'VPEVnfSsh'}]}} - - scenario_cfg = {'options': {'packetsize': 64, 'traffic_type': 4, - 'rfc2544': {'allowed_drop_rate': '0.8 - 1'}, - 'vnf__1': {'rules': 'acl_1rule.yaml', - 'vnf_config': {'lb_config': 'SW', - 'lb_count': 1, - 'worker_config': - '1C/1T', - 'worker_threads': 1}} - }, - 'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7', - 'tc': 'tc_ipv4_1Mflow_64B_packetsize', - 'runner': {'object': 'NetworkServiceTestCase', - 'interval': 35, - 'output_filename': '/tmp/yardstick.out', - 'runner_id': 74476, 'duration': 400, - 'type': 'Duration'}, - 'traffic_profile': 'ipv4_throughput_acl.yaml', - 'traffic_options': {'flow': 'ipv4_Packets_acl.yaml', - 'imix': 'imix_voice.yaml'}, - 'type': 'ISB', - 'nodes': {'tg__2': 'trafficgen_2.yardstick', - 'tg__1': 'trafficgen_1.yardstick', - 'vnf__1': 'vnf.yardstick'}, - 'topology': 'vpe-tg-topology-baremetal.yaml'} - - context_cfg = {'nodes': {'trafficgen_2.yardstick': - {'member-vnf-index': '3', - 'role': 'TrafficGen', - 'name': 'trafficgen_2.yardstick', - 'vnfd-id-ref': 'tg__2', - 'ip': '1.2.1.1', - 'interfaces': - {'xe0': {'local_iface_name': 'ens513f0', - 'vld_id': 'public', - 'netmask': '255.255.255.0', - 'local_ip': '152.16.40.20', - 'dst_mac': '00:00:00:00:00:01', - 'local_mac': '00:00:00:00:00:03', - 'dst_ip': '152.16.40.19', - 'driver': 'ixgbe', - 'vpci': '0000:02:00.0', - 'dpdk_port_num': 0}, - 'xe1': {'local_iface_name': 'ens513f1', - 'netmask': '255.255.255.0', - 'network': '202.16.100.0', - 'local_ip': '202.16.100.20', - 'local_mac': '00:1e:67:d0:60:5d', - 'driver': 'ixgbe', - 'vpci': '0000:02:00.1', - 'dpdk_port_num': 1}}, - 'password': 'r00t', - 'VNF model': 'l3fwd_vnf.yaml', - 'user': 'root'}, - 'trafficgen_1.yardstick': - {'member-vnf-index': '1', - 'role': 'TrafficGen', - 'name': 'trafficgen_1.yardstick', - 'vnfd-id-ref': 'tg__1', - 'ip': '1.2.1.1', - 'interfaces': - {'xe0': {'local_iface_name': 'ens785f0', - 'vld_id': 'private', - 'netmask': '255.255.255.0', - 'local_ip': '152.16.100.20', - 'dst_mac': '00:00:00:00:00:02', - 'local_mac': '00:00:00:00:00:04', - 'dst_ip': '152.16.100.19', - 'driver': 'i40e', - 'vpci': '0000:05:00.0', - 'dpdk_port_num': 0}, - 'xe1': {'local_iface_name': 'ens785f1', - 'netmask': '255.255.255.0', - 'local_ip': '152.16.100.21', - 'local_mac': '00:00:00:00:00:01', - 'driver': 'i40e', - 'vpci': '0000:05:00.1', - 'dpdk_port_num': 1}}, - 'password': 'r00t', - 'VNF model': 'tg_rfc2544_tpl.yaml', - 'user': 'root'}, - 'vnf__1': - {'name': 'vnf.yardstick', - 'vnfd-id-ref': 'vnf__1', - 'ip': '1.2.1.1', - 'interfaces': - {'xe0': {'local_iface_name': 'ens786f0', - 'vld_id': 'private', - 'netmask': '255.255.255.0', - 'local_ip': '152.16.100.19', - 'dst_mac': '00:00:00:00:00:04', - 'local_mac': '00:00:00:00:00:02', - 'dst_ip': '152.16.100.20', - 'driver': 'i40e', - 'vpci': '0000:05:00.0', - 'dpdk_port_num': 0}, - 'xe1': {'local_iface_name': 'ens786f1', - 'vld_id': 'public', - 'netmask': '255.255.255.0', - 'local_ip': '152.16.40.19', - 'dst_mac': '00:00:00:00:00:03', - 'local_mac': '00:00:00:00:00:01', - 'dst_ip': '152.16.40.20', - 'driver': 'i40e', - 'vpci': '0000:05:00.1', - 'dpdk_port_num': 1}}, - 'routing_table': - [{'netmask': '255.255.255.0', - 'gateway': '152.16.100.20', - 'network': '152.16.100.20', - 'if': 'xe0'}, - {'netmask': '255.255.255.0', - 'gateway': '152.16.40.20', - 'network': '152.16.40.20', - 'if': 'xe1'}], - 'member-vnf-index': '2', - 'host': '1.2.1.1', - 'role': 'vnf', - 'user': 'root', - 'nd_route_tbl': - [{'netmask': '112', - 'gateway': '0064:ff9b:0:0:0:0:9810:6414', - 'network': '0064:ff9b:0:0:0:0:9810:6414', - 'if': 'xe0'}, - {'netmask': '112', - 'gateway': '0064:ff9b:0:0:0:0:9810:2814', - 'network': '0064:ff9b:0:0:0:0:9810:2814', - 'if': 'xe1'}], - 'password': 'r00t', - 'VNF model': 'udp_replay.yaml'}}} - - def test___init__(self, mock_process): - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - self.assertIsNone(udp_approx_vnf._vnf_process) +class TestUdpReplayApproxVnf(unittest.TestCase): + + VNFD_0 = { + 'short-name': 'UdpReplayVnf', + 'vdu': [ + { + 'description': 'UDPReplay approximation using DPDK', + 'routing_table': [ + { + 'netmask': '255.255.255.0', + 'if': 'xe0', + 'network': '152.16.100.20', + 'gateway': '152.16.100.20', + }, + { + 'netmask': '255.255.255.0', + 'if': 'xe1', + 'network': '152.16.40.20', + 'gateway': '152.16.40.20', + } + ], + 'external-interface': [ + { + 'virtual-interface': { + 'dst_mac': '00:00:00:00:00:04', + 'driver': 'i40e', + 'local_iface_name': 'xe0', + 'bandwidth': '10 Gbps', + 'local_ip': '152.16.100.19', + 'local_mac': '00:00:00:00:00:02', + 'vpci': '0000:05:00.0', + 'dpdk_port_num': '0', + 'netmask': '255.255.255.0', + 'dst_ip': '152.16.100.20', + 'type': 'PCI-PASSTHROUGH', + }, + 'vnfd-connection-point-ref': 'xe0', + 'name': 'xe0', + }, + { + 'virtual-interface': { + 'dst_mac': '00:00:00:00:00:03', + 'driver': 'i40e', + 'local_iface_name': 'xe1', + 'bandwidth': '10 Gbps', + 'local_ip': '152.16.40.19', + 'local_mac': '00:00:00:00:00:01', + 'vpci': '0000:05:00.1', + 'dpdk_port_num': '1', + 'netmask': '255.255.255.0', + 'dst_ip': '152.16.40.20', + 'type': 'PCI-PASSTHROUGH', + }, + 'vnfd-connection-point-ref': 'xe1', + 'name': 'xe1', + } + ], + 'nd_route_tbl': [ + { + 'netmask': '112', + 'if': 'xe0', + 'network': '0064:ff9b:0:0:0:0:9810:6414', + 'gateway': '0064:ff9b:0:0:0:0:9810:6414', + }, + { + 'netmask': '112', + 'if': 'xe1', + 'network': '0064:ff9b:0:0:0:0:9810:2814', + 'gateway': '0064:ff9b:0:0:0:0:9810:2814', + } + ], + 'id': 'udpreplayvnf-baremetal', + 'name': 'udpreplayvnf-baremetal', + } + ], + 'description': 'UDPReplay approximation using DPDK', + 'name': 'VPEVnfSsh', + 'mgmt-interface': { + 'vdu-id': 'udpreplay-baremetal', + 'host': '1.2.1.1', + 'password': 'r00t', + 'user': 'root', + 'ip': '1.2.1.1', + }, + 'benchmark': { + 'kpi': [ + 'packets_in', + 'packets_fwd', + 'packets_dropped', + ] + }, + 'connection-point': [ + { + 'type': 'VPORT', + 'name': 'xe0', + }, + { + 'type': 'VPORT', + 'name': 'xe1', + } + ], + 'id': 'UdpReplayApproxVnf', + } + + SCENARIO_CFG = { + "options": { + "packetsize": 64, + "traffic_type": 4, + "rfc2544": { + "allowed_drop_rate": "0.8 - 1", + }, + "vnf__1": { + "rules": "acl_1rule.yaml", + "vnf_config": { + "lb_config": "SW", + "lb_count": 1, + "worker_config": "1C/1T", + "worker_threads": 1, + }, + "hw_csum": "false", + } + }, + "task_id": "a70bdf4a-8e67-47a3-9dc1-273c14506eb7", + "tc": "tc_ipv4_1Mflow_64B_packetsize", + "runner": { + "object": "NetworkServiceTestCase", + "interval": 35, + "output_filename": "/tmp/yardstick.out", + "runner_id": 74476, "duration": 400, + "type": "Duration" + }, + "traffic_profile": "ipv4_throughput_acl.yaml", + "traffic_options": { + "flow": "ipv4_Packets_acl.yaml", + "imix": "imix_voice.yaml" + }, + "type": "ISB", + "nodes": { + "tg__2": "trafficgen_2.yardstick", + "tg__1": "trafficgen_1.yardstick", + "vnf__1": "vnf.yardstick" + }, + "topology": "udpreplay-tg-topology-baremetal.yaml" + } + + CONTEXT_CFG = { + "nodes": { + "vnf__1": { + "vnfd-id-ref": "vnf__1", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens786f0", + "vld_id": "private", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.0", + "local_ip": "152.16.100.19", + "driver": "i40e", + "dst_ip": "152.16.100.20", + "local_mac": "00:00:00:00:00:02", + "dst_mac": "00:00:00:00:00:04", + "dpdk_port_num": 0 + }, + "xe1": { + "local_iface_name": "ens786f1", + "vld_id": "public", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.1", + "local_ip": "152.16.40.19", + "driver": "i40e", + "dst_ip": "152.16.40.20", + "local_mac": "00:00:00:00:00:01", + "dst_mac": "00:00:00:00:00:03", + "dpdk_port_num": 1 + } + }, + "host": "1.2.1.1", + "user": "root", + "nd_route_tbl": [ + { + "netmask": "112", + "if": "xe0", + "gateway": "0064:ff9b:0:0:0:0:9810:6414", + "network": "0064:ff9b:0:0:0:0:9810:6414" + }, + { + "netmask": "112", + "if": "xe1", + "gateway": "0064:ff9b:0:0:0:0:9810:2814", + "network": "0064:ff9b:0:0:0:0:9810:2814" + } + ], + "password": "r00t", + "VNF model": "udp_replay.yaml", + "name": "vnf.yardstick", + "member-vnf-index": "2", + "routing_table": [ + { + "netmask": "255.255.255.0", + "if": "xe0", + "gateway": "152.16.100.20", + "network": "152.16.100.20" + }, + { + "netmask": "255.255.255.0", + "if": "xe1", + "gateway": "152.16.40.20", + "network": "152.16.40.20" + } + ], + "role": "vnf" + }, + "trafficgen_2.yardstick": { + "member-vnf-index": "3", + "role": "TrafficGen", + "name": "trafficgen_2.yardstick", + "vnfd-id-ref": "tg__2", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens513f0", + "vld_id": "public", + "netmask": "255.255.255.0", + "vpci": "0000:02:00.0", + "local_ip": "152.16.40.20", + "driver": "ixgbe", + "dst_ip": "152.16.40.19", + "local_mac": "00:00:00:00:00:03", + "dst_mac": "00:00:00:00:00:01", + "dpdk_port_num": 0 + }, + "xe1": { + "local_iface_name": "ens513f1", + "netmask": "255.255.255.0", + "network": "202.16.100.0", + "local_ip": "202.16.100.20", + "driver": "ixgbe", + "local_mac": "00:1e:67:d0:60:5d", + "vpci": "0000:02:00.1", + "dpdk_port_num": 1 + } + }, + "password": "r00t", + "VNF model": "l3fwd_vnf.yaml", + "user": "root" + }, + "trafficgen_1.yardstick": { + "member-vnf-index": "1", + "role": "TrafficGen", + "name": "trafficgen_1.yardstick", + "vnfd-id-ref": "tg__1", + "ip": "1.2.1.1", + "interfaces": { + "xe0": { + "local_iface_name": "ens785f0", + "vld_id": "private", + "netmask": "255.255.255.0", + "vpci": "0000:05:00.0", + "local_ip": "152.16.100.20", + "driver": "i40e", + "dst_ip": "152.16.100.19", + "local_mac": "00:00:00:00:00:04", + "dst_mac": "00:00:00:00:00:02", + "dpdk_port_num": 0 + }, + "xe1": { + "local_ip": "152.16.100.21", + "driver": "i40e", + "vpci": "0000:05:00.1", + "dpdk_port_num": 1, + "local_iface_name": "ens785f1", + "netmask": "255.255.255.0", + "local_mac": "00:00:00:00:00:01" + } + }, + "password": "r00t", + "VNF model": "tg_rfc2544_tpl.yaml", + "user": "root" + } + } + } + + def test___init__(self, _): + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + self.assertIsNone(udp_replay_approx_vnf._vnf_process) @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") - def test_collect_kpi(self, mock_time, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - result = "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \ - "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\ - "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \ - "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>" - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - udp_approx_vnf.q_in = mock.MagicMock() - udp_approx_vnf.q_out = mock.MagicMock() - udp_approx_vnf.q_out.qsize = mock.Mock(return_value=0) - udp_approx_vnf.all_ports = [0, 1] - udp_approx_vnf.interfaces = vnfd["vdu"][0]['external-interface'] - udp_approx_vnf.get_stats = mock.Mock(return_value=result) - result = {'collect_stats': {}, 'packets_dropped': 0, - 'packets_fwd': 14748451, 'packets_in': 14748472} - self.assertEqual(result, udp_approx_vnf.collect_kpi()) + @mock.patch(SSH_HELPER) + def test_collect_kpi(self, ssh, mock_time, _): + mock_ssh(ssh) + + vnfd = self.VNFD_0 + result = "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \ + "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\ + "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \ + "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>" + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) + udp_replay_approx_vnf.q_in = mock.MagicMock() + udp_replay_approx_vnf.q_out = mock.MagicMock() + udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0) + udp_replay_approx_vnf.all_ports = [0, 1] + udp_replay_approx_vnf.get_stats = mock.Mock(return_value=result) + result = {'collect_stats': {}, 'packets_dropped': 0, + 'packets_fwd': 14748451, 'packets_in': 14748472} + self.assertEqual(result, udp_replay_approx_vnf.collect_kpi()) @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") - def test_vnf_execute_command(self, mock_time, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - cmd = "quit" - self.assertEqual("", udp_approx_vnf.vnf_execute(cmd)) - - def test_get_stats(self, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - udp_approx_vnf.q_in = mock.MagicMock() - udp_approx_vnf.q_out = mock.MagicMock() - udp_approx_vnf.q_out.qsize = mock.Mock(return_value=0) - mock_result = \ - "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress" - udp_approx_vnf.vnf_execute = mock.Mock(return_value=mock_result) - self.assertEqual(mock_result, - udp_approx_vnf.get_stats()) + @mock.patch(SSH_HELPER) + def test_vnf_execute_command(self, ssh, mock_time, _): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + cmd = "quit" + self.assertEqual("", udp_replay_approx_vnf.vnf_execute(cmd)) + + @mock.patch(SSH_HELPER) + def test_get_stats(self, ssh, _): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf.q_in = mock.MagicMock() + udp_replay_approx_vnf.q_out = mock.MagicMock() + udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0) + mock_result = \ + "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress" + + udp_replay_approx_vnf.vnf_execute = mock.Mock(return_value=mock_result) + + self.assertEqual(mock_result, + udp_replay_approx_vnf.get_stats()) def _get_file_abspath(self, filename): curr_path = os.path.dirname(os.path.abspath(__file__)) @@ -300,111 +379,115 @@ class TestAclApproxVnf(unittest.TestCase): return file_path @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open') - def test__build_pipeline_kwargs(self, mock_open, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - udp_approx_vnf._build_config = mock.MagicMock() - udp_approx_vnf.queue_wrapper = mock.MagicMock() - udp_approx_vnf.nfvi_type = "baremetal" - udp_approx_vnf.bound_pci = [] - udp_approx_vnf.all_ports = [0, 1] - udp_approx_vnf.ssh_helper = mock.MagicMock( - **{"provision_tool.return_value": "tool_path"}) - udp_approx_vnf.vnf_cfg = {'lb_config': 'SW', - 'lb_count': 1, - 'worker_config': '1C/1T', - 'worker_threads': 1} - udp_approx_vnf.options = {'traffic_type': '4', - 'topology': 'nsb_test_case.yaml'} - - udp_approx_vnf._build_pipeline_kwargs() - self.assertEqual(udp_approx_vnf.pipeline_kwargs, { - 'config': '(0, 0, 1)(1, 0, 2)', - 'cpu_mask_hex': '0x6', - 'hw_csum': '', - 'ports_len_hex': '0x3', - 'tool_path': 'tool_path', - 'whitelist': '' - }) - - @mock.patch("yardstick.network_services.vnf_generic.vnf.udp_replay.hex") - @mock.patch("yardstick.network_services.vnf_generic.vnf.udp_replay.eval") + @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context") + @mock.patch(SSH_HELPER) + def test__build_config(self, ssh, mock_context, *_): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() + udp_replay_approx_vnf.nfvi_context = mock_context + udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'} + udp_replay_approx_vnf.setup_helper.bound_pci = [] + udp_replay_approx_vnf.all_ports = [0, 1] + udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path") + udp_replay_approx_vnf.scenario_helper = ScenarioHelper(name='vnf__1') + udp_replay_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG + + cmd_line = udp_replay_approx_vnf._build_config() + + expected = "sudo tool_path -c 0x7 -n 4 -w -- -p 0x3 --config='(0, 0, 1)(1, 0, 2)'" + self.assertEqual(cmd_line, expected) + @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open') - def test_run_udp_replay(self, mock_open, eval, hex, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh_mock.run = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - udp_approx_vnf._build_config = mock.MagicMock() - udp_approx_vnf.queue_wrapper = mock.MagicMock() - udp_approx_vnf.ssh_helper = mock.MagicMock() - udp_approx_vnf.ssh_helper.run = mock.MagicMock() - udp_approx_vnf.vnf_cfg = {'lb_config': 'SW', - 'lb_count': 1, - 'worker_config': '1C/1T', - 'worker_threads': 1} - udp_approx_vnf.options = {'traffic_type': '4', - 'topology': 'nsb_test_case.yaml'} - - udp_approx_vnf._run() - udp_approx_vnf.ssh_helper.run.assert_called_once() + @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context") + @mock.patch(SSH_HELPER) + def test__build_pipeline_kwargs(self, ssh, mock_context, *_): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf._build_config = mock.MagicMock() + udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() + udp_replay_approx_vnf.nfvi_context = mock_context + udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'} + udp_replay_approx_vnf.setup_helper.bound_pci = [] + udp_replay_approx_vnf.all_ports = [0, 1] + udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path") + udp_replay_approx_vnf.scenario_helper = ScenarioHelper(name='vnf__1') + udp_replay_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG + + udp_replay_approx_vnf._build_pipeline_kwargs() + + self.assertEqual(udp_replay_approx_vnf.pipeline_kwargs, { + 'config': '(0, 0, 1)(1, 0, 2)', + 'cpu_mask_hex': '0x7', + 'hw_csum': '', + 'ports_len_hex': '0x3', + 'tool_path': 'tool_path', + 'whitelist': '' + }) + + @mock.patch(SSH_HELPER) + def test_run_udp_replay(self, ssh, _): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf._build_config = mock.MagicMock() + udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() + + udp_replay_approx_vnf._run() + + udp_replay_approx_vnf.ssh_helper.run.assert_called_once() @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context") - def test_instantiate(self, Context, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - self.scenario_cfg['vnf_options'] = {'cgnapt': {'cfg': "", - 'rules': ""}} - udp_approx_vnf._run_udp_replay = mock.Mock(return_value=0) - udp_approx_vnf._parse_rule_file = mock.Mock(return_value={}) - udp_approx_vnf.deploy_udp_replay_vnf = mock.Mock(return_value=1) - udp_approx_vnf.q_out.put("Replay>") - udp_approx_vnf.get_my_ports = mock.Mock(return_value=[0, 1]) - udp_replay.WAIT_TIME = 3 - udp_approx_vnf.get_nfvi_type = mock.Mock(return_value="baremetal") - - udp_approx_vnf._vnf_process = mock.MagicMock() - udp_approx_vnf._vnf_process.is_alive = \ - mock.Mock(return_value=1) - self.assertIsNone(udp_approx_vnf.instantiate(self.scenario_cfg, - self.context_cfg)) - - def test_scale(self, mock_process): - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) + @mock.patch(SSH_HELPER) + def test_instantiate(self, ssh, *_): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf.q_out.put("Replay>") + udp_replay_approx_vnf.WAIT_TIME = 0 + udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock() + + self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, + self.CONTEXT_CFG)) + + udp_replay_approx_vnf._vnf_process.is_alive = mock.Mock(return_value=1) + udp_replay_approx_vnf._vnf_process.exitcode = 0 + + self.assertEquals(udp_replay_approx_vnf.wait_for_instantiate(), 0) + + @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context") + @mock.patch('yardstick.ssh.SSH') + @mock.patch(SSH_HELPER) + def test_instantiate_panic(self, ssh, resource_ssh, *_): + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf.WAIT_TIME = 0 + udp_replay_approx_vnf.q_out.put("some text PANIC some text") + udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock() + + self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG)) + with self.assertRaises(RuntimeError): + udp_replay_approx_vnf.wait_for_instantiate() + + def test_scale(self, _): + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) flavor = "" - self.assertRaises(NotImplementedError, udp_approx_vnf.scale, flavor) + + self.assertRaises(NotImplementedError, udp_replay_approx_vnf.scale, flavor) @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") - def test_terminate(self, mock_time, mock_process): - with mock.patch("yardstick.ssh.SSH") as ssh: - ssh_mock = mock.Mock(autospec=ssh.SSH) - ssh_mock.execute = \ - mock.Mock(return_value=(0, "", "")) - ssh.from_node.return_value = ssh_mock - vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] - udp_approx_vnf = UdpReplayApproxVnf(NAME, vnfd) - udp_approx_vnf._vnf_process = mock.MagicMock() - udp_approx_vnf._vnf_process.terminate = mock.Mock() - udp_approx_vnf.used_drivers = {"01:01.0": "i40e", - "01:01.1": "i40e"} - udp_approx_vnf.execute_command = mock.Mock() - udp_approx_vnf.ssh_helper = ssh_mock - udp_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py" - self.assertEqual(None, udp_approx_vnf.terminate()) + @mock.patch(SSH_HELPER) + def test_terminate(self, ssh, mock_time, _): + mock_ssh(ssh) + + udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) + udp_replay_approx_vnf._vnf_process = mock.MagicMock() + udp_replay_approx_vnf._vnf_process.terminate = mock.Mock() + udp_replay_approx_vnf.used_drivers = {"01:01.0": "i40e", + "01:01.1": "i40e"} + udp_replay_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py" + self.assertEqual(None, udp_replay_approx_vnf.terminate()) if __name__ == '__main__': unittest.main() |