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.py77
1 files changed, 58 insertions, 19 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..757109d11 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
@@ -57,8 +57,8 @@ class TestConfigCreate(unittest.TestCase):
def test___init__(self):
config_create = ConfigCreate([0], [1], 2)
- self.assertEqual(config_create.priv_ports, [0])
- self.assertEqual(config_create.pub_ports, [1])
+ self.assertEqual(config_create.uplink_ports, [0])
+ self.assertEqual(config_create.downlink_ports, [1])
self.assertEqual(config_create.socket, 2)
def test_vpe_initialize(self):
@@ -110,7 +110,7 @@ class TestConfigCreate(unittest.TestCase):
self.assertNotEqual(result, '')
def test_create_vpe_config(self):
- priv_ports = [
+ uplink_ports = [
{
'index': 0,
'dpdk_port_num': 1,
@@ -121,7 +121,7 @@ class TestConfigCreate(unittest.TestCase):
},
]
- pub_ports = [
+ downlink_ports = [
{
'index': 2,
'dpdk_port_num': 3,
@@ -132,7 +132,7 @@ class TestConfigCreate(unittest.TestCase):
},
]
- config_create = ConfigCreate(priv_ports, pub_ports, 23)
+ config_create = ConfigCreate(uplink_ports, downlink_ports, 23)
curr_path = os.path.dirname(os.path.abspath(__file__))
vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
@@ -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': 'uplink_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': 'downlink_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',
},
@@ -308,7 +310,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': 'public',
+ 'vld_id': VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -342,7 +344,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': 'private',
+ 'vld_id': VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -373,7 +375,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': 'private',
+ 'vld_id': VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -385,7 +387,7 @@ class TestVpeApproxVnf(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': 'public',
+ 'vld_id': VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -499,9 +501,6 @@ 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.generate_port_pairs = mock.Mock()
- vpe_approx_vnf.tg_port_pairs = [[[0], [1]]]
- vpe_approx_vnf.vnf_port_pairs = [[[0], [1]]]
vpe_approx_vnf.vnf_cfg = {
'lb_config': 'SW',
'lb_count': 1,
@@ -513,16 +512,56 @@ class TestVpeApproxVnf(unittest.TestCase):
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.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.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, _):
mock_ssh(ssh)