From e82f52f0145b1e58b113b4e7810e3c0e1184a693 Mon Sep 17 00:00:00 2001 From: Carl Baillargeon Date: Thu, 7 Nov 2024 16:05:31 -0500 Subject: [PATCH] fix(anta.tests): Update logging tests docstrings for clarity --- anta/tests/logging.py | 51 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/anta/tests/logging.py b/anta/tests/logging.py index 74ae875c7..c391947c2 100644 --- a/anta/tests/logging.py +++ b/anta/tests/logging.py @@ -170,10 +170,22 @@ def test(self) -> None: class VerifyLoggingLogsGeneration(AntaTest): """Verifies if logs are generated. + This test performs the following checks: + + 1. Sends a test log message at the **informational** level + 2. Retrieves the most recent logs (last 30 seconds) + 3. Verifies that the test message was successfully logged + + !!! warning + EOS logging buffer should be set to severity level `informational` or higher for this test to work. + Expected Results ---------------- - * Success: The test will pass if logs are generated. - * Failure: The test will fail if logs are NOT generated. + * Success: If logs are being generated and the test message is found in recent logs. + * Failure: If any of the following occur: + - The test message is not found in recent logs + - The logging system is not capturing new messages + - No logs are being generated Examples -------- @@ -205,10 +217,23 @@ def test(self) -> None: class VerifyLoggingHostname(AntaTest): """Verifies if logs are generated with the device FQDN. + This test performs the following checks: + + 1. Retrieves the device's configured FQDN + 2. Sends a test log message at the **informational** level + 3. Retrieves the most recent logs (last 30 seconds) + 4. Verifies that the test message includes the complete FQDN of the device + + !!! warning + EOS logging buffer should be set to severity level `informational` or higher for this test to work. + Expected Results ---------------- - * Success: The test will pass if logs are generated with the device FQDN. - * Failure: The test will fail if logs are NOT generated with the device FQDN. + * Success: If logs are generated with the device's complete FQDN. + * Failure: If any of the following occur: + - The test message is not found in recent logs + - The log message does not include the device's FQDN + - The FQDN in the log message doesn't match the configured FQDN Examples -------- @@ -247,10 +272,24 @@ def test(self) -> None: class VerifyLoggingTimestamp(AntaTest): """Verifies if logs are generated with the appropriate timestamp. + This test performs the following checks: + + 1. Sends a test log message at the **informational** level + 2. Retrieves the most recent logs (last 30 seconds) + 3. Verifies that the test message is present with a high-resolution RFC3339 timestamp format + - Example format: `2024-01-25T15:30:45.123456+00:00` + - Includes microsecond precision + - Contains timezone offset + + !!! warning + EOS logging buffer should be set to severity level `informational` or higher for this test to work. + Expected Results ---------------- - * Success: The test will pass if logs are generated with the appropriate timestamp. - * Failure: The test will fail if logs are NOT generated with the appropriate timestamp. + * Success: If logs are generated with the correct high-resolution RFC3339 timestamp format. + * Failure: If any of the following occur: + - The test message is not found in recent logs + - The timestamp format does not match the expected RFC3339 format Examples --------