| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Tests for anta.tests.stp.py.""" |
| 5 |
|
| 6 |
from __future__ import annotations |
| 7 |
|
| 8 |
import sys |
| 9 |
from typing import TYPE_CHECKING, Any |
| 10 |
|
| 11 |
from anta.models import AntaTest |
| 12 |
from anta.result_manager.models import AntaTestStatus |
| 13 |
from anta.tests.stp import ( |
| 14 |
VerifySTPBlockedPorts, |
| 15 |
VerifySTPCounters, |
| 16 |
VerifySTPDisabledVlans, |
| 17 |
VerifySTPForwardingPorts, |
| 18 |
VerifySTPMode, |
| 19 |
VerifySTPRootPriority, |
| 20 |
VerifyStpTopologyChanges, |
| 21 |
) |
| 22 |
from tests.units.anta_tests import test |
| 23 |
|
| 24 |
if TYPE_CHECKING: |
| 25 |
from tests.units.anta_tests import AntaUnitTestData |
| 26 |
|
| 27 |
DATA: AntaUnitTestData = { |
| 28 |
(VerifySTPMode, "success"): { |
| 29 |
"eos_data": [ |
| 30 |
{"spanningTreeVlanInstances": {"10": {"spanningTreeVlanInstance": {"protocol": "rstp"}}}}, |
| 31 |
{"spanningTreeVlanInstances": {"20": {"spanningTreeVlanInstance": {"protocol": "rstp"}}}}, |
| 32 |
], |
| 33 |
"inputs": {"mode": "rstp", "vlans": [10, 20]}, |
| 34 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 35 |
}, |
| 36 |
(VerifySTPMode, "failure-no-instances"): { |
| 37 |
"eos_data": [{"spanningTreeVlanInstances": {}}, {"spanningTreeVlanInstances": {}}], |
| 38 |
"inputs": {"mode": "rstp", "vlans": [10, 20]}, |
| 39 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN 10 STP mode: rstp - Not configured", "VLAN 20 STP mode: rstp - Not configured"]}, |
| 40 |
}, |
| 41 |
(VerifySTPMode, "failure-wrong-mode"): { |
| 42 |
"eos_data": [ |
| 43 |
{"spanningTreeVlanInstances": {"10": {"spanningTreeVlanInstance": {"protocol": "mstp"}}}}, |
| 44 |
{"spanningTreeVlanInstances": {"20": {"spanningTreeVlanInstance": {"protocol": "mstp"}}}}, |
| 45 |
], |
| 46 |
"inputs": {"mode": "rstp", "vlans": [10, 20]}, |
| 47 |
"expected": { |
| 48 |
"result": AntaTestStatus.FAILURE, |
| 49 |
"messages": ["VLAN 10 - Incorrect STP mode - Expected: rstp Actual: mstp", "VLAN 20 - Incorrect STP mode - Expected: rstp Actual: mstp"], |
| 50 |
}, |
| 51 |
}, |
| 52 |
(VerifySTPMode, "failure-both"): { |
| 53 |
"eos_data": [{"spanningTreeVlanInstances": {}}, {"spanningTreeVlanInstances": {"20": {"spanningTreeVlanInstance": {"protocol": "mstp"}}}}], |
| 54 |
"inputs": {"mode": "rstp", "vlans": [10, 20]}, |
| 55 |
"expected": { |
| 56 |
"result": AntaTestStatus.FAILURE, |
| 57 |
"messages": ["VLAN 10 STP mode: rstp - Not configured", "VLAN 20 - Incorrect STP mode - Expected: rstp Actual: mstp"], |
| 58 |
}, |
| 59 |
}, |
| 60 |
(VerifySTPBlockedPorts, "success"): {"eos_data": [{"spanningTreeInstances": {}}], "expected": {"result": AntaTestStatus.SUCCESS}}, |
| 61 |
(VerifySTPBlockedPorts, "failure"): { |
| 62 |
"eos_data": [{"spanningTreeInstances": {"MST0": {"spanningTreeBlockedPorts": ["Ethernet10"]}, "MST10": {"spanningTreeBlockedPorts": ["Ethernet10"]}}}], |
| 63 |
"expected": { |
| 64 |
"result": AntaTestStatus.FAILURE, |
| 65 |
"messages": ["STP Instance: MST0 - Blocked ports - Ethernet10", "STP Instance: MST10 - Blocked ports - Ethernet10"], |
| 66 |
}, |
| 67 |
}, |
| 68 |
(VerifySTPCounters, "success"): { |
| 69 |
"eos_data": [{"interfaces": {"Ethernet10": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 0, "bpduRateLimitCount": 0}}}], |
| 70 |
"expected": { |
| 71 |
"result": AntaTestStatus.SUCCESS, |
| 72 |
"atomic_results": [ |
| 73 |
{ |
| 74 |
"description": "Interface: Ethernet10", |
| 75 |
"result": AntaTestStatus.SUCCESS, |
| 76 |
} |
| 77 |
], |
| 78 |
}, |
| 79 |
}, |
| 80 |
(VerifySTPCounters, "failure-bpdu-tagged-error-mismatch"): { |
| 81 |
"eos_data": [ |
| 82 |
{ |
| 83 |
"interfaces": { |
| 84 |
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 85 |
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 86 |
} |
| 87 |
} |
| 88 |
], |
| 89 |
"expected": { |
| 90 |
"result": AntaTestStatus.FAILURE, |
| 91 |
"messages": [ |
| 92 |
"Interface: Ethernet10 - STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3", |
| 93 |
"Interface: Ethernet11 - STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3", |
| 94 |
], |
| 95 |
"atomic_results": [ |
| 96 |
{ |
| 97 |
"description": "Interface: Ethernet10", |
| 98 |
"result": AntaTestStatus.FAILURE, |
| 99 |
"messages": ["STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3"], |
| 100 |
}, |
| 101 |
{ |
| 102 |
"description": "Interface: Ethernet11", |
| 103 |
"result": AntaTestStatus.FAILURE, |
| 104 |
"messages": ["STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3"], |
| 105 |
}, |
| 106 |
], |
| 107 |
}, |
| 108 |
}, |
| 109 |
(VerifySTPCounters, "failure-bpdu-other-error-mismatch"): { |
| 110 |
"eos_data": [ |
| 111 |
{ |
| 112 |
"interfaces": { |
| 113 |
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 3, "bpduRateLimitCount": 0}, |
| 114 |
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 6, "bpduRateLimitCount": 0}, |
| 115 |
} |
| 116 |
} |
| 117 |
], |
| 118 |
"expected": { |
| 119 |
"result": AntaTestStatus.FAILURE, |
| 120 |
"messages": [ |
| 121 |
"Interface: Ethernet10 - STP BPDU packet other errors count mismatch - Expected: 0 Actual: 3", |
| 122 |
"Interface: Ethernet11 - STP BPDU packet other errors count mismatch - Expected: 0 Actual: 6", |
| 123 |
], |
| 124 |
"atomic_results": [ |
| 125 |
{ |
| 126 |
"description": "Interface: Ethernet10", |
| 127 |
"result": AntaTestStatus.FAILURE, |
| 128 |
"messages": ["STP BPDU packet other errors count mismatch - Expected: 0 Actual: 3"], |
| 129 |
}, |
| 130 |
{ |
| 131 |
"description": "Interface: Ethernet11", |
| 132 |
"result": AntaTestStatus.FAILURE, |
| 133 |
"messages": ["STP BPDU packet other errors count mismatch - Expected: 0 Actual: 6"], |
| 134 |
}, |
| 135 |
], |
| 136 |
}, |
| 137 |
}, |
| 138 |
(VerifySTPCounters, "success-ignore-interface"): { |
| 139 |
"eos_data": [ |
| 140 |
{ |
| 141 |
"interfaces": { |
| 142 |
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 143 |
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 144 |
} |
| 145 |
} |
| 146 |
], |
| 147 |
"inputs": {"ignored_interfaces": ["Ethernet10"]}, |
| 148 |
"expected": { |
| 149 |
"result": AntaTestStatus.SUCCESS, |
| 150 |
"atomic_results": [ |
| 151 |
{ |
| 152 |
"description": "Interface: Ethernet11", |
| 153 |
"result": AntaTestStatus.SUCCESS, |
| 154 |
} |
| 155 |
], |
| 156 |
}, |
| 157 |
}, |
| 158 |
(VerifySTPCounters, "success-specific-interface"): { |
| 159 |
"eos_data": [ |
| 160 |
{ |
| 161 |
"interfaces": { |
| 162 |
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 163 |
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 164 |
} |
| 165 |
} |
| 166 |
], |
| 167 |
"inputs": {"interfaces": ["Ethernet11"]}, |
| 168 |
"expected": { |
| 169 |
"result": AntaTestStatus.SUCCESS, |
| 170 |
"atomic_results": [ |
| 171 |
{ |
| 172 |
"description": "Interface: Ethernet11", |
| 173 |
"result": AntaTestStatus.SUCCESS, |
| 174 |
} |
| 175 |
], |
| 176 |
}, |
| 177 |
}, |
| 178 |
(VerifySTPCounters, "failure-specific-interface-not-found"): { |
| 179 |
"eos_data": [ |
| 180 |
{ |
| 181 |
"interfaces": { |
| 182 |
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 183 |
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 0, "bpduRateLimitCount": 0}, |
| 184 |
} |
| 185 |
} |
| 186 |
], |
| 187 |
"inputs": {"interfaces": ["Ethernet12"]}, |
| 188 |
"expected": { |
| 189 |
"result": AntaTestStatus.FAILURE, |
| 190 |
"messages": ["Interface: Ethernet12 - Not found"], |
| 191 |
"atomic_results": [ |
| 192 |
{ |
| 193 |
"description": "Interface: Ethernet12", |
| 194 |
"result": AntaTestStatus.FAILURE, |
| 195 |
"messages": ["Not found"], |
| 196 |
} |
| 197 |
], |
| 198 |
}, |
| 199 |
}, |
| 200 |
(VerifySTPForwardingPorts, "success"): { |
| 201 |
"eos_data": [ |
| 202 |
{ |
| 203 |
"unmappedVlans": [], |
| 204 |
"topologies": {"Mst10": {"vlans": [10], "interfaces": {"Ethernet10": {"state": "forwarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 205 |
}, |
| 206 |
{ |
| 207 |
"unmappedVlans": [], |
| 208 |
"topologies": {"Mst20": {"vlans": [20], "interfaces": {"Ethernet10": {"state": "forwarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 209 |
}, |
| 210 |
], |
| 211 |
"inputs": {"vlans": [10, 20]}, |
| 212 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 213 |
}, |
| 214 |
(VerifySTPForwardingPorts, "success-vlan-not-in-topology"): { |
| 215 |
"eos_data": [ |
| 216 |
{ |
| 217 |
"unmappedVlans": [], |
| 218 |
"topologies": {"Mst10": {"vlans": [10], "interfaces": {"Ethernet10": {"state": "forwarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 219 |
}, |
| 220 |
{ |
| 221 |
"unmappedVlans": [], |
| 222 |
"topologies": {"Mst10": {"vlans": [10], "interfaces": {"Ethernet10": {"state": "forwarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 223 |
}, |
| 224 |
], |
| 225 |
"inputs": {"vlans": [10, 20]}, |
| 226 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 227 |
}, |
| 228 |
(VerifySTPForwardingPorts, "failure-no-instances"): { |
| 229 |
"eos_data": [{"unmappedVlans": [], "topologies": {}}, {"unmappedVlans": [], "topologies": {}}], |
| 230 |
"inputs": {"vlans": [10, 20]}, |
| 231 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN 10 - STP instance is not configured", "VLAN 20 - STP instance is not configured"]}, |
| 232 |
}, |
| 233 |
(VerifySTPForwardingPorts, "failure"): { |
| 234 |
"eos_data": [ |
| 235 |
{ |
| 236 |
"unmappedVlans": [], |
| 237 |
"topologies": {"Vl10": {"vlans": [10], "interfaces": {"Ethernet10": {"state": "discarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 238 |
}, |
| 239 |
{ |
| 240 |
"unmappedVlans": [], |
| 241 |
"topologies": {"Vl20": {"vlans": [20], "interfaces": {"Ethernet10": {"state": "discarding"}, "MplsTrunk1": {"state": "forwarding"}}}}, |
| 242 |
}, |
| 243 |
], |
| 244 |
"inputs": {"vlans": [10, 20]}, |
| 245 |
"expected": { |
| 246 |
"result": AntaTestStatus.FAILURE, |
| 247 |
"messages": [ |
| 248 |
"VLAN 10 Interface: Ethernet10 - Invalid state - Expected: forwarding Actual: discarding", |
| 249 |
"VLAN 20 Interface: Ethernet10 - Invalid state - Expected: forwarding Actual: discarding", |
| 250 |
], |
| 251 |
}, |
| 252 |
}, |
| 253 |
(VerifySTPRootPriority, "success-specific-instances"): { |
| 254 |
"eos_data": [ |
| 255 |
{ |
| 256 |
"instances": { |
| 257 |
"VL10": { |
| 258 |
"rootBridge": { |
| 259 |
"priority": 32768, |
| 260 |
"systemIdExtension": 10, |
| 261 |
"macAddress": "00:1c:73:27:95:a2", |
| 262 |
"helloTime": 2.0, |
| 263 |
"maxAge": 20, |
| 264 |
"forwardDelay": 15, |
| 265 |
} |
| 266 |
}, |
| 267 |
"VL20": { |
| 268 |
"rootBridge": { |
| 269 |
"priority": 32768, |
| 270 |
"systemIdExtension": 20, |
| 271 |
"macAddress": "00:1c:73:27:95:a2", |
| 272 |
"helloTime": 2.0, |
| 273 |
"maxAge": 20, |
| 274 |
"forwardDelay": 15, |
| 275 |
} |
| 276 |
}, |
| 277 |
"VL30": { |
| 278 |
"rootBridge": { |
| 279 |
"priority": 32768, |
| 280 |
"systemIdExtension": 30, |
| 281 |
"macAddress": "00:1c:73:27:95:a2", |
| 282 |
"helloTime": 2.0, |
| 283 |
"maxAge": 20, |
| 284 |
"forwardDelay": 15, |
| 285 |
} |
| 286 |
}, |
| 287 |
} |
| 288 |
} |
| 289 |
], |
| 290 |
"inputs": {"priority": 32768, "instances": [10, 20]}, |
| 291 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 292 |
}, |
| 293 |
(VerifySTPRootPriority, "success-all-instances"): { |
| 294 |
"eos_data": [ |
| 295 |
{ |
| 296 |
"instances": { |
| 297 |
"VL10": { |
| 298 |
"rootBridge": { |
| 299 |
"priority": 32768, |
| 300 |
"systemIdExtension": 10, |
| 301 |
"macAddress": "00:1c:73:27:95:a2", |
| 302 |
"helloTime": 2.0, |
| 303 |
"maxAge": 20, |
| 304 |
"forwardDelay": 15, |
| 305 |
} |
| 306 |
}, |
| 307 |
"VL20": { |
| 308 |
"rootBridge": { |
| 309 |
"priority": 32768, |
| 310 |
"systemIdExtension": 20, |
| 311 |
"macAddress": "00:1c:73:27:95:a2", |
| 312 |
"helloTime": 2.0, |
| 313 |
"maxAge": 20, |
| 314 |
"forwardDelay": 15, |
| 315 |
} |
| 316 |
}, |
| 317 |
"VL30": { |
| 318 |
"rootBridge": { |
| 319 |
"priority": 32768, |
| 320 |
"systemIdExtension": 30, |
| 321 |
"macAddress": "00:1c:73:27:95:a2", |
| 322 |
"helloTime": 2.0, |
| 323 |
"maxAge": 20, |
| 324 |
"forwardDelay": 15, |
| 325 |
} |
| 326 |
}, |
| 327 |
} |
| 328 |
} |
| 329 |
], |
| 330 |
"inputs": {"priority": 32768}, |
| 331 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 332 |
}, |
| 333 |
(VerifySTPRootPriority, "success-MST"): { |
| 334 |
"eos_data": [ |
| 335 |
{ |
| 336 |
"instances": { |
| 337 |
"MST0": { |
| 338 |
"rootBridge": { |
| 339 |
"priority": 16384, |
| 340 |
"systemIdExtension": 0, |
| 341 |
"macAddress": "02:1c:73:8b:93:ac", |
| 342 |
"helloTime": 2.0, |
| 343 |
"maxAge": 20, |
| 344 |
"forwardDelay": 15, |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
} |
| 349 |
], |
| 350 |
"inputs": {"priority": 16384, "instances": [0]}, |
| 351 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 352 |
}, |
| 353 |
(VerifySTPRootPriority, "success-input-instance-none"): { |
| 354 |
"eos_data": [ |
| 355 |
{ |
| 356 |
"instances": { |
| 357 |
"MST0": { |
| 358 |
"rootBridge": { |
| 359 |
"priority": 16384, |
| 360 |
"systemIdExtension": 0, |
| 361 |
"macAddress": "02:1c:73:8b:93:ac", |
| 362 |
"helloTime": 2.0, |
| 363 |
"maxAge": 20, |
| 364 |
"forwardDelay": 15, |
| 365 |
} |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
], |
| 370 |
"inputs": {"priority": 16384}, |
| 371 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 372 |
}, |
| 373 |
(VerifySTPRootPriority, "failure-no-instances"): { |
| 374 |
"eos_data": [ |
| 375 |
{ |
| 376 |
"instances": { |
| 377 |
"WRONG0": { |
| 378 |
"rootBridge": { |
| 379 |
"priority": 16384, |
| 380 |
"systemIdExtension": 0, |
| 381 |
"macAddress": "02:1c:73:8b:93:ac", |
| 382 |
"helloTime": 2.0, |
| 383 |
"maxAge": 20, |
| 384 |
"forwardDelay": 15, |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
], |
| 390 |
"inputs": {"priority": 32768, "instances": [0]}, |
| 391 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STP Instance: WRONG0 - Unsupported STP instance type"]}, |
| 392 |
}, |
| 393 |
(VerifySTPRootPriority, "failure-wrong-instance-type"): { |
| 394 |
"eos_data": [{"instances": {}}], |
| 395 |
"inputs": {"priority": 32768, "instances": [10, 20]}, |
| 396 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["No STP instances configured"]}, |
| 397 |
}, |
| 398 |
(VerifySTPRootPriority, "failure-instance-not-found"): { |
| 399 |
"eos_data": [ |
| 400 |
{ |
| 401 |
"instances": { |
| 402 |
"VL10": { |
| 403 |
"rootBridge": { |
| 404 |
"priority": 32768, |
| 405 |
"systemIdExtension": 10, |
| 406 |
"macAddress": "00:1c:73:27:95:a2", |
| 407 |
"helloTime": 2.0, |
| 408 |
"maxAge": 20, |
| 409 |
"forwardDelay": 15, |
| 410 |
} |
| 411 |
} |
| 412 |
} |
| 413 |
} |
| 414 |
], |
| 415 |
"inputs": {"priority": 32768, "instances": [11, 20]}, |
| 416 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Instance: VL11 - Not configured", "Instance: VL20 - Not configured"]}, |
| 417 |
}, |
| 418 |
(VerifySTPRootPriority, "failure-wrong-priority"): { |
| 419 |
"eos_data": [ |
| 420 |
{ |
| 421 |
"instances": { |
| 422 |
"VL10": { |
| 423 |
"rootBridge": { |
| 424 |
"priority": 32768, |
| 425 |
"systemIdExtension": 10, |
| 426 |
"macAddress": "00:1c:73:27:95:a2", |
| 427 |
"helloTime": 2.0, |
| 428 |
"maxAge": 20, |
| 429 |
"forwardDelay": 15, |
| 430 |
} |
| 431 |
}, |
| 432 |
"VL20": { |
| 433 |
"rootBridge": { |
| 434 |
"priority": 8196, |
| 435 |
"systemIdExtension": 20, |
| 436 |
"macAddress": "00:1c:73:27:95:a2", |
| 437 |
"helloTime": 2.0, |
| 438 |
"maxAge": 20, |
| 439 |
"forwardDelay": 15, |
| 440 |
} |
| 441 |
}, |
| 442 |
"VL30": { |
| 443 |
"rootBridge": { |
| 444 |
"priority": 8196, |
| 445 |
"systemIdExtension": 30, |
| 446 |
"macAddress": "00:1c:73:27:95:a2", |
| 447 |
"helloTime": 2.0, |
| 448 |
"maxAge": 20, |
| 449 |
"forwardDelay": 15, |
| 450 |
} |
| 451 |
}, |
| 452 |
} |
| 453 |
} |
| 454 |
], |
| 455 |
"inputs": {"priority": 32768, "instances": [10, 20, 30]}, |
| 456 |
"expected": { |
| 457 |
"result": AntaTestStatus.FAILURE, |
| 458 |
"messages": [ |
| 459 |
"STP Instance: VL20 - Incorrect root priority - Expected: 32768 Actual: 8196", |
| 460 |
"STP Instance: VL30 - Incorrect root priority - Expected: 32768 Actual: 8196", |
| 461 |
], |
| 462 |
}, |
| 463 |
}, |
| 464 |
(VerifyStpTopologyChanges, "success-mstp"): { |
| 465 |
"eos_data": [ |
| 466 |
{ |
| 467 |
"unmappedVlans": [], |
| 468 |
"topologies": { |
| 469 |
"Cist": { |
| 470 |
"interfaces": { |
| 471 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365}, |
| 472 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.7353542}, |
| 473 |
} |
| 474 |
}, |
| 475 |
"NoStp": { |
| 476 |
"interfaces": { |
| 477 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365}, |
| 478 |
"Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542}, |
| 479 |
} |
| 480 |
}, |
| 481 |
}, |
| 482 |
} |
| 483 |
], |
| 484 |
"inputs": {"threshold": 10}, |
| 485 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 486 |
}, |
| 487 |
(VerifyStpTopologyChanges, "success-rstp"): { |
| 488 |
"eos_data": [ |
| 489 |
{ |
| 490 |
"unmappedVlans": [], |
| 491 |
"topologies": { |
| 492 |
"Cist": { |
| 493 |
"interfaces": { |
| 494 |
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365}, |
| 495 |
"PeerEthernet3": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.7353542}, |
| 496 |
} |
| 497 |
}, |
| 498 |
"NoStp": { |
| 499 |
"interfaces": { |
| 500 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365}, |
| 501 |
"Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542}, |
| 502 |
} |
| 503 |
}, |
| 504 |
}, |
| 505 |
} |
| 506 |
], |
| 507 |
"inputs": {"threshold": 10}, |
| 508 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 509 |
}, |
| 510 |
(VerifyStpTopologyChanges, "success-rapid-pvst"): { |
| 511 |
"eos_data": [ |
| 512 |
{ |
| 513 |
"unmappedVlans": [], |
| 514 |
"topologies": { |
| 515 |
"NoStp": { |
| 516 |
"vlans": [4094, 4093, 1006], |
| 517 |
"interfaces": {"PeerEthernet2": {"state": "forwarding", "numChanges": 1, "lastChange": 1727151356.1330667}}, |
| 518 |
}, |
| 519 |
"Vl1": {"vlans": [1], "interfaces": {"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0615358}}}, |
| 520 |
"Vl10": { |
| 521 |
"vlans": [10], |
| 522 |
"interfaces": { |
| 523 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0673406}, |
| 524 |
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0677001}, |
| 525 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0728855}, |
| 526 |
"Ethernet3": {"state": "forwarding", "numChanges": 3, "lastChange": 1727326730.255137}, |
| 527 |
}, |
| 528 |
}, |
| 529 |
"Vl1198": { |
| 530 |
"vlans": [1198], |
| 531 |
"interfaces": { |
| 532 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074386}, |
| 533 |
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743902}, |
| 534 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743942}, |
| 535 |
}, |
| 536 |
}, |
| 537 |
"Vl1199": { |
| 538 |
"vlans": [1199], |
| 539 |
"interfaces": { |
| 540 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0744}, |
| 541 |
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.07453}, |
| 542 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074535}, |
| 543 |
}, |
| 544 |
}, |
| 545 |
"Vl20": { |
| 546 |
"vlans": [20], |
| 547 |
"interfaces": { |
| 548 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.073489}, |
| 549 |
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743747}, |
| 550 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743794}, |
| 551 |
"Ethernet3": {"state": "forwarding", "numChanges": 3, "lastChange": 1727326730.2551405}, |
| 552 |
}, |
| 553 |
}, |
| 554 |
"Vl3009": { |
| 555 |
"vlans": [3009], |
| 556 |
"interfaces": { |
| 557 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074541}, |
| 558 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745454}, |
| 559 |
}, |
| 560 |
}, |
| 561 |
"Vl3019": { |
| 562 |
"vlans": [3019], |
| 563 |
"interfaces": { |
| 564 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745502}, |
| 565 |
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745537}, |
| 566 |
}, |
| 567 |
}, |
| 568 |
}, |
| 569 |
} |
| 570 |
], |
| 571 |
"inputs": {"threshold": 10}, |
| 572 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 573 |
}, |
| 574 |
(VerifyStpTopologyChanges, "failure-unstable-topology"): { |
| 575 |
"eos_data": [ |
| 576 |
{ |
| 577 |
"unmappedVlans": [], |
| 578 |
"topologies": { |
| 579 |
"Cist": { |
| 580 |
"interfaces": { |
| 581 |
"Cpu": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.735365}, |
| 582 |
"Port-Channel5": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542}, |
| 583 |
} |
| 584 |
} |
| 585 |
}, |
| 586 |
} |
| 587 |
], |
| 588 |
"inputs": {"threshold": 10}, |
| 589 |
"expected": { |
| 590 |
"result": AntaTestStatus.FAILURE, |
| 591 |
"messages": [ |
| 592 |
"Topology: Cist Interface: Cpu - Number of changes not within the threshold - Expected: 10 Actual: 15", |
| 593 |
"Topology: Cist Interface: Port-Channel5 - Number of changes not within the threshold - Expected: 10 Actual: 15", |
| 594 |
], |
| 595 |
}, |
| 596 |
}, |
| 597 |
(VerifyStpTopologyChanges, "failure-topologies-not-configured"): { |
| 598 |
"eos_data": [ |
| 599 |
{ |
| 600 |
"unmappedVlans": [], |
| 601 |
"topologies": { |
| 602 |
"NoStp": { |
| 603 |
"interfaces": { |
| 604 |
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365}, |
| 605 |
"Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542}, |
| 606 |
} |
| 607 |
} |
| 608 |
}, |
| 609 |
} |
| 610 |
], |
| 611 |
"inputs": {"threshold": 10}, |
| 612 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STP is not configured"]}, |
| 613 |
}, |
| 614 |
(VerifySTPDisabledVlans, "success"): { |
| 615 |
"eos_data": [{"spanningTreeVlanInstances": {"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {"priority": 32768}}}, "6": {}, "4094": {}}}], |
| 616 |
"inputs": {"vlans": ["6", "4094"]}, |
| 617 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 618 |
}, |
| 619 |
(VerifySTPDisabledVlans, "failure-stp-not-configured"): { |
| 620 |
"eos_data": [{"spanningTreeVlanInstances": {}}], |
| 621 |
"inputs": {"vlans": ["6", "4094"]}, |
| 622 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["STP is not configured"]}, |
| 623 |
}, |
| 624 |
(VerifySTPDisabledVlans, "failure-vlans-not-found"): { |
| 625 |
"eos_data": [ |
| 626 |
{ |
| 627 |
"spanningTreeVlanInstances": { |
| 628 |
"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 629 |
"6": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 630 |
"4094": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 631 |
} |
| 632 |
} |
| 633 |
], |
| 634 |
"inputs": {"vlans": ["16", "4093"]}, |
| 635 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN: 16 - Not configured", "VLAN: 4093 - Not configured"]}, |
| 636 |
}, |
| 637 |
(VerifySTPDisabledVlans, "failure-vlans-enabled"): { |
| 638 |
"eos_data": [ |
| 639 |
{ |
| 640 |
"spanningTreeVlanInstances": { |
| 641 |
"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 642 |
"6": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 643 |
"4094": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}}, |
| 644 |
} |
| 645 |
} |
| 646 |
], |
| 647 |
"inputs": {"vlans": ["6", "4094"]}, |
| 648 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN: 6 - STP is enabled", "VLAN: 4094 - STP is enabled"]}, |
| 649 |
}, |
| 650 |
} |