8000 feat(anta.tests): Added testcase to validate power voltage and state by geetanjalimanegslab · Pull Request #1192 · aristanetworks/anta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(anta.tests): Added testcase to validate power voltage and state #1192

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

Merged
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
19 changes: 14 additions & 5 deletions anta/tests/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from typing import TYPE_CHECKING, ClassVar, Literal

from anta.custom_types import PowerSupplyFanStatus, PowerSupplyStatus
from anta.custom_types import PositiveInteger, PowerSupplyFanStatus, PowerSupplyStatus
from anta.decorators import skip_on_platforms
from anta.models import AntaCommand, AntaTest

Expand Down 8000 Expand Up @@ -203,12 +203,13 @@ def test(self) -> None:


class VerifyEnvironmentPower(AntaTest):
"""Verifies the power supplies status.
"""Verifies the power supplies state and input voltage.

Expected Results
----------------
* Success: The test will pass if the power supplies status are within the accepted states list.
* Failure: The test will fail if some power supplies status is not within the accepted states list.
* Success: The test will pass if all power supplies are in an accepted state and their input voltage is greater than or equal to `min_input_voltage`
(if provided).
* Failure: The test will fail if any power supply is in an unaccepted state or its input voltage is less than `min_input_voltage` (if provided).

Examples
--------
Expand All @@ -227,7 +228,9 @@ class Input(AntaTest.Input):
"""Input model for the VerifyEnvironmentPower test."""

states: list[PowerSupplyStatus]
"""List of accepted states list of power supplies status."""
"""List of accepted states for power supplies."""
min_input_voltage: PositiveInteger | None = None
"""Optional minimum input voltage (Volts) to verify."""

@skip_on_platforms(["cEOSLab", "vEOS-lab", "cEOSCloudLab", "vEOS"])
@AntaTest.anta_test
Expand All @@ -240,6 +243,12 @@ def test(self) -> None:
if (state := value["state"]) not in self.inputs.states:
self.result.is_failure(f"Power Slot: {power_supply} - Invalid power supplies state - Expected: {', '.join(self.inputs.states)} Actual: {state}")

# Verify if the power supply voltage is greater than the minimum input voltage
if self.inputs.min_input_voltage and value["inputVoltage"] < self.inputs.min_input_voltage:
self.result.is_failure(
f"Power Supply: {power_supply} - Input voltage mismatch - Expected: > {self.inputs.min_input_voltage} Actual: {value['inputVoltage']}"
)


class VerifyAdverseDrops(AntaTest):
"""Verifies there are no adverse drops on DCS-7280 and DCS-7500 family switches.
Expand Down
2 changes: 1 addition & 1 deletion examples/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ anta.tests.hardware:
states:
- ok
- VerifyEnvironmentPower:
# Verifies the power supplies status.
# Verifies the power supplies state and input voltage.
states:
- ok
- VerifyEnvironmentSystemCooling:
Expand Down
86 changes: 86 additions & 0 deletions tests/units/anta_tests/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,92 @@
"inputs": {"states": ["ok"]},
"expected": {"result": AntaTestStatus.SUCCESS},
},
(VerifyEnvironmentPower, "success-min_power-voltage"): {
"eos_data": [
{
"powerSupplies": {
"1": {
"modelName": "PWR-747AC-RED",
"capacity": 750.0,
"dominant": False,
"inputCurrent": 0.705078125,
"outputCurrent": 9.921875,
"inputVoltage": 206.25,
"outputVoltage": 12.025390625,
"outputPower": 119.375,
"state": "ok",
"uptime": 1730845612.5112484,
"fans": {"FanP1/1": {"status": "ok", "speed": 33}},
"tempSensors": {"TempSensorP1/2": {"status": "ok", "temperature": 50.0}, "TempSensorP1/1": {"status": "ok", "temperature": 61.0}},
"managed": True,
},
"2": {
"modelName": "PWR-747AC-RED",
"capacity": 750.0,
"dominant": False,
"inputCurrent": 0.724609375,
"outputCurrent": 10.765625,
"inputVoltage": 204.75,
"outputVoltage": 12.009765625,
"outputPower": 128.0,
"state": "ok",
"uptime": 1730142355.4805274,
"fans": {"FanP2/1": {"status": "ok", "speed": 33}},
"tempSensors": {"TempSensorP2/2": {"status": "ok", "temperature": 53.0}, "TempSensorP2/1": {"status": "ok", "temperature": 63.0}},
"managed": True,
},
}
}
],
"inputs": {"states": ["ok"], "min_input_voltage": 1},
"expected": {"result": AntaTestStatus.SUCCESS},
},
(VerifyEnvironmentPower, "failure-min_power-voltage"): {
"eos_data": [
{
"powerSupplies": {
"1": {
"modelName": "PWR-747AC-RED",
"capacity": 750.0,
"dominant": False,
"inputCurrent": 0.705078125,
"outputCurrent": 9.921875,
"inputVoltage": 0.25,
"outputVoltage": 12.025390625,
"outputPower": 119.375,
"state": "ok",
"uptime": 1730845612.5112484,
"fans": {"FanP1/1": {"status": "ok", "speed": 33}},
"tempSensors": {"TempSensorP1/2": {"status": "ok", "temperature": 50.0}, "TempSensorP1/1": {"status": "ok", "temperature": 61.0}},
"managed": True,
},
"2": {
"modelName": "PWR-747AC-RED",
"capacity": 750.0,
"dominant": False,
"inputCurrent": 0.724609375,
"outputCurrent": 10.765625,
"inputVoltage": 0.75,
"outputVoltage": 12.009765625,
"outputPower": 128.0,
"state": "ok",
"uptime": 1730142355.4805274,
"fans": {"FanP2/1": {"status": "ok", "speed": 33}},
"tempSensors": {"TempSensorP2/2": {"status": "ok", "temperature": 53.0}, "TempSensorP2/1": {"status": "ok", "temperature": 63.0}},
"managed": True,
},
}
}
],
"inputs": {"states": ["ok"], "min_input_voltage": 1},
"expected": {
"result": AntaTestStatus.FAILURE,
"messages": [
"Power Supply: 1 - Input voltage mismatch - Expected: > 1 Actual: 0.25",
"Power Supply: 2 - Input voltage mismatch - Expected: > 1 Actual: 0.75",
],
},
},
(VerifyEnvironmentPower, "success-additional-states"): {
"eos_data": [
{
Expand Down
0