summaryrefslogtreecommitdiffstats
path: root/tests/units/anta_tests/test_interfaces.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2025-01-14 10:18:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2025-01-14 10:18:29 +0000
commit6818d016122ee845a2011b94bbdad0ed28a9aae7 (patch)
treee9865932680acf05b8c353347cf362ab3fd10ff0 /tests/units/anta_tests/test_interfaces.py
parentReleasing debian version 1.1.0-1. (diff)
downloadanta-6818d016122ee845a2011b94bbdad0ed28a9aae7.tar.xz
anta-6818d016122ee845a2011b94bbdad0ed28a9aae7.zip
Merging upstream version 1.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/units/anta_tests/test_interfaces.py')
-rw-r--r--tests/units/anta_tests/test_interfaces.py144
1 files changed, 127 insertions, 17 deletions
diff --git a/tests/units/anta_tests/test_interfaces.py b/tests/units/anta_tests/test_interfaces.py
index ea8106e..f3b4ee0 100644
--- a/tests/units/anta_tests/test_interfaces.py
+++ b/tests/units/anta_tests/test_interfaces.py
@@ -1108,7 +1108,7 @@ DATA: list[dict[str, Any]] = [
"inputs": {"interfaces": [{"name": "Ethernet2", "status": "up"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]},
"expected": {
"result": "failure",
- "messages": ["The following interface(s) are not configured: ['Ethernet8']"],
+ "messages": ["Ethernet8 - Not configured"],
},
},
{
@@ -1126,7 +1126,7 @@ DATA: list[dict[str, Any]] = [
"inputs": {"interfaces": [{"name": "Ethernet2", "status": "up"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]},
"expected": {
"result": "failure",
- "messages": ["The following interface(s) are not in the expected state: ['Ethernet8 is down/down'"],
+ "messages": ["Ethernet8 - Expected: up/up, Actual: down/down"],
},
},
{
@@ -1150,7 +1150,7 @@ DATA: list[dict[str, Any]] = [
},
"expected": {
"result": "failure",
- "messages": ["The following interface(s) are not in the expected state: ['Ethernet8 is up/down'"],
+ "messages": ["Ethernet8 - Expected: up/up, Actual: up/down"],
},
},
{
@@ -1166,7 +1166,7 @@ DATA: list[dict[str, Any]] = [
"inputs": {"interfaces": [{"name": "PortChannel100", "status": "up"}]},
"expected": {
"result": "failure",
- "messages": ["The following interface(s) are not in the expected state: ['Port-Channel100 is down/lowerLayerDown'"],
+ "messages": ["Port-Channel100 - Expected: up/up, Actual: down/lowerLayerDown"],
},
},
{
@@ -1190,7 +1190,38 @@ DATA: list[dict[str, Any]] = [
},
"expected": {
"result": "failure",
- "messages": ["The following interface(s) are not in the expected state: ['Ethernet2 is up/unknown'"],
+ "messages": [
+ "Ethernet2 - Expected: up/down, Actual: up/unknown",
+ "Ethernet8 - Expected: up/up, Actual: up/down",
+ ],
+ },
+ },
+ {
+ "name": "failure-interface-status-down",
+ "test": VerifyInterfacesStatus,
+ "eos_data": [
+ {
+ "interfaceDescriptions": {
+ "Ethernet8": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "down"},
+ "Ethernet2": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "unknown"},
+ "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"},
+ }
+ }
+ ],
+ "inputs": {
+ "interfaces": [
+ {"name": "Ethernet2", "status": "down"},
+ {"name": "Ethernet8", "status": "down"},
+ {"name": "Ethernet3", "status": "down"},
+ ]
+ },
+ "expected": {
+ "result": "failure",
+ "messages": [
+ "Ethernet2 - Expected: down, Actual: up",
+ "Ethernet8 - Expected: down, Actual: up",
+ "Ethernet3 - Expected: down, Actual: up",
+ ],
},
},
{
@@ -1938,8 +1969,8 @@ DATA: list[dict[str, Any]] = [
"interfaces": {
"Ethernet2": {
"interfaceAddress": {
- "primaryIp": {"address": "172.30.11.0", "maskLen": 31},
- "secondaryIpsOrderedList": [{"address": "10.10.10.0", "maskLen": 31}, {"address": "10.10.10.10", "maskLen": 31}],
+ "primaryIp": {"address": "172.30.11.1", "maskLen": 31},
+ "secondaryIpsOrderedList": [{"address": "10.10.10.1", "maskLen": 31}, {"address": "10.10.10.10", "maskLen": 31}],
}
}
}
@@ -1957,7 +1988,7 @@ DATA: list[dict[str, Any]] = [
],
"inputs": {
"interfaces": [
- {"name": "Ethernet2", "primary_ip": "172.30.11.0/31", "secondary_ips": ["10.10.10.0/31", "10.10.10.10/31"]},
+ {"name": "Ethernet2", "primary_ip": "172.30.11.1/31", "secondary_ips": ["10.10.10.1/31", "10.10.10.10/31"]},
{"name": "Ethernet12", "primary_ip": "172.30.11.10/31", "secondary_ips": ["10.10.10.10/31", "10.10.10.20/31"]},
]
},
@@ -2480,6 +2511,43 @@ DATA: list[dict[str, Any]] = [
"expected": {"result": "success"},
},
{
+ "name": "success-short-timeout",
+ "test": VerifyLACPInterfacesStatus,
+ "eos_data": [
+ {
+ "portChannels": {
+ "Port-Channel5": {
+ "interfaces": {
+ "Ethernet5": {
+ "actorPortStatus": "bundled",
+ "partnerPortState": {
+ "activity": True,
+ "timeout": True,
+ "aggregation": True,
+ "synchronization": True,
+ "collecting": True,
+ "distributing": True,
+ },
+ "actorPortState": {
+ "activity": True,
+ "timeout": True,
+ "aggregation": True,
+ "synchronization": True,
+ "collecting": True,
+ "distributing": True,
+ },
+ }
+ }
+ }
+ },
+ "interface": "Ethernet5",
+ "orphanPorts": {},
+ }
+ ],
+ "inputs": {"interfaces": [{"name": "Ethernet5", "portchannel": "Port-Channel5", "lacp_rate_fast": True}]},
+ "expected": {"result": "success"},
+ },
+ {
"name": "failure-not-bundled",
"test": VerifyLACPInterfacesStatus,
"eos_data": [
@@ -2500,7 +2568,7 @@ DATA: list[dict[str, Any]] = [
"inputs": {"interfaces": [{"name": "Ethernet5", "portchannel": "Po5"}]},
"expected": {
"result": "failure",
- "messages": ["For Interface Ethernet5:\nExpected `bundled` as the local port status, but found `No Aggregate` instead.\n"],
+ "messages": ["Interface: Ethernet5 Port-Channel: Port-Channel5 - Not bundled - Port Status: No Aggregate"],
},
},
{
@@ -2514,7 +2582,7 @@ DATA: list[dict[str, Any]] = [
"inputs": {"interfaces": [{"name": "Ethernet5", "portchannel": "Po 5"}]},
"expected": {
"result": "failure",
- "messages": ["Interface 'Ethernet5' is not configured to be a member of LACP 'Port-Channel5'."],
+ "messages": ["Interface: Ethernet5 Port-Channel: Port-Channel5 - Not configured"],
},
},
{
@@ -2555,13 +2623,55 @@ DATA: list[dict[str, Any]] = [
"expected": {
"result": "failure",
"messages": [
- "For Interface Ethernet5:\n"
- "Actor port details:\nExpected `True` as the activity, but found `False` instead."
- "\nExpected `True` as the aggregation, but found `False` instead."
- "\nExpected `True` as the synchronization, but found `False` instead."
- "\nPartner port details:\nExpected `True` as the activity, but found `False` instead.\n"
- "Expected `True` as the aggregation, but found `False` instead.\n"
- "Expected `True` as the synchronization, but found `False` instead.\n"
+ "Interface: Ethernet5 Port-Channel: Port-Channel5 - Actor port details mismatch - Activity: False, Aggregation: False, "
+ "Synchronization: False, Collecting: True, Distributing: True, Timeout: False",
+ "Interface: Ethernet5 Port-Channel: Port-Channel5 - Partner port details mismatch - Activity: False, Aggregation: False, "
+ "Synchronization: False, Collecting: True, Distributing: True, Timeout: False",
+ ],
+ },
+ },
+ {
+ "name": "failure-short-timeout",
+ "test": VerifyLACPInterfacesStatus,
+ "eos_data": [
+ {
+ "portChannels": {
+ "Port-Channel5": {
+ "interfaces": {
+ "Ethernet5": {
+ "actorPortStatus": "bundled",
+ "partnerPortState": {
+ "activity": True,
+ "timeout": False,
+ "aggregation": True,
+ "synchronization": True,
+ "collecting": True,
+ "distributing": True,
+ },
+ "actorPortState": {
+ "activity": True,
+ "timeout": False,
+ "aggregation": True,
+ "synchronization": True,
+ "collecting": True,
+ "distributing": True,
+ },
+ }
+ }
+ }
+ },
+ "interface": "Ethernet5",
+ "orphanPorts": {},
+ }
+ ],
+ "inputs": {"interfaces": [{"name": "Ethernet5", "portchannel": "port-channel 5", "lacp_rate_fast": True}]},
+ "expected": {
+ "result": "failure",
+ "messages": [
+ "Interface: Ethernet5 Port-Channel: Port-Channel5 - Actor port details mismatch - Activity: True, Aggregation: True, "
+ "Synchronization: True, Collecting: True, Distributing: True, Timeout: False",
+ "Interface: Ethernet5 Port-Channel: Port-Channel5 - Partner port details mismatch - Activity: True, Aggregation: True, "
+ "Synchronization: True, Collecting: True, Distributing: True, Timeout: False",
],
},
},