]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/zebra_nht_resolution/test_verify_nh_resolution.py
6956ab74099678a4df4b35c4ec99ddb071a5f35b
2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2022 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
11 Test is indended for validating zebra NH resolution logic
18 from lib
.common_config
import (
26 # pylint: disable=C0413
27 from lib
import topotest
28 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
29 from lib
.topolog
import logger
31 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
32 sys
.path
.append(os
.path
.join(CWD
, "../"))
34 pytestmark
= [pytest
.mark
.sharpd
]
42 switch
= tgen
.add_switch("sw1")
43 switch
.add_link(tgen
.gears
["r1"])
45 def setup_module(mod
):
46 tgen
= Topogen(build_topo
, mod
.__name
__)
48 router_list
= tgen
.routers()
49 for rname
, router
in tgen
.routers().items():
50 router
.load_config(TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
)))
52 TopoRouter
.RD_SHARP
, os
.path
.join(CWD
, "{}/sharpd.conf".format(rname
))
56 def teardown_module(_mod
):
60 def test_verify_zebra_nh_resolution(request
):
62 tc_name
= request
.node
.name
63 if tgen
.routers_have_failure():
64 pytest
.skip(tgen
.errors
)
65 logger
.info("Starting Zebra NH resolution testcase")
68 step("Configure static route")
72 {"network": "2.2.2.0/24", "next_hop": "r1-eth0"}
77 result
= create_static_routes(tgen
, input_dict_1
)
78 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
82 step("Verify static routes in RIB of R1")
86 {"network": "2.2.2.0/24"}
92 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_2
)
93 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
96 step("Set the connected flag on the NH tracking entry")
97 r1
.vtysh_cmd("sharp watch nexthop 2.2.2.32 connected")
99 step("Verify that NH 2.2.2.32 gets resolved over static route")
103 "Address": "2.2.2.0/24",
104 "resolvedVia": "static",
105 "nexthops": {"nexthop1": {"Interfcae": "r1-eth0"}},
109 result
= verify_ip_nht(tgen
, input_dict_nh
)
110 assert result
is True, "Testcase {} : Failed \n"
111 "Error: Nexthop is missing in RIB".format(
114 step("Add a .32/32 route with the NH as itself")
115 r1
.vtysh_cmd("sharp install routes 2.2.2.32 nexthop 2.2.2.32 1")
117 step("Verify that the installation of .32/32 has no effect on the NHT")
121 "Address": "2.2.2.0/24",
122 "resolvedVia": "static",
123 "nexthops": {"nexthop1": {"Interface": "r1-eth0"}},
127 result
= verify_ip_nht(tgen
, input_dict_nh
)
128 assert result
is True, "Testcase {} : Failed \n"
129 "Error: Nexthop became unresolved".format(
132 step("Add a .31/32 route with the NH as 2.2.2.32"
133 "to verify the NH Resolution behaviour")
134 r1
.vtysh_cmd("sharp install routes 2.2.2.31 nexthop 2.2.2.32 1")
136 step("Verify that NH 2.2.2.2/32 doesn't become unresolved")
140 "Address": "2.2.2.0/24",
141 "resolvedVia": "static",
142 "nexthops": {"nexthop1": {"Interface": "r1-eth0"}},
146 result
= verify_ip_nht(tgen
, input_dict_nh
)
147 assert result
is True, "Testcase {} : Failed \n"
148 "Error: Nexthop became unresolved".format(
151 if __name__
== "__main__":
152 args
= ["-s"] + sys
.argv
[1:]
153 sys
.exit(pytest
.main(args
))