summaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/energy/test_functest_energy.py5
-rw-r--r--functest/tests/unit/odl/test_odl.py15
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py45
3 files changed, 57 insertions, 8 deletions
diff --git a/functest/tests/unit/energy/test_functest_energy.py b/functest/tests/unit/energy/test_functest_energy.py
index 177788bc4..f8bb13c99 100644
--- a/functest/tests/unit/energy/test_functest_energy.py
+++ b/functest/tests/unit/energy/test_functest_energy.py
@@ -248,7 +248,9 @@ class EnergyRecorderTest(unittest.TestCase):
self.__decorated_method() == self.returned_value_to_preserve
)
- def test_decorator_preserve_ex(self):
+ @mock.patch(
+ "functest.energy.energy.finish_session")
+ def test_decorator_preserve_ex(self, finish_mock=None):
"""Test that decorator preserve method exceptions."""
self.test_load_config()
with self.assertRaises(Exception) as context:
@@ -256,6 +258,7 @@ class EnergyRecorderTest(unittest.TestCase):
self.assertTrue(
self.exception_message_to_preserve in context.exception
)
+ self.assertTrue(finish_mock.called)
@mock.patch("functest.utils.functest_utils.get_functest_config",
side_effect=config_loader_mock)
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 070a8d2ec..8c8a6cec3 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -513,6 +513,21 @@ class ODLRunTesting(ODLTesting):
self._test_run(testcase.TestCase.EX_OK,
odlip=self._neutron_ip, odlwebport='8181')
+ def test_daisy_no_controller_ip(self):
+ with mock.patch('functest.utils.openstack_utils.get_endpoint',
+ return_value="http://{}:9696".format(
+ ODLTesting._neutron_ip)):
+ os.environ["INSTALLER_TYPE"] = "daisy"
+ self.assertEqual(self.test.run(),
+ testcase.TestCase.EX_RUN_ERROR)
+
+ def test_daisy(self):
+ os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
+ os.environ["INSTALLER_TYPE"] = "daisy"
+ self._test_run(testcase.TestCase.EX_OK,
+ odlip=self._sdn_controller_ip, odlwebport='8181',
+ odlrestconfport='8087')
+
class ODLArgParserTesting(ODLTesting):
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index 8845f6604..32cc15134 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -130,7 +130,10 @@ class OSRallyTesting(unittest.TestCase):
CONST.__setattr__('DEPLOY_SCENARIO', 'test_scenario')
dic = {'scenario': [{'scenarios': ['test_scenario'],
'installers': ['test_installer'],
- 'tests': ['test']}]}
+ 'tests': ['test']},
+ {'scenarios': ['other_scenario'],
+ 'installers': ['test_installer'],
+ 'tests': ['other_test']}]}
with mock.patch('__builtin__.open', mock.mock_open()), \
mock.patch('functest.opnfv_tests.openstack.rally.rally.'
'yaml.safe_load',
@@ -138,6 +141,34 @@ class OSRallyTesting(unittest.TestCase):
self.assertEqual(self.rally_base.excl_scenario(),
['test'])
+ def test_excl_scenario_regex(self):
+ CONST.__setattr__('INSTALLER_TYPE', 'test_installer')
+ CONST.__setattr__('DEPLOY_SCENARIO', 'os-ctrlT-featT-modeT')
+ dic = {'scenario': [{'scenarios': ['^os-[^-]+-featT-modeT$'],
+ 'installers': ['test_installer'],
+ 'tests': ['test1']},
+ {'scenarios': ['^os-ctrlT-[^-]+-modeT$'],
+ 'installers': ['test_installer'],
+ 'tests': ['test2']},
+ {'scenarios': ['^os-ctrlT-featT-[^-]+$'],
+ 'installers': ['test_installer'],
+ 'tests': ['test3']},
+ {'scenarios': ['^os-'],
+ 'installers': ['test_installer'],
+ 'tests': ['test4']},
+ {'scenarios': ['other_scenario'],
+ 'installers': ['test_installer'],
+ 'tests': ['test0a']},
+ {'scenarios': [''], # empty scenario
+ 'installers': ['test_installer'],
+ 'tests': ['test0b']}]}
+ with mock.patch('__builtin__.open', mock.mock_open()), \
+ mock.patch('functest.opnfv_tests.openstack.rally.rally.'
+ 'yaml.safe_load',
+ return_value=dic):
+ self.assertEqual(self.rally_base.excl_scenario(),
+ ['test1', 'test2', 'test3', 'test4'])
+
def test_excl_scenario_exception(self):
with mock.patch('__builtin__.open', side_effect=Exception):
self.assertEqual(self.rally_base.excl_scenario(),
@@ -186,7 +217,7 @@ class OSRallyTesting(unittest.TestCase):
self.assertRaises(Exception):
self.rally_base._run_task('test_name')
- @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.info')
+ @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.info')
def test_run_task_no_tests_for_scenario(self, mock_logger_info):
with mock.patch('functest.opnfv_tests.openstack.rally.rally.'
'os.path.exists',
@@ -196,10 +227,10 @@ class OSRallyTesting(unittest.TestCase):
mock.patch.object(self.rally_base, 'file_is_empty',
return_value=True):
self.rally_base._run_task('test_name')
- str = 'No tests for scenario "test_name"'
- mock_logger_info.assert_any_call(str)
+ mock_logger_info.assert_any_call('No tests for scenario \"%s\"',
+ 'test_name')
- @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.error')
+ @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.error')
def test_run_task_taskid_missing(self, mock_logger_error):
with mock.patch('functest.opnfv_tests.openstack.rally.rally.'
'os.path.exists',
@@ -222,8 +253,8 @@ class OSRallyTesting(unittest.TestCase):
str = 'Failed to retrieve task_id, validating task...'
mock_logger_error.assert_any_call(str)
- @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.info')
- @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.error')
+ @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.info')
+ @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.error')
def test_run_task_default(self, mock_logger_error,
mock_logger_info):
popen = mock.Mock()