Error logs on error/warn in logs

This commit is contained in:
Ayaz Salikhov
2025-03-25 09:39:02 +00:00
parent de998c41eb
commit 834b6c7e03

View File

@@ -94,16 +94,24 @@ class TrackedContainer:
assert self.container is not None assert self.container is not None
rv = self.container.wait(timeout=timeout) rv = self.container.wait(timeout=timeout)
logs = self.get_logs() logs = self.get_logs()
failed = rv["StatusCode"] != 0 rc_success = rv["StatusCode"] == 0
should_report = not (
no_failure == rc_success
and no_warnings == (not self.get_warnings(logs))
and no_errors == (not self.get_errors(logs))
)
if failed: if not rc_success or should_report:
LOGGER.error(f"Command output:\n{logs}") LOGGER.error(f"Command output:\n{logs}")
else: else:
LOGGER.debug(f"Command output:\n{logs}") LOGGER.debug(f"Command output:\n{logs}")
assert no_failure != failed self.remove()
# To see the reason, we run assert statements separately
assert no_failure == rc_success
assert no_warnings == (not self.get_warnings(logs)) assert no_warnings == (not self.get_warnings(logs))
assert no_errors == (not self.get_errors(logs)) assert no_errors == (not self.get_errors(logs))
self.remove()
return logs return logs
@staticmethod @staticmethod