diff options
Diffstat (limited to 'tests/unit/benchmark/core/test_task.py')
-rw-r--r-- | tests/unit/benchmark/core/test_task.py | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py index 14027e43c..bed0bb6d8 100644 --- a/tests/unit/benchmark/core/test_task.py +++ b/tests/unit/benchmark/core/test_task.py @@ -66,31 +66,27 @@ class TaskTestCase(unittest.TestCase): nodes = { 'node1': { 'interfaces': { - 'eth0': { - 'name': 'mgmt', + 'mgmt': { + 'network_name': 'mgmt', }, - 'eth1': { - 'name': 'external', - 'vld_id': '23', + 'xe0': { + 'network_name': 'uplink_0', }, - 'eth10': { - 'name': 'internal', - 'vld_id': '55', + 'xe1': { + 'network_name': 'downlink_0', }, }, }, 'node2': { 'interfaces': { - 'eth4': { - 'name': 'mgmt', + 'mgmt': { + 'network_name': 'mgmt', }, - 'eth2': { - 'name': 'external', - 'vld_id': '32', + 'uplink_0': { + 'network_name': 'uplink_0', }, - 'eth11': { - 'name': 'internal', - 'vld_id': '55', + 'downlink_0': { + 'network_name': 'downlink_0', }, }, }, @@ -99,30 +95,30 @@ class TaskTestCase(unittest.TestCase): mock_context.get_network.side_effect = iter([ None, { - 'name': 'a', - 'network_type': 'private', + 'name': 'mgmt', + 'network_type': 'flat', }, {}, { - 'name': 'b', - 'vld_id': 'y', + 'name': 'uplink_0', 'subnet_cidr': '10.20.0.0/16', }, { - 'name': 'c', - 'vld_id': 'x', + 'name': 'downlink_0', + 'segmentation_id': '1001', }, { - 'name': 'd', - 'vld_id': 'w', + 'name': 'uplink_1', }, ]) - # once for each vld_id in the nodes dict - expected_get_network_calls = 4 + # one for each interface + expected_get_network_calls = 6 expected = { - 'a': {'name': 'a', 'network_type': 'private'}, - 'b': {'name': 'b', 'vld_id': 'y', 'subnet_cidr': '10.20.0.0/16'}, + 'mgmt': {'name': 'mgmt', 'network_type': 'flat'}, + 'uplink_0': {'name': 'uplink_0', 'subnet_cidr': '10.20.0.0/16'}, + 'uplink_1': {'name': 'uplink_1'}, + 'downlink_0': {'name': 'downlink_0', 'segmentation_id': '1001'}, } networks = task.get_networks_from_nodes(nodes) @@ -169,12 +165,12 @@ class TaskTestCase(unittest.TestCase): result = t._check_precondition(cfg) self.assertTrue(result) - @mock.patch('yardstick.benchmark.core.task.os.environ') - def test_parse_suite_no_constraint_no_args(self, mock_environ): + def test_parse_suite_no_constraint_no_args(self): SAMPLE_SCENARIO_PATH = "no_constraint_no_args_scenario_sample.yaml" t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH)) - mock_environ.get.side_effect = ['huawei-pod1', 'compass'] - task_files, task_args, task_args_fnames = t.parse_suite() + with mock.patch('yardstick.benchmark.core.task.os.environ', + new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): + task_files, task_args, task_args_fnames = t.parse_suite() print("files=%s, args=%s, fnames=%s" % (task_files, task_args, task_args_fnames)) self.assertEqual(task_files[0], self.change_to_abspath( @@ -190,8 +186,9 @@ class TaskTestCase(unittest.TestCase): def test_parse_suite_no_constraint_with_args(self, mock_environ): SAMPLE_SCENARIO_PATH = "no_constraint_with_args_scenario_sample.yaml" t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH)) - mock_environ.get.side_effect = ['huawei-pod1', 'compass'] - task_files, task_args, task_args_fnames = t.parse_suite() + with mock.patch('yardstick.benchmark.core.task.os.environ', + new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): + task_files, task_args, task_args_fnames = t.parse_suite() print("files=%s, args=%s, fnames=%s" % (task_files, task_args, task_args_fnames)) self.assertEqual(task_files[0], self.change_to_abspath( @@ -208,8 +205,9 @@ class TaskTestCase(unittest.TestCase): def test_parse_suite_with_constraint_no_args(self, mock_environ): SAMPLE_SCENARIO_PATH = "with_constraint_no_args_scenario_sample.yaml" t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH)) - mock_environ.get.side_effect = ['huawei-pod1', 'compass'] - task_files, task_args, task_args_fnames = t.parse_suite() + with mock.patch('yardstick.benchmark.core.task.os.environ', + new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): + task_files, task_args, task_args_fnames = t.parse_suite() print("files=%s, args=%s, fnames=%s" % (task_files, task_args, task_args_fnames)) self.assertEqual(task_files[0], self.change_to_abspath( @@ -225,8 +223,9 @@ class TaskTestCase(unittest.TestCase): def test_parse_suite_with_constraint_with_args(self, mock_environ): SAMPLE_SCENARIO_PATH = "with_constraint_with_args_scenario_sample.yaml" t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH)) - mock_environ.get.side_effect = ['huawei-pod1', 'compass'] - task_files, task_args, task_args_fnames = t.parse_suite() + with mock.patch('yardstick.benchmark.core.task.os.environ', + new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}): + task_files, task_args, task_args_fnames = t.parse_suite() print("files=%s, args=%s, fnames=%s" % (task_files, task_args, task_args_fnames)) self.assertEqual(task_files[0], self.change_to_abspath( |