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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 12 additions & 4 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

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 Expand Up @@ -203,12 +203,12 @@ def test(self) -> None:


class VerifyEnvironmentPower(AntaTest):
"""Verifies the power supplies status.
"""Verifies the power supplies status and power voltage details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Verifies the power supplies status and power voltage details.
"""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 the statuses of all power supplies are in the accepted states list and the power voltage matches the expected value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Success: The test will pass if the statuses of all power supplies are in the accepted states list and the power voltage matches the expected value.
* Success: 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 the status of any power supply is not in the list of accepted states, or if the power voltage does not match the expected value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Failure: The test will fail if the status of any power supply is not in the list of accepted states, or if the power voltage does not match the expected value.
* Failure: Any power supply is in an unaccepted state or its input voltage is less than `min_input_voltage` (if provided).


Examples
--------
Expand All @@ -228,6 +228,8 @@ class Input(AntaTest.Input):

states: list[PowerSupplyStatus]
"""List of accepted states list of power supplies status."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""List of accepted states list of power supplies status."""
"""List of accepted states for power supplies."""

min_input_voltage: PositiveInteger | None = None
"""Minimum allowed input power voltage."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Minimum allowed input power voltage."""
"""Optional minimum input voltage (Volts) to verify."""


@skip_on_platforms(["cEOSLab", "vEOS-lab", "cEOSCloudLab", "vEOS"])
@AntaTest.anta_test
Expand All @@ -240,6 +242,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"Powersupply: {power_supply} - Input power voltage mismatch - Expected: > {self.inputs.min_input_voltage} Actual: {value['inputVoltage']}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Powersupply: {power_supply} - Input power voltage mismatch - Expected: > {self.inputs.min_input_voltage} Actual: {value['inputVoltage']}"
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 status and power voltage details.
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 @@ -777,6 +777,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},
B41A "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": [
"Powersupply: 1 - Input power voltage mismatch - Expected: > 1 Actual: 0.25",
"Powersupply: 2 - Input power voltage mismatch - Expected: > 1 Actual: 0.75",
],
},
},
(VerifyEnvironmentPower, "success-additional-states"): {
"eos_data": [
{
Expand Down
0