Skip to content

Commit

Permalink
fix(anta.tests): Fix PTP tests to be skipped be PTP is not configured (
Browse files Browse the repository at this point in the history
…#684)

Co-authored-by: Matthieu Tâche <mtache@arista.com>
  • Loading branch information
carl-baillargeon and mtache authored May 17, 2024
1 parent cf595fd commit a3cbd6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions anta/tests/ptp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------
Expand All @@ -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":
Expand All @@ -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
--------
Expand Down Expand Up @@ -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:
Expand All @@ -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
--------
Expand All @@ -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"]
Expand All @@ -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
--------
Expand Down
14 changes: 7 additions & 7 deletions tests/units/anta_tests/test_ptp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
],
},
},
Expand Down

0 comments on commit a3cbd6c

Please sign in to comment.