diff options
author | Konrad Djimeli <konraddjimeli@gmail.com> | 2018-05-20 01:40:21 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-05-30 13:46:46 +0200 |
commit | d1a1e7e92053d767e8322d17370a8700562b44a0 (patch) | |
tree | a84c08c8a73f146939d4ee6d649778e68d3dd0a6 /functest_kubernetes | |
parent | 42f601844447ebd5de1354f323e24326c55cf080 (diff) |
Fix functest-k8s logging to log all k8s testsopnfv-6.2.0
JIRA: FUNCTEST-967
Change-Id: If4924a5c6d66dcbda48ac5ea80d67fcef11ba40a
Signed-off-by: Konrad Djimeli <konraddjimeli@gmail.com>
(cherry picked from commit 816438f37e1a47bb3408c89d982c3fc37f893b64)
Diffstat (limited to 'functest_kubernetes')
-rw-r--r-- | functest_kubernetes/k8stest.py | 19 | ||||
-rw-r--r-- | functest_kubernetes/test_k8stest.py | 5 |
2 files changed, 16 insertions, 8 deletions
diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py index 2977bb81..95ebc321 100644 --- a/functest_kubernetes/k8stest.py +++ b/functest_kubernetes/k8stest.py @@ -47,21 +47,28 @@ class K8sTesting(testcase.TestCase): # Remove color code escape sequences output = re.sub(r'\x1B\[[0-?]*[ -/]*[@-~]', '', str(output)) + if ('Error loading client' in output or + 'Unexpected error' in output): + raise Exception(output) + remarks = [] lines = output.split('\n') + success = False + failure = False i = 0 while i < len(lines): - if 'Error' in lines[i]: + if '[Fail]' in lines[i] or 'Failures:' in lines[i]: self.__logger.error(lines[i]) - if '[k8s.io]' in lines[i]: - if i != 0 and 'seconds' in lines[i - 1]: - self.__logger.debug(lines[i - 1]) - while lines[i] != '-' * len(lines[i]): + if re.search(r'\[(.)*[0-9]+ seconds\]', lines[i]): + self.__logger.debug(lines[i]) + i = i + 1 + while i < len(lines) and lines[i] != '-' * len(lines[i]): if lines[i].startswith('STEP:') or ('INFO:' in lines[i]): break self.__logger.debug(lines[i]) i = i + 1 - + if i >= len(lines): + break success = 'SUCCESS!' in lines[i] failure = 'FAIL!' in lines[i] if success or failure: diff --git a/functest_kubernetes/test_k8stest.py b/functest_kubernetes/test_k8stest.py index 9db14d5a..c9faf35d 100644 --- a/functest_kubernetes/test_k8stest.py +++ b/functest_kubernetes/test_k8stest.py @@ -77,8 +77,9 @@ class K8sTests(unittest.TestCase): attrs = {'stdout.read.return_value': 'Error loading client'} mock_stdout.configure_mock(**attrs) mock_popen.return_value = mock_stdout - self.k8stesting.run_kubetest() - mock_logger.error.assert_called_with("Error loading client") + self.k8stesting.run() + mock_logger.exception.assert_called_with( + "Error with running kubetest:") @mock.patch('functest_kubernetes.k8stest.os.path.isfile') @mock.patch('functest_kubernetes.k8stest.subprocess.Popen') |