2 # SPDX-License-Identifier: ISC
5 # test_bgp_conditional_advertisement.py
7 # Copyright (c) 2020 by
8 # Samsung R&D Institute India - Bangalore.
9 # Madhurilatha Kuruganti
13 Test BGP conditional advertisement functionality.
15 +--------+ +--------+ +--------+
17 | R1 |------------| R2 |------------| R3 |
19 +--------+ +--------+ +--------+
21 R2 is DUT and peers with R1 and R3 in default bgp instance.
23 Following tests are covered under BGP conditional advertisement functionality.
24 Conditional advertisement
25 -------------------------
26 TC11: R3 BGP convergence, without advertise-map configuration.
27 All routes are advertised to R3.
29 TC21: exist-map routes present in R2's BGP table.
30 advertise-map routes present in R2's BGP table are advertised to R3.
31 TC22: exist-map routes not present in R2's BGP table
32 advertise-map routes present in R2's BGP table are withdrawn from R3.
33 TC23: advertise-map with exist-map configuration is removed from a peer
34 send normal BGP update to advertise previously withdrawn routes if any.
36 TC31: non-exist-map routes not present in R2's BGP table
37 advertise-map routes present in R2's BGP table are advertised to R3.
38 TC32: non-exist-map routes present in R2's BGP table
39 advertise-map routes present in R2's BGP table are withdrawn from R3.
40 TC33: advertise-map with non-exist-map configuration is removed from a peer
41 send normal BGP update to advertisepreviously withdrawn routes if any.
43 TC41: non-exist-map route-map configuration removed in R2.
44 advertise-map routes present in R2's BGP table are advertised to R3.
45 TC42: exist-map route-map configuration removed in R2
46 advertise-map routes present in R2's BGP table are withdrawn from R3.
48 Conditional advertisement(received routes) along with Route-map Filter
49 ----------------------------------------------------------------------
50 TC51: exist-map routes present in R2's BGP table, with route-map filter.
51 All routes are withdrawn from R3 except advertise-map routes.
52 TC52: exist-map routes present in R2's BGP table, without route-map filter.
53 All routes are advertised to R3 including advertise-map routes.
54 TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
55 All routes are withdrawn from R3 including advertise-map routes.
56 TC54: non-exist-map routes present in R2's BGP table, without route-map filter.
57 All routes are advertised to R3 except advertise-map routes.
59 TC61: exist-map routes not present in R2's BGP table, with route-map filter.
60 All routes are withdrawn from R3 including advertise-map routes.
61 TC62: exist-map routes not present in R2's BGP table, without route-map filter.
62 All routes are advertised to R3 except advertise-map routes.
63 TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
64 All routes are withdrawn from R3 except advertise-map routes.
65 TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
66 All routes are advertised to R3 including advertise-map routes.
68 Conditional advertisement(attached routes) along with Route-map Filter
69 -----------------------------------------------------------------
70 TC71: exist-map routes present in R2's BGP table, with route-map filter.
71 All routes are withdrawn from R3 except advertise-map routes.
72 TC72: exist-map routes present in R2's BGP table, without route-map filter.
73 All routes are advertised to R3 including advertise-map routes.
74 TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
75 All routes are withdrawn from R3 including advertise-map routes.
76 TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
77 All routes are advertised to R3 except advertise-map routes.
79 TC81: exist-map routes not present in R2's BGP table, with route-map filter.
80 All routes are withdrawn from R3 including advertise-map routes.
81 TC82: exist-map routes not present in R2's BGP table, without route-map filter.
82 All routes are advertised to R3 except advertise-map routes.
83 TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
84 All routes are withdrawn from R3 except advertise-map routes.
85 TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
86 All routes are advertised to R3 including advertise-map routes.
88 TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
89 All routes are advertised to R3 including advertise-map routes.
90 TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
91 All routes are advertised to R3 except advertise-map routes.
92 TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
93 All routes are advertised to R3 including advertise-map routes.
94 TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
95 All routes are advertised to R3 except advertise-map routes.
98 +----------------+-------------------------+------------------------+
99 | Routes in | exist-map status | advertise-map status |
101 +----------------+-------------------------+------------------------+
102 | Present | Condition matched | Advertise |
103 +----------------+-------------------------+------------------------+
104 | Not Present | Condition not matched | Withdrawn |
105 +----------------+-------------------------+------------------------+
106 | | non-exist-map status | advertise-map status |
108 +----------------+-------------------------+------------------------+
109 | Present | Condition matched | Withdrawn |
110 +----------------+-------------------------+------------------------+
111 | Not Present | Condition not matched | Advertise |
112 +----------------+-------------------------+------------------------+
113 Here in this topology, based on the default route presence in R2 and
114 the configured condition-map (exist-map/non-exist-map) 10.139.224.0/20
115 will be either advertised/withdrawn to/from R3.
125 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
126 sys
.path
.append(os
.path
.join(CWD
, "../"))
128 # pylint: disable=C0413
129 from lib
import topotest
130 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
131 from lib
.topolog
import logger
133 pytestmark
= [pytest
.mark
.bgpd
]
136 def build_topo(tgen
):
137 r1
= tgen
.add_router("r1")
138 r2
= tgen
.add_router("r2")
139 r3
= tgen
.add_router("r3")
141 switch
= tgen
.add_switch("s1")
145 switch
= tgen
.add_switch("s2")
150 def setup_module(mod
):
151 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
152 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
153 logger
.info("=" * 40)
155 logger
.info("Running setup_module to create topology")
157 tgen
= Topogen(build_topo
, mod
.__name
__)
158 tgen
.start_topology()
160 router_list
= tgen
.routers()
162 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
164 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
167 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
172 logger
.info("Running setup_module() done")
175 def teardown_module(mod
):
177 Teardown the pytest environment
181 logger
.info("Running teardown_module to delete topology")
187 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
189 logger
.info("=" * 40)
192 def all_routes_advertised(router
):
193 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
195 "0.0.0.0/0": [{"protocol": "bgp"}],
196 "192.0.2.1/32": [{"protocol": "bgp"}],
197 "192.0.2.5/32": [{"protocol": "bgp"}],
198 "10.139.224.0/20": [{"protocol": "bgp"}],
199 "203.0.113.1/32": [{"protocol": "bgp"}],
201 return topotest
.json_cmp(output
, expected
)
204 def all_routes_withdrawn(router
):
205 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
208 "192.0.2.1/32": None,
209 "192.0.2.5/32": None,
210 "10.139.224.0/20": None,
211 "203.0.113.1/32": None,
213 return topotest
.json_cmp(output
, expected
)
216 def default_route_withdrawn(router
):
217 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
220 "192.0.2.1/32": [{"protocol": "bgp"}],
221 "192.0.2.5/32": [{"protocol": "bgp"}],
222 "10.139.224.0/20": [{"protocol": "bgp"}],
223 "203.0.113.1/32": [{"protocol": "bgp"}],
225 return topotest
.json_cmp(output
, expected
)
228 # BGP conditional advertisement with route-maps
229 # EXIST-MAP, ADV-MAP-1 and RMAP-1
230 def exist_map_routes_present(router
):
231 return all_routes_advertised(router
)
234 def exist_map_routes_not_present(router
):
235 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
238 "192.0.2.1/32": None,
239 "192.0.2.5/32": [{"protocol": "bgp"}],
240 "10.139.224.0/20": None,
241 "203.0.113.1/32": [{"protocol": "bgp"}],
243 return topotest
.json_cmp(output
, expected
)
246 def non_exist_map_routes_present(router
):
247 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
249 "0.0.0.0/0": [{"protocol": "bgp"}],
250 "192.0.2.1/32": None,
251 "192.0.2.5/32": [{"protocol": "bgp"}],
252 "10.139.224.0/20": None,
253 "203.0.113.1/32": [{"protocol": "bgp"}],
255 return topotest
.json_cmp(output
, expected
)
258 def non_exist_map_routes_not_present(router
):
259 return default_route_withdrawn(router
)
262 def exist_map_no_condition_route_map(router
):
263 return non_exist_map_routes_present(router
)
266 def non_exist_map_no_condition_route_map(router
):
267 return all_routes_advertised(router
)
270 def exist_map_routes_present_rmap_filter(router
):
271 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
274 "192.0.2.1/32": [{"protocol": "bgp"}],
275 "192.0.2.5/32": None,
276 "10.139.224.0/20": [{"protocol": "bgp"}],
277 "203.0.113.1/32": None,
279 return topotest
.json_cmp(output
, expected
)
282 def exist_map_routes_present_no_rmap_filter(router
):
283 return all_routes_advertised(router
)
286 def non_exist_map_routes_present_rmap_filter(router
):
287 return all_routes_withdrawn(router
)
290 def non_exist_map_routes_present_no_rmap_filter(router
):
291 return non_exist_map_routes_present(router
)
294 def exist_map_routes_not_present_rmap_filter(router
):
295 return all_routes_withdrawn(router
)
298 def exist_map_routes_not_present_no_rmap_filter(router
):
299 return exist_map_routes_not_present(router
)
302 def non_exist_map_routes_not_present_rmap_filter(router
):
303 return exist_map_routes_present_rmap_filter(router
)
306 def non_exist_map_routes_not_present_no_rmap_filter(router
):
307 return non_exist_map_routes_not_present(router
)
310 # BGP conditional advertisement with route-maps
311 # EXIST-MAP, ADV-MAP-2 and RMAP-2
312 def exist_map_routes_not_present_rmap2_filter(router
):
313 return all_routes_withdrawn(router
)
316 def exist_map_routes_not_present_no_rmap2_filter(router
):
317 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
320 "192.0.2.1/32": [{"protocol": "bgp"}],
321 "192.0.2.5/32": [{"protocol": "bgp"}],
322 "10.139.224.0/20": [{"protocol": "bgp"}],
323 "203.0.113.1/32": None,
325 return topotest
.json_cmp(output
, expected
)
328 def non_exist_map_routes_not_present_rmap2_filter(router
):
329 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
332 "192.0.2.1/32": None,
333 "192.0.2.5/32": None,
334 "10.139.224.0/20": None,
335 "203.0.113.1/32": [{"protocol": "bgp", "metric": 911}],
337 return topotest
.json_cmp(output
, expected
)
340 def non_exist_map_routes_not_present_no_rmap2_filter(router
):
341 return non_exist_map_routes_not_present(router
)
344 def exist_map_routes_present_rmap2_filter(router
):
345 return non_exist_map_routes_not_present_rmap2_filter(router
)
348 def exist_map_routes_present_no_rmap2_filter(router
):
349 return all_routes_advertised(router
)
352 def non_exist_map_routes_present_rmap2_filter(router
):
353 return all_routes_withdrawn(router
)
356 def non_exist_map_routes_present_no_rmap2_filter(router
):
357 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
359 "0.0.0.0/0": [{"protocol": "bgp"}],
360 "192.0.2.1/32": [{"protocol": "bgp"}],
361 "192.0.2.5/32": [{"protocol": "bgp"}],
362 "10.139.224.0/20": [{"protocol": "bgp"}],
363 "203.0.113.1/32": None,
365 return topotest
.json_cmp(output
, expected
)
368 def exist_map_routes_present_rmap2_network(router
):
369 return non_exist_map_routes_not_present_rmap2_filter(router
)
372 def exist_map_routes_present_rmap2_no_network(router
):
373 return all_routes_withdrawn(router
)
376 def non_exist_map_routes_not_present_rmap2_network(router
):
377 return non_exist_map_routes_not_present_rmap2_filter(router
)
380 def non_exist_map_routes_not_present_rmap2_no_network(router
):
381 return all_routes_withdrawn(router
)
388 def test_bgp_conditional_advertisement_tc_1_1():
390 if tgen
.routers_have_failure():
391 pytest
.skip(tgen
.errors
)
393 router1
= tgen
.gears
["r1"]
394 router2
= tgen
.gears
["r2"]
395 router3
= tgen
.gears
["r3"]
397 # TC11: R3 BGP convergence, without advertise-map configuration.
398 # All routes are advertised to R3.
399 test_func
= functools
.partial(all_routes_advertised
, router3
)
400 success
, result
= topotest
.run_and_expect(test_func
, None, count
=130, wait
=1)
402 msg
= 'TC11: "router3" BGP convergence - '
403 assert result
is None, msg
+ failed
405 logger
.info(msg
+ passed
)
408 def test_bgp_conditional_advertisement_tc_2_1():
410 if tgen
.routers_have_failure():
411 pytest
.skip(tgen
.errors
)
413 router1
= tgen
.gears
["r1"]
414 router2
= tgen
.gears
["r2"]
415 router3
= tgen
.gears
["r3"]
417 # TC21: exist-map routes present in R2's BGP table.
418 # advertise-map routes present in R2's BGP table are advertised to R3.
423 address-family ipv4 unicast
424 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
428 test_func
= functools
.partial(exist_map_routes_present
, router3
)
429 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
431 msg
= 'TC21: exist-map routes present in "router2" BGP table - '
432 assert result
is None, msg
+ failed
434 logger
.info(msg
+ passed
)
437 def test_bgp_conditional_advertisement_tc_2_2():
439 if tgen
.routers_have_failure():
440 pytest
.skip(tgen
.errors
)
442 router1
= tgen
.gears
["r1"]
443 router2
= tgen
.gears
["r2"]
444 router3
= tgen
.gears
["r3"]
446 # TC22: exist-map routes not present in R2's BGP table
447 # advertise-map routes present in R2's BGP table are withdrawn from R3.
452 address-family ipv4 unicast
453 no network 0.0.0.0/0 route-map DEF
457 test_func
= functools
.partial(exist_map_routes_not_present
, router3
)
458 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
460 msg
= 'TC22: exist-map routes not present in "router2" BGP table - '
461 assert result
is None, msg
+ failed
463 logger
.info(msg
+ passed
)
466 def test_bgp_conditional_advertisement_tc_2_3():
468 if tgen
.routers_have_failure():
469 pytest
.skip(tgen
.errors
)
471 router1
= tgen
.gears
["r1"]
472 router2
= tgen
.gears
["r2"]
473 router3
= tgen
.gears
["r3"]
475 # TC23: advertise-map with exist-map configuration is removed from a peer
476 # send normal BGP update to advertise previously withdrawn routes if any.
481 address-family ipv4 unicast
482 no neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
486 test_func
= functools
.partial(default_route_withdrawn
, router3
)
487 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
489 msg
= "TC23: advertise-map with exist-map configuration is removed from peer - "
490 assert result
is None, msg
+ failed
492 logger
.info(msg
+ passed
)
495 def test_bgp_conditional_advertisement_tc_3_1():
497 if tgen
.routers_have_failure():
498 pytest
.skip(tgen
.errors
)
500 router1
= tgen
.gears
["r1"]
501 router2
= tgen
.gears
["r2"]
502 router3
= tgen
.gears
["r3"]
504 # TC31: non-exist-map routes not present in R2's BGP table
505 # advertise-map routes present in R2's BGP table are advertised to R3.
510 address-family ipv4 unicast
511 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
515 test_func
= functools
.partial(non_exist_map_routes_not_present
, router3
)
516 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
518 msg
= 'TC31: non-exist-map routes not present in "router2" BGP table - '
519 assert result
is None, msg
+ failed
521 logger
.info(msg
+ passed
)
524 def test_bgp_conditional_advertisement_tc_3_2():
526 if tgen
.routers_have_failure():
527 pytest
.skip(tgen
.errors
)
529 router1
= tgen
.gears
["r1"]
530 router2
= tgen
.gears
["r2"]
531 router3
= tgen
.gears
["r3"]
533 # TC32: non-exist-map routes present in R2's BGP table
534 # advertise-map routes present in R2's BGP table are withdrawn from R3.
539 address-family ipv4 unicast
540 network 0.0.0.0/0 route-map DEF
544 test_func
= functools
.partial(non_exist_map_routes_present
, router3
)
545 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
547 msg
= 'TC32: non-exist-map routes present in "router2" BGP table - '
548 assert result
is None, msg
+ failed
550 logger
.info(msg
+ passed
)
553 def test_bgp_conditional_advertisement_tc_3_3():
555 if tgen
.routers_have_failure():
556 pytest
.skip(tgen
.errors
)
558 router1
= tgen
.gears
["r1"]
559 router2
= tgen
.gears
["r2"]
560 router3
= tgen
.gears
["r3"]
562 # TC33: advertise-map with non-exist-map configuration is removed from a peer
563 # send normal BGP update to advertisepreviously withdrawn routes if any.
568 address-family ipv4 unicast
569 no neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
573 test_func
= functools
.partial(all_routes_advertised
, router3
)
574 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
577 "TC33: advertise-map with non-exist-map configuration is removed from a peer - "
579 assert result
is None, msg
+ failed
581 logger
.info(msg
+ passed
)
584 def test_bgp_conditional_advertisement_tc_4_1():
586 if tgen
.routers_have_failure():
587 pytest
.skip(tgen
.errors
)
589 router1
= tgen
.gears
["r1"]
590 router2
= tgen
.gears
["r2"]
591 router3
= tgen
.gears
["r3"]
593 # TC41: non-exist-map route-map configuration removed in R2.
594 # advertise-map routes present in R2's BGP table are advertised to R3.
599 address-family ipv4 unicast
600 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
601 no route-map EXIST-MAP permit 10
605 test_func
= functools
.partial(non_exist_map_no_condition_route_map
, router3
)
606 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
608 msg
= 'TC41: non-exist-map route-map removed in "router2" - '
609 assert result
is None, msg
+ failed
611 logger
.info(msg
+ passed
)
614 def test_bgp_conditional_advertisement_tc_4_2():
616 if tgen
.routers_have_failure():
617 pytest
.skip(tgen
.errors
)
619 router1
= tgen
.gears
["r1"]
620 router2
= tgen
.gears
["r2"]
621 router3
= tgen
.gears
["r3"]
623 # TC42: exist-map route-map configuration removed in R2
624 # advertise-map routes present in R2's BGP table are withdrawn from R3.
629 address-family ipv4 unicast
630 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
634 test_func
= functools
.partial(exist_map_no_condition_route_map
, router3
)
635 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
637 msg
= 'TC42: exist-map route-map removed in "router2" - '
638 assert result
is None, msg
+ failed
640 logger
.info(msg
+ passed
)
643 def test_bgp_conditional_advertisement_tc_5_1():
645 if tgen
.routers_have_failure():
646 pytest
.skip(tgen
.errors
)
648 router1
= tgen
.gears
["r1"]
649 router2
= tgen
.gears
["r2"]
650 router3
= tgen
.gears
["r3"]
652 # TC51: exist-map routes present in R2's BGP table, with route-map filter.
653 # All routes are withdrawn from R3 except advertise-map routes.
657 route-map EXIST-MAP permit 10
658 match community DEFAULT-ROUTE
659 match ip address prefix-list DEFAULT-ROUTE
662 address-family ipv4 unicast
663 neighbor 10.10.20.3 route-map RMAP-1 out
667 test_func
= functools
.partial(exist_map_routes_present_rmap_filter
, router3
)
668 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
670 msg
= "TC51: exist-map routes present with route-map filter - "
671 assert result
is None, msg
+ failed
673 logger
.info(msg
+ passed
)
676 def test_bgp_conditional_advertisement_tc_5_2():
678 if tgen
.routers_have_failure():
679 pytest
.skip(tgen
.errors
)
681 router1
= tgen
.gears
["r1"]
682 router2
= tgen
.gears
["r2"]
683 router3
= tgen
.gears
["r3"]
685 # TC52: exist-map routes present in R2's BGP table, no route-map filter.
686 # All routes are advertised to R3 including advertise-map routes.
691 address-family ipv4 unicast
692 no neighbor 10.10.20.3 route-map RMAP-1 out
696 test_func
= functools
.partial(exist_map_routes_present_no_rmap_filter
, router3
)
697 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
699 msg
= "TC52: exist-map routes present, no route-map filter - "
700 assert result
is None, msg
+ failed
702 logger
.info(msg
+ passed
)
705 def test_bgp_conditional_advertisement_tc_5_3():
707 if tgen
.routers_have_failure():
708 pytest
.skip(tgen
.errors
)
710 router1
= tgen
.gears
["r1"]
711 router2
= tgen
.gears
["r2"]
712 router3
= tgen
.gears
["r3"]
714 # TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
715 # All routes are withdrawn from R3 including advertise-map routes.
720 address-family ipv4 unicast
721 neighbor 10.10.20.3 route-map RMAP-1 out
722 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
726 test_func
= functools
.partial(non_exist_map_routes_present_rmap_filter
, router3
)
727 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
729 msg
= "TC53: non-exist-map routes present, with route-map filter - "
730 assert result
is None, msg
+ failed
732 logger
.info(msg
+ passed
)
735 def test_bgp_conditional_advertisement_tc_5_4():
737 if tgen
.routers_have_failure():
738 pytest
.skip(tgen
.errors
)
740 router1
= tgen
.gears
["r1"]
741 router2
= tgen
.gears
["r2"]
742 router3
= tgen
.gears
["r3"]
744 # TC54: non-exist-map routes present in R2's BGP table, no route-map filter.
745 # All routes are advertised to R3 except advertise-map routes.
750 address-family ipv4 unicast
751 no neighbor 10.10.20.3 route-map RMAP-1 out
755 test_func
= functools
.partial(non_exist_map_routes_present_no_rmap_filter
, router3
)
756 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
758 msg
= "TC54: non-exist-map routes present, no route-map filter - "
759 assert result
is None, msg
+ failed
761 logger
.info(msg
+ passed
)
764 def test_bgp_conditional_advertisement_tc_6_1():
766 if tgen
.routers_have_failure():
767 pytest
.skip(tgen
.errors
)
769 router1
= tgen
.gears
["r1"]
770 router2
= tgen
.gears
["r2"]
771 router3
= tgen
.gears
["r3"]
773 # TC61: exist-map routes not present in R2's BGP table, with route-map filter.
774 # All routes are withdrawn from R3 including advertise-map routes.
779 address-family ipv4 unicast
780 no network 0.0.0.0/0 route-map DEF
787 address-family ipv4 unicast
788 neighbor 10.10.20.3 route-map RMAP-1 out
789 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
793 test_func
= functools
.partial(exist_map_routes_not_present_rmap_filter
, router3
)
794 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
796 msg
= "TC61: exist-map routes not present, route-map filter - "
797 assert result
is None, msg
+ failed
799 logger
.info(msg
+ passed
)
802 def test_bgp_conditional_advertisement_tc_6_2():
804 if tgen
.routers_have_failure():
805 pytest
.skip(tgen
.errors
)
807 router1
= tgen
.gears
["r1"]
808 router2
= tgen
.gears
["r2"]
809 router3
= tgen
.gears
["r3"]
811 # TC62: exist-map routes not present in R2's BGP table, without route-map filter.
812 # All routes are advertised to R3 except advertise-map routes.
817 address-family ipv4 unicast
818 no neighbor 10.10.20.3 route-map RMAP-1 out
822 test_func
= functools
.partial(exist_map_routes_not_present_no_rmap_filter
, router3
)
823 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
825 msg
= "TC62: exist-map routes not present, no route-map filter - "
826 assert result
is None, msg
+ failed
828 logger
.info(msg
+ passed
)
831 def test_bgp_conditional_advertisement_tc_6_3():
833 if tgen
.routers_have_failure():
834 pytest
.skip(tgen
.errors
)
836 router1
= tgen
.gears
["r1"]
837 router2
= tgen
.gears
["r2"]
838 router3
= tgen
.gears
["r3"]
840 # TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
841 # All routes are withdrawn from R3 except advertise-map routes.
846 address-family ipv4 unicast
847 neighbor 10.10.20.3 route-map RMAP-1 out
848 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
852 test_func
= functools
.partial(non_exist_map_routes_not_present_rmap_filter
, router3
)
853 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
855 msg
= "TC63: non-exist-map routes not present, route-map filter - "
856 assert result
is None, msg
+ failed
858 logger
.info(msg
+ passed
)
861 def test_bgp_conditional_advertisement_tc_6_4():
863 if tgen
.routers_have_failure():
864 pytest
.skip(tgen
.errors
)
866 router1
= tgen
.gears
["r1"]
867 router2
= tgen
.gears
["r2"]
868 router3
= tgen
.gears
["r3"]
870 # TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
871 # All routes are advertised to R3 including advertise-map routes.
876 address-family ipv4 unicast
877 no neighbor 10.10.20.3 route-map RMAP-1 out
881 test_func
= functools
.partial(
882 non_exist_map_routes_not_present_no_rmap_filter
, router3
884 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
886 msg
= "TC64: non-exist-map routes not present, no route-map filter - "
887 assert result
is None, msg
+ failed
889 logger
.info(msg
+ passed
)
892 def test_bgp_conditional_advertisement_tc_7_1():
894 if tgen
.routers_have_failure():
895 pytest
.skip(tgen
.errors
)
897 router1
= tgen
.gears
["r1"]
898 router2
= tgen
.gears
["r2"]
899 router3
= tgen
.gears
["r3"]
901 # TC71: exist-map routes present in R2's BGP table, with route-map filter.
902 # All routes are withdrawn from R3 except advertise-map routes.
907 address-family ipv4 unicast
908 network 0.0.0.0/0 route-map DEF
915 address-family ipv4 unicast
916 neighbor 10.10.20.3 route-map RMAP-2 out
917 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
921 test_func
= functools
.partial(exist_map_routes_present_rmap2_filter
, router3
)
922 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
924 msg
= "TC71: exist-map routes present, route-map filter - "
925 assert result
is None, msg
+ failed
927 logger
.info(msg
+ passed
)
930 def test_bgp_conditional_advertisement_tc_7_2():
932 if tgen
.routers_have_failure():
933 pytest
.skip(tgen
.errors
)
935 router1
= tgen
.gears
["r1"]
936 router2
= tgen
.gears
["r2"]
937 router3
= tgen
.gears
["r3"]
939 # TC72: exist-map routes present in R2's BGP table, without route-map filter.
940 # All routes are advertised to R3 including advertise-map routes.
945 address-family ipv4 unicast
946 no neighbor 10.10.20.3 route-map RMAP-2 out
950 test_func
= functools
.partial(exist_map_routes_present_no_rmap2_filter
, router3
)
951 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
953 msg
= "TC72: exist-map routes present, no route-map filter - "
954 assert result
is None, msg
+ failed
956 logger
.info(msg
+ passed
)
959 def test_bgp_conditional_advertisement_tc_7_3():
961 if tgen
.routers_have_failure():
962 pytest
.skip(tgen
.errors
)
964 router1
= tgen
.gears
["r1"]
965 router2
= tgen
.gears
["r2"]
966 router3
= tgen
.gears
["r3"]
968 # TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
969 # All routes are advertised to R3 including advertise-map routes.
974 address-family ipv4 unicast
975 neighbor 10.10.20.3 route-map RMAP-2 out
976 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
980 test_func
= functools
.partial(non_exist_map_routes_present_rmap2_filter
, router3
)
981 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
983 msg
= "TC73: non-exist-map routes present, route-map filter - "
984 assert result
is None, msg
+ failed
986 logger
.info(msg
+ passed
)
989 def test_bgp_conditional_advertisement_tc_7_4():
991 if tgen
.routers_have_failure():
992 pytest
.skip(tgen
.errors
)
994 router1
= tgen
.gears
["r1"]
995 router2
= tgen
.gears
["r2"]
996 router3
= tgen
.gears
["r3"]
998 # TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
999 # All routes are advertised to R3 including advertise-map routes.
1004 address-family ipv4 unicast
1005 no neighbor 10.10.20.3 route-map RMAP-2 out
1009 test_func
= functools
.partial(non_exist_map_routes_present_no_rmap2_filter
, router3
)
1010 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1012 msg
= "TC74: non-exist-map routes present, no route-map filter - "
1013 assert result
is None, msg
+ failed
1015 logger
.info(msg
+ passed
)
1018 def test_bgp_conditional_advertisement_tc_8_1():
1019 tgen
= get_topogen()
1020 if tgen
.routers_have_failure():
1021 pytest
.skip(tgen
.errors
)
1023 router1
= tgen
.gears
["r1"]
1024 router2
= tgen
.gears
["r2"]
1025 router3
= tgen
.gears
["r3"]
1027 # TC81: exist-map routes not present in R2's BGP table, with route-map filter.
1028 # All routes are withdrawn from R3 including advertise-map routes.
1033 address-family ipv4 unicast
1034 no network 0.0.0.0/0 route-map DEF
1041 address-family ipv4 unicast
1042 neighbor 10.10.20.3 route-map RMAP-2 out
1043 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
1047 test_func
= functools
.partial(exist_map_routes_not_present_rmap2_filter
, router3
)
1048 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1050 msg
= "TC81: exist-map routes not present, route-map filter - "
1051 assert result
is None, msg
+ failed
1053 logger
.info(msg
+ passed
)
1056 def test_bgp_conditional_advertisement_tc_8_2():
1057 tgen
= get_topogen()
1058 if tgen
.routers_have_failure():
1059 pytest
.skip(tgen
.errors
)
1061 router1
= tgen
.gears
["r1"]
1062 router2
= tgen
.gears
["r2"]
1063 router3
= tgen
.gears
["r3"]
1065 # TC82: exist-map routes not present in R2's BGP table, without route-map filter.
1066 # All routes are advertised to R3 except advertise-map routes.
1071 address-family ipv4 unicast
1072 no neighbor 10.10.20.3 route-map RMAP-2 out
1076 test_func
= functools
.partial(exist_map_routes_not_present_no_rmap2_filter
, router3
)
1077 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1079 msg
= "TC82: exist-map routes not present, no route-map filter - "
1080 assert result
is None, msg
+ failed
1082 logger
.info(msg
+ passed
)
1085 def test_bgp_conditional_advertisement_tc_8_3():
1086 tgen
= get_topogen()
1087 if tgen
.routers_have_failure():
1088 pytest
.skip(tgen
.errors
)
1090 router1
= tgen
.gears
["r1"]
1091 router2
= tgen
.gears
["r2"]
1092 router3
= tgen
.gears
["r3"]
1094 # TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
1095 # All routes are advertised to R3 including advertise-map routes.
1100 address-family ipv4 unicast
1101 neighbor 10.10.20.3 route-map RMAP-2 out
1102 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
1106 test_func
= functools
.partial(
1107 non_exist_map_routes_not_present_rmap2_filter
, router3
1109 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1111 msg
= "TC83: non-exist-map routes not present, route-map filter - "
1112 assert result
is None, msg
+ failed
1114 logger
.info(msg
+ passed
)
1117 def test_bgp_conditional_advertisement_tc_8_4():
1118 tgen
= get_topogen()
1119 if tgen
.routers_have_failure():
1120 pytest
.skip(tgen
.errors
)
1122 router1
= tgen
.gears
["r1"]
1123 router2
= tgen
.gears
["r2"]
1124 router3
= tgen
.gears
["r3"]
1126 # TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
1127 # All routes are advertised to R3 including advertise-map routes.
1132 address-family ipv4 unicast
1133 no neighbor 10.10.20.3 route-map RMAP-2 out
1137 test_func
= functools
.partial(
1138 non_exist_map_routes_not_present_no_rmap2_filter
, router3
1140 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1142 msg
= "TC84: non-exist-map routes not present, no route-map filter - "
1143 assert result
is None, msg
+ failed
1145 logger
.info(msg
+ passed
)
1148 def test_bgp_conditional_advertisement_tc_9_1():
1149 tgen
= get_topogen()
1150 if tgen
.routers_have_failure():
1151 pytest
.skip(tgen
.errors
)
1153 router1
= tgen
.gears
["r1"]
1154 router2
= tgen
.gears
["r2"]
1155 router3
= tgen
.gears
["r3"]
1157 # TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
1158 # All routes are advertised to R3 including advertise-map routes.
1163 address-family ipv4 unicast
1164 network 0.0.0.0/0 route-map DEF
1171 address-family ipv4 unicast
1172 neighbor 10.10.20.3 route-map RMAP-2 out
1173 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
1177 test_func
= functools
.partial(exist_map_routes_present_rmap2_network
, router3
)
1178 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1180 msg
= "TC91: exist-map routes present, route-map filter and network - "
1181 assert result
is None, msg
+ failed
1183 logger
.info(msg
+ passed
)
1186 def test_bgp_conditional_advertisement_tc_9_2():
1187 tgen
= get_topogen()
1188 if tgen
.routers_have_failure():
1189 pytest
.skip(tgen
.errors
)
1191 router1
= tgen
.gears
["r1"]
1192 router2
= tgen
.gears
["r2"]
1193 router3
= tgen
.gears
["r3"]
1195 # TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
1196 # All routes are advertised to R3 except advertise-map routes.
1201 address-family ipv4 unicast
1202 no network 203.0.113.1/32
1206 test_func
= functools
.partial(exist_map_routes_present_rmap2_no_network
, router3
)
1207 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1209 msg
= "TC92: exist-map routes present, route-map filter and no network - "
1210 assert result
is None, msg
+ failed
1212 logger
.info(msg
+ passed
)
1215 def test_bgp_conditional_advertisement_tc_9_3():
1216 tgen
= get_topogen()
1217 if tgen
.routers_have_failure():
1218 pytest
.skip(tgen
.errors
)
1220 router1
= tgen
.gears
["r1"]
1221 router2
= tgen
.gears
["r2"]
1222 router3
= tgen
.gears
["r3"]
1224 # TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
1225 # All routes are advertised to R3 including advertise-map routes.
1230 address-family ipv4 unicast
1231 no network 0.0.0.0/0 route-map DEF
1238 address-family ipv4 unicast
1239 network 203.0.113.1/32
1240 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
1244 test_func
= functools
.partial(
1245 non_exist_map_routes_not_present_rmap2_network
, router3
1247 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1249 msg
= "TC93: non-exist-map routes not present, route-map filter and network - "
1250 assert result
is None, msg
+ failed
1252 logger
.info(msg
+ passed
)
1255 def test_bgp_conditional_advertisement_tc_9_4():
1256 tgen
= get_topogen()
1257 if tgen
.routers_have_failure():
1258 pytest
.skip(tgen
.errors
)
1260 router1
= tgen
.gears
["r1"]
1261 router2
= tgen
.gears
["r2"]
1262 router3
= tgen
.gears
["r3"]
1264 # TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
1265 # All routes are advertised to R3 except advertise-map routes.
1270 address-family ipv4 unicast
1271 no network 203.0.113.1/32
1275 test_func
= functools
.partial(
1276 non_exist_map_routes_not_present_rmap2_no_network
, router3
1278 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
1280 msg
= "TC94: non-exist-map routes not present, route-map filter and no network - "
1281 assert result
is None, msg
+ failed
1283 logger
.info(msg
+ passed
)
1286 def test_memory_leak():
1287 "Run the memory leak test and report results."
1288 tgen
= get_topogen()
1289 if not tgen
.is_memleak_enabled():
1290 pytest
.skip("Memory leak test/report is disabled")
1292 tgen
.report_memory_leaks()
1295 if __name__
== "__main__":
1296 args
= ["-s"] + sys
.argv
[1:]
1297 sys
.exit(pytest
.main(args
))