From c124cc89195ad37e987d5523beefe0c67785e6ad Mon Sep 17 00:00:00 2001 From: Maddie Ford Date: Mon, 10 Jul 2023 17:08:04 -0700 Subject: [PATCH] Fix timestamp parsing issue --- tests_e2e/tests/lib/agent_log.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests_e2e/tests/lib/agent_log.py b/tests_e2e/tests/lib/agent_log.py index 9f165a3e94..452c5552a0 100644 --- a/tests_e2e/tests/lib/agent_log.py +++ b/tests_e2e/tests/lib/agent_log.py @@ -65,15 +65,15 @@ def from_dictionary(dictionary: Dict[str, str]): @property def timestamp(self) -> datetime: # Extension logs may follow different timestamp formats - # 2023/07/10 20:50:13 - ext_timestamp_regex_1 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}" # 2023/07/10 20:50:13.459260 - ext_timestamp_regex_2 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}[.\d]*" + ext_timestamp_regex_1 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}[.\d]+" + # 2023/07/10 20:50:13 + ext_timestamp_regex_2 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}" if re.match(ext_timestamp_regex_1, self.when): - return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S') - elif re.match(ext_timestamp_regex_2, self.when): return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S.%f') + elif re.match(ext_timestamp_regex_2, self.when): + return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S') # Logs from agent follow this format: 2023-07-10T20:50:13.038599Z return datetime.strptime(self.when, u'%Y-%m-%dT%H:%M:%S.%fZ')