diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-03-10 21:06:37 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-03-10 21:23:11 +0100 |
commit | e1fa189b1c3dc69ab403658c4bd4396937db5ee0 (patch) | |
tree | be7b5aa4266c65754cc1616711ee89c8b6e40072 | |
parent | c6de7a67e7a54722da02decf0df33c1f1e92af53 (diff) |
Improve tempest files management
Calling apply_tempest_blacklist() is no longer mandatory.
Change-Id: Id9a4e970c8acca066a36be89920745127867cd63
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r-- | functest/opnfv_tests/openstack/patrole/patrole.py | 4 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/tempest/tempest.py | 5 | ||||
-rw-r--r-- | functest/tests/unit/openstack/tempest/test_tempest.py | 20 |
3 files changed, 22 insertions, 7 deletions
diff --git a/functest/opnfv_tests/openstack/patrole/patrole.py b/functest/opnfv_tests/openstack/patrole/patrole.py index 1f1674564..8dcc48a15 100644 --- a/functest/opnfv_tests/openstack/patrole/patrole.py +++ b/functest/opnfv_tests/openstack/patrole/patrole.py @@ -31,8 +31,7 @@ class Patrole(tempest.TempestCommon): super(Patrole, self).__init__(**kwargs) self.res_dir = os.path.join( getattr(config.CONF, 'dir_results'), 'patrole') - self.raw_list = os.path.join(self.res_dir, 'test_raw_list.txt') - self.list = os.path.join(self.res_dir, 'test_list.txt') + self.list = os.path.join(self.res_dir, 'tempest-list.txt') def run(self, **kwargs): self.start_time = time.time() @@ -54,7 +53,6 @@ class Patrole(tempest.TempestCommon): compute_cnt=compute_cnt, role=kwargs.get('role', 'admin')) self.generate_test_list(self.verifier_repo_dir) - self.apply_tempest_blacklist() self.run_verifier_tests() self.parse_verifier_result() self.generate_report() diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index a0c09ac06..d7b33ecb6 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -119,12 +119,15 @@ class TempestCommon(testcase.TestCase): "testr list-tests {1} > {2};" "cd -;".format(verifier_repo_dir, testr_mode, - self.raw_list)) + self.list)) functest_utils.execute_command(cmd) def apply_tempest_blacklist(self): """Exclude blacklisted test cases.""" LOGGER.debug("Applying tempest blacklist...") + if os.path.exists(self.raw_list): + os.remove(self.raw_list) + os.rename(self.list, self.raw_list) cases_file = self.read_file(self.raw_list) result_file = open(self.list, 'w') black_tests = [] diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py index 2b9dcff44..7a2394918 100644 --- a/functest/tests/unit/openstack/tempest/test_tempest.py +++ b/functest/tests/unit/openstack/tempest/test_tempest.py @@ -84,7 +84,7 @@ class OSTempestTesting(unittest.TestCase): cmd = ("cd {0};" "testr list-tests {1} > {2};" "cd -;".format(verifier_repo_dir, testr_mode, - self.tempestcommon.raw_list)) + self.tempestcommon.list)) self.tempestcommon.generate_test_list('test_verifier_repo_dir') mock_exec.assert_called_once_with(cmd) @@ -99,7 +99,10 @@ class OSTempestTesting(unittest.TestCase): with self.assertRaises(Exception): self.tempestcommon.parse_verifier_result() - def test_apply_missing_blacklist(self): + @mock.patch("os.rename") + @mock.patch("os.remove") + @mock.patch("os.path.exists", return_value=True) + def test_apply_missing_blacklist(self, *args): with mock.patch('__builtin__.open', mock.mock_open()) as mock_open, \ mock.patch.object(self.tempestcommon, 'read_file', return_value=['test1', 'test2']): @@ -110,8 +113,15 @@ class OSTempestTesting(unittest.TestCase): obj = mock_open() obj.write.assert_any_call('test1\n') obj.write.assert_any_call('test2\n') + args[0].assert_called_once_with(self.tempestcommon.raw_list) + args[1].assert_called_once_with(self.tempestcommon.raw_list) + args[2].assert_called_once_with( + self.tempestcommon.list, self.tempestcommon.raw_list) - def test_apply_blacklist_default(self): + @mock.patch("os.rename") + @mock.patch("os.remove") + @mock.patch("os.path.exists", return_value=True) + def test_apply_blacklist_default(self, *args): item_dict = {'scenarios': ['deploy_scenario'], 'installers': ['installer_type'], 'tests': ['test2']} @@ -126,6 +136,10 @@ class OSTempestTesting(unittest.TestCase): obj = mock_open() obj.write.assert_any_call('test1\n') self.assertFalse(obj.write.assert_any_call('test2\n')) + args[0].assert_called_once_with(self.tempestcommon.raw_list) + args[1].assert_called_once_with(self.tempestcommon.raw_list) + args[2].assert_called_once_with( + self.tempestcommon.list, self.tempestcommon.raw_list) @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.LOGGER.info') def test_run_verifier_tests_default(self, mock_logger_info): |