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-18 01:28:28 -0700 |
commit | 86083c8023f40d368f6339d2ab68d49c9ac8b8ee (patch) | |
tree | 0ca209f5bf0f00e36e856ffecd21184921265077 /tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py | |
parent | 38eb33a092e903b9854267d3e36496c919517103 (diff) |
NSB: fix port topology
Add a new PortPair class to resolve the
topology into list of public and private ports.
Before we were calculating public/private in multiple
locations and using different conventions.
In addition for all the DPDK test we need to use the DPDK
port number and no rely on interface ordering or interface naming
conventions.
We used to use xe0 -> 0, xe1 -> 1, etc. This is not the DPDK port
number.
Use the new dpdknicbind_helper class to parse the output of
dpdk-devbind.py to find the actual DPDK port number at runtime.
We then use this DPDK port number to correctly calculate the
port_mask_hex.
The port mask maps the DPDK port num (PMD ID) to the LINK ID
used in the pipeline config
We also need to make sure we only use the interfaces matched to the
topology and not use all the interfaces, because in some cases we will
have unused interfaces. In particular TRex always requires an even
number of interfaces, so for single port TRex tests we have to create
the second port and not use it.
Thus we had to modify the traffic generator stats code to only dump
stats for used ports and no unused ports.
Ixia was using interface ordering to map to Ixia ports, instead we use
the dpdk_port_num which must be hardcoded for Ixia.
Renamed traffic_profile.execute to traffic_profile.execute_traffic so
we can trace the code easier.
We pass the port used by the traffic profile to generate_samples so we
don't get stats for unused ports.
Fixed up vPE config creation and bring up issues.
Fixed up CGNAPT and UDP_Replay to work correctly.
Tested with 4-port scale-out
Change-Id: I2e4f328bff2904108081e92a4bf712333fa73869
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com>
Diffstat (limited to 'tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py')
-rw-r--r-- | tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py index 45bbfaea3..c1b2d27eb 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py @@ -20,6 +20,7 @@ from __future__ import absolute_import import unittest import mock from multiprocessing import Queue +import multiprocessing from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh from tests.unit import STL_MOCKS @@ -31,11 +32,40 @@ stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() if stl_patch: - from yardstick.network_services.vnf_generic.vnf.tg_ping import PingParser, PingTrafficGen - from yardstick.network_services.traffic_profile.base import TrafficProfile + from yardstick.network_services.vnf_generic.vnf.tg_ping import PingParser + from yardstick.network_services.vnf_generic.vnf.tg_ping import PingTrafficGen + from yardstick.network_services.vnf_generic.vnf.tg_ping import PingResourceHelper + from yardstick.network_services.vnf_generic.vnf.tg_ping import PingSetupEnvHelper from yardstick.network_services.vnf_generic.vnf.sample_vnf import VnfSshHelper +class TestPingResourceHelper(unittest.TestCase): + def test___init__(self): + setup_helper = mock.Mock() + helper = PingResourceHelper(setup_helper) + + self.assertIsInstance(helper._queue, multiprocessing.queues.Queue) + self.assertIsInstance(helper._parser, PingParser) + + def test_run_traffic(self): + setup_helper = mock.Mock() + traffic_profile = mock.Mock() + traffic_profile.params = { + 'traffic_profile': { + 'frame_size': 64, + }, + } + + helper = PingResourceHelper(setup_helper) + helper.cmd_kwargs = {'target_ip': '10.0.0.2', + 'local_ip': '10.0.0.1', + 'local_if_name': 'eth0', + } + helper.ssh_helper = mock.Mock() + helper.run_traffic(traffic_profile) + helper.ssh_helper.run.called_with('ping-s 64 10.0.0.2') + + class TestPingParser(unittest.TestCase): def test___init__(self): q_out = Queue() @@ -69,7 +99,6 @@ class TestPingParser(unittest.TestCase): class TestPingTrafficGen(unittest.TestCase): - VNFD_0_EXT_IF_0 = { 'virtual-interface': { 'dst_mac': '00:00:00:00:00:04', @@ -77,7 +106,6 @@ class TestPingTrafficGen(unittest.TestCase): 'local_ip': u'152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', 'bandwidth': '10 Gbps', 'driver': "i40e", 'dst_ip': u'152.16.100.20', @@ -96,14 +124,13 @@ class TestPingTrafficGen(unittest.TestCase): 'type': 'PCI-PASSTHROUGH', 'driver': "i40e", 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', 'bandwidth': '10 Gbps', 'dst_ip': u'152.16.40.20', 'local_iface_name': 'xe1', 'local_mac': '00:00:00:00:00:01', }, - 'vnfd-connection-point-ref': 'xe1', - 'name': 'xe1', + 'vnfd-connection-point-ref': 'xe1', + 'name': 'xe1', } VNFD_0_EXT_IF_LIST = [ @@ -151,7 +178,7 @@ class TestPingTrafficGen(unittest.TestCase): ], 'description': 'Vpe approximation using DPDK', 'mgmt-interface': { - 'vdu-id': 'vpevnf-baremetal', + 'vdu-id': 'vpevnf-baremetal', 'host': '1.1.1.1', 'password': 'r00t', 'user': 'root', @@ -198,11 +225,20 @@ class TestPingTrafficGen(unittest.TestCase): }, } + CMD_KWARGS = { + 'target_ip': u'152.16.100.20', + 'local_ip': u'152.16.100.19', + 'local_if_name': u'xe0', + } + @mock.patch("yardstick.ssh.SSH") def test___init__(self, ssh): ssh.from_node.return_value.execute.return_value = 0, "success", "" ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) - self.assertIsNotNone(ping_traffic_gen._queue) + + self.assertIsInstance(ping_traffic_gen.setup_helper, PingSetupEnvHelper) + self.assertIsInstance(ping_traffic_gen.resource_helper, PingResourceHelper) + self.assertEquals(ping_traffic_gen._result, {}) @mock.patch("yardstick.ssh.SSH") def test__bind_device_kernel_with_failure(self, ssh): @@ -234,35 +270,23 @@ class TestPingTrafficGen(unittest.TestCase): mock_ssh(ssh, spec=VnfSshHelper, exec_result=(0, "success", "")) ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) ping_traffic_gen.setup_helper.ssh_helper = mock.MagicMock( - **{"execute.return_value": (0, "", "")}) + **{"execute.return_value": (0, "success", "")}) self.assertIsInstance(ping_traffic_gen.ssh_helper, mock.Mock) self.assertEqual(ping_traffic_gen._result, {}) + self.assertIsNone(ping_traffic_gen.instantiate({}, {})) + + self.assertEqual( + ping_traffic_gen.vnfd_helper.interfaces[0]['virtual-interface']['local_iface_name'], + 'success') + self.assertEqual(self.CMD_KWARGS, ping_traffic_gen.resource_helper.cmd_kwargs) self.assertIsNotNone(ping_traffic_gen._result) @mock.patch("yardstick.ssh.SSH") def test_listen_traffic(self, ssh): - ssh.from_node.return_value.execute.return_value = 0, "success", "" ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) self.assertIsNone(ping_traffic_gen.listen_traffic({})) - @mock.patch(SSH_HELPER) - def test_run_traffic_process(self, ssh): - mock_ssh(ssh) - - mock_traffic_profile = mock.Mock(autospec=TrafficProfile) - mock_traffic_profile.get_traffic_definition.return_value = "64" - mock_traffic_profile.params = self.TRAFFIC_PROFILE - - ssh.from_node.return_value.execute.return_value = 0, "success", "" - ssh.from_node.return_value.run.return_value = 0, "success", "" - - sut = PingTrafficGen('vnf1', self.VNFD_0) - sut._traffic_runner(mock_traffic_profile) - sut.ssh_helper.run.assert_called_with( - "ping -s 64 152.16.100.20", - stdout=sut._parser, keep_stdin_open=True, pty=True) - @mock.patch("yardstick.ssh.SSH") def test_scale_negative(self, ssh): ssh.from_node.return_value.execute.return_value = 0, "success", "" @@ -277,4 +301,4 @@ class TestPingTrafficGen(unittest.TestCase): ssh.from_node.return_value.run.return_value = 0, "success", "" ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0) - self.assertIsNone(ping_traffic_gen.terminate())
\ No newline at end of file + self.assertIsNone(ping_traffic_gen.terminate()) |