4 # test_bgp_conditional_advertisement.py
6 # Copyright (c) 2020 by
7 # Samsung R&D Institute India - Bangalore.
8 # Madhurilatha Kuruganti
10 # Permission to use, copy, modify, and/or distribute this software
11 # for any purpose with or without fee is hereby granted, provided
12 # that the above copyright notice and this permission notice appear
15 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
19 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
21 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 Test BGP conditional advertisement functionality.
28 +--------+ +--------+ +--------+
30 | R1 |------------| R2 |------------| R3 |
32 +--------+ +--------+ +--------+
34 R2 is DUT and peers with R1 and R3 in default bgp instance.
36 Following tests are covered under BGP conditional advertisement functionality.
37 Conditional advertisement
38 -------------------------
39 TC11: R3 BGP convergence, without advertise-map configuration.
40 All routes are advertised to R3.
42 TC21: exist-map routes present in R2's BGP table.
43 advertise-map routes present in R2's BGP table are advertised to R3.
44 TC22: exist-map routes not present in R2's BGP table
45 advertise-map routes present in R2's BGP table are withdrawn from R3.
46 TC23: advertise-map with exist-map configuration is removed from a peer
47 send normal BGP update to advertise previously withdrawn routes if any.
49 TC31: non-exist-map routes not present in R2's BGP table
50 advertise-map routes present in R2's BGP table are advertised to R3.
51 TC32: non-exist-map routes present in R2's BGP table
52 advertise-map routes present in R2's BGP table are withdrawn from R3.
53 TC33: advertise-map with non-exist-map configuration is removed from a peer
54 send normal BGP update to advertisepreviously withdrawn routes if any.
56 TC41: non-exist-map route-map configuration removed in R2.
57 advertise-map routes present in R2's BGP table are advertised to R3.
58 TC42: exist-map route-map configuration removed in R2
59 advertise-map routes present in R2's BGP table are withdrawn from R3.
61 Conditional advertisement(received routes) along with Route-map Filter
62 ----------------------------------------------------------------------
63 TC51: exist-map routes present in R2's BGP table, with route-map filter.
64 All routes are withdrawn from R3 except advertise-map routes.
65 TC52: exist-map routes present in R2's BGP table, without route-map filter.
66 All routes are advertised to R3 including advertise-map routes.
67 TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
68 All routes are withdrawn from R3 including advertise-map routes.
69 TC54: non-exist-map routes present in R2's BGP table, without route-map filter.
70 All routes are advertised to R3 except advertise-map routes.
72 TC61: exist-map routes not present in R2's BGP table, with route-map filter.
73 All routes are withdrawn from R3 including advertise-map routes.
74 TC62: exist-map routes not present in R2's BGP table, without route-map filter.
75 All routes are advertised to R3 except advertise-map routes.
76 TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
77 All routes are withdrawn from R3 except advertise-map routes.
78 TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
79 All routes are advertised to R3 including advertise-map routes.
81 Conditional advertisement(attached routes) along with Route-map Filter
82 -----------------------------------------------------------------
83 TC71: exist-map routes present in R2's BGP table, with route-map filter.
84 All routes are withdrawn from R3 except advertise-map routes.
85 TC72: exist-map routes present in R2's BGP table, without route-map filter.
86 All routes are advertised to R3 including advertise-map routes.
87 TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
88 All routes are withdrawn from R3 including advertise-map routes.
89 TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
90 All routes are advertised to R3 except advertise-map routes.
92 TC81: exist-map routes not present in R2's BGP table, with route-map filter.
93 All routes are withdrawn from R3 including advertise-map routes.
94 TC82: exist-map routes not present in R2's BGP table, without route-map filter.
95 All routes are advertised to R3 except advertise-map routes.
96 TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
97 All routes are withdrawn from R3 except advertise-map routes.
98 TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
99 All routes are advertised to R3 including advertise-map routes.
101 TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
102 All routes are advertised to R3 including advertise-map routes.
103 TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
104 All routes are advertised to R3 except advertise-map routes.
105 TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
106 All routes are advertised to R3 including advertise-map routes.
107 TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
108 All routes are advertised to R3 except advertise-map routes.
111 +----------------+-------------------------+------------------------+
112 | Routes in | exist-map status | advertise-map status |
114 +----------------+-------------------------+------------------------+
115 | Present | Condition matched | Advertise |
116 +----------------+-------------------------+------------------------+
117 | Not Present | Condition not matched | Withdrawn |
118 +----------------+-------------------------+------------------------+
119 | | non-exist-map status | advertise-map status |
121 +----------------+-------------------------+------------------------+
122 | Present | Condition matched | Withdrawn |
123 +----------------+-------------------------+------------------------+
124 | Not Present | Condition not matched | Advertise |
125 +----------------+-------------------------+------------------------+
126 Here in this topology, based on the default route presence in R2 and
127 the configured condition-map (exist-map/non-exist-map) 10.139.224.0/20
128 will be either advertised/withdrawn to/from R3.
138 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
139 sys
.path
.append(os
.path
.join(CWD
, "../"))
141 # pylint: disable=C0413
142 from lib
import topotest
143 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
144 from lib
.topolog
import logger
146 pytestmark
= [pytest
.mark
.bgpd
]
149 def build_topo(tgen
):
150 r1
= tgen
.add_router("r1")
151 r2
= tgen
.add_router("r2")
152 r3
= tgen
.add_router("r3")
154 switch
= tgen
.add_switch("s1")
158 switch
= tgen
.add_switch("s2")
163 def setup_module(mod
):
164 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
165 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
166 logger
.info("=" * 40)
168 logger
.info("Running setup_module to create topology")
170 tgen
= Topogen(build_topo
, mod
.__name
__)
171 tgen
.start_topology()
173 router_list
= tgen
.routers()
175 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
177 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
180 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
185 logger
.info("Running setup_module() done")
188 def teardown_module(mod
):
190 Teardown the pytest environment
194 logger
.info("Running teardown_module to delete topology")
200 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
202 logger
.info("=" * 40)
205 def all_routes_advertised(router
):
206 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
208 "0.0.0.0/0": [{"protocol": "bgp"}],
209 "192.0.2.1/32": [{"protocol": "bgp"}],
210 "192.0.2.5/32": [{"protocol": "bgp"}],
211 "10.139.224.0/20": [{"protocol": "bgp"}],
212 "203.0.113.1/32": [{"protocol": "bgp"}],
214 return topotest
.json_cmp(output
, expected
)
217 def all_routes_withdrawn(router
):
218 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
221 "192.0.2.1/32": None,
222 "192.0.2.5/32": None,
223 "10.139.224.0/20": None,
224 "203.0.113.1/32": None,
226 return topotest
.json_cmp(output
, expected
)
229 def default_route_withdrawn(router
):
230 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
233 "192.0.2.1/32": [{"protocol": "bgp"}],
234 "192.0.2.5/32": [{"protocol": "bgp"}],
235 "10.139.224.0/20": [{"protocol": "bgp"}],
236 "203.0.113.1/32": [{"protocol": "bgp"}],
238 return topotest
.json_cmp(output
, expected
)
241 # BGP conditional advertisement with route-maps
242 # EXIST-MAP, ADV-MAP-1 and RMAP-1
243 def exist_map_routes_present(router
):
244 return all_routes_advertised(router
)
247 def exist_map_routes_not_present(router
):
248 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
251 "192.0.2.1/32": None,
252 "192.0.2.5/32": [{"protocol": "bgp"}],
253 "10.139.224.0/20": None,
254 "203.0.113.1/32": [{"protocol": "bgp"}],
256 return topotest
.json_cmp(output
, expected
)
259 def non_exist_map_routes_present(router
):
260 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
262 "0.0.0.0/0": [{"protocol": "bgp"}],
263 "192.0.2.1/32": None,
264 "192.0.2.5/32": [{"protocol": "bgp"}],
265 "10.139.224.0/20": None,
266 "203.0.113.1/32": [{"protocol": "bgp"}],
268 return topotest
.json_cmp(output
, expected
)
271 def non_exist_map_routes_not_present(router
):
272 return default_route_withdrawn(router
)
275 def exist_map_no_condition_route_map(router
):
276 return non_exist_map_routes_present(router
)
279 def non_exist_map_no_condition_route_map(router
):
280 return all_routes_advertised(router
)
283 def exist_map_routes_present_rmap_filter(router
):
284 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
287 "192.0.2.1/32": [{"protocol": "bgp"}],
288 "192.0.2.5/32": None,
289 "10.139.224.0/20": [{"protocol": "bgp"}],
290 "203.0.113.1/32": None,
292 return topotest
.json_cmp(output
, expected
)
295 def exist_map_routes_present_no_rmap_filter(router
):
296 return all_routes_advertised(router
)
299 def non_exist_map_routes_present_rmap_filter(router
):
300 return all_routes_withdrawn(router
)
303 def non_exist_map_routes_present_no_rmap_filter(router
):
304 return non_exist_map_routes_present(router
)
307 def exist_map_routes_not_present_rmap_filter(router
):
308 return all_routes_withdrawn(router
)
311 def exist_map_routes_not_present_no_rmap_filter(router
):
312 return exist_map_routes_not_present(router
)
315 def non_exist_map_routes_not_present_rmap_filter(router
):
316 return exist_map_routes_present_rmap_filter(router
)
319 def non_exist_map_routes_not_present_no_rmap_filter(router
):
320 return non_exist_map_routes_not_present(router
)
323 # BGP conditional advertisement with route-maps
324 # EXIST-MAP, ADV-MAP-2 and RMAP-2
325 def exist_map_routes_not_present_rmap2_filter(router
):
326 return all_routes_withdrawn(router
)
329 def exist_map_routes_not_present_no_rmap2_filter(router
):
330 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
333 "192.0.2.1/32": [{"protocol": "bgp"}],
334 "192.0.2.5/32": [{"protocol": "bgp"}],
335 "10.139.224.0/20": [{"protocol": "bgp"}],
336 "203.0.113.1/32": None,
338 return topotest
.json_cmp(output
, expected
)
341 def non_exist_map_routes_not_present_rmap2_filter(router
):
342 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
345 "192.0.2.1/32": None,
346 "192.0.2.5/32": None,
347 "10.139.224.0/20": None,
348 "203.0.113.1/32": [{"protocol": "bgp", "metric": 911}],
350 return topotest
.json_cmp(output
, expected
)
353 def non_exist_map_routes_not_present_no_rmap2_filter(router
):
354 return non_exist_map_routes_not_present(router
)
357 def exist_map_routes_present_rmap2_filter(router
):
358 return non_exist_map_routes_not_present_rmap2_filter(router
)
361 def exist_map_routes_present_no_rmap2_filter(router
):
362 return all_routes_advertised(router
)
365 def non_exist_map_routes_present_rmap2_filter(router
):
366 return all_routes_withdrawn(router
)
369 def non_exist_map_routes_present_no_rmap2_filter(router
):
370 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
372 "0.0.0.0/0": [{"protocol": "bgp"}],
373 "192.0.2.1/32": [{"protocol": "bgp"}],
374 "192.0.2.5/32": [{"protocol": "bgp"}],
375 "10.139.224.0/20": [{"protocol": "bgp"}],
376 "203.0.113.1/32": None,
378 return topotest
.json_cmp(output
, expected
)
381 def exist_map_routes_present_rmap2_network(router
):
382 return non_exist_map_routes_not_present_rmap2_filter(router
)
385 def exist_map_routes_present_rmap2_no_network(router
):
386 return all_routes_withdrawn(router
)
389 def non_exist_map_routes_not_present_rmap2_network(router
):
390 return non_exist_map_routes_not_present_rmap2_filter(router
)
393 def non_exist_map_routes_not_present_rmap2_no_network(router
):
394 return all_routes_withdrawn(router
)
401 def test_bgp_conditional_advertisement_tc_1_1():
403 if tgen
.routers_have_failure():
404 pytest
.skip(tgen
.errors
)
406 router1
= tgen
.gears
["r1"]
407 router2
= tgen
.gears
["r2"]
408 router3
= tgen
.gears
["r3"]
410 # TC11: R3 BGP convergence, without advertise-map configuration.
411 # All routes are advertised to R3.
412 test_func
= functools
.partial(all_routes_advertised
, router3
)
413 success
, result
= topotest
.run_and_expect(test_func
, None, count
=130, wait
=1)
415 msg
= 'TC11: "router3" BGP convergence - '
416 assert result
is None, msg
+ failed
418 logger
.info(msg
+ passed
)
421 def test_bgp_conditional_advertisement_tc_2_1():
423 if tgen
.routers_have_failure():
424 pytest
.skip(tgen
.errors
)
426 router1
= tgen
.gears
["r1"]
427 router2
= tgen
.gears
["r2"]
428 router3
= tgen
.gears
["r3"]
430 # TC21: exist-map routes present in R2's BGP table.
431 # advertise-map routes present in R2's BGP table are advertised to R3.
436 address-family ipv4 unicast
437 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
441 test_func
= functools
.partial(exist_map_routes_present
, router3
)
442 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
444 msg
= 'TC21: exist-map routes present in "router2" BGP table - '
445 assert result
is None, msg
+ failed
447 logger
.info(msg
+ passed
)
450 def test_bgp_conditional_advertisement_tc_2_2():
452 if tgen
.routers_have_failure():
453 pytest
.skip(tgen
.errors
)
455 router1
= tgen
.gears
["r1"]
456 router2
= tgen
.gears
["r2"]
457 router3
= tgen
.gears
["r3"]
459 # TC22: exist-map routes not present in R2's BGP table
460 # advertise-map routes present in R2's BGP table are withdrawn from R3.
465 address-family ipv4 unicast
466 no network 0.0.0.0/0 route-map DEF
470 test_func
= functools
.partial(exist_map_routes_not_present
, router3
)
471 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
473 msg
= 'TC22: exist-map routes not present in "router2" BGP table - '
474 assert result
is None, msg
+ failed
476 logger
.info(msg
+ passed
)
479 def test_bgp_conditional_advertisement_tc_2_3():
481 if tgen
.routers_have_failure():
482 pytest
.skip(tgen
.errors
)
484 router1
= tgen
.gears
["r1"]
485 router2
= tgen
.gears
["r2"]
486 router3
= tgen
.gears
["r3"]
488 # TC23: advertise-map with exist-map configuration is removed from a peer
489 # send normal BGP update to advertise previously withdrawn routes if any.
494 address-family ipv4 unicast
495 no neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
499 test_func
= functools
.partial(default_route_withdrawn
, router3
)
500 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
502 msg
= "TC23: advertise-map with exist-map configuration is removed from peer - "
503 assert result
is None, msg
+ failed
505 logger
.info(msg
+ passed
)
508 def test_bgp_conditional_advertisement_tc_3_1():
510 if tgen
.routers_have_failure():
511 pytest
.skip(tgen
.errors
)
513 router1
= tgen
.gears
["r1"]
514 router2
= tgen
.gears
["r2"]
515 router3
= tgen
.gears
["r3"]
517 # TC31: non-exist-map routes not present in R2's BGP table
518 # advertise-map routes present in R2's BGP table are advertised to R3.
523 address-family ipv4 unicast
524 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
528 test_func
= functools
.partial(non_exist_map_routes_not_present
, router3
)
529 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
531 msg
= 'TC31: non-exist-map routes not present in "router2" BGP table - '
532 assert result
is None, msg
+ failed
534 logger
.info(msg
+ passed
)
537 def test_bgp_conditional_advertisement_tc_3_2():
539 if tgen
.routers_have_failure():
540 pytest
.skip(tgen
.errors
)
542 router1
= tgen
.gears
["r1"]
543 router2
= tgen
.gears
["r2"]
544 router3
= tgen
.gears
["r3"]
546 # TC32: non-exist-map routes present in R2's BGP table
547 # advertise-map routes present in R2's BGP table are withdrawn from R3.
552 address-family ipv4 unicast
553 network 0.0.0.0/0 route-map DEF
557 test_func
= functools
.partial(non_exist_map_routes_present
, router3
)
558 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
560 msg
= 'TC32: non-exist-map routes present in "router2" BGP table - '
561 assert result
is None, msg
+ failed
563 logger
.info(msg
+ passed
)
566 def test_bgp_conditional_advertisement_tc_3_3():
568 if tgen
.routers_have_failure():
569 pytest
.skip(tgen
.errors
)
571 router1
= tgen
.gears
["r1"]
572 router2
= tgen
.gears
["r2"]
573 router3
= tgen
.gears
["r3"]
575 # TC33: advertise-map with non-exist-map configuration is removed from a peer
576 # send normal BGP update to advertisepreviously withdrawn routes if any.
581 address-family ipv4 unicast
582 no neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
586 test_func
= functools
.partial(all_routes_advertised
, router3
)
587 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
590 "TC33: advertise-map with non-exist-map configuration is removed from a peer - "
592 assert result
is None, msg
+ failed
594 logger
.info(msg
+ passed
)
597 def test_bgp_conditional_advertisement_tc_4_1():
599 if tgen
.routers_have_failure():
600 pytest
.skip(tgen
.errors
)
602 router1
= tgen
.gears
["r1"]
603 router2
= tgen
.gears
["r2"]
604 router3
= tgen
.gears
["r3"]
606 # TC41: non-exist-map route-map configuration removed in R2.
607 # advertise-map routes present in R2's BGP table are advertised to R3.
612 address-family ipv4 unicast
613 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
614 no route-map EXIST-MAP permit 10
618 test_func
= functools
.partial(non_exist_map_no_condition_route_map
, router3
)
619 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
621 msg
= 'TC41: non-exist-map route-map removed in "router2" - '
622 assert result
is None, msg
+ failed
624 logger
.info(msg
+ passed
)
627 def test_bgp_conditional_advertisement_tc_4_2():
629 if tgen
.routers_have_failure():
630 pytest
.skip(tgen
.errors
)
632 router1
= tgen
.gears
["r1"]
633 router2
= tgen
.gears
["r2"]
634 router3
= tgen
.gears
["r3"]
636 # TC42: exist-map route-map configuration removed in R2
637 # advertise-map routes present in R2's BGP table are withdrawn from R3.
642 address-family ipv4 unicast
643 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
647 test_func
= functools
.partial(exist_map_no_condition_route_map
, router3
)
648 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
650 msg
= 'TC42: exist-map route-map removed in "router2" - '
651 assert result
is None, msg
+ failed
653 logger
.info(msg
+ passed
)
656 def test_bgp_conditional_advertisement_tc_5_1():
658 if tgen
.routers_have_failure():
659 pytest
.skip(tgen
.errors
)
661 router1
= tgen
.gears
["r1"]
662 router2
= tgen
.gears
["r2"]
663 router3
= tgen
.gears
["r3"]
665 # TC51: exist-map routes present in R2's BGP table, with route-map filter.
666 # All routes are withdrawn from R3 except advertise-map routes.
670 route-map EXIST-MAP permit 10
671 match community DEFAULT-ROUTE
672 match ip address prefix-list DEFAULT-ROUTE
675 address-family ipv4 unicast
676 neighbor 10.10.20.3 route-map RMAP-1 out
680 test_func
= functools
.partial(exist_map_routes_present_rmap_filter
, router3
)
681 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
683 msg
= "TC51: exist-map routes present with route-map filter - "
684 assert result
is None, msg
+ failed
686 logger
.info(msg
+ passed
)
689 def test_bgp_conditional_advertisement_tc_5_2():
691 if tgen
.routers_have_failure():
692 pytest
.skip(tgen
.errors
)
694 router1
= tgen
.gears
["r1"]
695 router2
= tgen
.gears
["r2"]
696 router3
= tgen
.gears
["r3"]
698 # TC52: exist-map routes present in R2's BGP table, no route-map filter.
699 # All routes are advertised to R3 including advertise-map routes.
704 address-family ipv4 unicast
705 no neighbor 10.10.20.3 route-map RMAP-1 out
709 test_func
= functools
.partial(exist_map_routes_present_no_rmap_filter
, router3
)
710 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
712 msg
= "TC52: exist-map routes present, no route-map filter - "
713 assert result
is None, msg
+ failed
715 logger
.info(msg
+ passed
)
718 def test_bgp_conditional_advertisement_tc_5_3():
720 if tgen
.routers_have_failure():
721 pytest
.skip(tgen
.errors
)
723 router1
= tgen
.gears
["r1"]
724 router2
= tgen
.gears
["r2"]
725 router3
= tgen
.gears
["r3"]
727 # TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
728 # All routes are withdrawn from R3 including advertise-map routes.
733 address-family ipv4 unicast
734 neighbor 10.10.20.3 route-map RMAP-1 out
735 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
739 test_func
= functools
.partial(non_exist_map_routes_present_rmap_filter
, router3
)
740 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
742 msg
= "TC53: non-exist-map routes present, with route-map filter - "
743 assert result
is None, msg
+ failed
745 logger
.info(msg
+ passed
)
748 def test_bgp_conditional_advertisement_tc_5_4():
750 if tgen
.routers_have_failure():
751 pytest
.skip(tgen
.errors
)
753 router1
= tgen
.gears
["r1"]
754 router2
= tgen
.gears
["r2"]
755 router3
= tgen
.gears
["r3"]
757 # TC54: non-exist-map routes present in R2's BGP table, no route-map filter.
758 # All routes are advertised to R3 except advertise-map routes.
763 address-family ipv4 unicast
764 no neighbor 10.10.20.3 route-map RMAP-1 out
768 test_func
= functools
.partial(non_exist_map_routes_present_no_rmap_filter
, router3
)
769 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
771 msg
= "TC54: non-exist-map routes present, no route-map filter - "
772 assert result
is None, msg
+ failed
774 logger
.info(msg
+ passed
)
777 def test_bgp_conditional_advertisement_tc_6_1():
779 if tgen
.routers_have_failure():
780 pytest
.skip(tgen
.errors
)
782 router1
= tgen
.gears
["r1"]
783 router2
= tgen
.gears
["r2"]
784 router3
= tgen
.gears
["r3"]
786 # TC61: exist-map routes not present in R2's BGP table, with route-map filter.
787 # All routes are withdrawn from R3 including advertise-map routes.
792 address-family ipv4 unicast
793 no network 0.0.0.0/0 route-map DEF
800 address-family ipv4 unicast
801 neighbor 10.10.20.3 route-map RMAP-1 out
802 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
806 test_func
= functools
.partial(exist_map_routes_not_present_rmap_filter
, router3
)
807 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
809 msg
= "TC61: exist-map routes not present, route-map filter - "
810 assert result
is None, msg
+ failed
812 logger
.info(msg
+ passed
)
815 def test_bgp_conditional_advertisement_tc_6_2():
817 if tgen
.routers_have_failure():
818 pytest
.skip(tgen
.errors
)
820 router1
= tgen
.gears
["r1"]
821 router2
= tgen
.gears
["r2"]
822 router3
= tgen
.gears
["r3"]
824 # TC62: exist-map routes not present in R2's BGP table, without route-map filter.
825 # All routes are advertised to R3 except advertise-map routes.
830 address-family ipv4 unicast
831 no neighbor 10.10.20.3 route-map RMAP-1 out
835 test_func
= functools
.partial(exist_map_routes_not_present_no_rmap_filter
, router3
)
836 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
838 msg
= "TC62: exist-map routes not present, no route-map filter - "
839 assert result
is None, msg
+ failed
841 logger
.info(msg
+ passed
)
844 def test_bgp_conditional_advertisement_tc_6_3():
846 if tgen
.routers_have_failure():
847 pytest
.skip(tgen
.errors
)
849 router1
= tgen
.gears
["r1"]
850 router2
= tgen
.gears
["r2"]
851 router3
= tgen
.gears
["r3"]
853 # TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
854 # All routes are withdrawn from R3 except advertise-map routes.
859 address-family ipv4 unicast
860 neighbor 10.10.20.3 route-map RMAP-1 out
861 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
865 test_func
= functools
.partial(non_exist_map_routes_not_present_rmap_filter
, router3
)
866 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
868 msg
= "TC63: non-exist-map routes not present, route-map filter - "
869 assert result
is None, msg
+ failed
871 logger
.info(msg
+ passed
)
874 def test_bgp_conditional_advertisement_tc_6_4():
876 if tgen
.routers_have_failure():
877 pytest
.skip(tgen
.errors
)
879 router1
= tgen
.gears
["r1"]
880 router2
= tgen
.gears
["r2"]
881 router3
= tgen
.gears
["r3"]
883 # TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
884 # All routes are advertised to R3 including advertise-map routes.
889 address-family ipv4 unicast
890 no neighbor 10.10.20.3 route-map RMAP-1 out
894 test_func
= functools
.partial(
895 non_exist_map_routes_not_present_no_rmap_filter
, router3
897 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
899 msg
= "TC64: non-exist-map routes not present, no route-map filter - "
900 assert result
is None, msg
+ failed
902 logger
.info(msg
+ passed
)
905 def test_bgp_conditional_advertisement_tc_7_1():
907 if tgen
.routers_have_failure():
908 pytest
.skip(tgen
.errors
)
910 router1
= tgen
.gears
["r1"]
911 router2
= tgen
.gears
["r2"]
912 router3
= tgen
.gears
["r3"]
914 # TC71: exist-map routes present in R2's BGP table, with route-map filter.
915 # All routes are withdrawn from R3 except advertise-map routes.
920 address-family ipv4 unicast
921 network 0.0.0.0/0 route-map DEF
928 address-family ipv4 unicast
929 neighbor 10.10.20.3 route-map RMAP-2 out
930 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
934 test_func
= functools
.partial(exist_map_routes_present_rmap2_filter
, router3
)
935 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
937 msg
= "TC71: exist-map routes present, route-map filter - "
938 assert result
is None, msg
+ failed
940 logger
.info(msg
+ passed
)
943 def test_bgp_conditional_advertisement_tc_7_2():
945 if tgen
.routers_have_failure():
946 pytest
.skip(tgen
.errors
)
948 router1
= tgen
.gears
["r1"]
949 router2
= tgen
.gears
["r2"]
950 router3
= tgen
.gears
["r3"]
952 # TC72: exist-map routes present in R2's BGP table, without route-map filter.
953 # All routes are advertised to R3 including advertise-map routes.
958 address-family ipv4 unicast
959 no neighbor 10.10.20.3 route-map RMAP-2 out
963 test_func
= functools
.partial(exist_map_routes_present_no_rmap2_filter
, router3
)
964 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
966 msg
= "TC72: exist-map routes present, no route-map filter - "
967 assert result
is None, msg
+ failed
969 logger
.info(msg
+ passed
)
972 def test_bgp_conditional_advertisement_tc_7_3():
974 if tgen
.routers_have_failure():
975 pytest
.skip(tgen
.errors
)
977 router1
= tgen
.gears
["r1"]
978 router2
= tgen
.gears
["r2"]
979 router3
= tgen
.gears
["r3"]
981 # TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
982 # All routes are advertised to R3 including advertise-map routes.
987 address-family ipv4 unicast
988 neighbor 10.10.20.3 route-map RMAP-2 out
989 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
993 test_func
= functools
.partial(non_exist_map_routes_present_rmap2_filter
, router3
)
994 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
996 msg
= "TC73: non-exist-map routes present, route-map filter - "
997 assert result
is None, msg
+ failed
999 logger
.info(msg
+ passed
)
1002 def test_bgp_conditional_advertisement_tc_7_4():
1003 tgen
= get_topogen()
1004 if tgen
.routers_have_failure():
1005 pytest
.skip(tgen
.errors
)
1007 router1
= tgen
.gears
["r1"]
1008 router2
= tgen
.gears
["r2"]
1009 router3
= tgen
.gears
["r3"]
1011 # TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
1012 # All routes are advertised to R3 including advertise-map routes.
1017 address-family ipv4 unicast
1018 no neighbor 10.10.20.3 route-map RMAP-2 out
1022 test_func
= functools
.partial(non_exist_map_routes_present_no_rmap2_filter
, router3
)
1023 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1025 msg
= "TC74: non-exist-map routes present, no route-map filter - "
1026 assert result
is None, msg
+ failed
1028 logger
.info(msg
+ passed
)
1031 def test_bgp_conditional_advertisement_tc_8_1():
1032 tgen
= get_topogen()
1033 if tgen
.routers_have_failure():
1034 pytest
.skip(tgen
.errors
)
1036 router1
= tgen
.gears
["r1"]
1037 router2
= tgen
.gears
["r2"]
1038 router3
= tgen
.gears
["r3"]
1040 # TC81: exist-map routes not present in R2's BGP table, with route-map filter.
1041 # All routes are withdrawn from R3 including advertise-map routes.
1046 address-family ipv4 unicast
1047 no network 0.0.0.0/0 route-map DEF
1054 address-family ipv4 unicast
1055 neighbor 10.10.20.3 route-map RMAP-2 out
1056 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
1060 test_func
= functools
.partial(exist_map_routes_not_present_rmap2_filter
, router3
)
1061 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1063 msg
= "TC81: exist-map routes not present, route-map filter - "
1064 assert result
is None, msg
+ failed
1066 logger
.info(msg
+ passed
)
1069 def test_bgp_conditional_advertisement_tc_8_2():
1070 tgen
= get_topogen()
1071 if tgen
.routers_have_failure():
1072 pytest
.skip(tgen
.errors
)
1074 router1
= tgen
.gears
["r1"]
1075 router2
= tgen
.gears
["r2"]
1076 router3
= tgen
.gears
["r3"]
1078 # TC82: exist-map routes not present in R2's BGP table, without route-map filter.
1079 # All routes are advertised to R3 except advertise-map routes.
1084 address-family ipv4 unicast
1085 no neighbor 10.10.20.3 route-map RMAP-2 out
1089 test_func
= functools
.partial(exist_map_routes_not_present_no_rmap2_filter
, router3
)
1090 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1092 msg
= "TC82: exist-map routes not present, no route-map filter - "
1093 assert result
is None, msg
+ failed
1095 logger
.info(msg
+ passed
)
1098 def test_bgp_conditional_advertisement_tc_8_3():
1099 tgen
= get_topogen()
1100 if tgen
.routers_have_failure():
1101 pytest
.skip(tgen
.errors
)
1103 router1
= tgen
.gears
["r1"]
1104 router2
= tgen
.gears
["r2"]
1105 router3
= tgen
.gears
["r3"]
1107 # TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
1108 # All routes are advertised to R3 including advertise-map routes.
1113 address-family ipv4 unicast
1114 neighbor 10.10.20.3 route-map RMAP-2 out
1115 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
1119 test_func
= functools
.partial(
1120 non_exist_map_routes_not_present_rmap2_filter
, router3
1122 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1124 msg
= "TC83: non-exist-map routes not present, route-map filter - "
1125 assert result
is None, msg
+ failed
1127 logger
.info(msg
+ passed
)
1130 def test_bgp_conditional_advertisement_tc_8_4():
1131 tgen
= get_topogen()
1132 if tgen
.routers_have_failure():
1133 pytest
.skip(tgen
.errors
)
1135 router1
= tgen
.gears
["r1"]
1136 router2
= tgen
.gears
["r2"]
1137 router3
= tgen
.gears
["r3"]
1139 # TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
1140 # All routes are advertised to R3 including advertise-map routes.
1145 address-family ipv4 unicast
1146 no neighbor 10.10.20.3 route-map RMAP-2 out
1150 test_func
= functools
.partial(
1151 non_exist_map_routes_not_present_no_rmap2_filter
, router3
1153 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1155 msg
= "TC84: non-exist-map routes not present, no route-map filter - "
1156 assert result
is None, msg
+ failed
1158 logger
.info(msg
+ passed
)
1161 def test_bgp_conditional_advertisement_tc_9_1():
1162 tgen
= get_topogen()
1163 if tgen
.routers_have_failure():
1164 pytest
.skip(tgen
.errors
)
1166 router1
= tgen
.gears
["r1"]
1167 router2
= tgen
.gears
["r2"]
1168 router3
= tgen
.gears
["r3"]
1170 # TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
1171 # All routes are advertised to R3 including advertise-map routes.
1176 address-family ipv4 unicast
1177 network 0.0.0.0/0 route-map DEF
1184 address-family ipv4 unicast
1185 neighbor 10.10.20.3 route-map RMAP-2 out
1186 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
1190 test_func
= functools
.partial(exist_map_routes_present_rmap2_network
, router3
)
1191 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1193 msg
= "TC91: exist-map routes present, route-map filter and network - "
1194 assert result
is None, msg
+ failed
1196 logger
.info(msg
+ passed
)
1199 def test_bgp_conditional_advertisement_tc_9_2():
1200 tgen
= get_topogen()
1201 if tgen
.routers_have_failure():
1202 pytest
.skip(tgen
.errors
)
1204 router1
= tgen
.gears
["r1"]
1205 router2
= tgen
.gears
["r2"]
1206 router3
= tgen
.gears
["r3"]
1208 # TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
1209 # All routes are advertised to R3 except advertise-map routes.
1214 address-family ipv4 unicast
1215 no network 203.0.113.1/32
1219 test_func
= functools
.partial(exist_map_routes_present_rmap2_no_network
, router3
)
1220 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1222 msg
= "TC92: exist-map routes present, route-map filter and no network - "
1223 assert result
is None, msg
+ failed
1225 logger
.info(msg
+ passed
)
1228 def test_bgp_conditional_advertisement_tc_9_3():
1229 tgen
= get_topogen()
1230 if tgen
.routers_have_failure():
1231 pytest
.skip(tgen
.errors
)
1233 router1
= tgen
.gears
["r1"]
1234 router2
= tgen
.gears
["r2"]
1235 router3
= tgen
.gears
["r3"]
1237 # TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
1238 # All routes are advertised to R3 including advertise-map routes.
1243 address-family ipv4 unicast
1244 no network 0.0.0.0/0 route-map DEF
1251 address-family ipv4 unicast
1252 network 203.0.113.1/32
1253 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
1257 test_func
= functools
.partial(
1258 non_exist_map_routes_not_present_rmap2_network
, router3
1260 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1262 msg
= "TC93: non-exist-map routes not present, route-map filter and network - "
1263 assert result
is None, msg
+ failed
1265 logger
.info(msg
+ passed
)
1268 def test_bgp_conditional_advertisement_tc_9_4():
1269 tgen
= get_topogen()
1270 if tgen
.routers_have_failure():
1271 pytest
.skip(tgen
.errors
)
1273 router1
= tgen
.gears
["r1"]
1274 router2
= tgen
.gears
["r2"]
1275 router3
= tgen
.gears
["r3"]
1277 # TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
1278 # All routes are advertised to R3 except advertise-map routes.
1283 address-family ipv4 unicast
1284 no network 203.0.113.1/32
1288 test_func
= functools
.partial(
1289 non_exist_map_routes_not_present_rmap2_no_network
, router3
1291 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1293 msg
= "TC94: non-exist-map routes not present, route-map filter and no network - "
1294 assert result
is None, msg
+ failed
1296 logger
.info(msg
+ passed
)
1299 def test_memory_leak():
1300 "Run the memory leak test and report results."
1301 tgen
= get_topogen()
1302 if not tgen
.is_memleak_enabled():
1303 pytest
.skip("Memory leak test/report is disabled")
1305 tgen
.report_memory_leaks()
1308 if __name__
== "__main__":
1309 args
= ["-s"] + sys
.argv
[1:]
1310 sys
.exit(pytest
.main(args
))