master
go 295 lines 9.26 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 //go:build snmp_topology_fixtures
4
5 package parity
6
7 import (
8 "testing"
9
10 "github.com/stretchr/testify/require"
11 )
12
13 func TestValidateGoldenCache(t *testing.T) {
14 manifest, err := LoadManifest("../../../testdata/snmp/enlinkd/nms8003/manifest.yaml")
15 require.NoError(t, err)
16
17 scenario, ok := manifest.FindScenario("nms8003_lldp")
18 require.True(t, ok)
19
20 resolved, err := ResolveScenario("../../../testdata/snmp/enlinkd/nms8003/manifest.yaml", scenario)
21 require.NoError(t, err)
22
23 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
24 }
25
26 func TestValidateGoldenCache_NMS8000(t *testing.T) {
27 manifestPath := "../../../testdata/snmp/enlinkd/nms8000/manifest.yaml"
28 manifest, err := LoadManifest(manifestPath)
29 require.NoError(t, err)
30
31 scenarios := []string{"nms8000_cdp", "nms8000_lldp"}
32 for _, scenarioID := range scenarios {
33 scenario, ok := manifest.FindScenario(scenarioID)
34 require.True(t, ok)
35
36 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
37 require.NoError(t, resolveErr)
38 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
39 }
40 }
41
42 func TestValidateGoldenCache_NMS13637(t *testing.T) {
43 manifestPath := "../../../testdata/snmp/enlinkd/nms13637/manifest.yaml"
44 manifest, err := LoadManifest(manifestPath)
45 require.NoError(t, err)
46
47 scenario, ok := manifest.FindScenario("nms13637_lldp")
48 require.True(t, ok)
49
50 resolved, err := ResolveScenario(manifestPath, scenario)
51 require.NoError(t, err)
52 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
53 }
54
55 func TestValidateGoldenCache_NMS10205B(t *testing.T) {
56 manifestPath := "../../../testdata/snmp/enlinkd/nms10205b/manifest.yaml"
57 manifest, err := LoadManifest(manifestPath)
58 require.NoError(t, err)
59
60 scenario, ok := manifest.FindScenario("nms10205b_lldp")
61 require.True(t, ok)
62
63 resolved, err := ResolveScenario(manifestPath, scenario)
64 require.NoError(t, err)
65 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
66 }
67
68 func TestValidateGoldenCache_NMS17216(t *testing.T) {
69 manifestPath := "../../../testdata/snmp/enlinkd/nms17216/manifest.yaml"
70 manifest, err := LoadManifest(manifestPath)
71 require.NoError(t, err)
72
73 scenarios := []string{"nms17216_lldp", "nms17216_cdp"}
74 for _, scenarioID := range scenarios {
75 scenario, ok := manifest.FindScenario(scenarioID)
76 require.True(t, ok)
77
78 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
79 require.NoError(t, resolveErr)
80 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
81 }
82 }
83
84 func TestValidateGoldenCache_NMS0123(t *testing.T) {
85 manifestPath := "../../../testdata/snmp/enlinkd/nms0123/manifest.yaml"
86 manifest, err := LoadManifest(manifestPath)
87 require.NoError(t, err)
88
89 scenario, ok := manifest.FindScenario("nms0123_lldp")
90 require.True(t, ok)
91
92 resolved, err := ResolveScenario(manifestPath, scenario)
93 require.NoError(t, err)
94 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
95 }
96
97 func TestValidateGoldenCache_NMS0002(t *testing.T) {
98 manifestPath := "../../../testdata/snmp/enlinkd/nms0002/manifest.yaml"
99 manifest, err := LoadManifest(manifestPath)
100 require.NoError(t, err)
101
102 scenarios := []string{"nms0002_cisco_juniper_lldp", "nms0002_cisco_alcatel_lldp"}
103 for _, scenarioID := range scenarios {
104 scenario, ok := manifest.FindScenario(scenarioID)
105 require.True(t, ok)
106
107 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
108 require.NoError(t, resolveErr)
109 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
110 }
111 }
112
113 func TestValidateGoldenCache_NMS0000(t *testing.T) {
114 manifestPath := "../../../testdata/snmp/enlinkd/nms0000/manifest.yaml"
115 manifest, err := LoadManifest(manifestPath)
116 require.NoError(t, err)
117
118 scenarios := []string{
119 "nms0000_network_all_lldp",
120 "nms0000_network_two_connected_lldp",
121 "nms0000_network_three_connected_lldp",
122 "nms0000_microsense_lldp",
123 "nms0000_ms16_lldp",
124 "nms0000_planet_lldp",
125 }
126
127 for _, scenarioID := range scenarios {
128 scenario, ok := manifest.FindScenario(scenarioID)
129 require.True(t, ok)
130
131 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
132 require.NoError(t, resolveErr)
133 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
134 }
135 }
136
137 func TestValidateGoldenCache_NMS7467(t *testing.T) {
138 manifestPath := "../../../testdata/snmp/enlinkd/nms7467/manifest.yaml"
139 manifest, err := LoadManifest(manifestPath)
140 require.NoError(t, err)
141
142 scenario, ok := manifest.FindScenario("nms7467_cdp")
143 require.True(t, ok)
144
145 resolved, err := ResolveScenario(manifestPath, scenario)
146 require.NoError(t, err)
147 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
148 }
149
150 func TestValidateGoldenCache_NMS7563(t *testing.T) {
151 manifestPath := "../../../testdata/snmp/enlinkd/nms7563/manifest.yaml"
152 manifest, err := LoadManifest(manifestPath)
153 require.NoError(t, err)
154
155 scenarios := []string{"nms7563_cisco01", "nms7563_homeserver_lldp", "nms7563_switch02_cdp"}
156 for _, scenarioID := range scenarios {
157 scenario, ok := manifest.FindScenario(scenarioID)
158 require.True(t, ok)
159
160 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
161 require.NoError(t, resolveErr)
162 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
163 }
164 }
165
166 func TestValidateGoldenCache_NMS4930(t *testing.T) {
167 manifestPath := "../../../testdata/snmp/enlinkd/nms4930/manifest.yaml"
168 manifest, err := LoadManifest(manifestPath)
169 require.NoError(t, err)
170
171 scenarios := []string{
172 "nms4930_dlink1_bridge_fdb",
173 "nms4930_dlink2_bridge_fdb",
174 }
175
176 for _, scenarioID := range scenarios {
177 scenario, ok := manifest.FindScenario(scenarioID)
178 require.True(t, ok)
179
180 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
181 require.NoError(t, resolveErr)
182 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
183 }
184 }
185
186 func TestValidateGoldenCache_NMS7777DW(t *testing.T) {
187 manifestPath := "../../../testdata/snmp/enlinkd/nms7777dw/manifest.yaml"
188 manifest, err := LoadManifest(manifestPath)
189 require.NoError(t, err)
190
191 scenario, ok := manifest.FindScenario("nms7777dw_lldp_no_links")
192 require.True(t, ok)
193
194 resolved, err := ResolveScenario(manifestPath, scenario)
195 require.NoError(t, err)
196 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
197 }
198
199 func TestValidateGoldenCache_NMS13923(t *testing.T) {
200 manifestPath := "../../../testdata/snmp/enlinkd/nms13923/manifest.yaml"
201 manifest, err := LoadManifest(manifestPath)
202 require.NoError(t, err)
203
204 scenario, ok := manifest.FindScenario("nms13923_lldp")
205 require.True(t, ok)
206
207 resolved, err := ResolveScenario(manifestPath, scenario)
208 require.NoError(t, err)
209 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
210 }
211
212 func TestValidateGoldenCache_NMS13593(t *testing.T) {
213 manifestPath := "../../../testdata/snmp/enlinkd/nms13593/manifest.yaml"
214 manifest, err := LoadManifest(manifestPath)
215 require.NoError(t, err)
216
217 scenario, ok := manifest.FindScenario("nms13593_lldp")
218 require.True(t, ok)
219
220 resolved, err := ResolveScenario(manifestPath, scenario)
221 require.NoError(t, err)
222 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
223 }
224
225 func TestValidateGoldenCache_NMS7918(t *testing.T) {
226 manifestPath := "../../../testdata/snmp/enlinkd/nms7918/manifest.yaml"
227 manifest, err := LoadManifest(manifestPath)
228 require.NoError(t, err)
229
230 scenarios := []string{
231 "nms7918_asw01_bridge_fdb",
232 "nms7918_stcasw01_bridge_fdb",
233 "nms7918_samasw01_bridge_fdb",
234 "nms7918_ospwl01_arp",
235 "nms7918_ospess01_arp",
236 "nms7918_pe01_arp",
237 }
238
239 for _, scenarioID := range scenarios {
240 scenario, ok := manifest.FindScenario(scenarioID)
241 require.True(t, ok)
242
243 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
244 require.NoError(t, resolveErr)
245 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
246 }
247 }
248
249 func TestValidateGoldenCache_NMS18541(t *testing.T) {
250 manifestPath := "../../../testdata/snmp/enlinkd/nms18541/manifest.yaml"
251 manifest, err := LoadManifest(manifestPath)
252 require.NoError(t, err)
253
254 scenarios := []string{
255 "nms18541_network_all_lldp",
256 "nms18541_topoqfx_sw01_sw02_sw03_lldp",
257 "nms18541_topoqfx_sw01_lldp",
258 "nms18541_topoqfx_sw02_lldp",
259 "nms18541_topoqfx_sw03_lldp",
260 "nms18541_topoqfx_sw04_lldp",
261 "nms18541_topoqfx_sw08_lldp",
262 "nms18541_topoqfx_sw09_lldp",
263 "nms18541_qfx_lldp",
264 "nms18541_microsens_sw01_lldp",
265 "nms18541_microsens_sw02_lldp",
266 "nms18541_microsens_sw03_lldp",
267 "nms18541_microsens_sw04_lldp",
268 "nms18541_microsens_sw08_lldp",
269 "nms18541_microsens_sw09_lldp",
270 }
271
272 for _, scenarioID := range scenarios {
273 scenario, ok := manifest.FindScenario(scenarioID)
274 require.True(t, ok)
275
276 resolved, resolveErr := ResolveScenario(manifestPath, scenario)
277 require.NoError(t, resolveErr)
278 require.NoError(t, ValidateCache(resolved.GoldenYAML, resolved.GoldenJSON))
279 }
280 }
281
282 func TestGoldenYAMLValidation(t *testing.T) {
283 doc, err := LoadGoldenYAML("../../../testdata/snmp/enlinkd/nms8003/golden/nms8003_lldp.yaml")
284 require.NoError(t, err)
285
286 require.Equal(t, GoldenVersion, doc.Version)
287 require.Equal(t, "nms8003_lldp", doc.ScenarioID)
288 require.Len(t, doc.Devices, 5)
289 require.Len(t, doc.Adjacencies, 12)
290 require.Equal(t, 6, doc.Expectations.BidirectionalPairs)
291
292 payload, err := doc.CanonicalJSON()
293 require.NoError(t, err)
294 require.Contains(t, string(payload), "\"scenario_id\": \"nms8003_lldp\"")
295 }