Debian Codegraph @

tests/units/anta_tests/test_software.py

raw symbols SCIP
1 # Copyright (c) 2023-2026 Arista Networks, Inc.
2 # Use of this source code is governed by the Apache License 2.0
3 # that can be found in the LICENSE file.
4 """Test inputs for anta.tests.hardware."""
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.software import VerifyEOSExtensions, VerifyEOSVersion, VerifyTerminAttrVersion
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 (VerifyEOSVersion, "success"): {
21 "eos_data": [{"modelName": "vEOS-lab", "internalVersion": "4.27.0F-24305004.4270F", "version": "4.27.0F"}],
22 "inputs": {"versions": ["4.27.0F", "4.28.0F"]},
23 "expected": {"result": AntaTestStatus.SUCCESS},
24 },
25 (VerifyEOSVersion, "failure"): {
26 "eos_data": [{"modelName": "vEOS-lab", "internalVersion": "4.27.0F-24305004.4270F", "version": "4.27.0F"}],
27 "inputs": {"versions": ["4.27.1F"]},
28 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["EOS version mismatch - Actual: 4.27.0F not in Expected: 4.27.1F"]},
29 },
30 (VerifyTerminAttrVersion, "success"): {
31 "eos_data": [
32 {
33 "imageFormatVersion": "1.0",
34 "uptime": 1107543.52,
35 "modelName": "vEOS-lab",
36 "details": {
37 "deviations": [],
38 "components": [{"name": "Aboot", "version": "Aboot-veos-8.0.0-3255441"}],
39 "switchType": "fixedSystem",
40 "packages": {"TerminAttr-core": {"release": "1", "version": "v1.17.0"}},
41 },
42 }
43 ],
44 "inputs": {"versions": ["v1.17.0", "v1.18.1"]},
45 "expected": {"result": AntaTestStatus.SUCCESS},
46 },
47 (VerifyTerminAttrVersion, "failure"): {
48 "eos_data": [
49 {
50 "imageFormatVersion": "1.0",
51 "uptime": 1107543.52,
52 "modelName": "vEOS-lab",
53 "details": {
54 "deviations": [],
55 "components": [{"name": "Aboot", "version": "Aboot-veos-8.0.0-3255441"}],
56 "switchType": "fixedSystem",
57 "packages": {"TerminAttr-core": {"release": "1", "version": "v1.17.0"}},
58 },
59 }
60 ],
61 "inputs": {"versions": ["v1.17.1", "v1.18.1"]},
62 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["TerminAttr version mismatch - Actual: v1.17.0 not in Expected: v1.17.1, v1.18.1"]},
63 },
64 (VerifyEOSExtensions, "success-no-extensions"): {
65 "eos_data": [{"extensions": {}, "extensionStoredDir": "flash:", "warnings": ["No extensions are available"]}, {"extensions": []}],
66 "expected": {"result": AntaTestStatus.SUCCESS},
67 },
68 (VerifyEOSExtensions, "success-extensions"): {
69 "eos_data": [
70 {
71 "extensions": {
72 "AristaCloudGateway-1.0.1-1.swix": {
73 "version": "1.0.1",
74 "release": "1",
75 "presence": "present",
76 "status": "installed",
77 "boot": True,
78 "numPackages": 1,
79 "error": False,
80 "vendor": "",
81 "summary": "Arista Cloud Connect",
82 "installedSize": 60532424,
83 "packages": {"AristaCloudGateway-1.0.1-1.x86_64.rpm": {"version": "1.0.1", "release": "1"}},
84 "description": "An extension for Arista Cloud Connect gateway",
85 "affectedAgents": [],
86 "agentsToRestart": [],
87 }
88 }
89 },
90 {"extensions": ["AristaCloudGateway-1.0.1-1.swix"]},
91 ],
92 "expected": {"result": AntaTestStatus.SUCCESS},
93 },
94 (VerifyEOSExtensions, "failure"): {
95 "eos_data": [
96 {
97 "extensions": {
98 "AristaCloudGateway-1.0.1-1.swix": {
99 "version": "1.0.1",
100 "release": "1",
101 "presence": "present",
102 "status": "installed",
103 "boot": False,
104 "numPackages": 1,
105 "error": False,
106 "vendor": "",
107 "summary": "Arista Cloud Connect",
108 "installedSize": 60532424,
109 "packages": {"AristaCloudGateway-1.0.1-1.x86_64.rpm": {"version": "1.0.1", "release": "1"}},
110 "description": "An extension for Arista Cloud Connect gateway",
111 "affectedAgents": [],
112 "agentsToRestart": [],
113 }
114 }
115 },
116 {"extensions": []},
117 ],
118 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["EOS extensions mismatch - Installed: AristaCloudGateway-1.0.1-1.swix Configured: Not found"]},
119 },
120 (VerifyEOSExtensions, "failure-multiple-extensions"): {
121 "eos_data": [
122 {
123 "extensions": {
124 "AristaCloudGateway-1.0.1-1.swix": {
125 "version": "1.0.1",
126 "release": "1",
127 "presence": "present",
128 "status": "installed",
129 "boot": False,
130 "numPackages": 1,
131 "error": False,
132 "vendor": "",
133 "summary": "Arista Cloud Connect",
134 "installedSize": 60532424,
135 "packages": {"AristaCloudGateway-1.0.1-1.x86_64.rpm": {"version": "1.0.1", "release": "1"}},
136 "description": "An extension for Arista Cloud Connect gateway",
137 "affectedAgents": [],
138 "agentsToRestart": [],
139 },
140 "EOS-4.33.0F-NDRSensor.swix": {
141 "version": "4.33.0",
142 "release": "39050855.4330F",
143 "presence": "present",
144 "status": "notInstalled",
145 "boot": True,
146 "numPackages": 9,
147 "error": False,
148 "statusDetail": "No RPMs are compatible with current EOS version.",
149 "vendor": "",
150 "summary": "NDR sensor",
151 "installedSize": 0,
152 "packages": {},
153 "description": "NDR sensor provides libraries to generate flow activity records using DPI\nmetadata and IPFIX flow records.",
154 "affectedAgents": [],
155 "agentsToRestart": [],
156 },
157 }
158 },
159 {"extensions": ["AristaCloudGateway-1.0.1-1.swix", "EOS-4.33.0F-NDRSensor.swix"]},
160 ],
161 "expected": {
162 "result": AntaTestStatus.FAILURE,
163 "messages": [
164 "EOS extensions mismatch - Installed: AristaCloudGateway-1.0.1-1.swix Configured: AristaCloudGateway-1.0.1-1.swix, EOS-4.33.0F-NDRSensor.swix"
165 ],
166 },
167 },
168 }