diff --git a/tests/common/plugins/loganalyzer/__init__.py b/tests/common/plugins/loganalyzer/__init__.py index 6de64f68b0d..b9f66c35d87 100644 --- a/tests/common/plugins/loganalyzer/__init__.py +++ b/tests/common/plugins/loganalyzer/__init__.py @@ -2,6 +2,7 @@ import pytest from loganalyzer import LogAnalyzer +from tests.common.errors import RunAnsibleModuleFail def pytest_addoption(parser): @@ -15,10 +16,18 @@ def loganalyzer(duthost, request): logging.info("Log analyzer is disabled") yield return + # Force rotate logs - duthost.shell( - "/usr/sbin/logrotate -f /etc/logrotate.conf > /dev/null 2>&1" - ) + try: + duthost.shell( + "/usr/sbin/logrotate -f /etc/logrotate.conf > /dev/null 2>&1" + ) + except RunAnsibleModuleFail as e: + logging.warning("logrotate is failed. Command returned:\n" + "Stdout: {}\n" + "Stderr: {}\n" + "Return code: {}".format(e.results["stdout"], e.results["stderr"], e.results["rc"])) + loganalyzer = LogAnalyzer(ansible_host=duthost, marker_prefix=request.node.name) logging.info("Add start marker into DUT syslog") marker = loganalyzer.init()