]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/zebra_nht_resolution/test_verify_nh_resolution.py
4 # Copyright (c) 2022 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 Test is indended for validating zebra NH resolution logic
31 from lib
.common_config
import (
39 # pylint: disable=C0413
40 from lib
import topotest
41 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
42 from lib
.topolog
import logger
44 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
45 sys
.path
.append(os
.path
.join(CWD
, "../"))
47 pytestmark
= [pytest
.mark
.sharpd
]
55 switch
= tgen
.add_switch("sw1")
56 switch
.add_link(tgen
.gears
["r1"])
58 def setup_module(mod
):
59 tgen
= Topogen(build_topo
, mod
.__name
__)
61 router_list
= tgen
.routers()
62 for rname
, router
in tgen
.routers().items():
63 router
.load_config(TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
)))
65 TopoRouter
.RD_SHARP
, os
.path
.join(CWD
, "{}/sharpd.conf".format(rname
))
69 def teardown_module(_mod
):
73 def test_verify_zebra_nh_resolution(request
):
75 tc_name
= request
.node
.name
76 if tgen
.routers_have_failure():
77 pytest
.skip(tgen
.errors
)
78 logger
.info("Starting Zebra NH resolution testcase")
81 step("Configure static route")
85 {"network": "2.2.2.0/24", "next_hop": "r1-eth0"}
90 result
= create_static_routes(tgen
, input_dict_1
)
91 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
95 step("Verify static routes in RIB of R1")
99 {"network": "2.2.2.0/24"}
105 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_2
)
106 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
109 step("Set the connected flag on the NH tracking entry")
110 r1
.vtysh_cmd("sharp watch nexthop 2.2.2.32 connected")
112 step("Verify that NH 2.2.2.32 gets resolved over static route")
116 "Address": "2.2.2.0/24",
117 "resolvedVia": "static",
118 "nexthops": {"nexthop1": {"Interfcae": "r1-eth0"}},
122 result
= verify_ip_nht(tgen
, input_dict_nh
)
123 assert result
is True, "Testcase {} : Failed \n"
124 "Error: Nexthop is missing in RIB".format(
127 step("Add a .32/32 route with the NH as itself")
128 r1
.vtysh_cmd("sharp install routes 2.2.2.32 nexthop 2.2.2.32 1")
130 step("Verify that the installation of .32/32 has no effect on the NHT")
134 "Address": "2.2.2.0/24",
135 "resolvedVia": "static",
136 "nexthops": {"nexthop1": {"Interface": "r1-eth0"}},
140 result
= verify_ip_nht(tgen
, input_dict_nh
)
141 assert result
is True, "Testcase {} : Failed \n"
142 "Error: Nexthop became unresolved".format(
145 step("Add a .31/32 route with the NH as 2.2.2.32"
146 "to verify the NH Resolution behaviour")
147 r1
.vtysh_cmd("sharp install routes 2.2.2.31 nexthop 2.2.2.32 1")
149 step("Verify that NH 2.2.2.2/32 doesn't become unresolved")
153 "Address": "2.2.2.0/24",
154 "resolvedVia": "static",
155 "nexthops": {"nexthop1": {"Interface": "r1-eth0"}},
159 result
= verify_ip_nht(tgen
, input_dict_nh
)
160 assert result
is True, "Testcase {} : Failed \n"
161 "Error: Nexthop became unresolved".format(
164 if __name__
== "__main__":
165 args
= ["-s"] + sys
.argv
[1:]
166 sys
.exit(pytest
.main(args
))