]>
Commit | Line | Data |
---|---|---|
85d47773 AP |
1 | #!/usr/bin/env python |
2 | ||
3 | # | |
4 | # Copyright (c) 2019 by VMware, Inc. ("VMware") | |
5 | # Used Copyright (c) 2018 by Network Device Education Foundation, | |
6 | # Inc. ("NetDEF") in this file. | |
7 | # | |
8 | # Permission to use, copy, modify, and/or distribute this software | |
9 | # for any purpose with or without fee is hereby granted, provided | |
10 | # that the above copyright notice and this permission notice appear | |
11 | # in all copies. | |
12 | # | |
13 | # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES | |
14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
15 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR | |
16 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | |
17 | # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
18 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
19 | # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
20 | # OF THIS SOFTWARE. | |
21 | # | |
22 | ||
23 | ||
24 | """ | |
25 | Following tests are covered to test large-community/community functionality: | |
26 | 1. Verify if large community attribute can be configured only in correct | |
27 | canonical format. | |
28 | 2. Verify that the community attribute value, which we have advertised are | |
29 | received in correct format and values, at the receiving end. | |
30 | 3. Verify BGP Large Community attribute"s transitive property attribute. | |
31 | 4. Verify that BGP Large Communities attribute are malformed, if the length of | |
32 | the BGP Large Communities Attribute value, expressed in octets, | |
33 | is not a non-zero multiple of 12. | |
34 | 5. Verify if overriding large community values works fine. | |
35 | 6. Verify that large community values" aggregation works fine. | |
36 | 7. Standard community also work fine in conjunction with large-community. | |
37 | 8. Matching prefixes based on attributes other than prefix list and make use | |
38 | of set clause (IPV6). | |
39 | 9. Matching prefixes based on attributes other than prefix list and make use | |
40 | of set clause (IPV4). | |
41 | 10. Verify community and large-community list operations in route-map with all | |
42 | clause (exact, all, any, regex) works. | |
43 | 11. Verify that any value in BGP Large communities for boundary values. | |
44 | 12. Clear BGP neighbor-ship and check if large community and community | |
45 | attributes are getting re-populated. | |
46 | ||
47 | """ | |
48 | ||
49 | import pytest | |
50 | import time | |
51 | from os import path as os_path | |
52 | import sys | |
3dfd384e | 53 | |
85d47773 AP |
54 | # Required to instantiate the topology builder class. |
55 | from lib.topogen import Topogen, get_topogen | |
85d47773 AP |
56 | |
57 | from lib.common_config import ( | |
787e7624 | 58 | start_topology, |
59 | write_test_header, | |
60 | write_test_footer, | |
61 | reset_config_on_routers, | |
62 | create_route_maps, | |
63 | create_bgp_community_lists, | |
64 | create_prefix_lists, | |
65 | verify_bgp_community, | |
66 | step, | |
67 | check_address_types, | |
701a0192 | 68 | required_linux_kernel_version, |
85d47773 AP |
69 | ) |
70 | from lib.topolog import logger | |
787e7624 | 71 | from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify |
4953ca97 | 72 | from lib.topojson import build_config_from_json |
85d47773 | 73 | |
bf3a0a9a DS |
74 | pytestmark = [pytest.mark.bgpd] |
75 | ||
76 | ||
85d47773 AP |
77 | # Save the Current Working Directory to find configuration files. |
78 | CWD = os_path.dirname(os_path.realpath(__file__)) | |
79 | sys.path.append(os_path.join(CWD, "../")) | |
80 | sys.path.append(os_path.join(CWD, "../lib/")) | |
81 | ||
85d47773 AP |
82 | |
83 | # Global variables | |
84 | bgp_convergence = False | |
85 | NETWORK = { | |
86 | "ipv4": ["200.50.2.0", "200.50.2.1", "200.50.2.0"], | |
787e7624 | 87 | "ipv6": ["1::1", "1::2", "1::0"], |
85d47773 AP |
88 | } |
89 | MASK = {"ipv4": "32", "ipv6": "128"} | |
90 | NET_MASK = {"ipv4": "24", "ipv6": "120"} | |
91 | IPV4_NET = ["200.50.2.0"] | |
92 | IPV6_NET = ["1::0"] | |
93 | CONFIG_ROUTER_R1 = False | |
94 | CONFIG_ROUTER_R2 = False | |
95 | CONFIG_ROUTER_ADDITIVE = False | |
96 | ADDR_TYPES = [] | |
97 | LARGE_COMM = { | |
98 | "r1": "1:1:1 1:2:1 1:3:1 1:4:1 1:5:1", | |
99 | "r2": "2:1:1 2:2:1 2:3:1 2:4:1 2:5:1", | |
100 | "mal_1": "1:1 1:2 1:3 1:4 1:5", | |
101 | "pf_list_1": "0:0:1 0:0:10 0:0:100", | |
102 | "pf_list_2": "0:0:2 0:0:20 0:0:200", | |
103 | "agg_1": "0:0:1 0:0:2 0:0:10 0:0:20 0:0:100 0:0:200 2:1:1 " | |
787e7624 | 104 | "2:2:1 2:3:1 2:4:1 2:5:1", |
105 | "agg_2": "0:0:2 0:0:20 0:0:200 2:1:1 " "2:2:1 2:3:1 2:4:1 2:5:1", | |
85d47773 AP |
106 | } |
107 | STANDARD_COMM = { | |
108 | "r1": "1:1 1:2 1:3 1:4 1:5", | |
109 | "r2": "2:1 2:2 2:3 2:4 2:5", | |
110 | "mal_1": "1 2 3 4 5", | |
111 | "pf_list_1": "0:1 0:10 0:100", | |
112 | "pf_list_2": "0:2 0:20 0:200", | |
113 | "agg_1": "0:1 0:2 0:10 0:20 0:100 0:200 2:1 2:2 2:3 2:4 2:5", | |
787e7624 | 114 | "agg_2": "0:2 0:20 0:200 2:1 2:2 2:3 2:4 2:5", |
85d47773 AP |
115 | } |
116 | ||
117 | ||
85d47773 AP |
118 | def setup_module(mod): |
119 | """ | |
120 | Sets up the pytest environment | |
121 | ||
122 | * `mod`: module name | |
123 | """ | |
3dfd384e | 124 | # Required linux kernel version for this suite to run. |
701a0192 | 125 | result = required_linux_kernel_version("4.15") |
955212d9 | 126 | if result is not True: |
127 | pytest.skip("Kernel requirements are not met") | |
3dfd384e | 128 | |
85d47773 AP |
129 | global ADDR_TYPES |
130 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
131 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
132 | logger.info("=" * 40) | |
133 | ||
134 | logger.info("Running setup_module to create topology") | |
135 | ||
136 | # This function initiates the topology build with Topogen... | |
e82b531d CH |
137 | json_file = "{}/bgp_large_community_topo_1.json".format(CWD) |
138 | tgen = Topogen(json_file, mod.__name__) | |
139 | global topo | |
140 | topo = tgen.json_topo | |
85d47773 AP |
141 | # ... and here it calls Mininet initialization functions. |
142 | ||
143 | # Starting topology, create tmp files which are loaded to routers | |
144 | # to start deamons and then start routers | |
145 | start_topology(tgen) | |
146 | ||
147 | # Creating configuration from JSON | |
148 | build_config_from_json(tgen, topo) | |
149 | ||
150 | # Checking BGP convergence | |
151 | global bgp_convergence | |
152 | ||
153 | # Don"t run this test if we have any failure. | |
154 | if tgen.routers_have_failure(): | |
155 | pytest.skip(tgen.errors) | |
156 | ||
157 | ##tgen.mininet_cli() | |
158 | # Api call verify whether BGP is converged | |
159 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
787e7624 | 160 | assert bgp_convergence is True, "setup_module :Failed \n Error:" " {}".format( |
161 | bgp_convergence | |
162 | ) | |
85d47773 AP |
163 | |
164 | ADDR_TYPES = check_address_types() | |
165 | logger.info("Running setup_module() done") | |
166 | ||
167 | ||
168 | def teardown_module(): | |
169 | """ | |
170 | Teardown the pytest environment | |
171 | ||
172 | * `mod`: module name | |
173 | """ | |
174 | ||
175 | logger.info("Running teardown_module to delete topology") | |
176 | ||
177 | tgen = get_topogen() | |
178 | ||
179 | # Stop toplogy and Remove tmp files | |
180 | tgen.stop_topology() | |
181 | ||
787e7624 | 182 | logger.info( |
183 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
184 | ) | |
85d47773 AP |
185 | logger.info("=" * 40) |
186 | ||
187 | ||
188 | def config_router_r1(tgen, topo, tc_name): | |
189 | global CONFIG_ROUTER_R1 | |
190 | ||
191 | input_dict_1 = { | |
192 | "r1": { | |
193 | "route_maps": { | |
194 | "LC1": [ | |
195 | { | |
196 | "action": "permit", | |
197 | "seq_id": "10", | |
198 | "set": { | |
787e7624 | 199 | "large_community": {"num": LARGE_COMM["r1"]}, |
200 | "community": {"num": STANDARD_COMM["r1"]}, | |
201 | }, | |
85d47773 AP |
202 | } |
203 | ] | |
204 | } | |
205 | } | |
206 | } | |
207 | ||
208 | step("Configuring LC1 on r1") | |
209 | result = create_route_maps(tgen, input_dict_1) | |
787e7624 | 210 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
211 | |
212 | # Configure neighbor for route map | |
213 | input_dict_2 = { | |
214 | "r1": { | |
215 | "bgp": { | |
216 | "address_family": { | |
217 | "ipv4": { | |
218 | "unicast": { | |
219 | "advertise_networks": [ | |
220 | { | |
787e7624 | 221 | "network": "%s/%s" |
222 | % (NETWORK["ipv4"][0], MASK["ipv4"]), | |
223 | "no_of_network": 4, | |
85d47773 AP |
224 | } |
225 | ], | |
226 | "neighbor": { | |
227 | "r2": { | |
228 | "dest_link": { | |
229 | "r1-link1": { | |
787e7624 | 230 | "route_maps": [ |
231 | {"name": "LC1", "direction": "out"} | |
232 | ] | |
85d47773 AP |
233 | } |
234 | } | |
235 | }, | |
236 | "r3": { | |
237 | "dest_link": { | |
238 | "r1-link1": { | |
787e7624 | 239 | "route_maps": [ |
240 | {"name": "LC1", "direction": "out"} | |
241 | ] | |
85d47773 AP |
242 | } |
243 | } | |
787e7624 | 244 | }, |
245 | }, | |
85d47773 AP |
246 | } |
247 | }, | |
248 | "ipv6": { | |
249 | "unicast": { | |
250 | "advertise_networks": [ | |
251 | { | |
787e7624 | 252 | "network": "%s/%s" |
253 | % (NETWORK["ipv6"][0], MASK["ipv6"]), | |
254 | "no_of_network": 4, | |
85d47773 AP |
255 | } |
256 | ], | |
257 | "neighbor": { | |
258 | "r2": { | |
259 | "dest_link": { | |
260 | "r1-link1": { | |
787e7624 | 261 | "route_maps": [ |
262 | {"name": "LC1", "direction": "out"} | |
263 | ] | |
85d47773 AP |
264 | } |
265 | } | |
266 | }, | |
267 | "r3": { | |
268 | "dest_link": { | |
269 | "r1-link1": { | |
787e7624 | 270 | "route_maps": [ |
271 | {"name": "LC1", "direction": "out"} | |
272 | ] | |
85d47773 AP |
273 | } |
274 | } | |
787e7624 | 275 | }, |
276 | }, | |
85d47773 | 277 | } |
787e7624 | 278 | }, |
85d47773 AP |
279 | } |
280 | } | |
281 | } | |
282 | } | |
283 | ||
284 | step("Applying LC1 on r1 neighbors and advertising networks") | |
285 | result = create_router_bgp(tgen, topo, input_dict_2) | |
787e7624 | 286 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
287 | |
288 | CONFIG_ROUTER_R1 = True | |
289 | ||
290 | ||
291 | def config_router_r2(tgen, topo, tc_name): | |
292 | global CONFIG_ROUTER_R2 | |
293 | ||
294 | input_dict = { | |
295 | "r2": { | |
296 | "route_maps": { | |
297 | "LC2": [ | |
298 | { | |
299 | "action": "permit", | |
300 | "seq_id": "10", | |
301 | "set": { | |
787e7624 | 302 | "large_community": {"num": LARGE_COMM["r2"]}, |
303 | "community": {"num": STANDARD_COMM["r2"]}, | |
304 | }, | |
85d47773 AP |
305 | } |
306 | ] | |
307 | } | |
308 | } | |
309 | } | |
310 | ||
311 | step("Configuring route-maps LC2 on r2") | |
312 | result = create_route_maps(tgen, input_dict) | |
787e7624 | 313 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
314 | |
315 | input_dict_1 = { | |
316 | "r2": { | |
317 | "bgp": { | |
318 | "address_family": { | |
319 | "ipv4": { | |
320 | "unicast": { | |
321 | "neighbor": { | |
322 | "r4": { | |
323 | "dest_link": { | |
324 | "r2-link1": { | |
787e7624 | 325 | "route_maps": [ |
326 | {"name": "LC2", "direction": "out"} | |
327 | ] | |
85d47773 AP |
328 | } |
329 | } | |
330 | } | |
331 | } | |
332 | } | |
333 | }, | |
334 | "ipv6": { | |
335 | "unicast": { | |
336 | "neighbor": { | |
337 | "r4": { | |
338 | "dest_link": { | |
339 | "r2-link1": { | |
787e7624 | 340 | "route_maps": [ |
341 | {"name": "LC2", "direction": "out"} | |
342 | ] | |
85d47773 AP |
343 | } |
344 | } | |
345 | } | |
346 | } | |
347 | } | |
787e7624 | 348 | }, |
85d47773 AP |
349 | } |
350 | } | |
351 | } | |
352 | } | |
353 | ||
354 | step("Applying LC2 on r2 neighbors in out direction") | |
355 | result = create_router_bgp(tgen, topo, input_dict_1) | |
787e7624 | 356 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
357 | |
358 | CONFIG_ROUTER_R2 = True | |
359 | ||
360 | ||
361 | def config_router_additive(tgen, topo, tc_name): | |
362 | global CONFIG_ROUTER_ADDITIVE | |
363 | ||
364 | input_dict = { | |
365 | "r2": { | |
366 | "route_maps": { | |
367 | "LC2": [ | |
368 | { | |
369 | "action": "permit", | |
370 | "seq_id": "10", | |
371 | "set": { | |
372 | "large_community": { | |
373 | "num": LARGE_COMM["r2"], | |
787e7624 | 374 | "action": "additive", |
85d47773 AP |
375 | }, |
376 | "community": { | |
377 | "num": STANDARD_COMM["r2"], | |
787e7624 | 378 | "action": "additive", |
379 | }, | |
380 | }, | |
85d47773 AP |
381 | } |
382 | ] | |
383 | } | |
384 | } | |
385 | } | |
386 | ||
387 | step("Configuring LC2 with community attributes as additive") | |
388 | result = create_route_maps(tgen, input_dict) | |
787e7624 | 389 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
390 | |
391 | # tgen.mininet_cli() | |
392 | CONFIG_ROUTER_ADDITIVE = True | |
393 | ||
394 | ||
395 | def config_for_as_path(tgen, topo, tc_name): | |
396 | config_router_r1(tgen, topo, tc_name) | |
397 | ||
398 | config_router_r2(tgen, topo, tc_name) | |
399 | ||
400 | # Create ipv6 prefix list | |
401 | input_dict_1 = { | |
402 | "r1": { | |
403 | "prefix_lists": { | |
404 | "ipv4": { | |
405 | "pf_list_1": [ | |
406 | { | |
407 | "seqid": "10", | |
787e7624 | 408 | "network": "%s/%s" % (NETWORK["ipv4"][0], MASK["ipv4"]), |
409 | "action": "permit", | |
85d47773 AP |
410 | } |
411 | ], | |
412 | "pf_list_2": [ | |
413 | { | |
414 | "seqid": "10", | |
787e7624 | 415 | "network": "%s/%s" % (NETWORK["ipv4"][1], MASK["ipv4"]), |
416 | "action": "permit", | |
85d47773 | 417 | } |
787e7624 | 418 | ], |
85d47773 AP |
419 | }, |
420 | "ipv6": { | |
421 | "pf_list_3": [ | |
422 | { | |
423 | "seqid": "10", | |
787e7624 | 424 | "network": "%s/%s" % (NETWORK["ipv6"][0], MASK["ipv6"]), |
425 | "action": "permit", | |
85d47773 AP |
426 | } |
427 | ], | |
428 | "pf_list_4": [ | |
429 | { | |
430 | "seqid": "10", | |
787e7624 | 431 | "network": "%s/%s" % (NETWORK["ipv6"][1], MASK["ipv6"]), |
432 | "action": "permit", | |
85d47773 | 433 | } |
787e7624 | 434 | ], |
435 | }, | |
85d47773 AP |
436 | } |
437 | } | |
438 | } | |
439 | ||
440 | step("Configuring prefix-lists on r1 to filter networks") | |
441 | result = create_prefix_lists(tgen, input_dict_1) | |
787e7624 | 442 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
443 | |
444 | input_dict_2 = { | |
445 | "r1": { | |
446 | "route_maps": { | |
447 | "LC1": [ | |
448 | { | |
449 | "action": "permit", | |
450 | "seq_id": 10, | |
787e7624 | 451 | "match": {"ipv4": {"prefix_lists": "pf_list_1"}}, |
85d47773 | 452 | "set": { |
787e7624 | 453 | "large_community": {"num": LARGE_COMM["pf_list_1"]}, |
454 | "community": {"num": STANDARD_COMM["pf_list_1"]}, | |
455 | }, | |
85d47773 AP |
456 | }, |
457 | { | |
458 | "action": "permit", | |
459 | "seq_id": 20, | |
787e7624 | 460 | "match": {"ipv6": {"prefix_lists": "pf_list_3"}}, |
85d47773 | 461 | "set": { |
787e7624 | 462 | "large_community": {"num": LARGE_COMM["pf_list_1"]}, |
463 | "community": {"num": STANDARD_COMM["pf_list_1"]}, | |
464 | }, | |
85d47773 AP |
465 | }, |
466 | { | |
467 | "action": "permit", | |
468 | "seq_id": 30, | |
787e7624 | 469 | "match": {"ipv4": {"prefix_lists": "pf_list_2"}}, |
85d47773 | 470 | "set": { |
787e7624 | 471 | "large_community": {"num": LARGE_COMM["pf_list_2"]}, |
472 | "community": {"num": STANDARD_COMM["pf_list_2"]}, | |
473 | }, | |
85d47773 AP |
474 | }, |
475 | { | |
476 | "action": "permit", | |
477 | "seq_id": 40, | |
787e7624 | 478 | "match": {"ipv6": {"prefix_lists": "pf_list_4"}}, |
85d47773 | 479 | "set": { |
787e7624 | 480 | "large_community": {"num": LARGE_COMM["pf_list_2"]}, |
481 | "community": {"num": STANDARD_COMM["pf_list_2"]}, | |
482 | }, | |
483 | }, | |
85d47773 AP |
484 | ] |
485 | } | |
486 | } | |
487 | } | |
488 | ||
787e7624 | 489 | step( |
490 | "Applying prefix-lists match in route-map LC1 on r1. Setting" | |
491 | " community attritbute for filtered networks" | |
492 | ) | |
85d47773 | 493 | result = create_route_maps(tgen, input_dict_2) |
787e7624 | 494 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
495 | |
496 | config_router_additive(tgen, topo, tc_name) | |
497 | ||
498 | input_dict_3 = { | |
499 | "r4": { | |
500 | "bgp_community_lists": [ | |
501 | { | |
502 | "community_type": "standard", | |
503 | "action": "permit", | |
504 | "name": "ANY", | |
505 | "value": LARGE_COMM["pf_list_1"], | |
787e7624 | 506 | "large": True, |
85d47773 AP |
507 | }, |
508 | { | |
509 | "community_type": "standard", | |
510 | "action": "permit", | |
511 | "name": "ANY", | |
512 | "value": STANDARD_COMM["pf_list_1"], | |
787e7624 | 513 | }, |
85d47773 AP |
514 | ] |
515 | } | |
516 | } | |
517 | ||
518 | step("Configuring bgp community lists on r4") | |
519 | result = create_bgp_community_lists(tgen, input_dict_3) | |
787e7624 | 520 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
521 | |
522 | input_dict_4 = { | |
523 | "r4": { | |
524 | "route_maps": { | |
525 | "LC4": [ | |
526 | { | |
527 | "action": "permit", | |
528 | "seq_id": "10", | |
529 | "match": { | |
530 | "large_community_list": {"id": "ANY"}, | |
787e7624 | 531 | "community_list": {"id": "ANY"}, |
85d47773 | 532 | }, |
787e7624 | 533 | "set": {"path": {"as_num": "4000000", "as_action": "prepend"}}, |
85d47773 AP |
534 | } |
535 | ] | |
536 | } | |
537 | } | |
538 | } | |
539 | ||
540 | step("Applying community list on route-map on r4") | |
541 | result = create_route_maps(tgen, input_dict_4) | |
787e7624 | 542 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
543 | |
544 | input_dict_5 = { | |
545 | "r4": { | |
546 | "bgp": { | |
547 | "address_family": { | |
548 | "ipv4": { | |
549 | "unicast": { | |
550 | "neighbor": { | |
551 | "r5": { | |
552 | "dest_link": { | |
553 | "r4-link1": { | |
787e7624 | 554 | "route_maps": [ |
555 | {"name": "LC4", "direction": "out"} | |
556 | ] | |
85d47773 AP |
557 | } |
558 | } | |
559 | } | |
560 | } | |
561 | } | |
562 | }, | |
563 | "ipv6": { | |
564 | "unicast": { | |
565 | "neighbor": { | |
566 | "r5": { | |
567 | "dest_link": { | |
568 | "r4-link1": { | |
787e7624 | 569 | "route_maps": [ |
570 | {"name": "LC4", "direction": "out"} | |
571 | ] | |
85d47773 AP |
572 | } |
573 | } | |
574 | } | |
575 | } | |
576 | } | |
787e7624 | 577 | }, |
85d47773 AP |
578 | } |
579 | } | |
580 | } | |
581 | } | |
582 | ||
583 | step("Applying route-map LC4 out from r4 to r5 ") | |
584 | result = create_router_bgp(tgen, topo, input_dict_5) | |
787e7624 | 585 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
586 | |
587 | ||
588 | ##################################################### | |
589 | # | |
590 | # Test cases | |
591 | # | |
592 | ##################################################### | |
593 | def test_large_community_set(request): | |
594 | """ | |
595 | Verify if large community attribute can be configured only in correct | |
596 | canonical format. | |
597 | """ | |
598 | tc_name = request.node.name | |
599 | write_test_header(tc_name) | |
600 | tgen = get_topogen() | |
601 | ||
602 | # Don"t run this test if we have any failure. | |
603 | if tgen.routers_have_failure(): | |
604 | pytest.skip(tgen.errors) | |
605 | ||
606 | # API call to modify router id | |
607 | # input_dict dictionary to be provided to configure route_map | |
608 | input_dict = { | |
609 | "r1": { | |
610 | "route_maps": { | |
611 | "LC1": [ | |
612 | { | |
613 | "action": "permit", | |
614 | "seq_id": "10", | |
615 | "set": { | |
616 | "large_community": {"num": LARGE_COMM["r1"]}, | |
787e7624 | 617 | "community": {"num": STANDARD_COMM["r1"]}, |
618 | }, | |
85d47773 AP |
619 | } |
620 | ] | |
621 | } | |
622 | } | |
623 | } | |
624 | ||
625 | step("Trying to set bgp communities") | |
626 | result = create_route_maps(tgen, input_dict) | |
787e7624 | 627 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
628 | |
629 | write_test_footer(tc_name) | |
630 | ||
631 | ||
632 | def test_large_community_advertise(request): | |
633 | """ | |
634 | Verify that the community attribute value, which we have advertised are | |
635 | received in correct format and values, at the receiving end. | |
636 | """ | |
637 | tc_name = request.node.name | |
638 | write_test_header(tc_name) | |
639 | tgen = get_topogen() | |
640 | ||
641 | # Don"t run this test if we have any failure. | |
642 | if tgen.routers_have_failure(): | |
643 | pytest.skip(tgen.errors) | |
644 | ||
645 | reset_config_on_routers(tgen) | |
646 | config_router_r1(tgen, topo, tc_name) | |
647 | ||
648 | input_dict = { | |
649 | "largeCommunity": LARGE_COMM["r1"], | |
650 | "community": STANDARD_COMM["r1"], | |
651 | } | |
652 | ||
653 | for adt in ADDR_TYPES: | |
787e7624 | 654 | result = verify_bgp_community(tgen, adt, "r2", [NETWORK[adt][0]], input_dict) |
85d47773 | 655 | assert result is True, "Test case {} : Failed \n Error: {}".format( |
787e7624 | 656 | tc_name, result |
657 | ) | |
85d47773 | 658 | |
787e7624 | 659 | result = verify_bgp_community(tgen, adt, "r3", [NETWORK[adt][0]], input_dict) |
85d47773 | 660 | assert result is True, "Test case {} : Failed \n Error: {}".format( |
787e7624 | 661 | tc_name, result |
662 | ) | |
85d47773 AP |
663 | |
664 | write_test_footer(tc_name) | |
665 | ||
666 | ||
667 | def test_large_community_transitive(request): | |
668 | """ | |
669 | Verify BGP Large Community attribute"s transitive property attribute. | |
670 | """ | |
671 | tc_name = request.node.name | |
672 | write_test_header(tc_name) | |
673 | tgen = get_topogen() | |
674 | ||
675 | # Don"t run this test if we have any failure. | |
676 | if tgen.routers_have_failure(): | |
677 | pytest.skip(tgen.errors) | |
678 | ||
679 | reset_config_on_routers(tgen) | |
680 | ||
681 | config_router_r1(tgen, topo, tc_name) | |
682 | ||
683 | input_dict_1 = { | |
684 | "largeCommunity": LARGE_COMM["r1"], | |
787e7624 | 685 | "community": STANDARD_COMM["r1"], |
85d47773 AP |
686 | } |
687 | ||
688 | for adt in ADDR_TYPES: | |
787e7624 | 689 | result = verify_bgp_community(tgen, adt, "r4", [NETWORK[adt][0]], input_dict_1) |
85d47773 | 690 | assert result is True, "Test case {} : Failed \n Error: {}".format( |
787e7624 | 691 | tc_name, result |
692 | ) | |
85d47773 AP |
693 | |
694 | write_test_footer(tc_name) | |
695 | ||
696 | ||
697 | def test_large_community_override(request): | |
698 | """ | |
699 | Verify if overriding large community values works fine. | |
700 | """ | |
701 | tc_name = request.node.name | |
702 | write_test_header(tc_name) | |
703 | tgen = get_topogen() | |
704 | ||
705 | # Don"t run this test if we have any failure. | |
706 | if tgen.routers_have_failure(): | |
707 | pytest.skip(tgen.errors) | |
708 | ||
709 | reset_config_on_routers(tgen) | |
710 | config_router_r1(tgen, topo, tc_name) | |
711 | ||
712 | config_router_r2(tgen, topo, tc_name) | |
713 | ||
714 | input_dict_3 = { | |
715 | "largeCommunity": LARGE_COMM["r2"], | |
787e7624 | 716 | "community": STANDARD_COMM["r2"], |
85d47773 AP |
717 | } |
718 | ||
719 | for adt in ADDR_TYPES: | |
787e7624 | 720 | result = verify_bgp_community(tgen, adt, "r4", [NETWORK[adt][1]], input_dict_3) |
721 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
722 | tc_name, result | |
723 | ) | |
85d47773 AP |
724 | |
725 | write_test_footer(tc_name) | |
726 | ||
727 | ||
728 | def test_large_community_additive(request): | |
729 | """ | |
730 | Verify that large community values" aggregation works fine. | |
731 | """ | |
732 | tc_name = request.node.name | |
733 | write_test_header(tc_name) | |
734 | tgen = get_topogen() | |
735 | ||
736 | # Don"t run this test if we have any failure. | |
737 | if tgen.routers_have_failure(): | |
738 | pytest.skip(tgen.errors) | |
739 | ||
740 | reset_config_on_routers(tgen) | |
741 | config_router_r1(tgen, topo, tc_name) | |
742 | ||
743 | config_router_r2(tgen, topo, tc_name) | |
744 | ||
745 | config_router_additive(tgen, topo, tc_name) | |
746 | ||
747 | input_dict_1 = { | |
748 | "largeCommunity": "%s %s" % (LARGE_COMM["r1"], LARGE_COMM["r2"]), | |
787e7624 | 749 | "community": "%s %s" % (STANDARD_COMM["r1"], STANDARD_COMM["r2"]), |
85d47773 AP |
750 | } |
751 | ||
752 | for adt in ADDR_TYPES: | |
787e7624 | 753 | result = verify_bgp_community(tgen, adt, "r4", [NETWORK[adt][0]], input_dict_1) |
754 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
755 | tc_name, result | |
756 | ) | |
85d47773 AP |
757 | |
758 | write_test_footer(tc_name) | |
759 | ||
760 | ||
761 | def test_large_community_match_as_path(request): | |
762 | """ | |
763 | Matching prefixes based on attributes other than prefix list and make use | |
764 | of set clause. | |
765 | """ | |
766 | ||
767 | tc_name = request.node.name | |
768 | write_test_header(tc_name) | |
769 | tgen = get_topogen() | |
770 | ||
771 | # Don"t run this test if we have any failure. | |
772 | if tgen.routers_have_failure(): | |
773 | pytest.skip(tgen.errors) | |
774 | ||
775 | reset_config_on_routers(tgen) | |
776 | config_for_as_path(tgen, topo, tc_name) | |
777 | ||
778 | input_dict = { | |
787e7624 | 779 | "largeCommunity": "%s %s" % (LARGE_COMM["pf_list_1"], LARGE_COMM["r2"]), |
780 | "community": "%s %s" % (STANDARD_COMM["pf_list_1"], STANDARD_COMM["r2"]), | |
85d47773 AP |
781 | } |
782 | ||
783 | input_dict_1 = { | |
787e7624 | 784 | "largeCommunity": "%s %s" % (LARGE_COMM["pf_list_2"], LARGE_COMM["r2"]), |
785 | "community": "%s %s" % (STANDARD_COMM["pf_list_2"], STANDARD_COMM["r2"]), | |
85d47773 AP |
786 | } |
787 | ||
788 | for adt in ADDR_TYPES: | |
787e7624 | 789 | result = verify_bgp_community(tgen, adt, "r5", [NETWORK[adt][0]], input_dict) |
790 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
791 | tc_name, result | |
792 | ) | |
85d47773 | 793 | |
787e7624 | 794 | result = verify_bgp_community( |
795 | tgen, adt, "r5", [NETWORK[adt][1]], input_dict_1, expected=False | |
796 | ) | |
85d47773 | 797 | |
787e7624 | 798 | assert result is not True, "Test case {} : Should fail \n Error: {}".format( |
799 | tc_name, result | |
800 | ) | |
85d47773 AP |
801 | |
802 | write_test_footer(tc_name) | |
803 | ||
804 | ||
805 | def test_large_community_match_all(request): | |
806 | """ | |
807 | Verify community and large-community list operations in route-map with all | |
808 | clause (exact, all, any, regex) works. | |
809 | """ | |
810 | tc_name = request.node.name | |
811 | write_test_header(tc_name) | |
812 | tgen = get_topogen() | |
813 | ||
814 | # Don"t run this test if we have any failure. | |
815 | if tgen.routers_have_failure(): | |
816 | pytest.skip(tgen.errors) | |
817 | ||
818 | reset_config_on_routers(tgen) | |
819 | config_router_r1(tgen, topo, tc_name) | |
820 | ||
821 | config_router_r2(tgen, topo, tc_name) | |
822 | ||
823 | config_router_additive(tgen, topo, tc_name) | |
824 | ||
825 | input_dict_1 = { | |
826 | "r4": { | |
827 | "bgp_community_lists": [ | |
828 | { | |
829 | "community_type": "standard", | |
830 | "action": "permit", | |
831 | "name": "ANY", | |
832 | "value": "1:1:1", | |
787e7624 | 833 | "large": True, |
85d47773 AP |
834 | }, |
835 | { | |
836 | "community_type": "standard", | |
837 | "action": "permit", | |
838 | "name": "ALL", | |
839 | "value": "1:1:1 1:2:1 1:3:1 1:4:1 1:5:1 2:1:1 2:2:1", | |
787e7624 | 840 | "large": True, |
85d47773 AP |
841 | }, |
842 | { | |
843 | "community_type": "expanded", | |
844 | "action": "permit", | |
845 | "name": "EXP_ALL", | |
846 | "value": "1:1:1 1:2:1 1:3:1 1:4:1 1:5:1 2:[1-5]:1", | |
787e7624 | 847 | "large": True, |
848 | }, | |
85d47773 AP |
849 | ] |
850 | } | |
851 | } | |
852 | ||
853 | step("Create bgp community lists for ANY, EXACT and EXP_ALL match") | |
854 | ||
855 | result = create_bgp_community_lists(tgen, input_dict_1) | |
787e7624 | 856 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
857 | |
858 | input_dict_2 = { | |
859 | "r4": { | |
860 | "route_maps": { | |
861 | "LC4": [ | |
862 | { | |
863 | "action": "permit", | |
864 | "seq_id": "10", | |
787e7624 | 865 | "match": {"large-community-list": {"id": "ANY"}}, |
85d47773 AP |
866 | }, |
867 | { | |
868 | "action": "permit", | |
869 | "seq_id": "20", | |
787e7624 | 870 | "match": {"large-community-list": {"id": "EXACT"}}, |
85d47773 AP |
871 | }, |
872 | { | |
873 | "action": "permit", | |
874 | "seq_id": "30", | |
787e7624 | 875 | "match": {"large-community-list": {"id": "EXP_ALL"}}, |
876 | }, | |
85d47773 AP |
877 | ] |
878 | } | |
879 | } | |
880 | } | |
881 | ||
882 | step("Applying bgp community lits on LC4 route-map") | |
883 | result = create_route_maps(tgen, input_dict_2) | |
787e7624 | 884 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
885 | |
886 | input_dict_3 = { | |
887 | "r4": { | |
888 | "bgp": { | |
889 | "address_family": { | |
890 | "ipv4": { | |
891 | "unicast": { | |
892 | "neighbor": { | |
893 | "r5": { | |
894 | "dest_link": { | |
895 | "r4-link1": { | |
787e7624 | 896 | "route_maps": [ |
897 | {"name": "LC4", "direction": "in"} | |
898 | ] | |
85d47773 AP |
899 | } |
900 | } | |
901 | } | |
902 | } | |
903 | } | |
904 | }, | |
905 | "ipv6": { | |
906 | "unicast": { | |
907 | "neighbor": { | |
908 | "r5": { | |
909 | "dest_link": { | |
910 | "r4-link1": { | |
787e7624 | 911 | "route_maps": [ |
912 | {"name": "LC4", "direction": "in"} | |
913 | ] | |
85d47773 AP |
914 | } |
915 | } | |
916 | } | |
917 | } | |
918 | } | |
787e7624 | 919 | }, |
85d47773 AP |
920 | } |
921 | } | |
922 | } | |
923 | } | |
924 | ||
925 | step("Apply route-mpa LC4 on r4 for r2 neighbor, direction 'in'") | |
926 | ||
927 | result = create_router_bgp(tgen, topo, input_dict_3) | |
787e7624 | 928 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
929 | |
930 | input_dict_4 = { | |
931 | "largeCommunity": "1:1:1 1:2:1 1:3:1 1:4:1 1:5:1 2:1:1 2:2:1 2:3:1 " | |
787e7624 | 932 | "2:4:1 2:5:1" |
85d47773 AP |
933 | } |
934 | ||
935 | for adt in ADDR_TYPES: | |
787e7624 | 936 | result = verify_bgp_community(tgen, adt, "r4", [NETWORK[adt][0]], input_dict_4) |
937 | assert result is True, "Test case {} : Should fail \n Error: {}".format( | |
938 | tc_name, result | |
939 | ) | |
85d47773 AP |
940 | |
941 | write_test_footer(tc_name) | |
942 | ||
943 | ||
787e7624 | 944 | # @pytest.mark.skip(reason="as-set not working for ipv6") |
85d47773 AP |
945 | def test_large_community_aggregate_network(request): |
946 | """ | |
947 | Restart router and check if large community and community | |
948 | attributes are getting re-populated. | |
949 | """ | |
950 | ||
951 | tc_name = request.node.name | |
952 | write_test_header(tc_name) | |
953 | ||
954 | tgen = get_topogen() | |
955 | ||
956 | # Don"t run this test if we have any failure. | |
957 | if tgen.routers_have_failure(): | |
958 | pytest.skip(tgen.errors) | |
959 | ||
960 | reset_config_on_routers(tgen) | |
961 | ||
962 | config_for_as_path(tgen, topo, tc_name) | |
963 | ||
964 | input_dict = { | |
965 | "community": STANDARD_COMM["agg_1"], | |
787e7624 | 966 | "largeCommunity": LARGE_COMM["agg_1"], |
85d47773 AP |
967 | } |
968 | ||
969 | input_dict_1 = { | |
970 | "r2": { | |
971 | "bgp": { | |
972 | "address_family": { | |
973 | "ipv4": { | |
974 | "unicast": { | |
975 | "aggregate_address": [ | |
976 | { | |
787e7624 | 977 | "network": "%s/%s" |
978 | % (NETWORK["ipv4"][2], NET_MASK["ipv4"]), | |
979 | "as_set": True, | |
85d47773 AP |
980 | } |
981 | ] | |
982 | } | |
983 | }, | |
984 | "ipv6": { | |
985 | "unicast": { | |
986 | "aggregate_address": [ | |
987 | { | |
787e7624 | 988 | "network": "%s/%s" |
989 | % (NETWORK["ipv6"][2], NET_MASK["ipv6"]), | |
990 | "as_set": True, | |
85d47773 AP |
991 | } |
992 | ] | |
993 | } | |
787e7624 | 994 | }, |
85d47773 AP |
995 | } |
996 | } | |
997 | } | |
998 | } | |
999 | ||
1000 | step("Configuring aggregate address as-set on r2") | |
1001 | result = create_router_bgp(tgen, topo, input_dict_1) | |
787e7624 | 1002 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
1003 | |
1004 | for adt in ADDR_TYPES: | |
787e7624 | 1005 | result = verify_bgp_community( |
1006 | tgen, adt, "r4", ["%s/%s" % (NETWORK[adt][2], NET_MASK[adt])], input_dict | |
1007 | ) | |
1008 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1009 | tc_name, result | |
1010 | ) | |
85d47773 AP |
1011 | |
1012 | input_dict_2 = { | |
1013 | "r1": { | |
1014 | "bgp": { | |
1015 | "address_family": { | |
1016 | "ipv4": { | |
1017 | "unicast": { | |
1018 | "advertise_networks": [ | |
1019 | { | |
787e7624 | 1020 | "network": "%s/%s" |
1021 | % (NETWORK["ipv4"][0], MASK["ipv4"]), | |
85d47773 | 1022 | "no_of_network": 1, |
787e7624 | 1023 | "delete": True, |
85d47773 AP |
1024 | } |
1025 | ] | |
1026 | } | |
1027 | }, | |
1028 | "ipv6": { | |
1029 | "unicast": { | |
1030 | "advertise_networks": [ | |
1031 | { | |
787e7624 | 1032 | "network": "%s/%s" |
1033 | % (NETWORK["ipv6"][0], MASK["ipv6"]), | |
85d47773 | 1034 | "no_of_network": 1, |
787e7624 | 1035 | "delete": True, |
85d47773 AP |
1036 | } |
1037 | ] | |
1038 | } | |
787e7624 | 1039 | }, |
85d47773 AP |
1040 | } |
1041 | } | |
1042 | } | |
1043 | } | |
1044 | ||
1045 | step("Stop advertising one of the networks") | |
1046 | result = create_router_bgp(tgen, topo, input_dict_2) | |
787e7624 | 1047 | assert result is True, "Test case {} : Failed \n Error: {}".format(tc_name, result) |
85d47773 AP |
1048 | |
1049 | input_dict_3 = { | |
1050 | "community": STANDARD_COMM["agg_2"], | |
787e7624 | 1051 | "largeCommunity": LARGE_COMM["agg_2"], |
85d47773 AP |
1052 | } |
1053 | ||
1054 | for adt in ADDR_TYPES: | |
1055 | step("Verifying bgp community values on r5 is also modified") | |
787e7624 | 1056 | result = verify_bgp_community( |
1057 | tgen, adt, "r4", ["%s/%s" % (NETWORK[adt][2], NET_MASK[adt])], input_dict_3 | |
1058 | ) | |
1059 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1060 | tc_name, result | |
1061 | ) | |
85d47773 AP |
1062 | |
1063 | write_test_footer(tc_name) | |
1064 | ||
1065 | ||
1066 | def test_large_community_boundary_values(request): | |
1067 | """ | |
1068 | Verify that any value in BGP Large communities for boundary values. | |
1069 | """ | |
1070 | tc_name = request.node.name | |
1071 | write_test_header(tc_name) | |
1072 | tgen = get_topogen() | |
1073 | ||
1074 | # Don"t run this test if we have any failure. | |
1075 | if tgen.routers_have_failure(): | |
1076 | pytest.skip(tgen.errors) | |
1077 | ||
1078 | input_dict = { | |
1079 | "r4": { | |
1080 | "bgp_community_lists": [ | |
1081 | { | |
1082 | "community_type": "standard", | |
1083 | "action": "permit", | |
1084 | "name": "ANY", | |
787e7624 | 1085 | "value": "0:-1", |
85d47773 AP |
1086 | } |
1087 | ] | |
1088 | } | |
1089 | } | |
1090 | ||
1091 | step("Checking boundary value for community 0:-1") | |
1092 | result = create_bgp_community_lists(tgen, input_dict) | |
787e7624 | 1093 | assert result is not True, "Test case {} : Failed \n Error: {}".format( |
1094 | tc_name, result | |
1095 | ) | |
85d47773 AP |
1096 | |
1097 | step("Checking community attribute 0:65536") | |
1098 | input_dict_2 = { | |
1099 | "r4": { | |
1100 | "bgp_community_lists": [ | |
1101 | { | |
1102 | "community_type": "standard", | |
1103 | "action": "permit", | |
1104 | "name": "ANY", | |
787e7624 | 1105 | "value": "0:65536", |
85d47773 AP |
1106 | } |
1107 | ] | |
1108 | } | |
1109 | } | |
1110 | ||
1111 | step("Checking boundary value for community 0:65536") | |
1112 | result = create_bgp_community_lists(tgen, input_dict_2) | |
787e7624 | 1113 | assert result is not True, "Test case {} : Failed \n Error: {}".format( |
1114 | tc_name, result | |
1115 | ) | |
85d47773 AP |
1116 | |
1117 | step("Checking boundary value for community 0:4294967296") | |
1118 | input_dict_3 = { | |
1119 | "r4": { | |
1120 | "bgp_community_lists": [ | |
1121 | { | |
1122 | "community_type": "standard", | |
1123 | "action": "permit", | |
1124 | "name": "ANY", | |
1125 | "value": "0:4294967296", | |
787e7624 | 1126 | "large": True, |
85d47773 AP |
1127 | } |
1128 | ] | |
1129 | } | |
1130 | } | |
1131 | ||
1132 | result = create_bgp_community_lists(tgen, input_dict_3) | |
787e7624 | 1133 | assert result is not True, "Test case {} : Failed \n Error: {}".format( |
1134 | tc_name, result | |
1135 | ) | |
85d47773 AP |
1136 | step("Checking boundary value for community 0:-1:1") |
1137 | ||
1138 | input_dict_4 = { | |
1139 | "r4": { | |
1140 | "bgp_community_lists": [ | |
1141 | { | |
1142 | "community_type": "standard", | |
1143 | "action": "permit", | |
1144 | "name": "ANY", | |
1145 | "value": "0:-1:1", | |
787e7624 | 1146 | "large": True, |
85d47773 AP |
1147 | } |
1148 | ] | |
1149 | } | |
1150 | } | |
1151 | ||
1152 | result = create_bgp_community_lists(tgen, input_dict_4) | |
787e7624 | 1153 | assert result is not True, "Test case {} : Failed \n Error: {}".format( |
1154 | tc_name, result | |
1155 | ) | |
85d47773 AP |
1156 | |
1157 | ||
c850908b WC |
1158 | def test_large_community_invalid_chars(request): |
1159 | """ | |
1160 | BGP canonical lcommunities must only be digits | |
1161 | """ | |
1162 | tc_name = request.node.name | |
1163 | write_test_header(tc_name) | |
1164 | tgen = get_topogen() | |
1165 | ||
1166 | # Don"t run this test if we have any failure. | |
1167 | if tgen.routers_have_failure(): | |
1168 | pytest.skip(tgen.errors) | |
1169 | ||
1170 | input_dict = { | |
1171 | "r4": { | |
1172 | "bgp_community_lists": [ | |
1173 | { | |
1174 | "community_type": "standard", | |
1175 | "action": "permit", | |
1176 | "name": "ANY", | |
1177 | "value": "1:a:2", | |
1178 | "large": True, | |
1179 | } | |
1180 | ] | |
1181 | } | |
1182 | } | |
1183 | ||
1184 | step("Checking boundary value for community 1:a:2") | |
1185 | result = create_bgp_community_lists(tgen, input_dict) | |
1186 | assert result is not True, "Test case {} : Failed \n Error: {}".format( | |
1187 | tc_name, result | |
1188 | ) | |
1189 | ||
1190 | ||
85d47773 AP |
1191 | def test_large_community_after_clear_bgp(request): |
1192 | """ | |
1193 | Clear BGP neighbor-ship and check if large community and community | |
1194 | attributes are getting re-populated. | |
1195 | """ | |
1196 | tc_name = request.node.name | |
1197 | write_test_header(tc_name) | |
1198 | tgen = get_topogen() | |
1199 | ||
1200 | # Don"t run this test if we have any failure. | |
1201 | if tgen.routers_have_failure(): | |
1202 | pytest.skip(tgen.errors) | |
1203 | ||
1204 | reset_config_on_routers(tgen) | |
1205 | config_router_r1(tgen, topo, tc_name) | |
1206 | ||
787e7624 | 1207 | input_dict = {"largeCommunity": LARGE_COMM["r1"], "community": STANDARD_COMM["r1"]} |
85d47773 AP |
1208 | |
1209 | for adt in ADDR_TYPES: | |
787e7624 | 1210 | result = verify_bgp_community(tgen, adt, "r2", [NETWORK[adt][0]], input_dict) |
1211 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1212 | tc_name, result | |
1213 | ) | |
85d47773 AP |
1214 | |
1215 | step("Clearing BGP on r1") | |
1216 | clear_bgp_and_verify(tgen, topo, "r1") | |
1217 | ||
1218 | for adt in ADDR_TYPES: | |
787e7624 | 1219 | result = verify_bgp_community(tgen, adt, "r2", [NETWORK[adt][0]], input_dict) |
1220 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1221 | tc_name, result | |
1222 | ) | |
85d47773 AP |
1223 | |
1224 | write_test_footer(tc_name) | |
1225 | ||
1226 | ||
1227 | if __name__ == "__main__": | |
1228 | args = ["-s"] + sys.argv[1:] | |
1229 | sys.exit(pytest.main(args)) |