Skip to content

Commit

Permalink
fix(anta.tests): Adjust revision for show management cvx (#956)
Browse files Browse the repository at this point in the history
fix(anta.test): Adjust revision for show management cvx
  • Loading branch information
gmuloc authored Dec 12, 2024
1 parent 3f86d7e commit 23d8c2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions anta/tests/cvx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import TYPE_CHECKING, ClassVar

from anta.models import AntaCommand, AntaTest
from anta.tools import get_value

if TYPE_CHECKING:
from anta.models import AntaTemplate
Expand Down Expand Up @@ -71,7 +72,7 @@ class VerifyManagementCVX(AntaTest):
"""

categories: ClassVar[list[str]] = ["cvx"]
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management cvx", revision=1)]
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management cvx", revision=3)]

class Input(AntaTest.Input):
"""Input model for the VerifyManagementCVX test."""
Expand All @@ -84,6 +85,5 @@ def test(self) -> None:
"""Main test function for VerifyManagementCVX."""
command_output = self.instance_commands[0].json_output
self.result.is_success()
cluster_status = command_output["clusterStatus"]
if (cluster_state := cluster_status.get("enabled")) != self.inputs.enabled:
if (cluster_state := get_value(command_output, "clusterStatus.enabled")) != self.inputs.enabled:
self.result.is_failure(f"Management CVX status is not valid: {cluster_state}")
9 changes: 8 additions & 1 deletion tests/units/anta_tests/test_cvx.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,17 @@
"expected": {"result": "success"},
},
{
"name": "failure",
"name": "failure - no enabled state",
"test": VerifyManagementCVX,
"eos_data": [{"clusterStatus": {}}],
"inputs": {"enabled": False},
"expected": {"result": "failure", "messages": ["Management CVX status is not valid: None"]},
},
{
"name": "failure - no clusterStatus",
"test": VerifyManagementCVX,
"eos_data": [{}],
"inputs": {"enabled": False},
"expected": {"result": "failure", "messages": ["Management CVX status is not valid: None"]},
},
]

0 comments on commit 23d8c2b

Please sign in to comment.