| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Data for testing anta.tests.ptp.""" |
| 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.ptp import VerifyPtpGMStatus, VerifyPtpLockStatus, VerifyPtpModeStatus, VerifyPtpOffset, VerifyPtpPortModeStatus |
| 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 |
(VerifyPtpModeStatus, "success"): { |
| 21 |
"eos_data": [ |
| 22 |
{ |
| 23 |
"ptpMode": "ptpBoundaryClock", |
| 24 |
"ptpProfile": "ptpDefaultProfile", |
| 25 |
"ptpClockSummary": { |
| 26 |
"clockIdentity": "0xcc:1a:a3:ff:ff:c3:bf:eb", |
| 27 |
"gmClockIdentity": "0x00:00:00:00:00:00:00:00", |
| 28 |
"numberOfSlavePorts": 0, |
| 29 |
"numberOfMasterPorts": 0, |
| 30 |
"offsetFromMaster": 0, |
| 31 |
"meanPathDelay": 0, |
| 32 |
"stepsRemoved": 0, |
| 33 |
"skew": 1.0, |
| 34 |
}, |
| 35 |
"ptpIntfSummaries": {}, |
| 36 |
} |
| 37 |
], |
| 38 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 39 |
}, |
| 40 |
(VerifyPtpModeStatus, "failure"): { |
| 41 |
"eos_data": [{"ptpMode": "ptpDisabled", "ptpIntfSummaries": {}}], |
| 42 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Not configured as a PTP Boundary Clock - Actual: ptpDisabled"]}, |
| 43 |
}, |
| 44 |
(VerifyPtpModeStatus, "skipped"): { |
| 45 |
"eos_data": [{"ptpIntfSummaries": {}}], |
| 46 |
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["PTP is not configured"]}, |
| 47 |
}, |
| 48 |
(VerifyPtpGMStatus, "success"): { |
| 49 |
"eos_data": [ |
| 50 |
{ |
| 51 |
"ptpMode": "ptpBoundaryClock", |
| 52 |
"ptpProfile": "ptpDefaultProfile", |
| 53 |
"ptpClockSummary": { |
| 54 |
"clockIdentity": "0x00:1c:73:ff:ff:14:00:01", |
| 55 |
"gmClockIdentity": "0xec:46:70:ff:fe:00:ff:a8", |
| 56 |
"numberOfSlavePorts": 1, |
| 57 |
"numberOfMasterPorts": 8, |
| 58 |
"slavePort": "Ethernet27/1", |
| 59 |
"slaveVlanId": 0, |
| 60 |
"offsetFromMaster": -11, |
| 61 |
"meanPathDelay": 105, |
| 62 |
"stepsRemoved": 2, |
| 63 |
"skew": 1.0000015265007687, |
| 64 |
"lastSyncTime": 1708599750, |
| 65 |
"currentPtpSystemTime": 1708599750, |
| 66 |
}, |
| 67 |
} |
| 68 |
], |
| 69 |
"inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, |
| 70 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 71 |
}, |
| 72 |
(VerifyPtpGMStatus, "failure"): { |
| 73 |
"eos_data": [ |
| 74 |
{ |
| 75 |
"ptpMode": "ptpBoundaryClock", |
| 76 |
"ptpProfile": "ptpDefaultProfile", |
| 77 |
"ptpClockSummary": { |
| 78 |
"clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 79 |
"gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 80 |
"numberOfSlavePorts": 0, |
| 81 |
"numberOfMasterPorts": 4, |
| 82 |
"offsetFromMaster": 3, |
| 83 |
"meanPathDelay": 496, |
| 84 |
"stepsRemoved": 0, |
| 85 |
"skew": 1.0000074628720317, |
| 86 |
"lastSyncTime": 1708600129, |
| 87 |
"currentPtpSystemTime": 1708600153, |
| 88 |
}, |
| 89 |
} |
| 90 |
], |
| 91 |
"inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, |
| 92 |
"expected": { |
| 93 |
"result": AntaTestStatus.FAILURE, |
| 94 |
"messages": ["The device is locked to the incorrect Grandmaster - Expected: 0xec:46:70:ff:fe:00:ff:a8 Actual: 0x00:1c:73:ff:ff:0a:00:01"], |
| 95 |
}, |
| 96 |
}, |
| 97 |
(VerifyPtpGMStatus, "skipped"): { |
| 98 |
"eos_data": [{"ptpIntfSummaries": {}}], |
| 99 |
"inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, |
| 100 |
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["PTP is not configured"]}, |
| 101 |
}, |
| 102 |
(VerifyPtpLockStatus, "success"): { |
| 103 |
"eos_data": [ |
| 104 |
{ |
| 105 |
"ptpMode": "ptpBoundaryClock", |
| 106 |
"ptpProfile": "ptpDefaultProfile", |
| 107 |
"ptpClockSummary": { |
| 108 |
"clockIdentity": "0x00:1c:73:ff:ff:14:00:01", |
| 109 |
"gmClockIdentity": "0xec:46:70:ff:fe:00:ff:a8", |
| 110 |
"numberOfSlavePorts": 1, |
| 111 |
"numberOfMasterPorts": 8, |
| 112 |
"slavePort": "Ethernet27/1", |
| 113 |
"slaveVlanId": 0, |
| 114 |
"offsetFromMaster": -11, |
| 115 |
"meanPathDelay": 105, |
| 116 |
"stepsRemoved": 2, |
| 117 |
"skew": 1.0000015265007687, |
| 118 |
"lastSyncTime": 1708599750, |
| 119 |
"currentPtpSystemTime": 1708599750, |
| 120 |
}, |
| 121 |
} |
| 122 |
], |
| 123 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 124 |
}, |
| 125 |
(VerifyPtpLockStatus, "failure"): { |
| 126 |
"eos_data": [ |
| 127 |
{ |
| 128 |
"ptpMode": "ptpBoundaryClock", |
| 129 |
"ptpProfile": "ptpDefaultProfile", |
| 130 |
"ptpClockSummary": { |
| 131 |
"clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 132 |
"gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 133 |
"numberOfSlavePorts": 0, |
| 134 |
"numberOfMasterPorts": 4, |
| 135 |
"offsetFromMaster": 3, |
| 136 |
"meanPathDelay": 496, |
| 137 |
"stepsRemoved": 0, |
| 138 |
"skew": 1.0000074628720317, |
| 139 |
"lastSyncTime": 1708600129, |
| 140 |
"currentPtpSystemTime": 1708600286, |
| 141 |
}, |
| 142 |
} |
| 143 |
], |
| 144 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Lock is more than 60s old - Actual: 157s"]}, |
| 145 |
}, |
| 146 |
(VerifyPtpLockStatus, "skipped"): { |
| 147 |
"eos_data": [{"ptpIntfSummaries": {}}], |
| 148 |
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["PTP is not configured"]}, |
| 149 |
}, |
| 150 |
(VerifyPtpOffset, "success"): { |
| 151 |
"eos_data": [ |
| 152 |
{ |
| 153 |
"monitorEnabled": True, |
| 154 |
"ptpMode": "ptpBoundaryClock", |
| 155 |
"offsetFromMasterThreshold": 250, |
| 156 |
"meanPathDelayThreshold": 1500, |
| 157 |
"ptpMonitorData": [ |
| 158 |
{ |
| 159 |
"intf": "Ethernet27/1", |
| 160 |
"realLastSyncTime": 1708599815611398400, |
| 161 |
"lastSyncSeqId": 44413, |
| 162 |
"offsetFromMaster": 2, |
| 163 |
"meanPathDelay": 105, |
| 164 |
"skew": 1.000001614, |
| 165 |
}, |
| 166 |
{ |
| 167 |
"intf": "Ethernet27/1", |
| 168 |
"realLastSyncTime": 1708599815486101500, |
| 169 |
"lastSyncSeqId": 44412, |
| 170 |
"offsetFromMaster": -13, |
| 171 |
"meanPathDelay": 105, |
| 172 |
"skew": 1.000001614, |
| 173 |
}, |
| 174 |
], |
| 175 |
} |
| 176 |
], |
| 177 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 178 |
}, |
| 179 |
(VerifyPtpOffset, "failure"): { |
| 180 |
"eos_data": [ |
| 181 |
{ |
| 182 |
"monitorEnabled": True, |
| 183 |
"ptpMode": "ptpBoundaryClock", |
| 184 |
"offsetFromMasterThreshold": 250, |
| 185 |
"meanPathDelayThreshold": 1500, |
| 186 |
"ptpMonitorData": [ |
| 187 |
{ |
| 188 |
"intf": "Ethernet27/1", |
| 189 |
"realLastSyncTime": 1708599815611398400, |
| 190 |
"lastSyncSeqId": 44413, |
| 191 |
"offsetFromMaster": 1200, |
| 192 |
"meanPathDelay": 105, |
| 193 |
"skew": 1.000001614, |
| 194 |
}, |
| 195 |
{ |
| 196 |
"intf": "Ethernet27/1", |
| 197 |
"realLastSyncTime": 1708599815486101500, |
| 198 |
"lastSyncSeqId": 44412, |
| 199 |
"offsetFromMaster": -1300, |
| 200 |
"meanPathDelay": 105, |
| 201 |
"skew": 1.000001614, |
| 202 |
}, |
| 203 |
], |
| 204 |
} |
| 205 |
], |
| 206 |
"expected": { |
| 207 |
"result": AntaTestStatus.FAILURE, |
| 208 |
"messages": ["Interface: Ethernet27/1 - Timing offset from master is greater than +/- 1000ns: Actual: 1200, -1300"], |
| 209 |
}, |
| 210 |
}, |
| 211 |
(VerifyPtpOffset, "skipped"): { |
| 212 |
"eos_data": [{"monitorEnabled": True, "ptpMonitorData": []}], |
| 213 |
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["PTP is not configured"]}, |
| 214 |
}, |
| 215 |
(VerifyPtpPortModeStatus, "success"): { |
| 216 |
"eos_data": [ |
| 217 |
{ |
| 218 |
"ptpMode": "ptpBoundaryClock", |
| 219 |
"ptpProfile": "ptpDefaultProfile", |
| 220 |
"ptpClockSummary": { |
| 221 |
"clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 222 |
"gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 223 |
"numberOfSlavePorts": 0, |
| 224 |
"numberOfMasterPorts": 4, |
| 225 |
"offsetFromMaster": 0, |
| 226 |
"meanPathDelay": 0, |
| 227 |
"stepsRemoved": 0, |
| 228 |
"skew": 1.0, |
| 229 |
}, |
| 230 |
"ptpIntfSummaries": { |
| 231 |
"Ethernet53": { |
| 232 |
"interface": "Ethernet53", |
| 233 |
"ptpIntfVlanSummaries": [ |
| 234 |
{ |
| 235 |
"vlanId": 0, |
| 236 |
"portState": "psDisabled", |
| 237 |
"delayMechanism": "e2e", |
| 238 |
"transportMode": "ipv4", |
| 239 |
"mpassEnabled": False, |
| 240 |
"mpassStatus": "active", |
| 241 |
} |
| 242 |
], |
| 243 |
}, |
| 244 |
"Ethernet1": { |
| 245 |
"interface": "Ethernet1", |
| 246 |
"ptpIntfVlanSummaries": [ |
| 247 |
{"vlanId": 0, "portState": "psMaster", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} |
| 248 |
], |
| 249 |
}, |
| 250 |
}, |
| 251 |
} |
| 252 |
], |
| 253 |
"expected": {"result": AntaTestStatus.SUCCESS}, |
| 254 |
}, |
| 255 |
(VerifyPtpPortModeStatus, "failure-no-interfaces"): { |
| 256 |
"eos_data": [{"ptpIntfSummaries": {}}], |
| 257 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["No interfaces are PTP enabled"]}, |
| 258 |
}, |
| 259 |
(VerifyPtpPortModeStatus, "failure-invalid-state"): { |
| 260 |
"eos_data": [ |
| 261 |
{ |
| 262 |
"ptpMode": "ptpBoundaryClock", |
| 263 |
"ptpProfile": "ptpDefaultProfile", |
| 264 |
"ptpClockSummary": { |
| 265 |
"clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 266 |
"gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", |
| 267 |
"numberOfSlavePorts": 0, |
| 268 |
"numberOfMasterPorts": 4, |
| 269 |
"offsetFromMaster": 0, |
| 270 |
"meanPathDelay": 0, |
| 271 |
"stepsRemoved": 0, |
| 272 |
"skew": 1.0, |
| 273 |
}, |
| 274 |
"ptpIntfSummaries": { |
| 275 |
"Ethernet53": { |
| 276 |
"interface": "Ethernet53", |
| 277 |
"ptpIntfVlanSummaries": [ |
| 278 |
{"vlanId": 0, "portState": "none", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} |
| 279 |
], |
| 280 |
}, |
| 281 |
"Ethernet1": { |
| 282 |
"interface": "Ethernet1", |
| 283 |
"ptpIntfVlanSummaries": [ |
| 284 |
{"vlanId": 0, "portState": "none", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} |
| 285 |
], |
| 286 |
}, |
| 287 |
}, |
| 288 |
} |
| 289 |
], |
| 290 |
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["The following interface(s) are not in a valid PTP state: Ethernet53, Ethernet1"]}, |
| 291 |
}, |
| 292 |
} |