summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/benchmark/contexts/test_model.py48
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py6
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py115
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py109
4 files changed, 155 insertions, 123 deletions
diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py
index 5444c2bc8..48ee01cf0 100644
--- a/tests/unit/benchmark/contexts/test_model.py
+++ b/tests/unit/benchmark/contexts/test_model.py
@@ -179,6 +179,7 @@ class NetworkTestCase(unittest.TestCase):
test_network = model.Network('foo', self.mock_context, attrs)
self.assertIsNone(test_network.gateway_ip)
+
class ServerTestCase(unittest.TestCase):
def setUp(self):
@@ -190,7 +191,6 @@ class ServerTestCase(unittest.TestCase):
netattrs = {'cidr': '10.0.0.0/24', 'provider': None, 'external_network': 'ext_net'}
self.mock_context.networks = [model.Network("some-network", self.mock_context, netattrs)]
-
def test_construct_defaults(self):
attrs = None
@@ -227,8 +227,9 @@ class ServerTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance(self, mock_template):
-
- attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10', 'floating_ip_assoc': 'some-vm'}
+ attrs = {'image': 'some-image', 'flavor': 'some-flavor', 'floating_ip': '192.168.1.10',
+ 'floating_ip_assoc': 'some-vm',
+ 'availability_zone': 'zone'}
test_server = model.Server('foo', self.mock_context, attrs)
self.mock_context.flavors = ['flavor1', 'flavor2', 'some-flavor']
@@ -241,7 +242,8 @@ class ServerTestCase(unittest.TestCase):
mock_network.subnet_stack_name = 'some-network-stack-subnet'
mock_network.provider = 'sriov'
mock_network.external_network = 'ext_net'
- mock_network.router = model.Router('some-router', 'some-network', self.mock_context, 'ext_net')
+ mock_network.router = model.Router('some-router', 'some-network', self.mock_context,
+ 'ext_net')
test_server._add_instance(mock_template, 'some-server',
[mock_network], 'hints')
@@ -277,7 +279,8 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data='',
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone='zone')
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_with_user_data(self, mock_template):
@@ -299,7 +302,30 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone=None)
+
+ @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
+ def test__add_instance_with_availablity_zone(self, mock_template):
+ attrs = {
+ 'image': 'some-image', 'flavor': 'some-flavor',
+ 'availability_zone': 'zone',
+ }
+ test_server = model.Server('foo', self.mock_context, attrs)
+
+ test_server._add_instance(mock_template, 'some-server',
+ [], 'hints')
+
+ mock_template.add_server.assert_called_with(
+ 'some-server', 'some-image',
+ flavor='some-flavor',
+ flavors=self.mock_context.flavors,
+ ports=[],
+ user=self.mock_context.user,
+ key_name=self.mock_context.keypair_name,
+ user_data='',
+ scheduler_hints='hints',
+ availability_zone='zone')
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_plus_flavor(self, mock_template):
@@ -339,7 +365,8 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
+ scheduler_hints='hints',
+ availability_zone=None)
@mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate')
def test__add_instance_misc(self, mock_template):
@@ -351,7 +378,7 @@ class ServerTestCase(unittest.TestCase):
}
test_server = model.Server('ServerFlavor-3', self.mock_context, attrs)
- self.mock_context.flavors = ['flavor2']
+ self.mock_context.flavors = ['flavor2']
self.mock_context.flavor = {'vcpus': 4}
mock_network = mock.Mock()
mock_network.name = 'some-network'
@@ -361,7 +388,6 @@ class ServerTestCase(unittest.TestCase):
test_server._add_instance(mock_template, 'ServerFlavor-3',
[mock_network], 'hints')
-
mock_template.add_port(
'ServerFlavor-3-some-network-port',
mock_network.stack_name,
@@ -387,5 +413,5 @@ class ServerTestCase(unittest.TestCase):
user=self.mock_context.user,
key_name=self.mock_context.keypair_name,
user_data=user_data,
- scheduler_hints='hints')
-
+ scheduler_hints='hints',
+ availability_zone=None)
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index f3244fdbd..5c2f890e8 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -99,7 +99,7 @@ class TestResourceProfile(unittest.TestCase):
port_names = \
self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['vdu'][0]['external-interface']
self.resource_profile = \
- ResourceProfile(mgmt, port_names, [1, 2, 3])
+ ResourceProfile(mgmt, port_names)
self.resource_profile.connection = self.ssh_mock
def test___init__(self):
@@ -134,10 +134,6 @@ class TestResourceProfile(unittest.TestCase):
self.assertIsNone(
self.resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
- def test__setup_intel_pmu(self):
- self.assertIsNone(
- self.resource_profile._setup_intel_pmu(self.ssh_mock, "/opt/nsb_bin"))
-
def test__setup_ovs_stats(self):
self.assertIsNone(
self.resource_profile._setup_ovs_stats(self.ssh_mock))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index 3c073812c..a04698d68 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -44,6 +44,7 @@ if stl_patch:
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxMplsProfileHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxBngProfileHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxVpeProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxlwAFTRProfileHelper
class TestCoreTuple(unittest.TestCase):
@@ -2215,3 +2216,117 @@ class TestProxVpeProfileHelper(unittest.TestCase):
helper.run_test(120, 5, 6.5)
helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1
+
+
+class TestProxlwAFTRProfileHelper(unittest.TestCase):
+
+ def test_lwaftr_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tun'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'inet'),
+ ]),
+ ]
+
+ helper = ProxlwAFTRProfileHelper(resource_helper)
+ helper._cpu_topology = {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
+ 3: {
+ 7: (7, 3, 0)
+ },
+ 4: {
+ 8: (8, 3, 0)
+ },
+ }
+ }
+
+ expected_tun = [7]
+ expected_inet = [8]
+ expected_combined = (expected_tun, expected_inet)
+
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.tun_cores, expected_tun)
+ self.assertEqual(helper.inet_cores, expected_inet)
+ self.assertEqual(helper._cores_tuple, expected_combined)
+
+ def test_tun_ports(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('port 3', [
+ ('index', '5'),
+ ('name', 'lwB4'),
+ ('mac', 'hardware'),
+ ]),
+ ('port 4', [
+ ('index', '7'),
+ ('name', 'inet'),
+ ('mac', 'hardware'),
+ ]),
+ ]
+
+ helper = ProxlwAFTRProfileHelper(resource_helper)
+ helper._port_list = {
+ 0: {
+ 1: {
+ 5: 'lwB4'
+ },
+ 2: {
+ 6: 'inet'
+ },
+ 3: {
+ 7: 'lwB4'
+ },
+ 4: {
+ 8: 'inet'
+ },
+ }
+ }
+
+ expected_tun = [3]
+ expected_inet = [4]
+ expected_combined = (expected_tun, expected_inet)
+
+ self.assertIsNone(helper._ports_tuple)
+ self.assertEqual(helper.tun_ports, expected_tun)
+ self.assertEqual(helper.inet_ports, expected_inet)
+ self.assertEqual(helper._ports_tuple, expected_combined)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
+
+ helper = ProxlwAFTRProfileHelper(resource_helper)
+
+ helper.run_test(120, 5, 6.5)
+ helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1
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 6c102ed59..57f9fac61 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
@@ -29,7 +29,6 @@ from yardstick.benchmark.contexts.base import Context
from yardstick.network_services.nfvi.resource import ResourceProfile
from yardstick.network_services.traffic_profile.base import TrafficProfile
from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
-from yardstick.ssh import SSHError
class MockError(BaseException):
@@ -609,111 +608,6 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper._build_pipeline_kwargs()
self.assertDictEqual(dpdk_setup_helper.pipeline_kwargs, expected)
- def test__get_app_cpu(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.provision_tool.return_value = 'tool_path'
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
-
- dpdk_setup_helper.CORES = expected = [5, 4, 3]
- result = dpdk_setup_helper._get_app_cpu()
- self.assertEqual(result, expected)
-
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.CpuSysCores')
- def test__get_app_cpu_no_cores_sw(self, mock_cpu_sys_cores_class):
- mock_cpu_sys_cores = mock_cpu_sys_cores_class()
- mock_cpu_sys_cores.get_core_socket.return_value = {
- 'socket': [2, 4, 8, 10, 12],
- }
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.provision_tool.return_value = 'tool_path'
- scenario_helper = mock.Mock()
- scenario_helper.vnf_cfg = {
- 'worker_threads': '2',
- }
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper.CORES = []
- dpdk_setup_helper.SW_DEFAULT_CORE = 1
- dpdk_setup_helper.HW_DEFAULT_CORE = 2
- dpdk_setup_helper.socket = 'socket'
-
- expected = [2, 4, 8]
- result = dpdk_setup_helper._get_app_cpu()
- self.assertEqual(result, expected)
-
- @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.CpuSysCores')
- def test__get_app_cpu_no_cores_hw(self, mock_cpu_sys_cores_class):
- mock_cpu_sys_cores = mock_cpu_sys_cores_class()
- mock_cpu_sys_cores.get_core_socket.return_value = {
- 'socket': [2, 4, 8, 10, 12],
- }
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- scenario_helper.vnf_cfg = {
- 'worker_threads': '2',
- 'lb_config': 'HW',
- }
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper.CORES = []
- dpdk_setup_helper.SW_DEFAULT_CORE = 1
- dpdk_setup_helper.HW_DEFAULT_CORE = 2
- dpdk_setup_helper.socket = 'socket'
-
- expected = [2, 4, 8, 10]
- result = dpdk_setup_helper._get_app_cpu()
- self.assertEqual(result, expected)
-
- def test__get_cpu_sibling_list(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = iter([(0, '5', ''), (0, '3,4', ''), (0, '10', '')])
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._get_app_cpu = mock.Mock(return_value=[])
-
- expected = ['5', '3', '4', '10']
- result = dpdk_setup_helper._get_cpu_sibling_list([1, 3, 7])
- self.assertEqual(result, expected)
-
- def test__get_cpu_sibling_list_no_core_arg(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = iter([(0, '5', ''), (0, '3,4', ''), (0, '10', '')])
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._get_app_cpu = mock.Mock(return_value=[1, 7])
-
- expected = ['5', '3', '4']
- result = dpdk_setup_helper._get_cpu_sibling_list()
- self.assertEqual(result, expected)
-
- def test__get_cpu_sibling_list_ssh_failure(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = iter([(0, '5', ''), SSHError, (0, '10', '')])
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._get_app_cpu = mock.Mock(return_value=[])
-
- expected = []
- result = dpdk_setup_helper._get_cpu_sibling_list([1, 3, 7])
- self.assertEqual(result, expected)
-
- def test__validate_cpu_cfg(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- ssh_helper = mock.Mock()
- ssh_helper.execute.side_effect = iter([(0, '5', ''), (0, '3,4', ''), (0, '10', '')])
- scenario_helper = mock.Mock()
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
- dpdk_setup_helper._get_app_cpu = mock.Mock(return_value=[1, 3, 7])
-
- expected = ['5', '3', '4', '10']
- 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, _, mock_time):
@@ -1497,8 +1391,9 @@ class TestRfc2544ResourceHelper(unittest.TestCase):
class TestSampleVNFDeployHelper(unittest.TestCase):
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch('subprocess.check_output')
- def test_deploy_vnfs_disabled(self, mock_check_output):
+ def test_deploy_vnfs_disabled(self, mock_check_output, mock_time):
vnfd_helper = mock.Mock()
ssh_helper = mock.Mock()
ssh_helper.join_bin_path.return_value = 'joined_path'