diff --git a/tests/common/plugins/loganalyzer/README.md b/tests/common/plugins/loganalyzer/README.md index 4b6bfe7d9f4..2919fcdb4e7 100644 --- a/tests/common/plugins/loganalyzer/README.md +++ b/tests/common/plugins/loganalyzer/README.md @@ -85,7 +85,7 @@ loganalyzer.init() - can be called several times without calling "loganalyzer.an # Example 4 # Update previously configured marker # Now start marker will have new prefix - test_bgp - loganalyzer.update_marker_prefix("test_bgp") + marker = loganalyzer.update_marker_prefix("test_bgp") def get_platform_info(dut): """ diff --git a/tests/common/plugins/loganalyzer/loganalyzer.py b/tests/common/plugins/loganalyzer/loganalyzer.py index 54c77821e54..e66d8a23401 100644 --- a/tests/common/plugins/loganalyzer/loganalyzer.py +++ b/tests/common/plugins/loganalyzer/loganalyzer.py @@ -29,7 +29,7 @@ def __init__(self, ansible_host, marker_prefix, dut_run_dir="/tmp"): self.ansible_host = ansible_host self.dut_run_dir = dut_run_dir self.extracted_syslog = os.path.join(self.dut_run_dir, "syslog") - self.marker_prefix = marker_prefix + self.marker_prefix = marker_prefix.replace(' ', '_') self.ansible_loganalyzer = ansible_loganalyzer(self.marker_prefix, False) self.match_regex = [] @@ -88,7 +88,8 @@ def update_marker_prefix(self, marker_prefix): """ @summary: Update configured marker prefix """ - self.marker_prefix = marker_prefix + self.marker_prefix = marker_prefix.replace(' ', '_') + return self._setup_marker() def load_common_config(self): """ @@ -137,6 +138,12 @@ def init(self): self.ansible_host.copy(src=ANSIBLE_LOGANALYZER_MODULE, dest=os.path.join(self.dut_run_dir, "loganalyzer.py")) + return self._setup_marker() + + def _setup_marker(self): + """ + Adds the marker to the syslog + """ start_marker = ".".join((self.marker_prefix, time.strftime("%Y-%m-%d-%H:%M:%S", time.gmtime()))) cmd = "python {run_dir}/loganalyzer.py --action init --run_id {start_marker}".format(run_dir=self.dut_run_dir, start_marker=start_marker)