Merging upstream version 1.4.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-15 09:34:30 +02:00
parent a6f5a146cb
commit 3254dea030
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
166 changed files with 13787 additions and 11959 deletions

View file

@ -5,8 +5,11 @@
from __future__ import annotations
from typing import Any
import sys
from typing import TYPE_CHECKING, Any
from anta.models import AntaTest
from anta.result_manager.models import AntaTestStatus
from anta.tests.hardware import (
VerifyAdverseDrops,
VerifyEnvironmentCooling,
@ -18,44 +21,41 @@ from anta.tests.hardware import (
)
from tests.units.anta_tests import test
DATA: list[dict[str, Any]] = [
{
"name": "success",
"test": VerifyTransceiversManufacturers,
if TYPE_CHECKING:
from tests.units.anta_tests import AntaUnitTestDataDict
DATA: AntaUnitTestDataDict = {
(VerifyTransceiversManufacturers, "success"): {
"eos_data": [
{
"xcvrSlots": {
"1": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501340", "hardwareRev": "21"},
"2": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501337", "hardwareRev": "21"},
},
},
}
}
],
"inputs": {"manufacturers": ["Arista Networks"]},
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "failure",
"test": VerifyTransceiversManufacturers,
(VerifyTransceiversManufacturers, "failure"): {
"eos_data": [
{
"xcvrSlots": {
"1": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501340", "hardwareRev": "21"},
"2": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501337", "hardwareRev": "21"},
},
},
}
}
],
"inputs": {"manufacturers": ["Arista"]},
"expected": {
"result": "failure",
"result": AntaTestStatus.FAILURE,
"messages": [
"Interface: 1 - Transceiver is from unapproved manufacturers - Expected: Arista Actual: Arista Networks",
"Interface: 2 - Transceiver is from unapproved manufacturers - Expected: Arista Actual: Arista Networks",
],
},
},
{
"name": "success",
"test": VerifyTemperature,
(VerifyTemperature, "success"): {
"eos_data": [
{
"powercycleOnOverheat": "False",
@ -64,14 +64,11 @@ DATA: list[dict[str, Any]] = [
"shutdownOnOverheat": "True",
"systemStatus": "temperatureOk",
"recoveryModeOnOverheat": "recoveryModeNA",
},
}
],
"inputs": None,
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "failure",
"test": VerifyTemperature,
(VerifyTemperature, "failure"): {
"eos_data": [
{
"powercycleOnOverheat": "False",
@ -80,14 +77,14 @@ DATA: list[dict[str, Any]] = [
"shutdownOnOverheat": "True",
"systemStatus": "temperatureCritical",
"recoveryModeOnOverheat": "recoveryModeNA",
},
}
],
"inputs": None,
"expected": {"result": "failure", "messages": ["Device temperature exceeds acceptable limits - Expected: temperatureOk Actual: temperatureCritical"]},
"expected": {
"result": AntaTestStatus.FAILURE,
"messages": ["Device temperature exceeds acceptable limits - Expected: temperatureOk Actual: temperatureCritical"],
},
},
{
"name": "success",
"test": VerifyTransceiversTemperature,
(VerifyTransceiversTemperature, "success"): {
"eos_data": [
{
"tempSensors": [
@ -107,17 +104,14 @@ DATA: list[dict[str, Any]] = [
"pidDriverCount": 0,
"isPidDriver": False,
"name": "DomTemperatureSensor54",
},
}
],
"cardSlots": [],
},
}
],
"inputs": None,
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "failure-hwStatus",
"test": VerifyTransceiversTemperature,
(VerifyTransceiversTemperature, "failure-hwStatus"): {
"eos_data": [
{
"tempSensors": [
@ -137,20 +131,14 @@ DATA: list[dict[str, Any]] = [
"pidDriverCount": 0,
"isPidDriver": False,
"name": "DomTemperatureSensor54",
},
}
],
"cardSlots": [],
},
}
],
"inputs": None,
"expected": {
"result": "failure",
"messages": ["Sensor: DomTemperatureSensor54 - Invalid hardware state - Expected: ok Actual: ko"],
},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Sensor: DomTemperatureSensor54 - Invalid hardware state - Expected: ok Actual: ko"]},
},
{
"name": "failure-alertCount",
"test": VerifyTransceiversTemperature,
(VerifyTransceiversTemperature, "failure-alertCount"): {
"eos_data": [
{
"tempSensors": [
@ -170,20 +158,14 @@ DATA: list[dict[str, Any]] = [
"pidDriverCount": 0,
"isPidDriver": False,
"name": "DomTemperatureSensor54",
},
}
],
"cardSlots": [],
},
}
],
"inputs": None,
"expected": {
"result": "failure",
"messages": ["Sensor: DomTemperatureSensor54 - Incorrect alert counter - Expected: 0 Actual: 1"],
},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Sensor: DomTemperatureSensor54 - Incorrect alert counter - Expected: 0 Actual: 1"]},
},
{
"name": "success",
"test": VerifyEnvironmentSystemCooling,
(VerifyEnvironmentSystemCooling, "success"): {
"eos_data": [
{
"defaultZones": False,
@ -199,14 +181,11 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "coolingOk",
},
}
],
"inputs": None,
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "failure",
"test": VerifyEnvironmentSystemCooling,
(VerifyEnvironmentSystemCooling, "failure"): {
"eos_data": [
{
"defaultZones": False,
@ -222,14 +201,11 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "coolingKo",
},
}
],
"inputs": None,
"expected": {"result": "failure", "messages": ["Device system cooling status invalid - Expected: coolingOk Actual: coolingKo"]},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Device system cooling status invalid - Expected: coolingOk Actual: coolingKo"]},
},
{
"name": "success",
"test": VerifyEnvironmentCooling,
(VerifyEnvironmentCooling, "success"): {
"eos_data": [
{
"defaultZones": False,
@ -253,7 +229,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply1/1",
},
}
],
"speed": 30,
"label": "PowerSupply1",
@ -271,7 +247,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply2/1",
},
}
],
"speed": 30,
"label": "PowerSupply2",
@ -291,7 +267,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "1/1",
},
}
],
"speed": 30,
"label": "1",
@ -309,7 +285,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "2/1",
},
}
],
"speed": 30,
"label": "2",
@ -327,7 +303,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "3/1",
},
}
],
"speed": 30,
"label": "3",
@ -345,7 +321,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "4/1",
},
}
],
"speed": 30,
"label": "4",
@ -355,14 +331,12 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "coolingOk",
},
}
],
"inputs": {"states": ["ok"]},
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "success-additional-states",
"test": VerifyEnvironmentCooling,
(VerifyEnvironmentCooling, "success-additional-states"): {
"eos_data": [
{
"defaultZones": False,
@ -386,7 +360,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply1/1",
},
}
],
"speed": 30,
"label": "PowerSupply1",
@ -395,7 +369,7 @@ DATA: list[dict[str, Any]] = [
"status": "ok",
"fans": [
{
"status": "Not Inserted",
"status": "powerLoss",
"uptime": 1682498935.9121106,
"maxSpeed": 23000,
"lastSpeedStableChangeTime": 1682499092.4665174,
@ -404,7 +378,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply2/1",
},
}
],
"speed": 30,
"label": "PowerSupply2",
@ -424,7 +398,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "1/1",
},
}
],
"speed": 30,
"label": "1",
@ -442,7 +416,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "2/1",
},
}
],
"speed": 30,
"label": "2",
@ -460,7 +434,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "3/1",
},
}
],
"speed": 30,
"label": "3",
@ -478,7 +452,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "4/1",
},
}
],
"speed": 30,
"label": "4",
@ -488,14 +462,12 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "coolingOk",
},
}
],
"inputs": {"states": ["ok", "Not Inserted"]},
"expected": {"result": "success"},
"inputs": {"states": ["ok", "powerLoss"]},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "failure-fan-tray",
"test": VerifyEnvironmentCooling,
(VerifyEnvironmentCooling, "failure-fan-tray"): {
"eos_data": [
{
"defaultZones": False,
@ -519,7 +491,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply1/1",
},
}
],
"speed": 30,
"label": "PowerSupply1",
@ -537,7 +509,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply2/1",
},
}
],
"speed": 30,
"label": "PowerSupply2",
@ -548,7 +520,7 @@ DATA: list[dict[str, Any]] = [
"status": "ok",
"fans": [
{
"status": "down",
"status": "unknownHwStatus",
"uptime": 1682498923.9303148,
"maxSpeed": 17500,
"lastSpeedStableChangeTime": 1682498975.0139885,
@ -557,7 +529,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "1/1",
},
}
],
"speed": 30,
"label": "1",
@ -575,7 +547,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "2/1",
},
}
],
"speed": 30,
"label": "2",
@ -584,7 +556,7 @@ DATA: list[dict[str, Any]] = [
"status": "ok",
"fans": [
{
"status": "Not Inserted",
"status": "powerLoss",
"uptime": 1682498923.9383528,
"maxSpeed": 17500,
"lastSpeedStableChangeTime": 1682498975.0140095,
@ -593,7 +565,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "3/1",
},
}
],
"speed": 30,
"label": "3",
@ -611,7 +583,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "4/1",
},
}
],
"speed": 30,
"label": "4",
@ -621,14 +593,12 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "CoolingKo",
},
}
],
"inputs": {"states": ["ok", "Not Inserted"]},
"expected": {"result": "failure", "messages": ["Fan Tray: 1 Fan: 1/1 - Invalid state - Expected: ok, Not Inserted Actual: down"]},
"inputs": {"states": ["ok", "powerLoss"]},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Fan Tray: 1 Fan: 1/1 - Invalid state - Expected: ok, powerLoss Actual: unknownHwStatus"]},
},
{
"name": "failure-power-supply",
"test": VerifyEnvironmentCooling,
(VerifyEnvironmentCooling, "failure-power-supply"): {
"eos_data": [
{
"defaultZones": False,
@ -643,7 +613,7 @@ DATA: list[dict[str, Any]] = [
"status": "ok",
"fans": [
{
"status": "down",
"status": "unknownHwStatus",
"uptime": 1682498937.0240965,
"maxSpeed": 23000,
"lastSpeedStableChangeTime": 1682499033.0403435,
@ -652,7 +622,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply1/1",
},
}
],
"speed": 30,
"label": "PowerSupply1",
@ -670,7 +640,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": True,
"speedStable": True,
"label": "PowerSupply2/1",
},
}
],
"speed": 30,
"label": "PowerSupply2",
@ -690,7 +660,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "1/1",
},
}
],
"speed": 30,
"label": "1",
@ -708,7 +678,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "2/1",
},
}
],
"speed": 30,
"label": "2",
@ -717,7 +687,7 @@ DATA: list[dict[str, Any]] = [
"status": "ok",
"fans": [
{
"status": "Not Inserted",
"status": "powerLoss",
"uptime": 1682498923.9383528,
"maxSpeed": 17500,
"lastSpeedStableChangeTime": 1682498975.0140095,
@ -726,7 +696,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "3/1",
},
}
],
"speed": 30,
"label": "3",
@ -744,7 +714,7 @@ DATA: list[dict[str, Any]] = [
"speedHwOverride": False,
"speedStable": True,
"label": "4/1",
},
}
],
"speed": 30,
"label": "4",
@ -754,19 +724,15 @@ DATA: list[dict[str, Any]] = [
"currentZones": 1,
"configuredZones": 0,
"systemStatus": "CoolingKo",
},
}
],
"inputs": {"states": ["ok", "Not Inserted"]},
"inputs": {"states": ["ok", "powerLoss"]},
"expected": {
"result": "failure",
"messages": [
"Power Slot: PowerSupply1 Fan: PowerSupply1/1 - Invalid state - Expected: ok, Not Inserted Actual: down",
],
"result": AntaTestStatus.FAILURE,
"messages": ["Power Slot: PowerSupply1 Fan: PowerSupply1/1 - Invalid state - Expected: ok, powerLoss Actual: unknownHwStatus"],
},
},
{
"name": "success",
"test": VerifyEnvironmentPower,
(VerifyEnvironmentPower, "success"): {
"eos_data": [
{
"powerSupplies": {
@ -805,62 +771,13 @@ DATA: list[dict[str, Any]] = [
"outputCurrent": 9.828125,
"managed": True,
},
},
},
}
}
],
"inputs": {"states": ["ok"]},
"expected": {"result": "success"},
"expected": {"result": AntaTestStatus.SUCCESS},
},
{
"name": "success-additional-states",
"test": VerifyEnvironmentPower,
"eos_data": [
{
"powerSupplies": {
"1": {
"outputPower": 0.0,
"modelName": "PWR-500AC-F",
"capacity": 500.0,
"tempSensors": {
"TempSensorP1/2": {"status": "ok", "temperature": 0.0},
"TempSensorP1/3": {"status": "ok", "temperature": 0.0},
"TempSensorP1/1": {"status": "ok", "temperature": 0.0},
},
"fans": {"FanP1/1": {"status": "ok", "speed": 33}},
"state": "Not Inserted",
"inputCurrent": 0.0,
"dominant": False,
"inputVoltage": 0.0,
"outputCurrent": 0.0,
"managed": True,
},
"2": {
"outputPower": 117.375,
"uptime": 1682498935.9121966,
"modelName": "PWR-500AC-F",
"capacity": 500.0,
"tempSensors": {
"TempSensorP2/1": {"status": "ok", "temperature": 39.0},
"TempSensorP2/3": {"status": "ok", "temperature": 43.0},
"TempSensorP2/2": {"status": "ok", "temperature": 31.0},
},
"fans": {"FanP2/1": {"status": "ok", "speed": 33}},
"state": "ok",
"inputCurrent": 0.572265625,
"dominant": False,
"inputVoltage": 232.5,
"outputCurrent": 9.828125,
"managed": True,
},
},
},
],
"inputs": {"states": ["ok", "Not Inserted"]},
"expected": {"result": "success"},
},
{
"name": "failure",
"test": VerifyEnvironmentPower,
(VerifyEnvironmentPower, "success-additional-states"): {
"eos_data": [
{
"powerSupplies": {
@ -899,24 +816,60 @@ DATA: list[dict[str, Any]] = [
"outputCurrent": 9.828125,
"managed": True,
},
},
},
}
}
],
"inputs": {"states": ["ok", "powerLoss"]},
"expected": {"result": AntaTestStatus.SUCCESS},
},
(VerifyEnvironmentPower, "failure"): {
"eos_data": [
{
"powerSupplies": {
"1": {
"outputPower": 0.0,
"modelName": "PWR-500AC-F",
"capacity": 500.0,
"tempSensors": {
"TempSensorP1/2": {"status": "ok", "temperature": 0.0},
"TempSensorP1/3": {"status": "ok", "temperature": 0.0},
"TempSensorP1/1": {"status": "ok", "temperature": 0.0},
},
"fans": {"FanP1/1": {"status": "ok", "speed": 33}},
"state": "powerLoss",
"inputCurrent": 0.0,
"dominant": False,
"inputVoltage": 0.0,
"outputCurrent": 0.0,
"managed": True,
},
"2": {
"outputPower": 117.375,
"uptime": 1682498935.9121966,
"modelName": "PWR-500AC-F",
"capacity": 500.0,
"tempSensors": {
"TempSensorP2/1": {"status": "ok", "temperature": 39.0},
"TempSensorP2/3": {"status": "ok", "temperature": 43.0},
"TempSensorP2/2": {"status": "ok", "temperature": 31.0},
},
"fans": {"FanP2/1": {"status": "ok", "speed": 33}},
"state": "ok",
"inputCurrent": 0.572265625,
"dominant": False,
"inputVoltage": 232.5,
"outputCurrent": 9.828125,
"managed": True,
},
}
}
],
"inputs": {"states": ["ok"]},
"expected": {"result": "failure", "messages": ["Power Slot: 1 - Invalid power supplies state - Expected: ok Actual: powerLoss"]},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Power Slot: 1 - Invalid power supplies state - Expected: ok Actual: powerLoss"]},
},
{
"name": "success",
"test": VerifyAdverseDrops,
"eos_data": [{"totalAdverseDrops": 0}],
"inputs": None,
"expected": {"result": "success"},
},
{
"name": "failure",
"test": VerifyAdverseDrops,
(VerifyAdverseDrops, "success"): {"eos_data": [{"totalAdverseDrops": 0}], "expected": {"result": AntaTestStatus.SUCCESS}},
(VerifyAdverseDrops, "failure"): {
"eos_data": [{"totalAdverseDrops": 10}],
"inputs": None,
"expected": {"result": "failure", "messages": ["Incorrect total adverse drops counter - Expected: 0 Actual: 10"]},
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Incorrect total adverse drops counter - Expected: 0 Actual: 10"]},
},
]
}