bug fix: version not retrieved on weekly jobs 95/31195/1
authorMorgan Richomme <morgan.richomme@orange.com>
Mon, 20 Mar 2017 09:04:57 +0000 (10:04 +0100)
committerMorgan Richomme <morgan.richomme@orange.com>
Tue, 21 Mar 2017 13:04:05 +0000 (13:04 +0000)
a first fix had been done
but the version was retrieved 2 times with the regex
this patch removes the second regex and re-use get_version
the associated unit tests has been removed because even
if the build_tag is badly formated, it will not prevent
the results to be pushed with version = unknown

JIRA: FUNCTEST-765

Change-Id: I2cbe8ba1dd7278c3f3510a47c667c433f65e00f8
Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
(cherry picked from commit afc59e6af25a60c68a3095365c780974721f1364)

functest/tests/unit/utils/test_functest_utils.py
functest/utils/functest_utils.py

index e5bae62..eb241e5 100644 (file)
@@ -295,25 +295,6 @@ class FunctestUtilsTesting(unittest.TestCase):
     def test_push_results_to_db_missing_buildtag(self):
         self._test_push_results_to_db_missing_env('BUILD_TAG')
 
-    def test_push_results_to_db_incorrect_buildtag(self):
-        dic = self._get_env_dict(None)
-        dic['BUILD_TAG'] = 'incorrect_build_tag'
-        with mock.patch('functest.utils.functest_utils.get_db_url',
-                        return_value=self.db_url), \
-                mock.patch.dict(os.environ,
-                                dic,
-                                clear=True), \
-                mock.patch('functest.utils.functest_utils.logger.error') \
-                as mock_logger_error:
-            self.assertFalse(functest_utils.
-                             push_results_to_db(self.project, self.case_name,
-                                                self.start_date,
-                                                self.stop_date,
-                                                self.criteria, self.details))
-            mock_logger_error.assert_called_once_with("Please fix BUILD_TAG"
-                                                      " env var: incorrect_"
-                                                      "build_tag")
-
     def test_push_results_to_db_request_post_failed(self):
         dic = self._get_env_dict(None)
         with mock.patch('functest.utils.functest_utils.get_db_url',
index 9e13ffe..7cc5029 100644 (file)
@@ -207,13 +207,7 @@ def push_results_to_db(project, case_name,
     except KeyError as e:
         logger.error("Please set env var: " + str(e))
         return False
-    rule = "daily-(.+?)-[0-9]*"
-    m = re.search(rule, build_tag)
-    if m:
-        version = m.group(1)
-    else:
-        logger.error("Please fix BUILD_TAG env var: " + build_tag)
-        return False
+    version = get_version()
     test_start = dt.fromtimestamp(start_date).strftime('%Y-%m-%d %H:%M:%S')
     test_stop = dt.fromtimestamp(stop_date).strftime('%Y-%m-%d %H:%M:%S')