diff options
Diffstat (limited to 'tests/unit/benchmark/scenarios')
5 files changed, 107 insertions, 39 deletions
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py index 2e4fff417..0974f385a 100644 --- a/tests/unit/benchmark/scenarios/availability/test_util.py +++ b/tests/unit/benchmark/scenarios/availability/test_util.py @@ -20,8 +20,8 @@ from yardstick.benchmark.scenarios.availability import util class ExecuteShellTestCase(unittest.TestCase): def setUp(self): - self.param_config = {'serviceName': '$serviceName', 'value': 1} - self.intermediate_variables = {'$serviceName': 'nova-api'} + self.param_config = {'serviceName': '@serviceName', 'value': 1} + self.intermediate_variables = {'@serviceName': 'nova-api'} self.std_output = '| id | 1 |' self.cmd_config = {'cmd':'ls','param':'-a'} diff --git a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml b/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml index cfa166a74..2123e4705 100644 --- a/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml +++ b/tests/unit/benchmark/scenarios/networking/ipv4_throughput_vpe.yaml @@ -49,13 +49,13 @@ private: ipv4: outer_l2: framesize: - 64B: "{{ get(imix, 'imix.private.imix_small', '0') }}" - 128B: "{{ get(imix, 'imix.private.imix_128B', '0') }}" - 256B: "{{ get(imix, 'imix.private.imix_256B', '0') }}" - 373b: "{{ get(imix, 'imix.private.imix_373B', '0') }}" - 570B: "{{get(imix, 'imix.private.imix_570B', '0') }}" - 1400B: "{{get(imix, 'imix.private.imix_1400B', '0') }}" - 1518B: "{{get(imix, 'imix.private.imix_1500B', '0') }}" + 64B: "{{ get(imix, 'imix.uplink.imix_small', '0') }}" + 128B: "{{ get(imix, 'imix.uplink.imix_128B', '0') }}" + 256B: "{{ get(imix, 'imix.uplink.imix_256B', '0') }}" + 373b: "{{ get(imix, 'imix.uplink.imix_373B', '0') }}" + 570B: "{{get(imix, 'imix.uplink.imix_570B', '0') }}" + 1400B: "{{get(imix, 'imix.uplink.imix_1400B', '0') }}" + 1518B: "{{get(imix, 'imix.uplink.imix_1500B', '0') }}" QinQ: S-VLAN: @@ -81,13 +81,13 @@ public: ipv4: outer_l2: framesize: - 64B: "{{ get(imix, 'imix.private.imix_small', '0') }}" - 128B: "{{ get(imix, 'imix.private.imix_128B', '0') }}" - 256B: "{{ get(imix, 'imix.private.imix_256B', '0') }}" - 373b: "{{ get(imix, 'imix.private.imix_373B', '0') }}" - 570B: "{{get(imix, 'imix.private.imix_570B', '0') }}" - 1400B: "{{get(imix, 'imix.private.imix_1400B', '0') }}" - 1518B: "{{get(imix, 'imix.private.imix_1500B', '0') }}" + 64B: "{{ get(imix, 'imix.uplink.imix_small', '0') }}" + 128B: "{{ get(imix, 'imix.uplink.imix_128B', '0') }}" + 256B: "{{ get(imix, 'imix.uplink.imix_256B', '0') }}" + 373b: "{{ get(imix, 'imix.uplink.imix_373B', '0') }}" + 570B: "{{get(imix, 'imix.uplink.imix_570B', '0') }}" + 1400B: "{{get(imix, 'imix.uplink.imix_1400B', '0') }}" + 1518B: "{{get(imix, 'imix.uplink.imix_1500B', '0') }}" outer_l3v4: proto: "tcp" diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py index 0ca31d484..3928aacde 100644 --- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py +++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py @@ -264,7 +264,7 @@ class PktgenTestCase(unittest.TestCase): p._get_available_queue_number() mock_ssh.SSH.from_node().execute.assert_called_with( - "sudo ethtool -l eth0 | grep Combined | head -1 |" \ + "sudo ethtool -l eth0 | grep Combined | head -1 |" "awk '{printf $2}'") def test_pktgen_unsuccessful_get_available_queue_number(self, mock_ssh): @@ -290,7 +290,7 @@ class PktgenTestCase(unittest.TestCase): p._get_usable_queue_number() mock_ssh.SSH.from_node().execute.assert_called_with( - "sudo ethtool -l eth0 | grep Combined | tail -1 |" \ + "sudo ethtool -l eth0 | grep Combined | tail -1 |" "awk '{printf $2}'") def test_pktgen_unsuccessful_get_usable_queue_number(self, mock_ssh): @@ -541,7 +541,7 @@ class PktgenTestCase(unittest.TestCase): p._is_irqbalance_disabled = mock_result1 mock_result2 = mock.Mock() - mock_result2.return_value = "virtio_net" + mock_result2.return_value = "virtio_net" p._get_vnic_driver_name = mock_result2 mock_result3 = mock.Mock() @@ -571,7 +571,7 @@ class PktgenTestCase(unittest.TestCase): p._is_irqbalance_disabled = mock_result1 mock_result2 = mock.Mock() - mock_result2.return_value = "virtio_net" + mock_result2.return_value = "virtio_net" p._get_vnic_driver_name = mock_result2 mock_result3 = mock.Mock() @@ -601,7 +601,7 @@ class PktgenTestCase(unittest.TestCase): p._is_irqbalance_disabled = mock_result1 mock_result2 = mock.Mock() - mock_result2.return_value = "ixgbevf" + mock_result2.return_value = "ixgbevf" p._get_vnic_driver_name = mock_result2 p.multiqueue_setup() @@ -623,7 +623,7 @@ class PktgenTestCase(unittest.TestCase): p._is_irqbalance_disabled = mock_result1 mock_result2 = mock.Mock() - mock_result2.return_value = "ixgbevf" + mock_result2.return_value = "ixgbevf" p._get_vnic_driver_name = mock_result2 p.multiqueue_setup() @@ -670,7 +670,7 @@ class PktgenTestCase(unittest.TestCase): p.client = mock_ssh.SSH.from_node() mock_result = mock.Mock() - mock_result.return_value = "virtio_net" + mock_result.return_value = "virtio_net" p._get_vnic_driver_name = mock_result mock_result1 = mock.Mock() diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py index 58244b8f5..016608a21 100644 --- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py +++ b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py @@ -24,6 +24,8 @@ import errno import unittest import mock +from copy import deepcopy + from tests.unit import STL_MOCKS from yardstick.benchmark.scenarios.networking.vnf_generic import \ SshManager, NetworkServiceTestCase, IncorrectConfig, \ @@ -240,11 +242,11 @@ class TestNetworkServiceTestCase(unittest.TestCase): 'vnf__1': self.vnf__1, }, 'networks': { - 'private': { - 'vld_id': 'private', + GenericVNF.UPLINK: { + 'vld_id': GenericVNF.UPLINK, }, - 'public': { - 'vld_id': 'public', + GenericVNF.DOWNLINK: { + 'vld_id': GenericVNF.DOWNLINK, }, }, } @@ -263,7 +265,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): } ], 'type': 'ELAN', - 'id': 'private', + 'id': GenericVNF.UPLINK, 'name': 'tg__1 to vnf__1 link 1' } @@ -281,7 +283,7 @@ class TestNetworkServiceTestCase(unittest.TestCase): } ], 'type': 'ELAN', - 'id': 'public', + 'id': GenericVNF.DOWNLINK, 'name': 'vnf__1 to tg__1 link 2' } @@ -359,12 +361,36 @@ class TestNetworkServiceTestCase(unittest.TestCase): def test___init__(self): assert self.topology + def test__get_ip_flow_range_string(self): + self.scenario_cfg["traffic_options"]["flow"] = \ + self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml") + result = '152.16.100.2-152.16.100.254' + self.assertEqual(result, self.s._get_ip_flow_range('152.16.100.2-152.16.100.254')) + def test__get_ip_flow_range(self): self.scenario_cfg["traffic_options"]["flow"] = \ self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml") result = '152.16.100.2-152.16.100.254' self.assertEqual(result, self.s._get_ip_flow_range({"tg__1": 'xe0'})) + @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.ipaddress') + def test__get_ip_flow_range_no_node_data(self, mock_ipaddress): + scenario_cfg = deepcopy(self.scenario_cfg) + scenario_cfg["traffic_options"]["flow"] = \ + self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml") + + mock_ipaddress.ip_network.return_value = ipaddr = mock.Mock() + ipaddr.hosts.return_value = [] + + expected = '0.0.0.0' + result = self.s._get_ip_flow_range({"tg__2": 'xe0'}) + self.assertEqual(result, expected) + + def test__get_ip_flow_range_no_nodes(self): + expected = '0.0.0.0' + result = self.s._get_ip_flow_range({}) + self.assertEqual(result, expected) + def test___get_traffic_flow(self): self.scenario_cfg["traffic_options"]["flow"] = \ self._get_file_abspath("ipv4_1flow_Packets_vpe.yaml") @@ -419,6 +445,13 @@ class TestNetworkServiceTestCase(unittest.TestCase): self.assertIsNotNone( self.s.load_vnf_models(self.scenario_cfg, self.context_cfg)) + def test_load_vnf_models_no_model(self): + vnf = mock.Mock(autospec=GenericVNF) + self.s.get_vnf_impl = mock.Mock(return_value=vnf) + + self.assertIsNotNone( + self.s.load_vnf_models(self.scenario_cfg, self.context_cfg)) + def test_map_topology_to_infrastructure(self): with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) @@ -542,6 +575,35 @@ class TestNetworkServiceTestCase(unittest.TestCase): mock.Mock(return_value=TRAFFIC_PROFILE) self.assertEqual(None, self.s.setup()) + def test_setup_exception(self): + with mock.patch("yardstick.ssh.SSH") as ssh: + ssh_mock = mock.Mock(autospec=ssh.SSH) + ssh_mock.execute = \ + mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, "")) + ssh.from_node.return_value = ssh_mock + + tgen = mock.Mock(autospec=GenericTrafficGen) + tgen.traffic_finished = True + verified_dict = {"verified": True} + tgen.verify_traffic = lambda x: verified_dict + tgen.terminate = mock.Mock(return_value=True) + tgen.name = "tgen__1" + vnf = mock.Mock(autospec=GenericVNF) + vnf.runs_traffic = False + vnf.instantiate.side_effect = RuntimeError("error during instantiate") + vnf.terminate = mock.Mock(return_value=True) + self.s.vnfs = [tgen, vnf] + self.s.traffic_profile = mock.Mock() + self.s.collector = mock.Mock(autospec=Collector) + self.s.collector.get_kpi = \ + mock.Mock(return_value={tgen.name: verified_dict}) + self.s.map_topology_to_infrastructure = mock.Mock(return_value=0) + self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs) + self.s._fill_traffic_profile = \ + mock.Mock(return_value=TRAFFIC_PROFILE) + with self.assertRaises(RuntimeError): + self.s.setup() + def test__get_traffic_profile(self): self.scenario_cfg["traffic_profile"] = \ self._get_file_abspath("ipv4_throughput_vpe.yaml") @@ -568,8 +630,8 @@ class TestNetworkServiceTestCase(unittest.TestCase): def test_teardown(self): vnf = mock.Mock(autospec=GenericVNF) - vnf.terminate = \ - mock.Mock(return_value=True) + vnf.terminate = mock.Mock(return_value=True) + vnf.name = str(vnf) self.s.vnfs = [vnf] self.s.traffic_profile = mock.Mock() self.s.collector = mock.Mock(autospec=Collector) @@ -577,6 +639,18 @@ class TestNetworkServiceTestCase(unittest.TestCase): mock.Mock(return_value=True) self.assertIsNone(self.s.teardown()) + def test_teardown_exception(self): + vnf = mock.Mock(autospec=GenericVNF) + vnf.terminate = mock.Mock(side_effect=RuntimeError("error duing terminate")) + vnf.name = str(vnf) + self.s.vnfs = [vnf] + self.s.traffic_profile = mock.Mock() + self.s.collector = mock.Mock(autospec=Collector) + self.s.collector.stop = \ + mock.Mock(return_value=True) + with self.assertRaises(RuntimeError): + self.s.teardown() + SAMPLE_NETDEVS = { 'enp11s0': { 'address': '0a:de:ad:be:ef:f5', @@ -653,12 +727,6 @@ class TestNetworkServiceTestCase(unittest.TestCase): res = NetworkServiceTestCase.parse_netdev_info(output) assert res == self.SAMPLE_VM_NETDEVS - def test_sort_dpdk_port_num(self): - netdevs = self.SAMPLE_NETDEVS.copy() - NetworkServiceTestCase._sort_dpdk_port_num(netdevs) - assert netdevs['lan']['dpdk_port_num'] == 0 - assert netdevs['enp11s0']['dpdk_port_num'] == 1 - def test_probe_missing_values(self): netdevs = self.SAMPLE_NETDEVS.copy() network = {'local_mac': '0a:de:ad:be:ef:f5'} diff --git a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml b/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml index 0de4b6e79..1ac6c1f89 100644 --- a/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml +++ b/tests/unit/benchmark/scenarios/networking/vpe_vnf_topology.yaml @@ -27,7 +27,7 @@ nsd:nsd-catalog: VNF model: ../../vnf_descriptors/vpe_vnf.yaml #tg_l3fwd.yaml #tg_trex_tpl.yaml #TREX vld: - - id: private + - id: uplink name: tg__1 to vnf__1 link 1 type: ELAN vnfd-connection-point-ref: @@ -38,7 +38,7 @@ nsd:nsd-catalog: vnfd-connection-point-ref: xe0 vnfd-id-ref: vnf__1 #VNF - - id: public + - id: downlink name: vnf__1 to tg__1 link 2 type: ELAN vnfd-connection-point-ref: |