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 TC31: non-exist-map routes not present in R2's BGP table
47 advertise-map routes present in R2's BGP table are advertised to R3.
48 TC32: non-exist-map routes present in R2's BGP table
49 advertise-map routes present in R2's BGP table are withdrawn from R3.
51 TC41: non-exist-map route-map configuration removed in R2.
52 advertise-map routes present in R2's BGP table are advertised to R3.
53 TC42: exist-map route-map configuration removed in R2
54 advertise-map routes present in R2's BGP table are withdrawn from R3.
56 Conditional advertisement(received routes) along with Route-map Filter
57 ----------------------------------------------------------------------
58 TC51: exist-map routes present in R2's BGP table, with route-map filter.
59 All routes are withdrawn from R3 except advertise-map routes.
60 TC52: exist-map routes present in R2's BGP table, without route-map filter.
61 All routes are advertised to R3 including advertise-map routes.
62 TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
63 All routes are withdrawn from R3 including advertise-map routes.
64 TC54: non-exist-map routes present in R2's BGP table, without route-map filter.
65 All routes are advertised to R3 except advertise-map routes.
67 TC61: exist-map routes not present in R2's BGP table, with route-map filter.
68 All routes are withdrawn from R3 including advertise-map routes.
69 TC62: exist-map routes not present in R2's BGP table, without route-map filter.
70 All routes are advertised to R3 except advertise-map routes.
71 TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
72 All routes are withdrawn from R3 except advertise-map routes.
73 TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
74 All routes are advertised to R3 including advertise-map routes.
76 Conditional advertisement(attached routes) along with Route-map Filter
77 -----------------------------------------------------------------
78 TC71: exist-map routes present in R2's BGP table, with route-map filter.
79 All routes are withdrawn from R3 except advertise-map routes.
80 TC72: exist-map routes present in R2's BGP table, without route-map filter.
81 All routes are advertised to R3 including advertise-map routes.
82 TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
83 All routes are withdrawn from R3 including advertise-map routes.
84 TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
85 All routes are advertised to R3 except advertise-map routes.
87 TC81: exist-map routes not present in R2's BGP table, with route-map filter.
88 All routes are withdrawn from R3 including advertise-map routes.
89 TC82: exist-map routes not present in R2's BGP table, without route-map filter.
90 All routes are advertised to R3 except advertise-map routes.
91 TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
92 All routes are withdrawn from R3 except advertise-map routes.
93 TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
94 All routes are advertised to R3 including advertise-map routes.
96 TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
97 All routes are advertised to R3 including advertise-map routes.
98 TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
99 All routes are advertised to R3 except advertise-map routes.
100 TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
101 All routes are advertised to R3 including advertise-map routes.
102 TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
103 All routes are advertised to R3 except advertise-map routes.
106 +----------------+-------------------------+------------------------+
107 | Routes in | exist-map status | advertise-map status |
109 +----------------+-------------------------+------------------------+
110 | Present | Condition matched | Advertise |
111 +----------------+-------------------------+------------------------+
112 | Not Present | Condition not matched | Withdrawn |
113 +----------------+-------------------------+------------------------+
114 | | non-exist-map status | advertise-map status |
116 +----------------+-------------------------+------------------------+
117 | Present | Condition matched | Withdrawn |
118 +----------------+-------------------------+------------------------+
119 | Not Present | Condition not matched | Advertise |
120 +----------------+-------------------------+------------------------+
121 Here in this topology, based on the default route presence in R2 and
122 the configured condition-map (exist-map/non-exist-map) 10.139.224.0/20
123 will be either advertised/withdrawn to/from R3.
133 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
134 sys
.path
.append(os
.path
.join(CWD
, "../"))
136 # pylint: disable=C0413
137 from lib
import topotest
138 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
139 from lib
.topolog
import logger
141 pytestmark
= [pytest
.mark
.bgpd
]
144 def build_topo(tgen
):
145 r1
= tgen
.add_router("r1")
146 r2
= tgen
.add_router("r2")
147 r3
= tgen
.add_router("r3")
149 switch
= tgen
.add_switch("s1")
153 switch
= tgen
.add_switch("s2")
158 def setup_module(mod
):
159 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
160 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
161 logger
.info("=" * 40)
163 logger
.info("Running setup_module to create topology")
165 tgen
= Topogen(build_topo
, mod
.__name
__)
166 tgen
.start_topology()
168 router_list
= tgen
.routers()
170 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
172 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
175 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
180 logger
.info("Running setup_module() done")
183 def teardown_module(mod
):
185 Teardown the pytest environment
189 logger
.info("Running teardown_module to delete topology")
195 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
197 logger
.info("=" * 40)
200 def test_bgp_conditional_advertisement():
202 Test BGP conditional advertisement functionality.
206 if tgen
.routers_have_failure():
207 pytest
.skip(tgen
.errors
)
209 router1
= tgen
.gears
["r1"]
210 router2
= tgen
.gears
["r2"]
211 router3
= tgen
.gears
["r3"]
216 def _all_routes_advertised(router
):
217 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
219 "0.0.0.0/0": [{"protocol": "bgp"}],
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
)
227 def _all_routes_withdrawn(router
):
228 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
231 "192.0.2.1/32": None,
232 "192.0.2.5/32": None,
233 "10.139.224.0/20": None,
234 "203.0.113.1/32": None,
236 return topotest
.json_cmp(output
, expected
)
238 # BGP conditional advertisement with route-maps
239 # EXIST-MAP, ADV-MAP-1 and RMAP-1
240 def _exist_map_routes_present(router
):
241 return _all_routes_advertised(router
)
243 def _exist_map_routes_not_present(router
):
244 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
247 "192.0.2.1/32": None,
248 "192.0.2.5/32": [{"protocol": "bgp"}],
249 "10.139.224.0/20": None,
250 "203.0.113.1/32": [{"protocol": "bgp"}],
252 return topotest
.json_cmp(output
, expected
)
254 def _non_exist_map_routes_present(router
):
255 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
257 "0.0.0.0/0": [{"protocol": "bgp"}],
258 "192.0.2.1/32": None,
259 "192.0.2.5/32": [{"protocol": "bgp"}],
260 "10.139.224.0/20": None,
261 "203.0.113.1/32": [{"protocol": "bgp"}],
263 return topotest
.json_cmp(output
, expected
)
265 def _non_exist_map_routes_not_present(router
):
266 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
269 "192.0.2.1/32": [{"protocol": "bgp"}],
270 "192.0.2.5/32": [{"protocol": "bgp"}],
271 "10.139.224.0/20": [{"protocol": "bgp"}],
272 "203.0.113.1/32": [{"protocol": "bgp"}],
274 return topotest
.json_cmp(output
, expected
)
276 def _exist_map_no_condition_route_map(router
):
277 return _non_exist_map_routes_present(router
)
279 def _non_exist_map_no_condition_route_map(router
):
280 return _all_routes_advertised(router
)
282 def _exist_map_routes_present_rmap_filter(router
):
283 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
286 "192.0.2.1/32": [{"protocol": "bgp"}],
287 "192.0.2.5/32": None,
288 "10.139.224.0/20": [{"protocol": "bgp"}],
289 "203.0.113.1/32": None,
291 return topotest
.json_cmp(output
, expected
)
293 def _exist_map_routes_present_no_rmap_filter(router
):
294 return _all_routes_advertised(router
)
296 def _non_exist_map_routes_present_rmap_filter(router
):
297 return _all_routes_withdrawn(router
)
299 def _non_exist_map_routes_present_no_rmap_filter(router
):
300 return _non_exist_map_routes_present(router
)
302 def _exist_map_routes_not_present_rmap_filter(router
):
303 return _all_routes_withdrawn(router
)
305 def _exist_map_routes_not_present_no_rmap_filter(router
):
306 return _exist_map_routes_not_present(router
)
308 def _non_exist_map_routes_not_present_rmap_filter(router
):
309 return _exist_map_routes_present_rmap_filter(router
)
311 def _non_exist_map_routes_not_present_no_rmap_filter(router
):
312 return _non_exist_map_routes_not_present(router
)
314 # BGP conditional advertisement with route-maps
315 # EXIST-MAP, ADV-MAP-2 and RMAP-2
316 def _exist_map_routes_not_present_rmap2_filter(router
):
317 return _all_routes_withdrawn(router
)
319 def _exist_map_routes_not_present_no_rmap2_filter(router
):
320 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
323 "192.0.2.1/32": [{"protocol": "bgp"}],
324 "192.0.2.5/32": [{"protocol": "bgp"}],
325 "10.139.224.0/20": [{"protocol": "bgp"}],
326 "203.0.113.1/32": None,
328 return topotest
.json_cmp(output
, expected
)
330 def _non_exist_map_routes_not_present_rmap2_filter(router
):
331 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
334 "192.0.2.1/32": None,
335 "192.0.2.5/32": None,
336 "10.139.224.0/20": None,
337 "203.0.113.1/32": [{"protocol": "bgp"}],
339 return topotest
.json_cmp(output
, expected
)
341 def _non_exist_map_routes_not_present_no_rmap2_filter(router
):
342 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
)
347 def _exist_map_routes_present_no_rmap2_filter(router
):
348 return _all_routes_advertised(router
)
350 def _non_exist_map_routes_present_rmap2_filter(router
):
351 return _all_routes_withdrawn(router
)
353 def _non_exist_map_routes_present_no_rmap2_filter(router
):
354 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
356 "0.0.0.0/0": [{"protocol": "bgp"}],
357 "192.0.2.1/32": [{"protocol": "bgp"}],
358 "192.0.2.5/32": [{"protocol": "bgp"}],
359 "10.139.224.0/20": [{"protocol": "bgp"}],
360 "203.0.113.1/32": None,
362 return topotest
.json_cmp(output
, expected
)
364 def _exist_map_routes_present_rmap2_network(router
):
365 return _non_exist_map_routes_not_present_rmap2_filter(router
)
367 def _exist_map_routes_present_rmap2_no_network(router
):
368 return _all_routes_withdrawn(router
)
370 def _non_exist_map_routes_not_present_rmap2_network(router
):
371 return _non_exist_map_routes_not_present_rmap2_filter(router
)
373 def _non_exist_map_routes_not_present_rmap2_no_network(router
):
374 return _all_routes_withdrawn(router
)
376 # TC11: R3 BGP convergence, without advertise-map configuration.
377 # All routes are advertised to R3.
378 test_func
= functools
.partial(_all_routes_advertised
, router3
)
379 success
, result
= topotest
.run_and_expect(test_func
, None, count
=130, wait
=1)
381 msg
= 'TC11: "router3" BGP convergence - '
382 assert result
is None, msg
+ failed
384 logger
.info(msg
+ passed
)
386 # TC21: exist-map routes present in R2's BGP table.
387 # advertise-map routes present in R2's BGP table are advertised to R3.
392 address-family ipv4 unicast
393 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
397 test_func
= functools
.partial(_exist_map_routes_present
, router3
)
398 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
400 msg
= 'TC21: exist-map routes present in "router2" BGP table - '
401 assert result
is None, msg
+ failed
403 logger
.info(msg
+ passed
)
405 # TC22: exist-map routes not present in R2's BGP table
406 # advertise-map routes present in R2's BGP table are withdrawn from R3.
411 address-family ipv4 unicast
412 no network 0.0.0.0/0 route-map DEF
416 test_func
= functools
.partial(_exist_map_routes_not_present
, router3
)
417 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
419 msg
= 'TC22: exist-map routes not present in "router2" BGP table - '
420 assert result
is None, msg
+ failed
422 logger
.info(msg
+ passed
)
424 # TC31: non-exist-map routes not present in R2's BGP table
425 # advertise-map routes present in R2's BGP table are advertised to R3.
430 address-family ipv4 unicast
431 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
435 test_func
= functools
.partial(_non_exist_map_routes_not_present
, router3
)
436 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
438 msg
= 'TC31: non-exist-map routes not present in "router2" BGP table - '
439 assert result
is None, msg
+ failed
441 logger
.info(msg
+ passed
)
443 # TC32: non-exist-map routes present in R2's BGP table
444 # advertise-map routes present in R2's BGP table are withdrawn from R3.
449 address-family ipv4 unicast
450 network 0.0.0.0/0 route-map DEF
454 test_func
= functools
.partial(_non_exist_map_routes_present
, router3
)
455 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
457 msg
= 'TC32: non-exist-map routes present in "router2" BGP table - '
458 assert result
is None, msg
+ failed
460 logger
.info(msg
+ passed
)
462 # TC41: non-exist-map route-map configuration removed in R2.
463 # advertise-map routes present in R2's BGP table are advertised to R3.
467 no route-map EXIST-MAP permit 10
471 test_func
= functools
.partial(_non_exist_map_no_condition_route_map
, router3
)
472 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
474 msg
= 'TC41: non-exist-map route-map removed in "router2" - '
475 assert result
is None, msg
+ failed
477 logger
.info(msg
+ passed
)
479 # TC42: exist-map route-map configuration removed in R2
480 # advertise-map routes present in R2's BGP table are withdrawn from R3.
485 address-family ipv4 unicast
486 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
490 test_func
= functools
.partial(_exist_map_no_condition_route_map
, router3
)
491 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
493 msg
= 'TC42: exist-map route-map removed in "router2" - '
494 assert result
is None, msg
+ failed
496 logger
.info(msg
+ passed
)
498 # TC51: exist-map routes present in R2's BGP table, with route-map filter.
499 # All routes are withdrawn from R3 except advertise-map routes.
503 route-map EXIST-MAP permit 10
504 match community DEFAULT-ROUTE
505 match ip address prefix-list DEFAULT-ROUTE
508 address-family ipv4 unicast
509 neighbor 10.10.20.3 route-map RMAP-1 out
513 test_func
= functools
.partial(_exist_map_routes_present_rmap_filter
, router3
)
514 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
516 msg
= "TC51: exist-map routes present with route-map filter - "
517 assert result
is None, msg
+ failed
519 logger
.info(msg
+ passed
)
521 # TC52: exist-map routes present in R2's BGP table, no route-map filter.
522 # All routes are advertised to R3 including advertise-map routes.
527 address-family ipv4 unicast
528 no neighbor 10.10.20.3 route-map RMAP-1 out
532 test_func
= functools
.partial(_exist_map_routes_present_no_rmap_filter
, router3
)
533 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
535 msg
= "TC52: exist-map routes present, no route-map filter - "
536 assert result
is None, msg
+ failed
538 logger
.info(msg
+ passed
)
540 # TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
541 # All routes are withdrawn from R3 including advertise-map routes.
546 address-family ipv4 unicast
547 neighbor 10.10.20.3 route-map RMAP-1 out
548 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
552 test_func
= functools
.partial(_non_exist_map_routes_present_rmap_filter
, router3
)
553 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
555 msg
= "TC53: non-exist-map routes present, with route-map filter - "
556 assert result
is None, msg
+ failed
558 logger
.info(msg
+ passed
)
560 # TC54: non-exist-map routes present in R2's BGP table, no route-map filter.
561 # All routes are advertised to R3 except advertise-map routes.
566 address-family ipv4 unicast
567 no neighbor 10.10.20.3 route-map RMAP-1 out
571 test_func
= functools
.partial(_non_exist_map_routes_present_no_rmap_filter
, router3
)
572 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
574 msg
= "TC54: non-exist-map routes present, no route-map filter - "
575 assert result
is None, msg
+ failed
577 logger
.info(msg
+ passed
)
579 # TC61: exist-map routes not present in R2's BGP table, with route-map filter.
580 # All routes are withdrawn from R3 including advertise-map routes.
585 address-family ipv4 unicast
586 no network 0.0.0.0/0 route-map DEF
593 address-family ipv4 unicast
594 neighbor 10.10.20.3 route-map RMAP-1 out
595 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
599 test_func
= functools
.partial(_exist_map_routes_not_present_rmap_filter
, router3
)
600 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
602 msg
= "TC61: exist-map routes not present, route-map filter - "
603 assert result
is None, msg
+ failed
605 logger
.info(msg
+ passed
)
607 # TC62: exist-map routes not present in R2's BGP table, without route-map filter.
608 # All routes are advertised to R3 except advertise-map routes.
613 address-family ipv4 unicast
614 no neighbor 10.10.20.3 route-map RMAP-1 out
618 test_func
= functools
.partial(_exist_map_routes_not_present_no_rmap_filter
, router3
)
619 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
621 msg
= "TC62: exist-map routes not present, no route-map filter - "
622 assert result
is None, msg
+ failed
624 logger
.info(msg
+ passed
)
626 # TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
627 # All routes are withdrawn from R3 except advertise-map routes.
632 address-family ipv4 unicast
633 neighbor 10.10.20.3 route-map RMAP-1 out
634 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
638 test_func
= functools
.partial(
639 _non_exist_map_routes_not_present_rmap_filter
, router3
641 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
643 msg
= "TC63: non-exist-map routes not present, route-map filter - "
644 assert result
is None, msg
+ failed
646 logger
.info(msg
+ passed
)
648 # TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
649 # All routes are advertised to R3 including advertise-map routes.
654 address-family ipv4 unicast
655 no neighbor 10.10.20.3 route-map RMAP-1 out
659 test_func
= functools
.partial(
660 _non_exist_map_routes_not_present_no_rmap_filter
, router3
662 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
664 msg
= "TC64: non-exist-map routes not present, no route-map filter - "
665 assert result
is None, msg
+ failed
667 logger
.info(msg
+ passed
)
669 # TC71: exist-map routes present in R2's BGP table, with route-map filter.
670 # All routes are withdrawn from R3 except advertise-map routes.
675 address-family ipv4 unicast
676 network 0.0.0.0/0 route-map DEF
683 address-family ipv4 unicast
684 neighbor 10.10.20.3 route-map RMAP-2 out
685 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
689 test_func
= functools
.partial(_exist_map_routes_present_rmap2_filter
, router3
)
690 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
692 msg
= "TC71: exist-map routes present, route-map filter - "
693 assert result
is None, msg
+ failed
695 logger
.info(msg
+ passed
)
697 # TC72: exist-map routes present in R2's BGP table, without route-map filter.
698 # All routes are advertised to R3 including advertise-map routes.
703 address-family ipv4 unicast
704 no neighbor 10.10.20.3 route-map RMAP-2 out
708 test_func
= functools
.partial(_exist_map_routes_present_no_rmap2_filter
, router3
)
709 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
711 msg
= "TC72: exist-map routes present, no route-map filter - "
712 assert result
is None, msg
+ failed
714 logger
.info(msg
+ passed
)
716 # TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
717 # All routes are advertised to R3 including advertise-map routes.
722 address-family ipv4 unicast
723 neighbor 10.10.20.3 route-map RMAP-2 out
724 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
728 test_func
= functools
.partial(_non_exist_map_routes_present_rmap2_filter
, router3
)
729 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
731 msg
= "TC73: non-exist-map routes present, route-map filter - "
732 assert result
is None, msg
+ failed
734 logger
.info(msg
+ passed
)
736 # TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
737 # All routes are advertised to R3 including advertise-map routes.
742 address-family ipv4 unicast
743 no neighbor 10.10.20.3 route-map RMAP-2 out
747 test_func
= functools
.partial(
748 _non_exist_map_routes_present_no_rmap2_filter
, router3
750 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
752 msg
= "TC74: non-exist-map routes present, no route-map filter - "
753 assert result
is None, msg
+ failed
755 logger
.info(msg
+ passed
)
757 # TC81: exist-map routes not present in R2's BGP table, with route-map filter.
758 # All routes are withdrawn from R3 including advertise-map routes.
763 address-family ipv4 unicast
764 no network 0.0.0.0/0 route-map DEF
771 address-family ipv4 unicast
772 neighbor 10.10.20.3 route-map RMAP-2 out
773 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
777 test_func
= functools
.partial(_exist_map_routes_not_present_rmap2_filter
, router3
)
778 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
780 msg
= "TC81: exist-map routes not present, route-map filter - "
781 assert result
is None, msg
+ failed
783 logger
.info(msg
+ passed
)
785 # TC82: exist-map routes not present in R2's BGP table, without route-map filter.
786 # All routes are advertised to R3 except advertise-map routes.
791 address-family ipv4 unicast
792 no neighbor 10.10.20.3 route-map RMAP-2 out
796 test_func
= functools
.partial(
797 _exist_map_routes_not_present_no_rmap2_filter
, router3
799 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
801 msg
= "TC82: exist-map routes not present, no route-map filter - "
802 assert result
is None, msg
+ failed
804 logger
.info(msg
+ passed
)
806 # TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
807 # All routes are advertised to R3 including advertise-map routes.
812 address-family ipv4 unicast
813 neighbor 10.10.20.3 route-map RMAP-2 out
814 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
818 test_func
= functools
.partial(
819 _non_exist_map_routes_not_present_rmap2_filter
, router3
821 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
823 msg
= "TC83: non-exist-map routes not present, route-map filter - "
824 assert result
is None, msg
+ failed
826 logger
.info(msg
+ passed
)
828 # TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
829 # All routes are advertised to R3 including advertise-map routes.
834 address-family ipv4 unicast
835 no neighbor 10.10.20.3 route-map RMAP-2 out
839 test_func
= functools
.partial(
840 _non_exist_map_routes_not_present_no_rmap2_filter
, router3
842 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
844 msg
= "TC84: non-exist-map routes not present, no route-map filter - "
845 assert result
is None, msg
+ failed
847 logger
.info(msg
+ passed
)
849 # TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
850 # All routes are advertised to R3 including advertise-map routes.
855 address-family ipv4 unicast
856 network 0.0.0.0/0 route-map DEF
863 address-family ipv4 unicast
864 neighbor 10.10.20.3 route-map RMAP-2 out
865 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
869 test_func
= functools
.partial(_exist_map_routes_present_rmap2_network
, router3
)
870 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
872 msg
= "TC91: exist-map routes present, route-map filter and network - "
873 assert result
is None, msg
+ failed
875 logger
.info(msg
+ passed
)
877 # TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
878 # All routes are advertised to R3 except advertise-map routes.
883 address-family ipv4 unicast
884 no network 203.0.113.1/32
888 test_func
= functools
.partial(_exist_map_routes_present_rmap2_no_network
, router3
)
889 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
891 msg
= "TC92: exist-map routes present, route-map filter and no network - "
892 assert result
is None, msg
+ failed
894 logger
.info(msg
+ passed
)
896 # TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
897 # All routes are advertised to R3 including advertise-map routes.
902 address-family ipv4 unicast
903 no network 0.0.0.0/0 route-map DEF
910 address-family ipv4 unicast
911 network 203.0.113.1/32
912 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
916 test_func
= functools
.partial(
917 _non_exist_map_routes_not_present_rmap2_network
, router3
919 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
921 msg
= "TC93: non-exist-map routes not present, route-map filter and network - "
922 assert result
is None, msg
+ failed
924 logger
.info(msg
+ passed
)
926 # TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
927 # All routes are advertised to R3 except advertise-map routes.
932 address-family ipv4 unicast
933 no network 203.0.113.1/32
937 test_func
= functools
.partial(
938 _non_exist_map_routes_not_present_rmap2_no_network
, router3
940 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
942 msg
= "TC94: non-exist-map routes not present, route-map filter and no network - "
943 assert result
is None, msg
+ failed
945 logger
.info(msg
+ passed
)
948 def test_memory_leak():
949 "Run the memory leak test and report results."
951 if not tgen
.is_memleak_enabled():
952 pytest
.skip("Memory leak test/report is disabled")
954 tgen
.report_memory_leaks()
957 if __name__
== "__main__":
958 args
= ["-s"] + sys
.argv
[1:]
959 sys
.exit(pytest
.main(args
))