aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/benchmark/contexts/test_kubernetes.py65
-rw-r--r--tests/unit/network_services/libs/ixia_libs/test_IxNet.py12
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py163
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py10
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py18
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py140
-rw-r--r--tests/unit/orchestrator/test_kubernetes.py8
7 files changed, 250 insertions, 166 deletions
diff --git a/tests/unit/benchmark/contexts/test_kubernetes.py b/tests/unit/benchmark/contexts/test_kubernetes.py
index 4976a9fe0..3a926f85c 100644
--- a/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -47,13 +47,15 @@ class KubernetesTestCase(unittest.TestCase):
# clear kubernetes contexts from global list so we don't break other tests
Context.list = []
+ @mock.patch('{}.KubernetesContext._delete_services'.format(prefix))
@mock.patch('{}.KubernetesContext._delete_ssh_key'.format(prefix))
@mock.patch('{}.KubernetesContext._delete_rcs'.format(prefix))
@mock.patch('{}.KubernetesContext._delete_pods'.format(prefix))
def test_undeploy(self,
mock_delete_pods,
mock_delete_rcs,
- mock_delete_ssh):
+ mock_delete_ssh,
+ mock_delete_services):
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
@@ -61,7 +63,9 @@ class KubernetesTestCase(unittest.TestCase):
self.assertTrue(mock_delete_ssh.called)
self.assertTrue(mock_delete_rcs.called)
self.assertTrue(mock_delete_pods.called)
+ self.assertTrue(mock_delete_services.called)
+ @mock.patch('{}.KubernetesContext._create_services'.format(prefix))
@mock.patch('{}.KubernetesContext._wait_until_running'.format(prefix))
@mock.patch('{}.KubernetesTemplate.get_rc_pods'.format(prefix))
@mock.patch('{}.KubernetesContext._create_rcs'.format(prefix))
@@ -70,7 +74,8 @@ class KubernetesTestCase(unittest.TestCase):
mock_set_ssh_key,
mock_create_rcs,
mock_get_rc_pods,
- mock_wait_until_running):
+ mock_wait_until_running,
+ mock_create_services):
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
@@ -78,6 +83,7 @@ class KubernetesTestCase(unittest.TestCase):
k8s_context.deploy()
self.assertTrue(mock_set_ssh_key.called)
self.assertTrue(mock_create_rcs.called)
+ self.assertTrue(mock_create_services.called)
self.assertTrue(mock_get_rc_pods.called)
self.assertTrue(mock_wait_until_running.called)
@@ -106,14 +112,39 @@ class KubernetesTestCase(unittest.TestCase):
mock_read_pod_status.return_value = 'Running'
k8s_context._wait_until_running()
- @mock.patch('{}.k8s_utils.get_pod_list'.format(prefix))
- def test_get_server(self, mock_get_pod_list):
+ @mock.patch('{}.k8s_utils.get_pod_by_name'.format(prefix))
+ @mock.patch('{}.KubernetesContext._get_node_ip'.format(prefix))
+ @mock.patch('{}.k8s_utils.get_service_by_name'.format(prefix))
+ def test_get_server(self,
+ mock_get_service_by_name,
+ mock_get_node_ip,
+ mock_get_pod_by_name):
+ class Service(object):
+ def __init__(self):
+ self.name = 'yardstick'
+ self.node_port = 30000
+
+ class Services(object):
+ def __init__(self):
+ self.ports = [Service()]
+
+ class Status(object):
+ def __init__(self):
+ self.pod_ip = '172.16.10.131'
+
+ class Pod(object):
+ def __init__(self):
+ self.status = Status()
+
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
- mock_get_pod_list.return_value.items = []
+ mock_get_service_by_name.return_value = Services()
+ mock_get_pod_by_name.return_value = Pod()
+ mock_get_node_ip.return_value = '172.16.10.131'
+
server = k8s_context._get_server('server')
- self.assertIsNone(server)
+ self.assertIsNotNone(server)
@mock.patch('{}.KubernetesContext._create_rc'.format(prefix))
def test_create_rcs(self, mock_create_rc):
@@ -143,6 +174,28 @@ class KubernetesTestCase(unittest.TestCase):
k8s_context._delete_rc({})
self.assertTrue(mock_delete_replication_controller.called)
+ @mock.patch('{}.k8s_utils.get_node_list'.format(prefix))
+ def test_get_node_ip(self, mock_get_node_list):
+
+ k8s_context = KubernetesContext()
+ k8s_context.init(context_cfg)
+ k8s_context._get_node_ip()
+ self.assertTrue(mock_get_node_list.called)
+
+ @mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.create')
+ def test_create_services(self, mock_create):
+ k8s_context = KubernetesContext()
+ k8s_context.init(context_cfg)
+ k8s_context._create_services()
+ self.assertTrue(mock_create.called)
+
+ @mock.patch('yardstick.orchestrator.kubernetes.ServiceObject.delete')
+ def test_delete_services(self, mock_delete):
+ k8s_context = KubernetesContext()
+ k8s_context.init(context_cfg)
+ k8s_context._delete_services()
+ self.assertTrue(mock_delete.called)
+
def main():
unittest.main()
diff --git a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
index 0c82d74a8..3f374fb50 100644
--- a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
+++ b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
@@ -82,10 +82,8 @@ class TestIxNextgen(unittest.TestCase):
config = {
'chassis': '1.1.1.1',
- 'card1': '1',
- 'card2': '2',
- 'port1': '2',
- 'port2': '2',
+ 'cards': ['1', '2'],
+ 'ports': ['2', '2'],
}
ixnet_gen = IxNextgen(ixnet)
@@ -673,10 +671,8 @@ class TestIxNextgen(unittest.TestCase):
'machine': 'test1',
'port': 'test5',
'chassis': 'test4',
- 'card1': '0000',
- 'port1': '07',
- 'card2': '0001',
- 'port2': '08',
+ 'cards': ['0000', '0001'],
+ 'ports': ['07', '08'],
'output_dir': 'test2',
'version': 'test3',
'bidir': True,
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index 1c2c1f3e2..eba38c688 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -14,7 +14,6 @@
from __future__ import absolute_import
import unittest
-import multiprocessing
import mock
from yardstick.network_services.nfvi.resource import ResourceProfile
@@ -86,17 +85,20 @@ class TestResourceProfile(unittest.TestCase):
'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
def setUp(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
+ with mock.patch("yardstick.ssh.AutoConnectSSH") as ssh:
+ self.ssh_mock = mock.Mock(autospec=ssh.SSH)
+ self.ssh_mock.execute = \
mock.Mock(return_value=(0, {}, ""))
- ssh.from_node.return_value = ssh_mock
+ ssh.from_node.return_value = self.ssh_mock
mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
+ # interfaces = \
+ # self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
+ port_names = \
self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
self.resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
+ ResourceProfile(mgmt, port_names, [1, 2, 3])
+ self.resource_profile.connection = self.ssh_mock
def test___init__(self):
self.assertEqual(True, self.resource_profile.enable)
@@ -118,133 +120,33 @@ class TestResourceProfile(unittest.TestCase):
self.assertEqual(val, ('error', 'Invalid', '', ''))
def test__start_collectd(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._prepare_collectd_conf = mock.Mock()
- self.assertIsNone(
- resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_BM(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_managed_ovs_dpdk(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
- def test__prepare_collectd_conf_ovs_dpdk(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
+ self.resource_profile._start_collectd(self.ssh_mock, "/opt/nsb_bin"))
- def test__prepare_collectd_conf_managed_sriov(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
+ def test__prepare_collectd_conf(self):
self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
+ self.resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
- def test__prepare_collectd_conf_sriov(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._provide_config_file = mock.Mock()
- self.assertIsNone(
- resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
@mock.patch("yardstick.network_services.nfvi.resource.open")
- @mock.patch("yardstick.network_services.nfvi.resource.tempfile")
@mock.patch("yardstick.network_services.nfvi.resource.os")
- def test__provide_config_file(self, mock_open, mock_tempfile, mock_os):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._prepare_collectd_conf = mock.Mock()
- resource_profile.connection = ssh_mock
- resource_profile.connection.put = \
- mock.Mock(return_value=(0, "", ""))
- mock_tempfile.mkstemp = mock.Mock(return_value=["test", ""])
- self.assertIsNone(
- resource_profile._provide_config_file("/opt/nsb_bin",
- "collectd.cfg", {}))
+ def test__provide_config_file(self, mock_open, mock_os):
+ loadplugin = range(5)
+ port_names = range(5)
+ kwargs = {
+ "interval": '25',
+ "loadplugin": loadplugin,
+ "port_names": port_names,
+ }
+ self.resource_profile._provide_config_file("/opt/nsb_bin", "collectd.conf", kwargs)
+ self.ssh_mock.execute.assert_called_once()
+
@mock.patch("yardstick.network_services.nfvi.resource.open")
def test_initiate_systemagent(self, mock_open):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
- interfaces = \
- self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
- resource_profile = \
- ResourceProfile(mgmt, interfaces, [1, 2, 3])
- resource_profile._start_collectd = mock.Mock()
- self.assertIsNone(
- resource_profile.initiate_systemagent("/opt/nsb_bin"))
+ self.resource_profile._start_collectd = mock.Mock()
+ self.assertIsNone(
+ self.resource_profile.initiate_systemagent("/opt/nsb_bin"))
def test__parse_hugepages(self):
reskey = ["cpu", "cpuFreq"]
@@ -301,21 +203,21 @@ class TestResourceProfile(unittest.TestCase):
self.assertDictEqual(res, expected_result)
def test_parse_collectd_result_hugepage(self):
- metric = {"nsb_stats/hugepages/free": "101"}
+ # amqp returns bytes
+ metric = {b"nsb_stats/hugepages/free": b"101"}
self.resource_profile.parse_hugepages = \
mock.Mock(return_value={"free": "101"})
res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
- expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {'free':
- '101'},
+ expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {'free': '101'},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
'virt': {}}
self.assertDictEqual(res, expected_result)
def test_parse_collectd_result_dpdk_virt_ovs(self):
- metric = {"nsb_stats/dpdkstat/tx": "101",
- "nsb_stats/ovs_stats/tx": "101",
- "nsb_stats/virt/virt/memory": "101"}
+ metric = {b"nsb_stats/dpdkstat/tx": b"101",
+ b"nsb_stats/ovs_stats/tx": b"101",
+ b"nsb_stats/virt/virt/memory": b"101"}
self.resource_profile.parse_dpdkstat = \
mock.Mock(return_value={"tx": "101"})
self.resource_profile.parse_virt = \
@@ -347,7 +249,6 @@ class TestResourceProfile(unittest.TestCase):
self.assertIsNotNone(res)
def test_run_collectd_amqp(self):
- _queue = multiprocessing.Queue()
resource.AmqpConsumer = mock.Mock(autospec=collectd)
self.assertIsNone(self.resource_profile.run_collectd_amqp())
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 4b9f4172e..d0c4b6f42 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
@@ -723,8 +723,9 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
result = dpdk_setup_helper._validate_cpu_cfg()
self.assertEqual(result, expected)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch('yardstick.ssh.SSH')
- def test_setup_vnf_environment(self, _):
+ def test_setup_vnf_environment(self, _, mock_time):
def execute(cmd, *args, **kwargs):
if cmd.startswith('which '):
return exec_failure
@@ -782,6 +783,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
+ dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+ vnfd_helper.interfaces]
result = dpdk_setup_helper._setup_resources()
self.assertIsInstance(result, ResourceProfile)
self.assertEqual(dpdk_setup_helper.socket, 0)
@@ -796,11 +799,14 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
+ dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+ vnfd_helper.interfaces]
result = dpdk_setup_helper._setup_resources()
self.assertIsInstance(result, ResourceProfile)
self.assertEqual(dpdk_setup_helper.socket, 1)
- def test__detect_and_bind_drivers(self):
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
+ def test__detect_and_bind_drivers(self, mock_time):
vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0))
ssh_helper = mock.Mock()
# ssh_helper.execute = mock.Mock(return_value = (0, 'text', ''))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index 0c3520c44..f62a0fb3b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -252,7 +252,8 @@ class TestIXIATrafficGen(unittest.TestCase):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
- mock_traffic_profile.ports = ["xe0", "xe1"]
+ # traffic_profile.ports is standardized on port_num
+ mock_traffic_profile.ports = [0, 1]
mock_ssh_instance = mock.Mock(autospec=mock_ssh.SSH)
mock_ssh_instance.execute.return_value = 0, "", ""
@@ -346,9 +347,12 @@ class TestIXIATrafficGen(unittest.TestCase):
'task_path': '/path/to/task'
}
- with mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open',
- create=True) as mock_open:
- with mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.open',
- create=True) as mock_ixia_open:
- result = sut._traffic_runner(mock_traffic_profile)
- self.assertIsNone(result)
+ @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.open',
+ mock.mock_open(), create=True)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.LOG.exception')
+ def _traffic_runner(*args):
+ result = sut._traffic_runner(mock_traffic_profile)
+ self.assertIsNone(result)
+
+ _traffic_runner()
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 757109d11..3813aaa21 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
@@ -25,6 +25,7 @@ from multiprocessing import Process, Queue
from tests.unit import STL_MOCKS
from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
+from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -55,14 +56,117 @@ get_file_abspath = MODULE_PATH.get_path
class TestConfigCreate(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',
+ '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': 'uplink_0',
+ 'ifname': 'xe0',
+ },
+ 'vnfd-connection-point-ref': 'xe0',
+ 'name': 'xe0'
+ },
+ {
+ 'virtual-interface': {
+ 'dst_mac': '00:00:00:00:00:04',
+ 'vpci': '0000:05:00.1',
+ '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': 'downlink_0',
+ 'ifname': 'xe1',
+ },
+ '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___init__(self):
- config_create = ConfigCreate([0], [1], 2)
- self.assertEqual(config_create.uplink_ports, [0])
- self.assertEqual(config_create.downlink_ports, [1])
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
+ self.assertEqual(config_create.uplink_ports, ['xe0'])
+ self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
def test_vpe_initialize(self):
- config_create = ConfigCreate([0], [1], 2)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config_create.vpe_initialize(config)
self.assertEqual(config.get('EAL', 'log_level'), '0')
@@ -72,14 +176,16 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
def test_vpe_rxq(self):
- config_create = ConfigCreate([0], [1, 2], 3)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
+ config_create.downlink_ports = ['xe0']
config_create.vpe_rxq(config)
- self.assertEqual(config.get('RXQ1.0', 'mempool'), 'MEMPOOL1')
- self.assertEqual(config.get('RXQ2.0', 'mempool'), 'MEMPOOL1')
+ self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
def test_get_sink_swq(self):
- config_create = ConfigCreate([0], [1], 2)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config.add_section('PIPELINE0')
config.set('PIPELINE0', 'key1', 'value1')
@@ -96,15 +202,26 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
def test_generate_vpe_script(self):
- vpe_config_vnf = ConfigCreate([0], [0], 0)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ vpe_config_vnf = ConfigCreate(vnfd_helper, 2)
intf = [
{
+ "name": 'xe1',
+ "virtual-interface": {
+ "dst_ip": "1.1.1.1",
+ "dst_mac": "00:00:00:00:00:00:02",
+ },
+ },
+ {
+ "name": 'xe2',
"virtual-interface": {
"dst_ip": "1.1.1.1",
"dst_mac": "00:00:00:00:00:00:02",
},
},
]
+ vpe_config_vnf.downlink_ports = ['xe1']
+ vpe_config_vnf.uplink_ports = ['xe2']
result = vpe_config_vnf.generate_vpe_script(intf)
self.assertIsInstance(result, str)
self.assertNotEqual(result, '')
@@ -132,7 +249,10 @@ class TestConfigCreate(unittest.TestCase):
},
]
- config_create = ConfigCreate(uplink_ports, downlink_ports, 23)
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 23)
+ config_create.downlink_ports = ['xe1']
+ config_create.uplink_ports = ['xe1']
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)
diff --git a/tests/unit/orchestrator/test_kubernetes.py b/tests/unit/orchestrator/test_kubernetes.py
index 51718ab86..1a3291c89 100644
--- a/tests/unit/orchestrator/test_kubernetes.py
+++ b/tests/unit/orchestrator/test_kubernetes.py
@@ -62,7 +62,10 @@ service ssh restart;while true ; do sleep 10000; done"
},
"name": "k8s-86096c30-key"
}
- ]
+ ],
+ "nodeSelector": {
+ "kubernetes.io/hostname": "node-01"
+ }
}
}
}
@@ -71,7 +74,8 @@ service ssh restart;while true ; do sleep 10000; done"
'command': '/bin/bash',
'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
service ssh restart;while true ; do sleep 10000; done'],
- 'ssh_key': 'k8s-86096c30-key'
+ 'ssh_key': 'k8s-86096c30-key',
+ 'nodeSelector': { 'kubernetes.io/hostname': 'node-01'}
}
name = 'host-k8s-86096c30'
output_r = KubernetesObject(name, **input_s).get_template()