From 92240acb5cc600eec60624ece9ed4b9ec43b386f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 23 May 2024 07:06:46 +0200 Subject: Adding upstream version 0.15.0. Signed-off-by: Daniel Baumann --- tests/units/anta_tests/test_interfaces.py | 288 +++++++++++++++++++++++++++++- 1 file changed, 286 insertions(+), 2 deletions(-) (limited to 'tests/units/anta_tests/test_interfaces.py') diff --git a/tests/units/anta_tests/test_interfaces.py b/tests/units/anta_tests/test_interfaces.py index 58f568f..b8cf493 100644 --- a/tests/units/anta_tests/test_interfaces.py +++ b/tests/units/anta_tests/test_interfaces.py @@ -1,7 +1,7 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.hardware.""" +"""Test inputs for anta.tests.interfaces.""" # pylint: disable=C0302 from __future__ import annotations @@ -14,6 +14,7 @@ from anta.tests.interfaces import ( VerifyInterfaceErrDisabled, VerifyInterfaceErrors, VerifyInterfaceIPv4, + VerifyInterfacesSpeed, VerifyInterfacesStatus, VerifyInterfaceUtilization, VerifyIPProxyARP, @@ -1354,6 +1355,14 @@ DATA: list[dict[str, Any]] = [ "lineProtocolStatus": "up", "mtu": 65535, }, + # Checking not loopbacks are skipped + "Ethernet666": { + "name": "Ethernet666", + "interfaceStatus": "connected", + "interfaceAddress": {"ipAddr": {"maskLen": 32, "address": "6.6.6.6"}}, + "ipv4Routable240": False, + "lineProtocolStatus": "up", + }, }, }, ], @@ -1733,7 +1742,7 @@ DATA: list[dict[str, Any]] = [ }, }, ], - "inputs": {"mtu": 9214}, + "inputs": {"mtu": 9214, "ignored_interfaces": ["Loopback", "Port-Channel", "Management", "Vxlan"], "specific_mtu": [{"Ethernet10": 9214}]}, "expected": {"result": "success"}, }, { @@ -2157,4 +2166,279 @@ DATA: list[dict[str, Any]] = [ "inputs": {"mac_address": "00:1c:73:00:dc:01"}, "expected": {"result": "failure", "messages": ["IP virtual router MAC address `00:1c:73:00:dc:01` is not configured."]}, }, + { + "name": "success", + "test": VerifyInterfacesSpeed, + "eos_data": [ + { + "interfaces": { + "Ethernet1": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 2, + }, + "Ethernet1/1/2": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 2, + }, + "Ethernet3": { + "bandwidth": 100000000000, + "autoNegotiate": "success", + "duplex": "duplexFull", + "lanes": 8, + }, + "Ethernet4": { + "bandwidth": 2500000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 8, + }, + } + } + ], + "inputs": { + "interfaces": [ + {"name": "Ethernet1", "auto": False, "speed": 1}, + {"name": "Ethernet1", "auto": False, "speed": 1, "lanes": 2}, + {"name": "Ethernet1/1/2", "auto": False, "speed": 1}, + {"name": "Ethernet3", "auto": True, "speed": 100}, + {"name": "Ethernet3", "auto": True, "speed": 100, "lanes": 8}, + {"name": "Ethernet3", "auto": True, "speed": 100}, + {"name": "Ethernet4", "auto": False, "speed": 2.5}, + ] + }, + "expected": {"result": "success"}, + }, + { + "name": "failure-incorrect-speed", + "test": VerifyInterfacesSpeed, + "eos_data": [ + { + "interfaces": { + "Ethernet1": { + "bandwidth": 100000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 2, + }, + "Ethernet1/1/1": { + "bandwidth": 100000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 2, + }, + "Ethernet3": { + "bandwidth": 10000000000, + "autoNegotiate": "success", + "duplex": "duplexFull", + "lanes": 8, + }, + "Ethernet4": { + "bandwidth": 25000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 8, + }, + } + } + ], + "inputs": { + "interfaces": [ + {"name": "Ethernet1", "auto": False, "speed": 1}, + {"name": "Ethernet1/1/1", "auto": False, "speed": 1}, + {"name": "Ethernet3", "auto": True, "speed": 100}, + {"name": "Ethernet4", "auto": False, "speed": 2.5}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "For interface Ethernet1:\nExpected `1Gbps` as the speed, but found `100Gbps` instead.", + "For interface Ethernet1/1/1:\nExpected `1Gbps` as the speed, but found `100Gbps` instead.", + "For interface Ethernet3:\nExpected `100Gbps` as the speed, but found `10Gbps` instead.", + "For interface Ethernet4:\nExpected `2.5Gbps` as the speed, but found `25Gbps` instead.", + ], + }, + }, + { + "name": "failure-incorrect-mode", + "test": VerifyInterfacesSpeed, + "eos_data": [ + { + "interfaces": { + "Ethernet1": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 2, + }, + "Ethernet1/2/2": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 2, + }, + "Ethernet3": { + "bandwidth": 100000000000, + "autoNegotiate": "success", + "duplex": "duplexHalf", + "lanes": 8, + }, + "Ethernet4": { + "bandwidth": 2500000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 8, + }, + } + } + ], + "inputs": { + "interfaces": [ + {"name": "Ethernet1", "auto": False, "speed": 1}, + {"name": "Ethernet1/2/2", "auto": False, "speed": 1}, + {"name": "Ethernet3", "auto": True, "speed": 100}, + {"name": "Ethernet3", "auto": True, "speed": 100, "lanes": 8}, + {"name": "Ethernet4", "auto": False, "speed": 2.5}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "For interface Ethernet1:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + "For interface Ethernet1/2/2:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + "For interface Ethernet3:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + "For interface Ethernet3:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + "For interface Ethernet4:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + ], + }, + }, + { + "name": "failure-incorrect-lane", + "test": VerifyInterfacesSpeed, + "eos_data": [ + { + "interfaces": { + "Ethernet1": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 4, + }, + "Ethernet2": { + "bandwidth": 10000000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 4, + }, + "Ethernet3": { + "bandwidth": 100000000000, + "autoNegotiate": "success", + "duplex": "duplexFull", + "lanes": 4, + }, + "Ethernet4": { + "bandwidth": 2500000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 6, + }, + "Ethernet4/1/1": { + "bandwidth": 2500000000, + "autoNegotiate": "unknown", + "duplex": "duplexFull", + "lanes": 6, + }, + } + } + ], + "inputs": { + "interfaces": [ + {"name": "Ethernet1", "auto": False, "speed": 1, "lanes": 2}, + {"name": "Ethernet3", "auto": True, "speed": 100, "lanes": 8}, + {"name": "Ethernet4", "auto": False, "speed": 2.5, "lanes": 4}, + {"name": "Ethernet4/1/1", "auto": False, "speed": 2.5, "lanes": 4}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "For interface Ethernet1:\nExpected `2` as the lanes, but found `4` instead.", + "For interface Ethernet3:\nExpected `8` as the lanes, but found `4` instead.", + "For interface Ethernet4:\nExpected `4` as the lanes, but found `6` instead.", + "For interface Ethernet4/1/1:\nExpected `4` as the lanes, but found `6` instead.", + ], + }, + }, + { + "name": "failure-all-type", + "test": VerifyInterfacesSpeed, + "eos_data": [ + { + "interfaces": { + "Ethernet1": { + "bandwidth": 10000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 4, + }, + "Ethernet2/1/2": { + "bandwidth": 1000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 2, + }, + "Ethernet3": { + "bandwidth": 10000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 6, + }, + "Ethernet4": { + "bandwidth": 25000000000, + "autoNegotiate": "unknown", + "duplex": "duplexHalf", + "lanes": 4, + }, + } + } + ], + "inputs": { + "interfaces": [ + {"name": "Ethernet1", "auto": False, "speed": 1}, + {"name": "Ethernet1", "auto": False, "speed": 1, "lanes": 2}, + {"name": "Ethernet2/1/2", "auto": False, "speed": 10}, + {"name": "Ethernet3", "auto": True, "speed": 1}, + {"name": "Ethernet3", "auto": True, "speed": 100, "lanes": 8}, + {"name": "Ethernet3", "auto": True, "speed": 100}, + {"name": "Ethernet4", "auto": False, "speed": 2.5}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "For interface Ethernet1:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `1Gbps` as the speed, but found `10Gbps` instead.", + "For interface Ethernet1:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `1Gbps` as the speed, but found `10Gbps` instead.\n" + "Expected `2` as the lanes, but found `4` instead.", + "For interface Ethernet2/1/2:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `10Gbps` as the speed, but found `1Gbps` instead.", + "For interface Ethernet3:\nExpected `success` as the auto negotiation, but found `unknown` instead.\n" + "Expected `duplexFull` as the duplex mode, but found `duplexHalf` instead.", + "For interface Ethernet3:\nExpected `success` as the auto negotiation, but found `unknown` instead.\n" + "Expected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `100Gbps` as the speed, but found `10Gbps` instead.\n" + "Expected `8` as the lanes, but found `6` instead.", + "For interface Ethernet3:\nExpected `success` as the auto negotiation, but found `unknown` instead.\n" + "Expected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `100Gbps` as the speed, but found `10Gbps` instead.", + "For interface Ethernet4:\nExpected `duplexFull` as the duplex mode, but found `duplexHalf` instead.\n" + "Expected `2.5Gbps` as the speed, but found `25Gbps` instead.", + ], + }, + }, ] -- cgit v1.2.3