summaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py')
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py59
1 files changed, 50 insertions, 9 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index ffd0d539b..e210aa0e4 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -36,8 +36,8 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.vnf_generic.vnf.vpe_vnf import ConfigCreate
from yardstick.network_services.nfvi.resource import ResourceProfile
- from yardstick.network_services.vnf_generic.vnf import vpe_vnf
- from yardstick.network_services.vnf_generic.vnf.vpe_vnf import VpeApproxVnf
+ from yardstick.network_services.vnf_generic.vnf.vpe_vnf import \
+ VpeApproxVnf, VpeApproxSetupEnvHelper
from tests.unit.network_services.vnf_generic.vnf.test_base import FileAbsPath
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@ -185,14 +185,15 @@ class TestVpeApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
'netmask': '255.255.255.0',
- 'dpdk_port_num': '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',
+ 'vld_id': 'private_0',
+ 'ifname': 'xe0',
},
'vnfd-connection-point-ref': 'xe0',
'name': 'xe0',
@@ -203,14 +204,15 @@ class TestVpeApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.1',
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
'driver': "i40e",
'netmask': '255.255.255.0',
- 'dpdk_port_num': '1',
+ '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',
+ 'vld_id': 'public_0',
+ 'ifname': 'xe1',
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1',
@@ -258,7 +260,7 @@ class TestVpeApproxVnf(unittest.TestCase):
SCENARIO_CFG = {
'options': {
'packetsize': 64,
- 'traffic_type': 4 ,
+ 'traffic_type': 4,
'rfc2544': {
'allowed_drop_rate': '0.8 - 1',
},
@@ -499,6 +501,40 @@ class TestVpeApproxVnf(unittest.TestCase):
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
+ vpe_approx_vnf.vnf_cfg = {
+ 'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config': '1C/1T',
+ 'worker_threads': 1,
+ }
+ vpe_approx_vnf.scenario_helper.scenario_cfg = {
+ 'options': {
+ NAME: {
+ 'traffic_type': '4',
+ 'topology': 'nsb_test_case.yaml',
+ 'vnf_config': 'vpe_config',
+ }
+ }
+ }
+ vpe_approx_vnf.topology = "nsb_test_case.yaml"
+ vpe_approx_vnf.nfvi_type = "baremetal"
+ vpe_approx_vnf._provide_config_file = mock.Mock()
+ vpe_approx_vnf._build_config = mock.MagicMock()
+
+ self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
+ self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
+ self.assertIsNone(vpe_approx_vnf._run())
+
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.ConfigCreate")
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.open")
+ @mock.patch(SSH_HELPER)
+ def test_build_config(self, mock_mul, mock_context, mock_config, mock_open, ssh, _):
+ mock_ssh(ssh)
+ vpe_approx_vnf = VpeApproxSetupEnvHelper(mock.MagicMock(),
+ mock.MagicMock, mock.MagicMock)
+ vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
vpe_approx_vnf.generate_port_pairs = mock.Mock()
vpe_approx_vnf.tg_port_pairs = [[[0], [1]]]
vpe_approx_vnf.vnf_port_pairs = [[[0], [1]]]
@@ -513,6 +549,7 @@ class TestVpeApproxVnf(unittest.TestCase):
NAME: {
'traffic_type': '4',
'topology': 'nsb_test_case.yaml',
+ 'vnf_config': 'vpe_config',
}
}
}
@@ -520,8 +557,12 @@ class TestVpeApproxVnf(unittest.TestCase):
vpe_approx_vnf.nfvi_type = "baremetal"
vpe_approx_vnf._provide_config_file = mock.Mock()
- self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
- self.assertIsNone(vpe_approx_vnf._run())
+ vpe_approx_vnf.ssh_helper = mock.MagicMock()
+ vpe_approx_vnf.scenario_helper = mock.MagicMock()
+ vpe_approx_vnf.ssh_helper.bin_path = mock.Mock()
+ vpe_approx_vnf.ssh_helper.upload_config_file = mock.MagicMock()
+ self.assertIsNone(vpe_approx_vnf._build_vnf_ports())
+ self.assertIsNotNone(vpe_approx_vnf.build_config())
@mock.patch(SSH_HELPER)
def test_wait_for_instantiate(self, ssh, _):