| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Test inputs for anta.tests.flow_tracking.""" |
| 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.flow_tracking import VerifyHardwareFlowTrackerStatus |
| 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 |
(VerifyHardwareFlowTrackerStatus, "success"): { |
| 21 |
"eos_data": [ |
| 22 |
{ |
| 23 |
"trackers": { |
| 24 |
"FLOW-TRACKER": { |
| 25 |
"active": True, |
| 26 |
"inactiveTimeout": 60000, |
| 27 |
"activeInterval": 300000, |
| 28 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 29 |
}, |
| 30 |
"HARDWARE-TRACKER": { |
| 31 |
"active": True, |
| 32 |
"inactiveTimeout": 60000, |
| 33 |
"activeInterval": 300000, |
| 34 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 35 |
}, |
| 36 |
}, |
| 37 |
"running": True, |
| 38 |
} |
| 39 |
], |
| 40 |
"inputs": {"trackers": [{"name": "FLOW-TRACKER"}, {"name": "HARDWARE-TRACKER"}]}, |
| 41 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 42 |
}, |
| 43 |
(VerifyHardwareFlowTrackerStatus, "success-with-optional-field"): { |
| 44 |
"eos_data": [ |
| 45 |
{ |
| 46 |
"trackers": { |
| 47 |
"FLOW-TRACKER": { |
| 48 |
"active": True, |
| 49 |
"inactiveTimeout": 60000, |
| 50 |
"activeInterval": 300000, |
| 51 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 52 |
}, |
| 53 |
"HARDWARE-TRACKER": { |
| 54 |
"active": True, |
| 55 |
"inactiveTimeout": 60000, |
| 56 |
"activeInterval": 300000, |
| 57 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 58 |
}, |
| 59 |
}, |
| 60 |
"running": True, |
| 61 |
} |
| 62 |
], |
| 63 |
"inputs": { |
| 64 |
"trackers": [ |
| 65 |
{ |
| 66 |
"name": "FLOW-TRACKER", |
| 67 |
"record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}, |
| 68 |
"exporters": [{"name": "CV-TELEMETRY", "local_interface": "Loopback0", "template_interval": 3600000}], |
| 69 |
}, |
| 70 |
{ |
| 71 |
"name": "HARDWARE-TRACKER", |
| 72 |
"record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}, |
| 73 |
"exporters": [{"name": "CVP-TELEMETRY", "local_interface": "Loopback10", "template_interval": 3600000}], |
| 74 |
}, |
| 75 |
] |
| 76 |
}, |
| 77 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 78 |
}, |
| 79 |
(VerifyHardwareFlowTrackerStatus, "failure-flow-tracking-not-running"): { |
| 80 |
"eos_data": [{"trackers": {}, "running": False}], |
| 81 |
"inputs": {"trackers": [{"name": "FLOW-TRACKER"}]}, |
| 82 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Hardware flow tracking is not running"]}, |
| 83 |
}, |
| 84 |
(VerifyHardwareFlowTrackerStatus, "failure-tracker-not-configured"): { |
| 85 |
"eos_data": [ |
| 86 |
{ |
| 87 |
"trackers": { |
| 88 |
"HARDWARE-TRACKER": { |
| 89 |
"active": True, |
| 90 |
"inactiveTimeout": 60000, |
| 91 |
"activeInterval": 300000, |
| 92 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 93 |
} |
| 94 |
}, |
| 95 |
"running": True, |
| 96 |
} |
| 97 |
], |
| 98 |
"inputs": {"trackers": [{"name": "FLOW-Sample"}]}, |
| 99 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Flow Tracker: FLOW-Sample - Not found"]}, |
| 100 |
}, |
| 101 |
(VerifyHardwareFlowTrackerStatus, "failure-tracker-not-active"): { |
| 102 |
"eos_data": [ |
| 103 |
{ |
| 104 |
"trackers": { |
| 105 |
"FLOW-TRACKER": { |
| 106 |
"active": False, |
| 107 |
"inactiveTimeout": 60000, |
| 108 |
"activeInterval": 300000, |
| 109 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 110 |
}, |
| 111 |
"HARDWARE-TRACKER": { |
| 112 |
"active": False, |
| 113 |
"inactiveTimeout": 60000, |
| 114 |
"activeInterval": 300000, |
| 115 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 116 |
}, |
| 117 |
}, |
| 118 |
"running": True, |
| 119 |
} |
| 120 |
], |
| 121 |
"inputs": { |
| 122 |
"trackers": [ |
| 123 |
{ |
| 124 |
"name": "FLOW-TRACKER", |
| 125 |
"record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}, |
| 126 |
"exporters": [{"name": "CV-TELEMETRY", "local_interface": "Loopback0", "template_interval": 3600000}], |
| 127 |
}, |
| 128 |
{ |
| 129 |
"name": "HARDWARE-TRACKER", |
| 130 |
"record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}, |
| 131 |
"exporters": [{"name": "CVP-TELEMETRY", "local_interface": "Loopback10", "template_interval": 3600000}], |
| 132 |
}, |
| 133 |
] |
| 134 |
}, |
| 135 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Flow Tracker: FLOW-TRACKER - Disabled", "Flow Tracker: HARDWARE-TRACKER - Disabled"]}, |
| 136 |
}, |
| 137 |
(VerifyHardwareFlowTrackerStatus, "failure-incorrect-record-export"): { |
| 138 |
"eos_data": [ |
| 139 |
{ |
| 140 |
"trackers": { |
| 141 |
"FLOW-TRACKER": { |
| 142 |
"active": True, |
| 143 |
"inactiveTimeout": 60000, |
| 144 |
"activeInterval": 300000, |
| 145 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 146 |
}, |
| 147 |
"HARDWARE-TRACKER": { |
| 148 |
"active": True, |
| 149 |
"inactiveTimeout": 6000, |
| 150 |
"activeInterval": 30000, |
| 151 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 152 |
}, |
| 153 |
}, |
| 154 |
"running": True, |
| 155 |
} |
| 156 |
], |
| 157 |
"inputs": { |
| 158 |
"trackers": [ |
| 159 |
{"name": "FLOW-TRACKER", "record_export": {"on_inactive_timeout": 6000, "on_interval": 30000}}, |
| 160 |
{"name": "HARDWARE-TRACKER", "record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}}, |
| 161 |
] |
| 162 |
}, |
| 163 |
"expected": { |
| 164 |
"result": AntaTestStatus.FAILURE, |
| 165 |
"messages": [ |
| 166 |
"Flow Tracker: FLOW-TRACKER Inactive Timeout: 6000 Active Interval: 30000 - Incorrect timers - Inactive Timeout: 60000 OnActive Interval: 300000", |
| 167 |
"Flow Tracker: HARDWARE-TRACKER Inactive Timeout: 60000 Active Interval: 300000 - Incorrect timers - " |
| 168 |
"Inactive Timeout: 6000 OnActive Interval: 30000", |
| 169 |
], |
| 170 |
}, |
| 171 |
}, |
| 172 |
(VerifyHardwareFlowTrackerStatus, "failure-incorrect-exporters"): { |
| 173 |
"eos_data": [ |
| 174 |
{ |
| 175 |
"trackers": { |
| 176 |
"FLOW-TRACKER": { |
| 177 |
"active": True, |
| 178 |
"inactiveTimeout": 60000, |
| 179 |
"activeInterval": 300000, |
| 180 |
"exporters": { |
| 181 |
"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}, |
| 182 |
"CVP-FLOW": {"localIntf": "Loopback0", "templateInterval": 3600000}, |
| 183 |
}, |
| 184 |
}, |
| 185 |
"HARDWARE-TRACKER": { |
| 186 |
"active": True, |
| 187 |
"inactiveTimeout": 6000, |
| 188 |
"activeInterval": 30000, |
| 189 |
"exporters": { |
| 190 |
"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}, |
| 191 |
"Hardware-flow": {"localIntf": "Loopback10", "templateInterval": 3600000}, |
| 192 |
}, |
| 193 |
}, |
| 194 |
}, |
| 195 |
"running": True, |
| 196 |
} |
| 197 |
], |
| 198 |
"inputs": { |
| 199 |
"trackers": [ |
| 200 |
{ |
| 201 |
"name": "FLOW-TRACKER", |
| 202 |
"exporters": [ |
| 203 |
{"name": "CV-TELEMETRY", "local_interface": "Loopback0", "template_interval": 3600000}, |
| 204 |
{"name": "CVP-FLOW", "local_interface": "Loopback10", "template_interval": 3500000}, |
| 205 |
], |
| 206 |
}, |
| 207 |
{ |
| 208 |
"name": "HARDWARE-TRACKER", |
| 209 |
"exporters": [ |
| 210 |
{"name": "Hardware-flow", "local_interface": "Loopback99", "template_interval": 3000000}, |
| 211 |
{"name": "Reverse-flow", "local_interface": "Loopback101", "template_interval": 3000000}, |
| 212 |
], |
| 213 |
}, |
| 214 |
] |
| 215 |
}, |
| 216 |
"expected": { |
| 217 |
"result": AntaTestStatus.FAILURE, |
| 218 |
"messages": [ |
| 219 |
"Flow Tracker: FLOW-TRACKER Exporter: CVP-FLOW - Incorrect local interface - Expected: Loopback10 Actual: Loopback0", |
| 220 |
"Flow Tracker: FLOW-TRACKER Exporter: CVP-FLOW - Incorrect template interval - Expected: 3500000 Actual: 3600000", |
| 221 |
"Flow Tracker: HARDWARE-TRACKER Exporter: Hardware-flow - Incorrect local interface - Expected: Loopback99 Actual: Loopback10", |
| 222 |
"Flow Tracker: HARDWARE-TRACKER Exporter: Hardware-flow - Incorrect template interval - Expected: 3000000 Actual: 3600000", |
| 223 |
"Flow Tracker: HARDWARE-TRACKER Exporter: Reverse-flow - Not configured", |
| 224 |
], |
| 225 |
}, |
| 226 |
}, |
| 227 |
(VerifyHardwareFlowTrackerStatus, "failure-all-type"): { |
| 228 |
"eos_data": [ |
| 229 |
{ |
| 230 |
"trackers": { |
| 231 |
"HARDWARE-TRACKER": { |
| 232 |
"active": True, |
| 233 |
"inactiveTimeout": 60000, |
| 234 |
"activeInterval": 300000, |
| 235 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 236 |
}, |
| 237 |
"FLOW-TRIGGER": { |
| 238 |
"active": False, |
| 239 |
"inactiveTimeout": 60000, |
| 240 |
"activeInterval": 300000, |
| 241 |
"exporters": {"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}}, |
| 242 |
}, |
| 243 |
"HARDWARE-FLOW": { |
| 244 |
"active": True, |
| 245 |
"inactiveTimeout": 6000, |
| 246 |
"activeInterval": 30000, |
| 247 |
"exporters": {"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}}, |
| 248 |
}, |
| 249 |
"FLOW-TRACKER2": { |
| 250 |
"active": True, |
| 251 |
"inactiveTimeout": 60000, |
| 252 |
"activeInterval": 300000, |
| 253 |
"exporters": { |
| 254 |
"CV-TELEMETRY": {"localIntf": "Loopback0", "templateInterval": 3600000}, |
| 255 |
"CVP-FLOW": {"localIntf": "Loopback0", "templateInterval": 3600000}, |
| 256 |
}, |
| 257 |
}, |
| 258 |
"HARDWARE-TRACKER2": { |
| 259 |
"active": True, |
| 260 |
"inactiveTimeout": 6000, |
| 261 |
"activeInterval": 30000, |
| 262 |
"exporters": { |
| 263 |
"CVP-TELEMETRY": {"localIntf": "Loopback10", "templateInterval": 3600000}, |
| 264 |
"Hardware-flow": {"localIntf": "Loopback10", "templateInterval": 3600000}, |
| 265 |
}, |
| 266 |
}, |
| 267 |
}, |
| 268 |
"running": True, |
| 269 |
} |
| 270 |
], |
| 271 |
"inputs": { |
| 272 |
"trackers": [ |
| 273 |
{"name": "FLOW-Sample"}, |
| 274 |
{ |
| 275 |
"name": "FLOW-TRIGGER", |
| 276 |
"record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}, |
| 277 |
"exporters": [{"name": "CV-TELEMETRY", "local_interface": "Loopback0", "template_interval": 3600000}], |
| 278 |
}, |
| 279 |
{"name": "HARDWARE-FLOW", "record_export": {"on_inactive_timeout": 60000, "on_interval": 300000}}, |
| 280 |
{ |
| 281 |
"name": "FLOW-TRACKER2", |
| 282 |
"exporters": [ |
| 283 |
{"name": "CV-TELEMETRY", "local_interface": "Loopback0", "template_interval": 3600000}, |
| 284 |
{"name": "CVP-FLOW", "local_interface": "Loopback10", "template_interval": 3500000}, |
| 285 |
], |
| 286 |
}, |
| 287 |
{ |
| 288 |
"name": "HARDWARE-TRACKER2", |
| 289 |
"exporters": [ |
| 290 |
{"name": "Hardware-flow", "local_interface": "Loopback99", "template_interval": 3000000}, |
| 291 |
{"name": "Reverse-flow", "local_interface": "Loopback101", "template_interval": 3000000}, |
| 292 |
], |
| 293 |
}, |
| 294 |
] |
| 295 |
}, |
| 296 |
"expected": { |
| 297 |
"result": AntaTestStatus.FAILURE, |
| 298 |
"messages": [ |
| 299 |
"Flow Tracker: FLOW-Sample - Not found", |
| 300 |
"Flow Tracker: FLOW-TRIGGER - Disabled", |
| 301 |
"Flow Tracker: HARDWARE-FLOW Inactive Timeout: 60000 Active Interval: 300000 - Incorrect timers - Inactive Timeout: 6000 OnActive Interval: 30000", |
| 302 |
"Flow Tracker: FLOW-TRACKER2 Exporter: CVP-FLOW - Incorrect local interface - Expected: Loopback10 Actual: Loopback0", |
| 303 |
"Flow Tracker: FLOW-TRACKER2 Exporter: CVP-FLOW - Incorrect template interval - Expected: 3500000 Actual: 3600000", |
| 304 |
"Flow Tracker: HARDWARE-TRACKER2 Exporter: Hardware-flow - Incorrect local interface - Expected: Loopback99 Actual: Loopback10", |
| 305 |
"Flow Tracker: HARDWARE-TRACKER2 Exporter: Hardware-flow - Incorrect template interval - Expected: 3000000 Actual: 3600000", |
| 306 |
"Flow Tracker: HARDWARE-TRACKER2 Exporter: Reverse-flow - Not configured", |
| 307 |
], |
| 308 |
}, |
| 309 |
}, |
| 310 |
} |