From a3cbd6c0dc6afadd1920e3016b8d7e2cec1da2c7 Mon Sep 17 00:00:00 2001 From: Carl Baillargeon Date: Fri, 17 May 2024 11:12:22 -0400 Subject: [PATCH] fix(anta.tests): Fix PTP tests to be skipped be PTP is not configured (#684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthieu Tâche --- anta/tests/ptp.py | 14 +++++++------- tests/units/anta_tests/test_ptp.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/anta/tests/ptp.py b/anta/tests/ptp.py index eabda8835..cbb8ee357 100644 --- a/anta/tests/ptp.py +++ b/anta/tests/ptp.py @@ -23,7 +23,7 @@ class VerifyPtpModeStatus(AntaTest): ---------------- * Success: The test will pass if the device is a BC. * Failure: The test will fail if the device is not a BC. - * Error: The test will error if the 'ptpMode' variable is not present in the command output. + * Skipped: The test will be skipped if PTP is not configured on the device. Examples -------- @@ -45,7 +45,7 @@ def test(self) -> None: command_output = self.instance_commands[0].json_output if (ptp_mode := command_output.get("ptpMode")) is None: - self.result.is_error("'ptpMode' variable is not present in the command output") + self.result.is_skipped("PTP is not configured") return if ptp_mode != "ptpBoundaryClock": @@ -63,7 +63,7 @@ class VerifyPtpGMStatus(AntaTest): ---------------- * Success: The test will pass if the device is locked to the provided Grandmaster. * Failure: The test will fail if the device is not locked to the provided Grandmaster. - * Error: The test will error if the 'gmClockIdentity' variable is not present in the command output. + * Skipped: The test will be skipped if PTP is not configured on the device. Examples -------- @@ -92,7 +92,7 @@ def test(self) -> None: command_output = self.instance_commands[0].json_output if (ptp_clock_summary := command_output.get("ptpClockSummary")) is None: - self.result.is_error("'ptpClockSummary' variable is not present in the command output") + self.result.is_skipped("PTP is not configured") return if ptp_clock_summary["gmClockIdentity"] != self.inputs.gmid: @@ -110,7 +110,7 @@ class VerifyPtpLockStatus(AntaTest): ---------------- * Success: The test will pass if the device was locked to the upstream GM in the last minute. * Failure: The test will fail if the device was not locked to the upstream GM in the last minute. - * Error: The test will error if the 'lastSyncTime' variable is not present in the command output. + * Skipped: The test will be skipped if PTP is not configured on the device. Examples -------- @@ -133,7 +133,7 @@ def test(self) -> None: command_output = self.instance_commands[0].json_output if (ptp_clock_summary := command_output.get("ptpClockSummary")) is None: - self.result.is_error("'ptpClockSummary' variable is not present in the command output") + self.result.is_skipped("PTP is not configured") return time_difference = ptp_clock_summary["currentPtpSystemTime"] - ptp_clock_summary["lastSyncTime"] @@ -151,7 +151,7 @@ class VerifyPtpOffset(AntaTest): ---------------- * Success: The test will pass if the PTP timing offset is within +/- 1000ns from the master clock. * Failure: The test will fail if the PTP timing offset is greater than +/- 1000ns from the master clock. - * Skipped: The test will be skipped if PTP is not configured. + * Skipped: The test will be skipped if PTP is not configured on the device. Examples -------- diff --git a/tests/units/anta_tests/test_ptp.py b/tests/units/anta_tests/test_ptp.py index ef42a5804..8f4c77ff9 100644 --- a/tests/units/anta_tests/test_ptp.py +++ b/tests/units/anta_tests/test_ptp.py @@ -42,11 +42,11 @@ "expected": {"result": "failure", "messages": ["The device is not configured as a PTP Boundary Clock: 'ptpDisabled'"]}, }, { - "name": "error", + "name": "skipped", "test": VerifyPtpModeStatus, "eos_data": [{"ptpIntfSummaries": {}}], "inputs": None, - "expected": {"result": "error", "messages": ["'ptpMode' variable is not present in the command output"]}, + "expected": {"result": "skipped", "messages": ["PTP is not configured"]}, }, { "name": "success", @@ -104,11 +104,11 @@ }, }, { - "name": "error", + "name": "skipped", "test": VerifyPtpGMStatus, "eos_data": [{"ptpIntfSummaries": {}}], "inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, - "expected": {"result": "error", "messages": ["'ptpClockSummary' variable is not present in the command output"]}, + "expected": {"result": "skipped", "messages": ["PTP is not configured"]}, }, { "name": "success", @@ -161,14 +161,14 @@ "expected": {"result": "failure", "messages": ["The device lock is more than 60s old: 157s"]}, }, { - "name": "error", + "name": "skipped", "test": VerifyPtpLockStatus, "eos_data": [{"ptpIntfSummaries": {}}], "inputs": None, "expected": { - "result": "error", + "result": "skipped", "messages": [ - "'ptpClockSummary' variable is not present in the command output", + "PTP is not configured", ], }, },