| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Test inputs for anta.tests.multicast.""" |
| 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.multicast import VerifyIGMPSnoopingGlobal, VerifyIGMPSnoopingVlans |
| 14 |
from tests.units.anta_tests import test |
| 15 |
|
| 16 |
if TYPE_CHECKING: |
| 17 |
from tests.units.anta_tests import AntaUnitTestData |
| 18 |
|
| 19 |
DATA: AntaUnitTestData = { |
| 20 |
(VerifyIGMPSnoopingVlans, "success-enabled"): { |
| 21 |
"eos_data": [ |
| 22 |
{ |
| 23 |
"reportFlooding": "disabled", |
| 24 |
"igmpSnoopingState": "enabled", |
| 25 |
"vlans": { |
| 26 |
"1": { |
| 27 |
"reportFlooding": "disabled", |
| 28 |
"proxyActive": False, |
| 29 |
"groupsOverrun": False, |
| 30 |
"multicastRouterLearningMode": "pim-dvmrp", |
| 31 |
"igmpSnoopingState": "enabled", |
| 32 |
"pruningActive": False, |
| 33 |
"maxGroups": 65534, |
| 34 |
"immediateLeave": "default", |
| 35 |
"floodingTraffic": True, |
| 36 |
}, |
| 37 |
"42": { |
| 38 |
"reportFlooding": "disabled", |
| 39 |
"proxyActive": False, |
| 40 |
"groupsOverrun": False, |
| 41 |
"multicastRouterLearningMode": "pim-dvmrp", |
| 42 |
"igmpSnoopingState": "enabled", |
| 43 |
"pruningActive": False, |
| 44 |
"maxGroups": 65534, |
| 45 |
"immediateLeave": "default", |
| 46 |
"floodingTraffic": True, |
| 47 |
}, |
| 48 |
}, |
| 49 |
"robustness": 2, |
| 50 |
"immediateLeave": "enabled", |
| 51 |
"reportFloodingSwitchPorts": [], |
| 52 |
} |
| 53 |
], |
| 54 |
"inputs": {"vlans": {1: True, 42: True}}, |
| 55 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 56 |
}, |
| 57 |
(VerifyIGMPSnoopingVlans, "success-disabled"): { |
| 58 |
"eos_data": [ |
| 59 |
{ |
| 60 |
"reportFlooding": "disabled", |
| 61 |
"igmpSnoopingState": "enabled", |
| 62 |
"vlans": { |
| 63 |
"42": { |
| 64 |
"reportFlooding": "disabled", |
| 65 |
"proxyActive": False, |
| 66 |
"groupsOverrun": False, |
| 67 |
"multicastRouterLearningMode": "pim-dvmrp", |
| 68 |
"igmpSnoopingState": "disabled", |
| 69 |
"pruningActive": False, |
| 70 |
"maxGroups": 65534, |
| 71 |
"immediateLeave": "default", |
| 72 |
"floodingTraffic": True, |
| 73 |
} |
| 74 |
}, |
| 75 |
"robustness": 2, |
| 76 |
"immediateLeave": "enabled", |
| 77 |
"reportFloodingSwitchPorts": [], |
| 78 |
} |
| 79 |
], |
| 80 |
"inputs": {"vlans": {42: False}}, |
| 81 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 82 |
}, |
| 83 |
(VerifyIGMPSnoopingVlans, "failure-missing-vlan"): { |
| 84 |
"eos_data": [ |
| 85 |
{ |
| 86 |
"reportFlooding": "disabled", |
| 87 |
"igmpSnoopingState": "enabled", |
| 88 |
"vlans": { |
| 89 |
"1": { |
| 90 |
"reportFlooding": "disabled", |
| 91 |
"proxyActive": False, |
| 92 |
"groupsOverrun": False, |
| 93 |
"multicastRouterLearningMode": "pim-dvmrp", |
| 94 |
"igmpSnoopingState": "enabled", |
| 95 |
"pruningActive": False, |
| 96 |
"maxGroups": 65534, |
| 97 |
"immediateLeave": "default", |
| 98 |
"floodingTraffic": True, |
| 99 |
} |
| 100 |
}, |
| 101 |
"robustness": 2, |
| 102 |
"immediateLeave": "enabled", |
| 103 |
"reportFloodingSwitchPorts": [], |
| 104 |
} |
| 105 |
], |
| 106 |
"inputs": {"vlans": {1: False, 42: False}}, |
| 107 |
"expected": { |
| 108 |
"result": AntaTestStatus.FAILURE, |
| 109 |
"messages": ["VLAN1 - Incorrect IGMP state - Expected: disabled Actual: enabled", "Supplied vlan 42 is not present on the device"], |
| 110 |
}, |
| 111 |
}, |
| 112 |
(VerifyIGMPSnoopingVlans, "failure-wrong-state"): { |
| 113 |
"eos_data": [ |
| 114 |
{ |
| 115 |
"reportFlooding": "disabled", |
| 116 |
"igmpSnoopingState": "enabled", |
| 117 |
"vlans": { |
| 118 |
"1": { |
| 119 |
"reportFlooding": "disabled", |
| 120 |
"proxyActive": False, |
| 121 |
"groupsOverrun": False, |
| 122 |
"multicastRouterLearningMode": "pim-dvmrp", |
| 123 |
"igmpSnoopingState": "disabled", |
| 124 |
"pruningActive": False, |
| 125 |
"maxGroups": 65534, |
| 126 |
"immediateLeave": "default", |
| 127 |
"floodingTraffic": True, |
| 128 |
} |
| 129 |
}, |
| 130 |
"robustness": 2, |
| 131 |
"immediateLeave": "enabled", |
| 132 |
"reportFloodingSwitchPorts": [], |
| 133 |
} |
| 134 |
], |
| 135 |
"inputs": {"vlans": {1: True}}, |
| 136 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN1 - Incorrect IGMP state - Expected: enabled Actual: disabled"]}, |
| 137 |
}, |
| 138 |
(VerifyIGMPSnoopingGlobal, "success-enabled"): { |
| 139 |
"eos_data": [{"reportFlooding": "disabled", "igmpSnoopingState": "enabled", "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": []}], |
| 140 |
"inputs": {"enabled": True}, |
| 141 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 142 |
}, |
| 143 |
(VerifyIGMPSnoopingGlobal, "success-disabled"): { |
| 144 |
"eos_data": [{"reportFlooding": "disabled", "igmpSnoopingState": "disabled"}], |
| 145 |
"inputs": {"enabled": False}, |
| 146 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 147 |
}, |
| 148 |
(VerifyIGMPSnoopingGlobal, "failure-wrong-state"): { |
| 149 |
"eos_data": [{"reportFlooding": "disabled", "igmpSnoopingState": "disabled"}], |
| 150 |
"inputs": {"enabled": True}, |
| 151 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["IGMP state is not valid - Expected: enabled Actual: disabled"]}, |
| 152 |
}, |
| 153 |
} |