aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_model.py20
-rw-r--r--tests/unit/network_services/helpers/test_iniparser.py (renamed from tests/unit/network_services/vnf_generic/vnf/test_iniparser.py)14
-rw-r--r--tests/unit/network_services/helpers/test_samplevnf_helper.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py7
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py9
6 files changed, 19 insertions, 35 deletions
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py
index ddbc1a4bb..6899a0af6 100644
--- a/tests/unit/benchmark/contexts/standalone/test_model.py
+++ b/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -91,10 +91,12 @@ class ModelLibvirtTestCase(unittest.TestCase):
image = Libvirt.create_snapshot_qemu(ssh_mock, "0", "ubuntu.img")
self.assertEqual(image, result)
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.pin_vcpu_for_perf")
@mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.create_snapshot_qemu")
@mock.patch('yardstick.benchmark.contexts.standalone.model.open')
@mock.patch('yardstick.benchmark.contexts.standalone.model.write_file')
- def test_build_vm_xml(self, mock_open, mock_write_file, mock_create_snapshot_qemu):
+ def test_build_vm_xml(self, mock_open, mock_write_file, mock_create_snapshot_qemu,
+ mock_pin_vcpu_for_perf):
result = [4]
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -102,17 +104,10 @@ class ModelLibvirtTestCase(unittest.TestCase):
mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
mock_create_snapshot_qemu.return_value = "0.img"
+
status = Libvirt.build_vm_xml(ssh_mock, {}, "test", "vm_0", 0)
self.assertEqual(status[0], result[0])
- def test_split_cpu_list(self):
- result = Libvirt.split_cpu_list("1,2,3")
- self.assertEqual(result, [1, 2, 3])
-
- def test_get_numa_nodes(self):
- result = Libvirt.get_numa_nodes()
- self.assertIsNotNone(result)
-
def test_update_interrupts_hugepages_perf(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -122,17 +117,16 @@ class ModelLibvirtTestCase(unittest.TestCase):
status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
self.assertIsNone(status)
- @mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.get_numa_nodes")
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.CpuSysCores")
@mock.patch("yardstick.benchmark.contexts.standalone.model.Libvirt.update_interrupts_hugepages_perf")
- def test_pin_vcpu_for_perf(self, mock_update_interrupts_hugepages_perf, mock_get_numa_nodes):
+ def test_pin_vcpu_for_perf(self, mock_update_interrupts_hugepages_perf, mock_CpuSysCores):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- mock_get_numa_nodes.return_value = {'1': [18, 19, 20, 21], '0': [0, 1, 2, 3]}
status = Libvirt.pin_vcpu_for_perf(ssh_mock, "vm_0", 4)
- self.assertIsNone(status)
+ self.assertIsNotNone(status)
class StandaloneContextHelperTestCase(unittest.TestCase):
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py b/tests/unit/network_services/helpers/test_iniparser.py
index 1ad8df9c6..bd27b497e 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py
+++ b/tests/unit/network_services/helpers/test_iniparser.py
@@ -27,10 +27,10 @@ stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.iniparser import ParseError
- from yardstick.network_services.vnf_generic.vnf.iniparser import LineParser
- from yardstick.network_services.vnf_generic.vnf.iniparser import BaseParser
- from yardstick.network_services.vnf_generic.vnf.iniparser import ConfigParser
+ from yardstick.network_services.helpers.iniparser import ParseError
+ from yardstick.network_services.helpers.iniparser import LineParser
+ from yardstick.network_services.helpers.iniparser import BaseParser
+ from yardstick.network_services.helpers.iniparser import ConfigParser
PARSE_TEXT_1 = """\
@@ -141,7 +141,7 @@ class TestConfigParser(unittest.TestCase):
return internal_open
- @mock.patch('yardstick.network_services.vnf_generic.vnf.iniparser.open')
+ @mock.patch('yardstick.network_services.helpers.iniparser.open')
def test_parse(self, mock_open):
mock_open.side_effect = self.make_open(PARSE_TEXT_1)
@@ -182,7 +182,7 @@ class TestConfigParser(unittest.TestCase):
self.assertEqual(config_parser.find_section_index('section1'), 1)
self.assertEqual(config_parser.find_section_index('section3'), -1)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.iniparser.open')
+ @mock.patch('yardstick.network_services.helpers.iniparser.open')
def test_parse_2(self, mock_open):
mock_open.side_effect = self.make_open(PARSE_TEXT_2)
@@ -200,7 +200,7 @@ class TestConfigParser(unittest.TestCase):
self.assertEqual(config_parser.sections, expected)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.iniparser.open')
+ @mock.patch('yardstick.network_services.helpers.iniparser.open')
def test_parse_negative(self, mock_open):
bad_text_dict = {
'no section': PARSE_TEXT_BAD_1,
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py
index bff3a7722..05acdfaa9 100644
--- a/tests/unit/network_services/helpers/test_samplevnf_helper.py
+++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py
@@ -797,7 +797,7 @@ class TestMultiPortConfig(unittest.TestCase):
def test_generate_arp_route_tbl(self, *_):
topology_file = mock.Mock()
config_tpl = mock.Mock()
- tmp_file = mock.Mock()
+ tmp_file = ""
vnfd_mock = mock.MagicMock()
vnfd_mock.port_num.side_effect = ['32', '1', '987']
vnfd_mock.find_interface.side_effect = [
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index b0ef1da91..832509ea7 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@ -72,13 +72,12 @@ link 1 up
self.assertNotIn("This is a header", out)
def test__get_cgnapt_config(self):
- vnfd_helper = mock.Mock()
+ vnfd_helper = mock.MagicMock()
vnfd_helper.port_pairs.uplink_ports = [{"name": 'a'}, {"name": "b"}, {"name": "c"}]
helper = CgnaptApproxSetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
- helper._get_ports_gateway = mock.Mock(side_effect=[3, 5, 2])
- result = helper._get_cgnapt_config([{"name": 'a'}, {}, {"name": "b"}, {}, {"name": "c"}])
- self.assertEqual(result, [3, 5, 2])
+ result = helper._get_cgnapt_config()
+ self.assertIsNotNone(result)
def test_scale(self):
helper = CgnaptApproxSetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index 09060ff57..a6d40877d 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -376,7 +376,7 @@ class TestProxApproxVnf(unittest.TestCase):
return file_path
@mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.iniparser.open', create=True)
+ @mock.patch('yardstick.network_services.helpers.iniparser.open', create=True)
@mock.patch(SSH_HELPER)
def test_run_prox(self, ssh, *_):
mock_ssh(ssh)
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 c41da2c45..6c102ed59 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
@@ -360,15 +360,6 @@ class TestSetupEnvHelper(unittest.TestCase):
with self.assertRaises(NotImplementedError):
setup_env_helper.build_config()
- def test__get_ports_gateway(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- setup_env_helper = SetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
- result = setup_env_helper._get_ports_gateway("xe0")
- self.assertEqual(result, "152.16.100.20")
-
- result = setup_env_helper._get_ports_gateway("xe123")
- self.assertIsNone(result)
-
def test_setup_vnf_environment(self):
setup_env_helper = SetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
self.assertIsNone(setup_env_helper.setup_vnf_environment())