2025-03-17 07:33:45 +01:00
# Copyright (c) 2023-2025 Arista Networks, Inc.
2025-02-05 11:32:35 +01:00
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
2025-02-05 11:38:32 +01:00
""" Test inputs for anta.tests.system. """
2025-02-05 11:32:35 +01:00
from __future__ import annotations
2025-05-15 09:34:27 +02:00
import sys
from typing import TYPE_CHECKING , Any
2025-02-05 11:32:35 +01:00
2025-05-15 09:34:27 +02:00
from anta . models import AntaTest
from anta . result_manager . models import AntaTestStatus
2025-02-05 11:32:35 +01:00
from anta . tests . system import (
VerifyAgentLogs ,
VerifyCoredump ,
VerifyCPUUtilization ,
VerifyFileSystemUtilization ,
2025-03-17 07:33:45 +01:00
VerifyMaintenance ,
2025-02-05 11:32:35 +01:00
VerifyMemoryUtilization ,
VerifyNTP ,
2025-02-05 11:54:23 +01:00
VerifyNTPAssociations ,
2025-02-05 11:32:35 +01:00
VerifyReloadCause ,
VerifyUptime ,
)
2025-02-05 11:54:23 +01:00
from tests . units . anta_tests import test
2025-02-05 11:32:35 +01:00
2025-05-15 09:34:27 +02:00
if TYPE_CHECKING :
from tests . units . anta_tests import AntaUnitTestDataDict
DATA : AntaUnitTestDataDict = {
( VerifyUptime , " success " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " upTime " : 1186689.15 , " loadAvg " : [ 0.13 , 0.12 , 0.09 ] , " users " : 1 , " currentTime " : 1683186659.139859 } ] ,
" inputs " : { " minimum " : 666 } ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyUptime , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " upTime " : 665.15 , " loadAvg " : [ 0.13 , 0.12 , 0.09 ] , " users " : 1 , " currentTime " : 1683186659.139859 } ] ,
" inputs " : { " minimum " : 666 } ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Device uptime is incorrect - Expected: 666s Actual: 665.15s " ] } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyReloadCause , " success-no-reload " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " kernelCrashData " : [ ] , " resetCauses " : [ ] , " full " : False } ] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyReloadCause , " success-valid-cause-user " ) : {
" eos_data " : [
{
" resetCauses " : [
{ " recommendedAction " : " No action necessary. " , " description " : " Reload requested by the user. " , " timestamp " : 1683186892.0 , " debugInfoIsDir " : False }
] ,
" full " : False ,
}
] ,
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
} ,
( VerifyReloadCause , " success-valid-reload-cause-ztp " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
{
" resetCauses " : [
2025-02-05 11:38:32 +01:00
{
2025-05-15 09:34:27 +02:00
" description " : " System reloaded due to Zero Touch Provisioning " ,
" timestamp " : 1729856740.0 ,
2025-02-05 11:38:32 +01:00
" recommendedAction " : " No action necessary. " ,
" debugInfoIsDir " : False ,
2025-05-15 09:34:27 +02:00
}
] ,
" full " : False ,
}
] ,
" inputs " : { " allowed_causes " : [ " ZTP " ] } ,
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
} ,
( VerifyReloadCause , " success-valid-reload-cause-fpga " ) : {
" eos_data " : [
{
" resetCauses " : [
{
" description " : " Reload requested after FPGA upgrade " ,
" timestamp " : 1729856740.0 ,
" recommendedAction " : " No action necessary. " ,
" debugInfoIsDir " : False ,
}
] ,
" full " : False ,
}
] ,
" inputs " : { " allowed_causes " : [ " fpga " ] } ,
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
} ,
( VerifyReloadCause , " failure-invalid-reload-cause " ) : {
" eos_data " : [
{
" resetCauses " : [
{
" description " : " Reload requested after FPGA upgrade " ,
" timestamp " : 1729856740.0 ,
" recommendedAction " : " No action necessary. " ,
" debugInfoIsDir " : False ,
}
2025-02-05 11:32:35 +01:00
] ,
" full " : False ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" inputs " : { " allowed_causes " : [ " ZTP " ] } ,
" expected " : {
" result " : AntaTestStatus . FAILURE ,
" messages " : [ " Invalid reload cause - Expected: ' System reloaded due to Zero Touch Provisioning ' Actual: ' Reload requested after FPGA upgrade ' " ] ,
} ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyReloadCause , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
{
" resetCauses " : [
2025-05-15 09:34:27 +02:00
{ " recommendedAction " : " No action necessary. " , " description " : " Reload after crash. " , " timestamp " : 1683186892.0 , " debugInfoIsDir " : False }
2025-02-05 11:32:35 +01:00
] ,
" full " : False ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : {
" result " : AntaTestStatus . FAILURE ,
" messages " : [ " Invalid reload cause - Expected: ' Reload requested by the user. ' , ' Reload requested after FPGA upgrade ' Actual: ' Reload after crash. ' " ] ,
} ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyCoredump , " success-without-minidump " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " mode " : " compressedDeferred " , " coreFiles " : [ ] } ] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyCoredump , " success-with-minidump " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " mode " : " compressedDeferred " , " coreFiles " : [ " minidump " ] } ] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyCoredump , " failure-without-minidump " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " mode " : " compressedDeferred " , " coreFiles " : [ " core.2344.1584483862.Mlag.gz " , " core.23101.1584483867.Mlag.gz " ] } ] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Core dump(s) have been found: core.2344.1584483862.Mlag.gz, core.23101.1584483867.Mlag.gz " ] } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyCoredump , " failure-with-minidump " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [ { " mode " : " compressedDeferred " , " coreFiles " : [ " minidump " , " core.2344.1584483862.Mlag.gz " , " core.23101.1584483867.Mlag.gz " ] } ] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Core dump(s) have been found: core.2344.1584483862.Mlag.gz, core.23101.1584483867.Mlag.gz " ] } ,
} ,
( VerifyAgentLogs , " success " ) : { " eos_data " : [ " " ] , " expected " : { " result " : AntaTestStatus . SUCCESS } } ,
( VerifyAgentLogs , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
2025-05-15 09:34:27 +02:00
" ===> /var/log/agents/Test-666 Thu May 4 09:57:02 2023 <=== \n CLI Exception: Exception \n CLI Exception: Backtrace \n ===> /var/log/agents/Aaa-855 "
" Fri Jul 7 15:07:00 2023 <=== \n ===== Output from /usr/bin/Aaa [] (PID=855) started Jul 7 15:06:11.606414 === \n "
" EntityManager::doBackoff waiting for remote sysdb version ....ok \n \n ===> /var/log/agents/Acl-830 "
" Fri Jul 7 15:07:00 2023 <=== \n ===== Output from /usr/bin/Acl [] (PID=830) started Jul 7 15:06:10.871700 === \n "
" EntityManager::doBackoff waiting for remote sysdb version ...................ok \n "
2025-02-05 11:32:35 +01:00
] ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-02-05 11:32:35 +01:00
" messages " : [
2025-05-15 09:34:27 +02:00
" Device has reported agent crashes: \n * /var/log/agents/Test-666 Thu May 4 09:57:02 2023 \n "
" * /var/log/agents/Aaa-855 Fri Jul 7 15:07:00 2023 \n * /var/log/agents/Acl-830 Fri Jul 7 15:07:00 2023 "
2025-02-05 11:32:35 +01:00
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyCPUUtilization , " success " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
{
" cpuInfo " : { " % Cpu(s) " : { " idle " : 88.2 , " stolen " : 0.0 , " user " : 5.9 , " swIrq " : 0.0 , " ioWait " : 0.0 , " system " : 0.0 , " hwIrq " : 5.9 , " nice " : 0.0 } } ,
" processes " : {
" 1 " : {
" userName " : " root " ,
" status " : " S " ,
" memPct " : 0.3 ,
" niceValue " : 0 ,
" cpuPct " : 0.0 ,
" cpuPctType " : " {:.1f} " ,
" cmd " : " systemd " ,
" residentMem " : " 5096 " ,
" priority " : " 20 " ,
" activeTime " : 360 ,
" virtMem " : " 6644 " ,
" sharedMem " : " 3996 " ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyCPUUtilization , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
{
" cpuInfo " : { " % Cpu(s) " : { " idle " : 24.8 , " stolen " : 0.0 , " user " : 5.9 , " swIrq " : 0.0 , " ioWait " : 0.0 , " system " : 0.0 , " hwIrq " : 5.9 , " nice " : 0.0 } } ,
" processes " : {
" 1 " : {
" userName " : " root " ,
" status " : " S " ,
" memPct " : 0.3 ,
" niceValue " : 0 ,
" cpuPct " : 0.0 ,
" cpuPctType " : " {:.1f} " ,
" cmd " : " systemd " ,
" residentMem " : " 5096 " ,
" priority " : " 20 " ,
" activeTime " : 360 ,
" virtMem " : " 6644 " ,
" sharedMem " : " 3996 " ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
}
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Device has reported a high CPU utilization - Expected: < 75 % Actual: 75.2 % " ] } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMemoryUtilization , " success " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
2025-05-15 09:34:27 +02:00
{ " uptime " : 1994.67 , " modelName " : " vEOS-lab " , " internalVersion " : " 4.27.3F-26379303.4273F " , " memTotal " : 2004568 , " memFree " : 879004 , " version " : " 4.27.3F " }
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMemoryUtilization , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
2025-05-15 09:34:27 +02:00
{ " uptime " : 1994.67 , " modelName " : " vEOS-lab " , " internalVersion " : " 4.27.3F-26379303.4273F " , " memTotal " : 2004568 , " memFree " : 89004 , " version " : " 4.27.3F " }
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Device has reported a high memory usage - Expected: < 75 % Actual: 95.56 % " ] } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyFileSystemUtilization , " success " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
2025-05-15 09:34:27 +02:00
" Filesystem Size Used Avail Use % Mounted on \n /dev/sda2 3.9G 988M 2.9G 26 % /mnt/flash \n none 294M 78M 217M 27 % / \n "
" none 294M 78M 217M 27 % /.overlay \n /dev/loop0 461M 461M 0 100 % /rootfs-i386 \n "
2025-02-05 11:32:35 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyFileSystemUtilization , " failure " ) : {
2025-02-05 11:32:35 +01:00
" eos_data " : [
2025-05-15 09:34:27 +02:00
" Filesystem Size Used Avail Use % Mounted on \n /dev/sda2 3.9G 988M 2.9G 84 % /mnt/flash \n none 294M 78M 217M 27 % / \n "
" none 294M 78M 217M 84 % /.overlay \n /dev/loop0 461M 461M 0 100 % /rootfs-i386 \n "
2025-02-05 11:32:35 +01:00
] ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-02-05 11:32:35 +01:00
" messages " : [
2025-03-17 07:33:45 +01:00
" Mount point: /dev/sda2 3.9G 988M 2.9G 84 % /mnt/flash - Higher disk space utilization - Expected: 75 % Actual: 84 % " ,
" Mount point: none 294M 78M 217M 84 % /.overlay - Higher disk space utilization - Expected: 75 % Actual: 84 % " ,
2025-02-05 11:32:35 +01:00
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTP , " success " ) : { " eos_data " : [ " synchronised \n poll interval unknown \n " ] , " expected " : { " result " : AntaTestStatus . SUCCESS } } ,
( VerifyNTP , " failure " ) : {
" eos_data " : [ " unsynchronised \n poll interval unknown \n " ] ,
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " NTP status mismatch - Expected: synchronised Actual: unsynchronised " ] } ,
2025-02-05 11:32:35 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " success " ) : {
2025-02-05 11:54:23 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.1.1.1 " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" 2.2.2.2 " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" 3.3.3.3 " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-02-05 11:54:23 +01:00
}
}
] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 2 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 2 } ,
]
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:54:23 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " success-pool-name " ) : {
2025-02-05 11:54:23 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.ntp.networks.com " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" 2.ntp.networks.com " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" 3.ntp.networks.com " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-02-05 11:54:23 +01:00
}
}
] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.ntp.networks.com " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.ntp.networks.com " , " stratum " : 2 } ,
{ " server_address " : " 3.ntp.networks.com " , " stratum " : 2 } ,
]
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:54:23 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " success-ntp-pool-as-input " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.1.1.1 " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" 2.2.2.2 " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" 3.3.3.3 " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-03-17 07:33:45 +01:00
}
}
] ,
" inputs " : { " ntp_pool " : { " server_addresses " : [ " 1.1.1.1 " , " 2.2.2.2 " , " 3.3.3.3 " ] , " preferred_stratum_range " : [ 1 , 2 ] } } ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " success-ntp-pool-hostname " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" itsys-ntp010p.aristanetworks.com " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" itsys-ntp011p.aristanetworks.com " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" itsys-ntp012p.aristanetworks.com " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-03-17 07:33:45 +01:00
}
}
] ,
" inputs " : {
" ntp_pool " : {
" server_addresses " : [ " itsys-ntp010p.aristanetworks.com " , " itsys-ntp011p.aristanetworks.com " , " itsys-ntp012p.aristanetworks.com " ] ,
" preferred_stratum_range " : [ 1 , 2 ] ,
}
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " success-ip-dns " ) : {
2025-02-05 11:55:09 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.1.1.1 (1.ntp.networks.com) " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" 2.2.2.2 (2.ntp.networks.com) " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" 3.3.3.3 (3.ntp.networks.com) " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-02-05 11:55:09 +01:00
}
}
] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 2 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 2 } ,
]
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-02-05 11:55:09 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-ntp-server " ) : {
2025-02-05 11:54:23 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.1.1.1 " : { " condition " : " candidate " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 2 } ,
" 2.2.2.2 " : { " condition " : " sys.peer " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" 3.3.3.3 " : { " condition " : " sys.peer " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 3 } ,
2025-02-05 11:54:23 +01:00
}
}
] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 2 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 2 } ,
]
} ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-02-05 11:54:23 +01:00
" messages " : [
2025-03-17 07:33:45 +01:00
" NTP Server: 1.1.1.1 Preferred: True Stratum: 1 - Incorrect condition - Expected: sys.peer Actual: candidate " ,
" NTP Server: 1.1.1.1 Preferred: True Stratum: 1 - Incorrect stratum level - Expected: 1 Actual: 2 " ,
" NTP Server: 2.2.2.2 Preferred: False Stratum: 2 - Incorrect condition - Expected: candidate Actual: sys.peer " ,
" NTP Server: 3.3.3.3 Preferred: False Stratum: 2 - Incorrect condition - Expected: candidate Actual: sys.peer " ,
" NTP Server: 3.3.3.3 Preferred: False Stratum: 2 - Incorrect stratum level - Expected: 2 Actual: 3 " ,
2025-02-05 11:54:23 +01:00
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-no-peers " ) : {
2025-02-05 11:54:23 +01:00
" eos_data " : [ { " peers " : { } } ] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 1 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 1 } ,
]
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " No NTP peers configured " ] } ,
2025-02-05 11:54:23 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-one-peer-not-found " ) : {
2025-02-05 11:54:23 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" 1.1.1.1 " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" 2.2.2.2 " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 1 } ,
2025-02-05 11:54:23 +01:00
}
}
] ,
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 1 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 1 } ,
]
} ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " NTP Server: 3.3.3.3 Preferred: False Stratum: 1 - Not configured " ] } ,
2025-02-05 11:54:23 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-with-two-peers-not-found " ) : {
" eos_data " : [ { " peers " : { " 1.1.1.1 " : { " condition " : " candidate " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } } } ] ,
2025-02-05 11:54:23 +01:00
" inputs " : {
" ntp_servers " : [
{ " server_address " : " 1.1.1.1 " , " preferred " : True , " stratum " : 1 } ,
{ " server_address " : " 2.2.2.2 " , " stratum " : 1 } ,
{ " server_address " : " 3.3.3.3 " , " stratum " : 1 } ,
]
} ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-02-05 11:54:23 +01:00
" messages " : [
2025-03-17 07:33:45 +01:00
" NTP Server: 1.1.1.1 Preferred: True Stratum: 1 - Incorrect condition - Expected: sys.peer Actual: candidate " ,
" NTP Server: 2.2.2.2 Preferred: False Stratum: 1 - Not configured " ,
" NTP Server: 3.3.3.3 Preferred: False Stratum: 1 - Not configured " ,
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-ntp-pool-as-input " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" ntp1.pool " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" ntp2.pool " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" ntp3.pool " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-03-17 07:33:45 +01:00
}
}
] ,
" inputs " : { " ntp_pool " : { " server_addresses " : [ " 1.1.1.1 " , " 2.2.2.2 " ] , " preferred_stratum_range " : [ 1 , 2 ] } } ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " NTP Server: 3.3.3.3 Hostname: ntp3.pool - Associated but not part of the provided NTP pool " ] } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-ntp-pool-as-input-bad-association " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" ntp1.pool " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 1 } ,
" ntp2.pool " : { " condition " : " candidate " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 2 } ,
" ntp3.pool " : { " condition " : " reject " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 3 } ,
2025-03-17 07:33:45 +01:00
}
}
] ,
" inputs " : { " ntp_pool " : { " server_addresses " : [ " 1.1.1.1 " , " 2.2.2.2 " , " 3.3.3.3 " ] , " preferred_stratum_range " : [ 1 , 2 ] } } ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-03-17 07:33:45 +01:00
" messages " : [
" NTP Server: 3.3.3.3 Hostname: ntp3.pool - Incorrect condition - Expected: sys.peer, candidate Actual: reject " ,
" NTP Server: 3.3.3.3 Hostname: ntp3.pool - Incorrect stratum level - Expected Stratum Range: 1 to 2 Actual: 3 " ,
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyNTPAssociations , " failure-ntp-pool-hostname " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" peers " : {
2025-05-15 09:34:27 +02:00
" itsys-ntp010p.aristanetworks.com " : { " condition " : " sys.peer " , " peerIpAddr " : " 1.1.1.1 " , " stratumLevel " : 5 } ,
" itsys-ntp011p.aristanetworks.com " : { " condition " : " reject " , " peerIpAddr " : " 2.2.2.2 " , " stratumLevel " : 4 } ,
" itsys-ntp012p.aristanetworks.com " : { " condition " : " candidate " , " peerIpAddr " : " 3.3.3.3 " , " stratumLevel " : 2 } ,
2025-03-17 07:33:45 +01:00
}
}
] ,
" inputs " : { " ntp_pool " : { " server_addresses " : [ " itsys-ntp010p.aristanetworks.com " , " itsys-ntp011p.aristanetworks.com " ] , " preferred_stratum_range " : [ 1 , 2 ] } } ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
2025-03-17 07:33:45 +01:00
" messages " : [
" NTP Server: 1.1.1.1 Hostname: itsys-ntp010p.aristanetworks.com - Incorrect stratum level - Expected Stratum Range: 1 to 2 Actual: 5 " ,
" NTP Server: 2.2.2.2 Hostname: itsys-ntp011p.aristanetworks.com - Incorrect condition - Expected: sys.peer, candidate Actual: reject " ,
" NTP Server: 2.2.2.2 Hostname: itsys-ntp011p.aristanetworks.com - Incorrect stratum level - Expected Stratum Range: 1 to 2 Actual: 4 " ,
" NTP Server: 3.3.3.3 Hostname: itsys-ntp012p.aristanetworks.com - Associated but not part of the provided NTP pool " ,
] ,
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " success-no-maintenance-configured " ) : {
" eos_data " : [ { " units " : { } , " interfaces " : { } , " vrfs " : { } , " warnings " : [ " Maintenance Mode is disabled. " ] } ] ,
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " success-maintenance-configured-but-not-enabled " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" System " : {
" state " : " active " ,
" adminState " : " active " ,
" stateChangeTime " : 0.0 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
}
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " success-multiple-units-but-not-enabled " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" mlag " : {
" state " : " active " ,
" adminState " : " active " ,
" stateChangeTime " : 0.0 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
" System " : {
" state " : " active " ,
" adminState " : " active " ,
" stateChangeTime " : 0.0 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . SUCCESS } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " failure-maintenance-enabled " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" mlag " : {
" state " : " underMaintenance " ,
" adminState " : " underMaintenance " ,
" stateChangeTime " : 1741257120.9532886 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
" System " : {
" state " : " active " ,
" adminState " : " active " ,
" stateChangeTime " : 0.0 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
2025-05-15 09:34:27 +02:00
" expected " : { " result " : AntaTestStatus . FAILURE , " messages " : [ " Units under maintenance: ' mlag ' " , " Possible causes: ' Quiesce is configured ' " ] } ,
2025-03-17 07:33:45 +01:00
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " failure-multiple-reasons " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" mlag " : {
" state " : " underMaintenance " ,
" adminState " : " underMaintenance " ,
" stateChangeTime " : 1741257120.9532895 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
" System " : {
" state " : " maintenanceModeEnter " ,
" adminState " : " underMaintenance " ,
" stateChangeTime " : 1741257669.7231765 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
} ,
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
" messages " : [ " Units under maintenance: ' mlag ' " , " Units entering maintenance: ' System ' " , " Possible causes: ' Quiesce is configured ' " ] ,
2025-03-17 07:33:45 +01:00
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " failure-onboot-maintenance " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" System " : {
" state " : " underMaintenance " ,
" adminState " : " underMaintenance " ,
" stateChangeTime " : 1741258774.3756502 ,
" onBootMaintenance " : True ,
" intfsViolatingTrafficThreshold " : False ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
}
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
" messages " : [ " Units under maintenance: ' System ' " , " Possible causes: ' On-boot maintenance is configured, Quiesce is configured ' " ] ,
2025-03-17 07:33:45 +01:00
} ,
} ,
2025-05-15 09:34:27 +02:00
( VerifyMaintenance , " failure-entering-maintenance-interface-violation " ) : {
2025-03-17 07:33:45 +01:00
" eos_data " : [
{
" units " : {
" System " : {
" state " : " maintenanceModeEnter " ,
" adminState " : " underMaintenance " ,
" stateChangeTime " : 1741257669.7231765 ,
" onBootMaintenance " : False ,
" intfsViolatingTrafficThreshold " : True ,
" aggInBpsRate " : 0 ,
" aggOutBpsRate " : 0 ,
}
} ,
" interfaces " : { } ,
" vrfs " : { } ,
2025-05-15 09:34:27 +02:00
}
2025-03-17 07:33:45 +01:00
] ,
" expected " : {
2025-05-15 09:34:27 +02:00
" result " : AntaTestStatus . FAILURE ,
" messages " : [ " Units entering maintenance: ' System ' " , " Possible causes: ' Interface traffic threshold violation, Quiesce is configured ' " ] ,
2025-02-05 11:54:23 +01:00
} ,
} ,
2025-05-15 09:34:27 +02:00
}