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
140 from lib
.micronet_compat
import Topo
142 pytestmark
= [pytest
.mark
.bgpd
]
145 class BgpConditionalAdvertisementTopo(Topo
):
146 def build(self
, *_args
, **_opts
):
147 tgen
= get_topogen(self
)
149 r1
= tgen
.add_router("r1")
150 r2
= tgen
.add_router("r2")
151 r3
= tgen
.add_router("r3")
153 switch
= tgen
.add_switch("s1")
157 switch
= tgen
.add_switch("s2")
162 def setup_module(mod
):
163 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
164 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
165 logger
.info("=" * 40)
167 logger
.info("Running setup_module to create topology")
169 tgen
= Topogen(BgpConditionalAdvertisementTopo
, mod
.__name
__)
170 tgen
.start_topology()
172 router_list
= tgen
.routers()
174 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
176 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
179 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
184 logger
.info("Running setup_module() done")
187 def teardown_module(mod
):
189 Teardown the pytest environment
193 logger
.info("Running teardown_module to delete topology")
199 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
201 logger
.info("=" * 40)
204 def test_bgp_conditional_advertisement():
206 Test BGP conditional advertisement functionality.
210 if tgen
.routers_have_failure():
211 pytest
.skip(tgen
.errors
)
213 router1
= tgen
.gears
["r1"]
214 router2
= tgen
.gears
["r2"]
215 router3
= tgen
.gears
["r3"]
220 def _all_routes_advertised(router
):
221 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
223 "0.0.0.0/0": [{"protocol": "bgp"}],
224 "192.0.2.1/32": [{"protocol": "bgp"}],
225 "192.0.2.5/32": [{"protocol": "bgp"}],
226 "10.139.224.0/20": [{"protocol": "bgp"}],
227 "203.0.113.1/32": [{"protocol": "bgp"}],
229 return topotest
.json_cmp(output
, expected
)
231 def _all_routes_withdrawn(router
):
232 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
235 "192.0.2.1/32": None,
236 "192.0.2.5/32": None,
237 "10.139.224.0/20": None,
238 "203.0.113.1/32": None,
240 return topotest
.json_cmp(output
, expected
)
242 # BGP conditional advertisement with route-maps
243 # EXIST-MAP, ADV-MAP-1 and RMAP-1
244 def _exist_map_routes_present(router
):
245 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
)
258 def _non_exist_map_routes_present(router
):
259 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
261 "0.0.0.0/0": [{"protocol": "bgp"}],
262 "192.0.2.1/32": None,
263 "192.0.2.5/32": [{"protocol": "bgp"}],
264 "10.139.224.0/20": None,
265 "203.0.113.1/32": [{"protocol": "bgp"}],
267 return topotest
.json_cmp(output
, expected
)
269 def _non_exist_map_routes_not_present(router
):
270 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
273 "192.0.2.1/32": [{"protocol": "bgp"}],
274 "192.0.2.5/32": [{"protocol": "bgp"}],
275 "10.139.224.0/20": [{"protocol": "bgp"}],
276 "203.0.113.1/32": [{"protocol": "bgp"}],
278 return topotest
.json_cmp(output
, expected
)
280 def _exist_map_no_condition_route_map(router
):
281 return _non_exist_map_routes_present(router
)
283 def _non_exist_map_no_condition_route_map(router
):
284 return _all_routes_advertised(router
)
286 def _exist_map_routes_present_rmap_filter(router
):
287 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
290 "192.0.2.1/32": [{"protocol": "bgp"}],
291 "192.0.2.5/32": None,
292 "10.139.224.0/20": [{"protocol": "bgp"}],
293 "203.0.113.1/32": None,
295 return topotest
.json_cmp(output
, expected
)
297 def _exist_map_routes_present_no_rmap_filter(router
):
298 return _all_routes_advertised(router
)
300 def _non_exist_map_routes_present_rmap_filter(router
):
301 return _all_routes_withdrawn(router
)
303 def _non_exist_map_routes_present_no_rmap_filter(router
):
304 return _non_exist_map_routes_present(router
)
306 def _exist_map_routes_not_present_rmap_filter(router
):
307 return _all_routes_withdrawn(router
)
309 def _exist_map_routes_not_present_no_rmap_filter(router
):
310 return _exist_map_routes_not_present(router
)
312 def _non_exist_map_routes_not_present_rmap_filter(router
):
313 return _exist_map_routes_present_rmap_filter(router
)
315 def _non_exist_map_routes_not_present_no_rmap_filter(router
):
316 return _non_exist_map_routes_not_present(router
)
318 # BGP conditional advertisement with route-maps
319 # EXIST-MAP, ADV-MAP-2 and RMAP-2
320 def _exist_map_routes_not_present_rmap2_filter(router
):
321 return _all_routes_withdrawn(router
)
323 def _exist_map_routes_not_present_no_rmap2_filter(router
):
324 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
327 "192.0.2.1/32": [{"protocol": "bgp"}],
328 "192.0.2.5/32": [{"protocol": "bgp"}],
329 "10.139.224.0/20": [{"protocol": "bgp"}],
330 "203.0.113.1/32": None,
332 return topotest
.json_cmp(output
, expected
)
334 def _non_exist_map_routes_not_present_rmap2_filter(router
):
335 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
338 "192.0.2.1/32": None,
339 "192.0.2.5/32": None,
340 "10.139.224.0/20": None,
341 "203.0.113.1/32": [{"protocol": "bgp"}],
343 return topotest
.json_cmp(output
, expected
)
345 def _non_exist_map_routes_not_present_no_rmap2_filter(router
):
346 return _non_exist_map_routes_not_present(router
)
348 def _exist_map_routes_present_rmap2_filter(router
):
349 return _non_exist_map_routes_not_present_rmap2_filter(router
)
351 def _exist_map_routes_present_no_rmap2_filter(router
):
352 return _all_routes_advertised(router
)
354 def _non_exist_map_routes_present_rmap2_filter(router
):
355 return _all_routes_withdrawn(router
)
357 def _non_exist_map_routes_present_no_rmap2_filter(router
):
358 output
= json
.loads(router
.vtysh_cmd("show ip route json"))
360 "0.0.0.0/0": [{"protocol": "bgp"}],
361 "192.0.2.1/32": [{"protocol": "bgp"}],
362 "192.0.2.5/32": [{"protocol": "bgp"}],
363 "10.139.224.0/20": [{"protocol": "bgp"}],
364 "203.0.113.1/32": None,
366 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
)
371 def _exist_map_routes_present_rmap2_no_network(router
):
372 return _all_routes_withdrawn(router
)
374 def _non_exist_map_routes_not_present_rmap2_network(router
):
375 return _non_exist_map_routes_not_present_rmap2_filter(router
)
377 def _non_exist_map_routes_not_present_rmap2_no_network(router
):
378 return _all_routes_withdrawn(router
)
380 # TC11: R3 BGP convergence, without advertise-map configuration.
381 # All routes are advertised to R3.
382 test_func
= functools
.partial(_all_routes_advertised
, router3
)
383 success
, result
= topotest
.run_and_expect(test_func
, None, count
=130, wait
=1)
385 msg
= 'TC11: "router3" BGP convergence - '
386 assert result
is None, msg
+ failed
388 logger
.info(msg
+ passed
)
390 # TC21: exist-map routes present in R2's BGP table.
391 # advertise-map routes present in R2's BGP table are advertised to R3.
396 address-family ipv4 unicast
397 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
401 test_func
= functools
.partial(_exist_map_routes_present
, router3
)
402 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
404 msg
= 'TC21: exist-map routes present in "router2" BGP table - '
405 assert result
is None, msg
+ failed
407 logger
.info(msg
+ passed
)
409 # TC22: exist-map routes not present in R2's BGP table
410 # advertise-map routes present in R2's BGP table are withdrawn from R3.
415 address-family ipv4 unicast
416 no network 0.0.0.0/0 route-map DEF
420 test_func
= functools
.partial(_exist_map_routes_not_present
, router3
)
421 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
423 msg
= 'TC22: exist-map routes not present in "router2" BGP table - '
424 assert result
is None, msg
+ failed
426 logger
.info(msg
+ passed
)
428 # TC31: non-exist-map routes not present in R2's BGP table
429 # advertise-map routes present in R2's BGP table are advertised to R3.
434 address-family ipv4 unicast
435 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
439 test_func
= functools
.partial(_non_exist_map_routes_not_present
, router3
)
440 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
442 msg
= 'TC31: non-exist-map routes not present in "router2" BGP table - '
443 assert result
is None, msg
+ failed
445 logger
.info(msg
+ passed
)
447 # TC32: non-exist-map routes present in R2's BGP table
448 # advertise-map routes present in R2's BGP table are withdrawn from R3.
453 address-family ipv4 unicast
454 network 0.0.0.0/0 route-map DEF
458 test_func
= functools
.partial(_non_exist_map_routes_present
, router3
)
459 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
461 msg
= 'TC32: non-exist-map routes present in "router2" BGP table - '
462 assert result
is None, msg
+ failed
464 logger
.info(msg
+ passed
)
466 # TC41: non-exist-map route-map configuration removed in R2.
467 # advertise-map routes present in R2's BGP table are advertised to R3.
471 no route-map EXIST-MAP permit 10
475 test_func
= functools
.partial(_non_exist_map_no_condition_route_map
, router3
)
476 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
478 msg
= 'TC41: non-exist-map route-map removed in "router2" - '
479 assert result
is None, msg
+ failed
481 logger
.info(msg
+ passed
)
483 # TC42: exist-map route-map configuration removed in R2
484 # advertise-map routes present in R2's BGP table are withdrawn from R3.
489 address-family ipv4 unicast
490 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
494 test_func
= functools
.partial(_exist_map_no_condition_route_map
, router3
)
495 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
497 msg
= 'TC42: exist-map route-map removed in "router2" - '
498 assert result
is None, msg
+ failed
500 logger
.info(msg
+ passed
)
502 # TC51: exist-map routes present in R2's BGP table, with route-map filter.
503 # All routes are withdrawn from R3 except advertise-map routes.
507 route-map EXIST-MAP permit 10
508 match community DEFAULT-ROUTE
509 match ip address prefix-list DEFAULT-ROUTE
512 address-family ipv4 unicast
513 neighbor 10.10.20.3 route-map RMAP-1 out
517 test_func
= functools
.partial(_exist_map_routes_present_rmap_filter
, router3
)
518 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
520 msg
= "TC51: exist-map routes present with route-map filter - "
521 assert result
is None, msg
+ failed
523 logger
.info(msg
+ passed
)
525 # TC52: exist-map routes present in R2's BGP table, no route-map filter.
526 # All routes are advertised to R3 including advertise-map routes.
531 address-family ipv4 unicast
532 no neighbor 10.10.20.3 route-map RMAP-1 out
536 test_func
= functools
.partial(_exist_map_routes_present_no_rmap_filter
, router3
)
537 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
539 msg
= "TC52: exist-map routes present, no route-map filter - "
540 assert result
is None, msg
+ failed
542 logger
.info(msg
+ passed
)
544 # TC53: non-exist-map routes present in R2's BGP table, with route-map filter.
545 # All routes are withdrawn from R3 including advertise-map routes.
550 address-family ipv4 unicast
551 neighbor 10.10.20.3 route-map RMAP-1 out
552 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
556 test_func
= functools
.partial(_non_exist_map_routes_present_rmap_filter
, router3
)
557 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
559 msg
= "TC53: non-exist-map routes present, with route-map filter - "
560 assert result
is None, msg
+ failed
562 logger
.info(msg
+ passed
)
564 # TC54: non-exist-map routes present in R2's BGP table, no route-map filter.
565 # All routes are advertised to R3 except advertise-map routes.
570 address-family ipv4 unicast
571 no neighbor 10.10.20.3 route-map RMAP-1 out
575 test_func
= functools
.partial(_non_exist_map_routes_present_no_rmap_filter
, router3
)
576 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
578 msg
= "TC54: non-exist-map routes present, no route-map filter - "
579 assert result
is None, msg
+ failed
581 logger
.info(msg
+ passed
)
583 # TC61: exist-map routes not present in R2's BGP table, with route-map filter.
584 # All routes are withdrawn from R3 including advertise-map routes.
589 address-family ipv4 unicast
590 no network 0.0.0.0/0 route-map DEF
597 address-family ipv4 unicast
598 neighbor 10.10.20.3 route-map RMAP-1 out
599 neighbor 10.10.20.3 advertise-map ADV-MAP-1 exist-map EXIST-MAP
603 test_func
= functools
.partial(_exist_map_routes_not_present_rmap_filter
, router3
)
604 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
606 msg
= "TC61: exist-map routes not present, route-map filter - "
607 assert result
is None, msg
+ failed
609 logger
.info(msg
+ passed
)
611 # TC62: exist-map routes not present in R2's BGP table, without route-map filter.
612 # All routes are advertised to R3 except advertise-map routes.
617 address-family ipv4 unicast
618 no neighbor 10.10.20.3 route-map RMAP-1 out
622 test_func
= functools
.partial(_exist_map_routes_not_present_no_rmap_filter
, router3
)
623 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
625 msg
= "TC62: exist-map routes not present, no route-map filter - "
626 assert result
is None, msg
+ failed
628 logger
.info(msg
+ passed
)
630 # TC63: non-exist-map routes not present in R2's BGP table, with route-map filter.
631 # All routes are withdrawn from R3 except advertise-map routes.
636 address-family ipv4 unicast
637 neighbor 10.10.20.3 route-map RMAP-1 out
638 neighbor 10.10.20.3 advertise-map ADV-MAP-1 non-exist-map EXIST-MAP
642 test_func
= functools
.partial(
643 _non_exist_map_routes_not_present_rmap_filter
, router3
645 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
647 msg
= "TC63: non-exist-map routes not present, route-map filter - "
648 assert result
is None, msg
+ failed
650 logger
.info(msg
+ passed
)
652 # TC64: non-exist-map routes not present in R2's BGP table, without route-map filter.
653 # All routes are advertised to R3 including advertise-map routes.
658 address-family ipv4 unicast
659 no neighbor 10.10.20.3 route-map RMAP-1 out
663 test_func
= functools
.partial(
664 _non_exist_map_routes_not_present_no_rmap_filter
, router3
666 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
668 msg
= "TC64: non-exist-map routes not present, no route-map filter - "
669 assert result
is None, msg
+ failed
671 logger
.info(msg
+ passed
)
673 # TC71: exist-map routes present in R2's BGP table, with route-map filter.
674 # All routes are withdrawn from R3 except advertise-map routes.
679 address-family ipv4 unicast
680 network 0.0.0.0/0 route-map DEF
687 address-family ipv4 unicast
688 neighbor 10.10.20.3 route-map RMAP-2 out
689 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
693 test_func
= functools
.partial(_exist_map_routes_present_rmap2_filter
, router3
)
694 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
696 msg
= "TC71: exist-map routes present, route-map filter - "
697 assert result
is None, msg
+ failed
699 logger
.info(msg
+ passed
)
701 # TC72: exist-map routes present in R2's BGP table, without route-map filter.
702 # All routes are advertised to R3 including advertise-map routes.
707 address-family ipv4 unicast
708 no neighbor 10.10.20.3 route-map RMAP-2 out
712 test_func
= functools
.partial(_exist_map_routes_present_no_rmap2_filter
, router3
)
713 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
715 msg
= "TC72: exist-map routes present, no route-map filter - "
716 assert result
is None, msg
+ failed
718 logger
.info(msg
+ passed
)
720 # TC73: non-exist-map routes present in R2's BGP table, with route-map filter.
721 # All routes are advertised to R3 including advertise-map routes.
726 address-family ipv4 unicast
727 neighbor 10.10.20.3 route-map RMAP-2 out
728 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
732 test_func
= functools
.partial(_non_exist_map_routes_present_rmap2_filter
, router3
)
733 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
735 msg
= "TC73: non-exist-map routes present, route-map filter - "
736 assert result
is None, msg
+ failed
738 logger
.info(msg
+ passed
)
740 # TC74: non-exist-map routes present in R2's BGP table, without route-map filter.
741 # All routes are advertised to R3 including advertise-map routes.
746 address-family ipv4 unicast
747 no neighbor 10.10.20.3 route-map RMAP-2 out
751 test_func
= functools
.partial(
752 _non_exist_map_routes_present_no_rmap2_filter
, router3
754 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
756 msg
= "TC74: non-exist-map routes present, no route-map filter - "
757 assert result
is None, msg
+ failed
759 logger
.info(msg
+ passed
)
761 # TC81: exist-map routes not present in R2's BGP table, with route-map filter.
762 # All routes are withdrawn from R3 including advertise-map routes.
767 address-family ipv4 unicast
768 no network 0.0.0.0/0 route-map DEF
775 address-family ipv4 unicast
776 neighbor 10.10.20.3 route-map RMAP-2 out
777 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
781 test_func
= functools
.partial(_exist_map_routes_not_present_rmap2_filter
, router3
)
782 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
784 msg
= "TC81: exist-map routes not present, route-map filter - "
785 assert result
is None, msg
+ failed
787 logger
.info(msg
+ passed
)
789 # TC82: exist-map routes not present in R2's BGP table, without route-map filter.
790 # All routes are advertised to R3 except advertise-map routes.
795 address-family ipv4 unicast
796 no neighbor 10.10.20.3 route-map RMAP-2 out
800 test_func
= functools
.partial(
801 _exist_map_routes_not_present_no_rmap2_filter
, router3
803 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
805 msg
= "TC82: exist-map routes not present, no route-map filter - "
806 assert result
is None, msg
+ failed
808 logger
.info(msg
+ passed
)
810 # TC83: non-exist-map routes not present in R2's BGP table, with route-map filter.
811 # All routes are advertised to R3 including advertise-map routes.
816 address-family ipv4 unicast
817 neighbor 10.10.20.3 route-map RMAP-2 out
818 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
822 test_func
= functools
.partial(
823 _non_exist_map_routes_not_present_rmap2_filter
, router3
825 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
827 msg
= "TC83: non-exist-map routes not present, route-map filter - "
828 assert result
is None, msg
+ failed
830 logger
.info(msg
+ passed
)
832 # TC84: non-exist-map routes not present in R2's BGP table, without route-map filter.
833 # All routes are advertised to R3 including advertise-map routes.
838 address-family ipv4 unicast
839 no neighbor 10.10.20.3 route-map RMAP-2 out
843 test_func
= functools
.partial(
844 _non_exist_map_routes_not_present_no_rmap2_filter
, router3
846 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
848 msg
= "TC84: non-exist-map routes not present, no route-map filter - "
849 assert result
is None, msg
+ failed
851 logger
.info(msg
+ passed
)
853 # TC91: exist-map routes present in R2's BGP table, with route-map filter and network.
854 # All routes are advertised to R3 including advertise-map routes.
859 address-family ipv4 unicast
860 network 0.0.0.0/0 route-map DEF
867 address-family ipv4 unicast
868 neighbor 10.10.20.3 route-map RMAP-2 out
869 neighbor 10.10.20.3 advertise-map ADV-MAP-2 exist-map EXIST-MAP
873 test_func
= functools
.partial(_exist_map_routes_present_rmap2_network
, router3
)
874 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
876 msg
= "TC91: exist-map routes present, route-map filter and network - "
877 assert result
is None, msg
+ failed
879 logger
.info(msg
+ passed
)
881 # TC92: exist-map routes present in R2's BGP table, with route-map filter and no network.
882 # All routes are advertised to R3 except advertise-map routes.
887 address-family ipv4 unicast
888 no network 203.0.113.1/32
892 test_func
= functools
.partial(_exist_map_routes_present_rmap2_no_network
, router3
)
893 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
895 msg
= "TC92: exist-map routes present, route-map filter and no network - "
896 assert result
is None, msg
+ failed
898 logger
.info(msg
+ passed
)
900 # TC93: non-exist-map routes not present in R2's BGP table, with route-map filter and network.
901 # All routes are advertised to R3 including advertise-map routes.
906 address-family ipv4 unicast
907 no network 0.0.0.0/0 route-map DEF
914 address-family ipv4 unicast
915 network 203.0.113.1/32
916 neighbor 10.10.20.3 advertise-map ADV-MAP-2 non-exist-map EXIST-MAP
920 test_func
= functools
.partial(
921 _non_exist_map_routes_not_present_rmap2_network
, router3
923 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
925 msg
= "TC93: non-exist-map routes not present, route-map filter and network - "
926 assert result
is None, msg
+ failed
928 logger
.info(msg
+ passed
)
930 # TC94: non-exist-map routes not present in R2's BGP table, with route-map filter and no network.
931 # All routes are advertised to R3 except advertise-map routes.
936 address-family ipv4 unicast
937 no network 203.0.113.1/32
941 test_func
= functools
.partial(
942 _non_exist_map_routes_not_present_rmap2_no_network
, router3
944 success
, result
= topotest
.run_and_expect(test_func
, None, count
=90, wait
=1)
946 msg
= "TC94: non-exist-map routes not present, route-map filter and no network - "
947 assert result
is None, msg
+ failed
949 logger
.info(msg
+ passed
)
952 def test_memory_leak():
953 "Run the memory leak test and report results."
955 if not tgen
.is_memleak_enabled():
956 pytest
.skip("Memory leak test/report is disabled")
958 tgen
.report_memory_leaks()
961 if __name__
== "__main__":
962 args
= ["-s"] + sys
.argv
[1:]
963 sys
.exit(pytest
.main(args
))