Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anta.tests): VerifyUnifiedForwardingTableMode test is now skipped on unsupported platforms #1007

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions anta/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@
r"No source interface .*",
]
"""List of known EOS errors that should set a test status to 'failure' with the error message."""

UNSUPPORTED_PLATFORM_ERRORS = [
"not supported on this hardware platform",
"Invalid input (at token 2: 'trident')",
]
"""Error messages indicating platform or hardware unsupported commands.
Will set the test status to 'skipped'. Includes both general hardware
platform errors and specific ASIC family limitations."""
8 changes: 3 additions & 5 deletions anta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from pydantic import BaseModel, ConfigDict, ValidationError, create_model

from anta import GITHUB_SUGGESTION
from anta.constants import KNOWN_EOS_ERRORS
from anta.constants import KNOWN_EOS_ERRORS, UNSUPPORTED_PLATFORM_ERRORS
from anta.custom_types import REGEXP_EOS_BLACKLIST_CMDS, Revision
from anta.logger import anta_log_exception, exc_to_str
from anta.result_manager.models import AntaTestStatus, TestResult
Expand Down Expand Up @@ -258,7 +257,8 @@ def supported(self) -> bool:
msg = f"Command '{self.command}' has not been collected and has not returned an error. Call AntaDevice.collect()."

raise RuntimeError(msg)
return all("not supported on this hardware platform" not in e for e in self.errors)

return not any(any(error in e for error in UNSUPPORTED_PLATFORM_ERRORS) for e in self.errors)

@property
def returned_known_eos_error(self) -> bool:
Expand Down Expand Up @@ -683,8 +683,6 @@ def _handle_failed_commands(self) -> None:
cmds = self.failed_commands
unsupported_commands = [f"'{c.command}' is not supported on {self.device.hw_model}" for c in cmds if not c.supported]
if unsupported_commands:
msg = f"Test {self.name} has been skipped because it is not supported on {self.device.hw_model}: {GITHUB_SUGGESTION}"
self.logger.warning(msg)
self.result.is_skipped("\n".join(unsupported_commands))
return
returned_known_eos_error = [f"'{c.command}' failed on {self.device.name}: {', '.join(c.errors)}" for c in cmds if c.returned_known_eos_error]
Expand Down
2 changes: 1 addition & 1 deletion anta/tests/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test(self) -> None:
if command_output["uftMode"] == str(self.inputs.mode):
self.result.is_success()
else:
self.result.is_failure(f"Device is not running correct UFT mode (expected: {self.inputs.mode} / running: {command_output['uftMode']})")
self.result.is_failure(f"Not running the correct UFT mode - Expected: {self.inputs.mode}, Actual: {command_output['uftMode']}")


class VerifyTcamProfile(AntaTest):
Expand Down
2 changes: 1 addition & 1 deletion tests/units/anta_tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test": VerifyUnifiedForwardingTableMode,
"eos_data": [{"uftMode": "2", "urpfEnabled": False, "chipModel": "bcm56870", "l2TableSize": 163840, "l3TableSize": 147456, "lpmTableSize": 32768}],
"inputs": {"mode": 3},
"expected": {"result": "failure", "messages": ["Device is not running correct UFT mode (expected: 3 / running: 2)"]},
"expected": {"result": "failure", "messages": ["Not running the correct UFT mode - Expected: 3, Actual: 2"]},
},
{
"name": "success",
Expand Down
Loading