Skip to content

Commit

Permalink
Merge branch 'main' into check-connection-with-head
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Oct 7, 2024
2 parents 6e61446 + 29e08cb commit 0abf28c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit 0abf28c

Please sign in to comment.