diff options
Diffstat (limited to 'tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py')
-rw-r--r-- | tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py | 389 |
1 files changed, 197 insertions, 192 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py index 983c21e61..4b9f4172e 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py @@ -98,10 +98,12 @@ class TestVnfSshHelper(unittest.TestCase): 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', - 'local_mac': '00:00:00:00:00:01' + 'local_mac': '00:00:00:00:00:01', + 'vld_id': 'uplink_0', + 'ifname': 'xe0', }, 'vnfd-connection-point-ref': 'xe0', 'name': 'xe0' @@ -113,10 +115,12 @@ class TestVnfSshHelper(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', - 'local_mac': '00:00:00:00:00:02' + 'local_mac': '00:00:00:00:00:02', + 'vld_id': 'downlink_0', + 'ifname': 'xe1', }, 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1' @@ -292,10 +296,12 @@ class TestSetupEnvHelper(unittest.TestCase): 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', - 'local_mac': '00:00:00:00:00:01' + 'local_mac': '00:00:00:00:00:01', + 'vld_id': 'uplink_0', + 'ifname': 'xe0', }, 'vnfd-connection-point-ref': 'xe0', 'name': 'xe0' @@ -307,10 +313,12 @@ class TestSetupEnvHelper(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', - 'local_mac': '00:00:00:00:00:02' + 'local_mac': '00:00:00:00:00:02', + 'vld_id': 'downlink_0', + 'ifname': 'xe1', }, 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1' @@ -414,16 +422,15 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): 'virtual-interface': { 'dst_mac': '00:00:00:00:00:03', 'vpci': '0000:05:00.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'driver': 'i40e', 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', 'local_mac': '00:00:00:00:00:01', - 'vld_id': 'private_0', + 'vld_id': 'uplink_0', 'ifname': 'xe0', }, 'vnfd-connection-point-ref': 'xe0', @@ -433,16 +440,15 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): 'virtual-interface': { 'dst_mac': '00:00:00:00:00:04', 'vpci': '0000:05:00.1', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'driver': 'ixgbe', 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', 'local_mac': '00:00:00:00:00:02', - 'vld_id': 'public_0', + 'vld_id': 'downlink_0', 'ifname': 'xe1', }, 'vnfd-connection-point-ref': 'xe1', @@ -549,7 +555,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): call_args_iter = (args[0][0] for args in ssh_helper.execute.call_args_list) self.assertIsNone(result) self.assertEqual(ssh_helper.execute.call_count, 3) - for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, call_args_iter): + for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, + call_args_iter): self.assertTrue(arg0.startswith(expect_start)) self.assertIn(expect_in, arg0) @@ -566,19 +573,11 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): call_args_iter = (args[0][0] for args in ssh_helper.execute.call_args_list) self.assertIsNone(result) self.assertEqual(ssh_helper.execute.call_count, 3) - for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, call_args_iter): + for expect_start, expect_in, arg0 in zip(expect_start_list, expect_in_list, + call_args_iter): self.assertTrue(arg0.startswith(expect_start)) self.assertIn(expect_in, arg0) - def test__get_dpdk_port_num(self): - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - expected = '0' - result = dpdk_setup_helper._get_dpdk_port_num('xe0') - self.assertEqual(result, expected) - @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.open') @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.find_relative_file') @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig') @@ -590,7 +589,6 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): scenario_helper.vnf_cfg = {} scenario_helper.all_options = {} dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper.all_ports = [] dpdk_setup_helper.PIPELINE_COMMAND = expected = 'pipeline command' result = dpdk_setup_helper.build_config() @@ -614,7 +612,7 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): expected = { 'cfg_file': 'config', 'script': 'script', - 'ports_len_hex': '0xf', + 'port_mask_hex': '0x3', 'tool_path': 'tool_path', } dpdk_setup_helper._build_pipeline_kwargs() @@ -725,73 +723,24 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): result = dpdk_setup_helper._validate_cpu_cfg() self.assertEqual(result, expected) - def test__find_used_drivers(self): - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - stdout = ''' -00:01.2 foo drv=name1 -00:01.4 drv foo=name2 -00:02.2 drv=name3 -00:02.3 drv=name4 -''' - ssh_helper.execute.return_value = 0, stdout, '' - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper.used_drivers = None - dpdk_setup_helper._dpdk_nic_bind = '' - dpdk_setup_helper.bound_pci = [ - 'pci 00:01.2', - 'pci 00:02.3', - ] + @mock.patch('yardstick.ssh.SSH') + def test_setup_vnf_environment(self, _): + def execute(cmd, *args, **kwargs): + if cmd.startswith('which '): + return exec_failure + return exec_success - expected = { - '00:01.2': (0, 'name1'), - '00:02.3': (2, 'name4'), - } - dpdk_setup_helper._find_used_drivers() - self.assertEqual(dpdk_setup_helper.used_drivers, expected) + exec_success = (0, 'good output', '') + exec_failure = (1, 'bad output', 'error output') - def test_dpdk_nic_bind(self): vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() - ssh_helper.provision_tool.return_value = nic_bind = object() - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - - self.assertIsNone(dpdk_setup_helper._dpdk_nic_bind) - self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind) - self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind) - self.assertEqual(ssh_helper.provision_tool.call_count, 1) + ssh_helper.execute = execute - # ensure provision tool is not called a second time - self.assertIs(dpdk_setup_helper.dpdk_nic_bind, nic_bind) - self.assertEqual(ssh_helper.provision_tool.call_count, 1) - - @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time') - @mock.patch('yardstick.ssh.SSH') - def test_setup_vnf_environment(self, _, mock_time): - cores = ['3', '4'] - - vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0)) - ssh_helper = mock.Mock() - ssh_helper.execute.return_value = 1, 'bad output', 'error output' - ssh_helper.join_bin_path.return_value = 'joined_path' - ssh_helper.provision_tool.return_value = 'provision string' - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper._setup_hugepages = mock.Mock() - dpdk_setup_helper._validate_cpu_cfg = mock.Mock(return_value=cores) - dpdk_setup_helper._find_used_drivers = mock.Mock() - dpdk_setup_helper.used_drivers = { - '0000:05:00.0': (1, ''), - '0000:05:01.0': (3, ''), - } + dpdk_vnf_setup_env_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, mock.Mock()) + dpdk_vnf_setup_env_helper._validate_cpu_cfg = mock.Mock(return_value=[]) - result = dpdk_setup_helper.setup_vnf_environment() - self.assertIsInstance(result, ResourceProfile) - self.assertEqual(result.cores, cores) - self.assertEqual(vnfd_helper.interfaces[0]['dpdk_port_num'], 1) - self.assertNotIn('dpdk_port_num', vnfd_helper.interfaces[1]) + self.assertIsInstance(dpdk_vnf_setup_env_helper.setup_vnf_environment(), ResourceProfile) def test__setup_dpdk_early_success(self): vnfd_helper = VnfdHelper(self.VNFD_0) @@ -851,83 +800,146 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase): self.assertIsInstance(result, ResourceProfile) self.assertEqual(dpdk_setup_helper.socket, 1) - def test__bind_dpdk_unforced(self): - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - - dpdk_setup_helper._bind_dpdk('x', 'y', force=False) - self.assertNotIn('--force', ssh_helper.execute.call_args_list[0][0][0]) - - def test__detect_and_bind_dpdk_short(self): - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - ssh_helper.execute.return_value = 0, 'output', '' - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - - self.assertIsNone(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b')) - self.assertEqual(ssh_helper.execute.call_count, 1) - - def test__detect_and_bind_dpdk_fail_to_bind(self): - vnfd_helper = VnfdHelper(self.VNFD_0) + def test__detect_and_bind_drivers(self): + vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0)) ssh_helper = mock.Mock() - ssh_helper.execute.return_value = 1, 'bad output', 'error output' + # ssh_helper.execute = mock.Mock(return_value = (0, 'text', '')) + # ssh_helper.execute.return_value = 0, 'output', '' scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper._bind_dpdk = mock.Mock() - - self.assertIsNone(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b')) - self.assertEqual(ssh_helper.execute.call_count, 2) + rv = ['0000:05:00.1', '0000:05:00.0'] - def test__detect_and_bind_dpdk(self): - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - ssh_helper.execute.side_effect = iter([ - (1, 'bad output', 'error output'), - (0, 'output', ''), - ]) - scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper._bind_dpdk = mock.Mock() + dpdk_setup_helper.dpdk_bind_helper._get_bound_pci_addresses = mock.Mock(return_value=rv) + dpdk_setup_helper.dpdk_bind_helper.bind = mock.Mock() + dpdk_setup_helper.dpdk_bind_helper.read_status = mock.Mock() - self.assertEqual(dpdk_setup_helper._detect_and_bind_dpdk('a', 'b'), 'output') - self.assertEqual(ssh_helper.execute.call_count, 2) + self.assertIsNone(dpdk_setup_helper._detect_and_bind_drivers()) - def test__bind_kernel_devices(self): - bind_iter = iter([ - None, - 'output', - ]) - - vnfd_helper = VnfdHelper(self.VNFD_0) - ssh_helper = mock.Mock() - scenario_helper = mock.Mock() - dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper._detect_and_bind_dpdk = mock.Mock(side_effect=bind_iter) - - self.assertIsNone(dpdk_setup_helper._bind_kernel_devices()) + intf_0 = vnfd_helper.vdu[0]['external-interface'][0]['virtual-interface'] + intf_1 = vnfd_helper.vdu[0]['external-interface'][1]['virtual-interface'] + self.assertEquals(0, intf_0['dpdk_port_num']) + self.assertEquals(1, intf_1['dpdk_port_num']) def test_tear_down(self): vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) - dpdk_setup_helper._dpdk_nic_bind = 'a' - dpdk_setup_helper.used_drivers = { - '0000:05:00.0': (1, 'd1'), - '0000:05:01.0': (3, 'd3'), + dpdk_setup_helper.dpdk_bind_helper.bind = mock.Mock() + dpdk_setup_helper.dpdk_bind_helper.used_drivers = { + '0000:05:00.0': 'd1', + '0000:05:01.0': 'd3', } self.assertIsNone(dpdk_setup_helper.tear_down()) + dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call('0000:05:00.0', 'd1', True) + dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call('0000:05:01.0', 'd3', True) class TestResourceHelper(unittest.TestCase): + VNFD_0 = { + '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:03', + 'vpci': '0000:05:00.0', + 'driver': 'i40e', + 'local_ip': '152.16.100.19', + 'type': 'PCI-PASSTHROUGH', + 'netmask': '255.255.255.0', + 'dpdk_port_num': 0, + 'bandwidth': '10 Gbps', + 'dst_ip': '152.16.100.20', + 'local_mac': '00:00:00:00:00:01' + }, + 'vnfd-connection-point-ref': 'xe0', + 'name': 'xe0' + }, + { + 'virtual-interface': { + 'dst_mac': '00:00:00:00:00:04', + 'vpci': '0000:05:00.1', + 'driver': 'ixgbe', + 'local_ip': '152.16.40.19', + 'type': 'PCI-PASSTHROUGH', + 'netmask': '255.255.255.0', + 'dpdk_port_num': 1, + 'bandwidth': '10 Gbps', + 'dst_ip': '152.16.40.20', + 'local_mac': '00:00:00:00:00:02' + }, + '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' + } + def test_setup(self): resource = object() - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -938,7 +950,7 @@ class TestResourceHelper(unittest.TestCase): self.assertIs(resource_helper.resource, resource) def test_generate_cfg(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -947,7 +959,7 @@ class TestResourceHelper(unittest.TestCase): self.assertIsNone(resource_helper.generate_cfg()) def test_stop_collect(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -957,7 +969,7 @@ class TestResourceHelper(unittest.TestCase): self.assertIsNone(resource_helper.stop_collect()) def test_stop_collect_none(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -966,6 +978,7 @@ class TestResourceHelper(unittest.TestCase): self.assertIsNone(resource_helper.stop_collect()) + class TestClientResourceHelper(unittest.TestCase): VNFD_0 = { @@ -1012,10 +1025,12 @@ class TestClientResourceHelper(unittest.TestCase): 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', - 'local_mac': '00:00:00:00:00:01' + 'local_mac': '00:00:00:00:00:01', + 'vld_id': 'uplink_0', + 'ifname': 'xe0', }, 'vnfd-connection-point-ref': 'xe0', 'name': 'xe0' @@ -1028,10 +1043,12 @@ class TestClientResourceHelper(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', - 'local_mac': '00:00:00:00:00:02' + 'local_mac': '00:00:00:00:00:02', + 'vld_id': 'downlink_0', + 'ifname': 'xe1', }, 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1' @@ -1044,7 +1061,7 @@ class TestClientResourceHelper(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 2, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.30', 'local_mac': '00:00:00:00:00:11' @@ -1095,7 +1112,7 @@ class TestClientResourceHelper(unittest.TestCase): @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.STLError', new_callable=lambda: MockError) def test_get_stats_not_connected(self, mock_state_error, mock_logger): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1151,16 +1168,9 @@ class TestClientResourceHelper(unittest.TestCase): "in_packets": 0, "out_packets": 48791, }, - 'xe2': { - "rx_throughput_fps": 0.0, - "tx_throughput_fps": 0.0, - "rx_throughput_mbps": 0.0, - "tx_throughput_mbps": 0.0, - "in_packets": 0, - "out_packets": 0, - }, } - result = client_resource_helper.generate_samples() + ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports) + result = client_resource_helper.generate_samples(ports) self.assertDictEqual(result, expected) def test_generate_samples_with_key(self): @@ -1211,7 +1221,8 @@ class TestClientResourceHelper(unittest.TestCase): "out_packets": 48791, }, } - result = client_resource_helper.generate_samples('key_name') + ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports) + result = client_resource_helper.generate_samples(ports, 'key_name') self.assertDictEqual(result, expected) def test_generate_samples_with_key_and_default(self): @@ -1261,11 +1272,12 @@ class TestClientResourceHelper(unittest.TestCase): "out_packets": 48791, }, } - result = client_resource_helper.generate_samples('key_name', 'default') + ports = vnfd_helper.port_nums(vnfd_helper.port_pairs.all_ports) + result = client_resource_helper.generate_samples(ports, 'key_name', 'default') self.assertDictEqual(result, expected) def test_clear_stats(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1276,7 +1288,7 @@ class TestClientResourceHelper(unittest.TestCase): self.assertEqual(client_resource_helper.client.clear_stats.call_count, 1) def test_clear_stats_of_ports(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1287,7 +1299,7 @@ class TestClientResourceHelper(unittest.TestCase): self.assertEqual(client_resource_helper.client.clear_stats.call_count, 1) def test_start(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1298,7 +1310,7 @@ class TestClientResourceHelper(unittest.TestCase): self.assertEqual(client_resource_helper.client.start.call_count, 1) def test_start_ports(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1309,7 +1321,7 @@ class TestClientResourceHelper(unittest.TestCase): self.assertEqual(client_resource_helper.client.start.call_count, 1) def test_collect_kpi_with_queue(self): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1332,7 +1344,7 @@ class TestClientResourceHelper(unittest.TestCase): @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.STLError', new_callable=lambda: MockError) def test__connect_with_failures(self, mock_error, mock_logger, mock_time): - vnfd_helper = VnfdHelper({}) + vnfd_helper = VnfdHelper(self.VNFD_0) ssh_helper = mock.Mock() scenario_helper = mock.Mock() dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper) @@ -1667,7 +1679,7 @@ class TestSampleVnf(unittest.TestCase): 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', 'local_mac': '00:00:00:00:00:01' @@ -1682,7 +1694,7 @@ class TestSampleVnf(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', 'local_mac': '00:00:00:00:00:02' @@ -1757,7 +1769,6 @@ class TestSampleVnf(unittest.TestCase): class MySetupEnvHelper(SetupEnvHelper): pass - class MyResourceHelper(ResourceHelper): pass @@ -1895,6 +1906,16 @@ class TestSampleVnf(unittest.TestCase): self.assertEqual(sample_vnf.wait_for_instantiate(), 0) + def test__build_ports(self): + vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] + sample_vnf = SampleVNF('vnf1', vnfd) + + self.assertIsNone(sample_vnf._build_ports()) + self.assertIsNotNone(sample_vnf.networks) + self.assertIsNotNone(sample_vnf.uplink_ports) + self.assertIsNotNone(sample_vnf.downlink_ports) + self.assertIsNotNone(sample_vnf.my_ports) + @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") def test_vnf_execute_with_queue_data(self, mock_time): queue_size_list = [ @@ -2022,7 +2043,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase): 'local_ip': '152.16.100.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '0', + 'dpdk_port_num': 0, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.100.20', 'local_mac': '00:00:00:00:00:01' @@ -2038,7 +2059,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase): 'local_ip': '152.16.40.19', 'type': 'PCI-PASSTHROUGH', 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', + 'dpdk_port_num': 1, 'bandwidth': '10 Gbps', 'dst_ip': '152.16.40.20', 'local_mac': '00:00:00:00:00:02' @@ -2046,22 +2067,6 @@ class TestSampleVNFTrafficGen(unittest.TestCase): 'vnfd-connection-point-ref': 'xe1', 'name': 'xe1' }, - { - 'virtual-interface': { - 'dst_mac': '00:00:00:00:00:13', - 'vpci': '0000:05:00.2', - 'driver': 'ixgbe', - 'local_ip': '152.16.40.19', - 'type': 'PCI-PASSTHROUGH', - 'netmask': '255.255.255.0', - 'dpdk_port_num': '1', - 'bandwidth': '10 Gbps', - 'dst_ip': '152.16.40.30', - 'local_mac': '00:00:00:00:00:11' - }, - 'vnfd-connection-point-ref': 'xe2', - 'name': 'xe2' - }, ], }, ], @@ -2174,7 +2179,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase): mock_traffic_profile = mock.Mock(autospec=TrafficProfile) mock_traffic_profile.get_traffic_definition.return_value = "64" - mock_traffic_profile.execute.return_value = "64" + mock_traffic_profile.execute_traffic.return_value = "64" mock_traffic_profile.params = self.TRAFFIC_PROFILE sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0) |