Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anta.tests): allow for positive or negative offset time zones #842

Merged
merged 6 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions anta/tests/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class VerifyLoggingTimestamp(AntaTest):
"""

name = "VerifyLoggingTimestamp"
description = "Verifies if logs are generated with the riate timestamp."
description = "Verifies if logs are generated with the appropriate timestamp."
categories: ClassVar[list[str]] = ["logging"]
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [
AntaCommand(command="send log level informational message ANTA VerifyLoggingTimestamp validation", ofmt="text"),
Expand All @@ -282,7 +282,7 @@ class VerifyLoggingTimestamp(AntaTest):
def test(self) -> None:
"""Main test function for VerifyLoggingTimestamp."""
log_pattern = r"ANTA VerifyLoggingTimestamp validation"
timestamp_pattern = r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}-\d{2}:\d{2}"
timestamp_pattern = r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}[+-]\d{2}:\d{2}"
output = self.instance_commands[1].text_output
lines = output.strip().split("\n")[::-1]
last_line_with_pattern = ""
Expand Down
15 changes: 14 additions & 1 deletion tests/units/anta_tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"expected": {"result": "failure", "messages": ["Logs are not generated with the device FQDN"]},
},
{
"name": "success",
"name": "success-negative-offset",
"test": VerifyLoggingTimestamp,
"eos_data": [
"",
Expand All @@ -213,6 +213,19 @@
"inputs": None,
"expected": {"result": "success"},
},
{
"name": "success-positive-offset",
"test": VerifyLoggingTimestamp,
"eos_data": [
"",
"2023-05-10T15:41:44.680813+05:00 NW-CORE.example.org ConfigAgent: %SYS-6-LOGMSG_INFO: "
"Message from arista on command-api (10.22.1.107): ANTA VerifyLoggingTimestamp validation\n"
"2023-05-10T15:42:44.680813+05:00 NW-CORE.example.org ConfigAgent: %SYS-6-LOGMSG_INFO: "
"Other log\n",
],
"inputs": None,
"expected": {"result": "success"},
},
{
"name": "failure",
"test": VerifyLoggingTimestamp,
Expand Down
Loading