# 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:
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')