]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/isis_te_topo1/test_isis_te_topo1.py
4 # test_isis_te_topo1.py
5 # Part of NetDEF Topology Tests
7 # Copyright (c) 2021 by Orange
8 # Author: Olivier Dugeon <olivier.dugeon@orange.com>
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_isis_te_topo1.py: Test the FRR IS-IS with Traffic Engineering.
36 10.0.0.0/24| |10.0.1.0/24
40 +------------+ +------------+
42 | R2 |r2-eth2 r3-eth0| R3 |
43 | 10.0.255.2 +------------------+ 10.0.255.3 |
45 +------------+ 2001:db8:3:/64 +------+-----+
51 r4-eth0| 2001:db8:5:/64|
55 | 10.0.255.4 +-------------------------+
64 from functools
import partial
66 # Save the Current Working Directory to find configuration files.
67 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
68 sys
.path
.append(os
.path
.join(CWD
, "../"))
70 # pylint: disable=C0413
72 # Import topogen and topotest helpers
73 from lib
import topotest
74 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
75 from lib
.topolog
import logger
80 pytestmark
= [pytest
.mark
.isisd
]
87 for routern
in range(1, 5):
88 tgen
.add_router("r{}".format(routern
))
90 # Interconect router 1 and 2 with 2 links
91 switch
= tgen
.add_switch("s1")
92 switch
.add_link(tgen
.gears
["r1"])
93 switch
.add_link(tgen
.gears
["r2"])
94 switch
= tgen
.add_switch("s2")
95 switch
.add_link(tgen
.gears
["r1"])
96 switch
.add_link(tgen
.gears
["r2"])
98 # Interconect router 3 and 2
99 switch
= tgen
.add_switch("s3")
100 switch
.add_link(tgen
.gears
["r3"])
101 switch
.add_link(tgen
.gears
["r2"])
103 # Interconect router 4 and 2
104 switch
= tgen
.add_switch("s4")
105 switch
.add_link(tgen
.gears
["r4"])
106 switch
.add_link(tgen
.gears
["r2"])
108 # Interconnect router 3 and 4
109 switch
= tgen
.add_switch("s5")
110 switch
.add_link(tgen
.gears
["r3"])
111 switch
.add_link(tgen
.gears
["r4"])
114 def setup_module(mod
):
115 "Sets up the pytest environment"
117 logger
.info("\n\n---- Starting IS-IS TE tests ----\n")
119 tgen
= Topogen(build_topo
, mod
.__name
__)
120 tgen
.start_topology()
122 router_list
= tgen
.routers()
124 for rname
, router
in router_list
.items():
126 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
129 TopoRouter
.RD_ISIS
, os
.path
.join(CWD
, "{}/isisd.conf".format(rname
))
132 # Initialize all routers.
136 def teardown_module():
137 "Teardown the pytest environment"
142 logger
.info("\n\n---- IS-IS TE tests End ----\n")
145 def compare_ted_json_output(tgen
, rname
, fileref
):
146 "Compare TED JSON output"
148 logger
.info('Comparing router "%s" TED output', rname
)
150 filename
= "{}/reference/{}".format(CWD
, fileref
)
151 expected
= json
.loads(open(filename
).read())
152 command
= "show isis mpls-te database json"
154 # Run test function until we get an result. Wait at most 60 seconds.
155 test_func
= partial(topotest
.router_json_cmp
, tgen
.gears
[rname
], command
, expected
)
156 _
, diff
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=2)
157 assertmsg
= '"{}" TED JSON output mismatches the expected result'.format(rname
)
158 assert diff
is None, assertmsg
161 def setup_testcase(msg
):
167 # Skip if previous fatal error condition is raised
168 if tgen
.routers_have_failure():
169 pytest
.skip(tgen
.errors
)
174 # Note that all routers must discover the same Network Topology, so the same TED.
178 "Step1: Check initial topology"
180 tgen
= setup_testcase("Step1: test initial IS-IS TE Data Base")
182 for rname
in ["r1", "r2", "r3", "r4"]:
183 compare_ted_json_output(tgen
, rname
, "ted_step1.json")
187 "Step2: Shutdown interface between r1 and r2 and verify that \
188 corresponding Edges are removed from the TED on all routers "
190 tgen
= setup_testcase("Step2: Shutdown interface between r1 & r2")
192 tgen
.net
["r1"].cmd('vtysh -c "conf t" -c "interface r1-eth1" -c "shutdown"')
193 tgen
.net
["r2"].cmd('vtysh -c "conf t" -c "interface r2-eth1" -c "shutdown"')
195 for rname
in ["r1", "r2", "r3", "r4"]:
196 compare_ted_json_output(tgen
, rname
, "ted_step2.json")
200 "Step3: Enable IPv6 address between r1 and r2 and verify that \
201 corresponding Edges are added in the TED on all routers"
203 tgen
= setup_testcase("Step3: Add IPv6 on r1 and r2 interfaces")
205 tgen
.net
["r1"].cmd('vtysh -c "conf t" -c "interface r1-eth0" -c "ipv6 address 2001:db8:0::1/64"')
206 tgen
.net
["r1"].cmd('vtysh -c "conf t" -c "interface r1-eth0" -c "ipv6 router isis TE"')
207 tgen
.net
["r2"].cmd('vtysh -c "conf t" -c "interface r2-eth0" -c "ipv6 address 2001:db8:0::2/64"')
208 tgen
.net
["r2"].cmd('vtysh -c "conf t" -c "interface r2-eth0" -c "ipv6 router isis TE"')
209 for rname
in ["r1", "r2", "r3", "r4"]:
210 compare_ted_json_output(tgen
, rname
, "ted_step3.json")
214 "Step4: Modify Segment Routing Prefix SID advertisement on Router r4"
216 tgen
= setup_testcase("Step4: Modify Prefix SID on router r4")
218 tgen
.net
["r4"].cmd('vtysh -c "conf t" -c "router isis TE" -c "segment-routing prefix 10.0.255.4/32 index 40"')
219 tgen
.net
["r4"].cmd('vtysh -c "conf t" -c "router isis TE" -c "segment-routing prefix 2001:db8:ffff::4/128 index 1040"')
221 for rname
in ["r1", "r2", "r3", "r4"]:
222 compare_ted_json_output(tgen
, rname
, "ted_step4.json")
226 "Step5: Re-enable interface between r1 & r2 and verify that corresponding \
227 Edges are added in the TED on all routers"
229 tgen
= setup_testcase("Step5: Re-enable interface between r1 & r2")
231 tgen
.net
["r1"].cmd('vtysh -c "conf t" -c "interface r1-eth1" -c "no shutdown"')
232 tgen
.net
["r2"].cmd('vtysh -c "conf t" -c "interface r2-eth1" -c "no shutdown"')
234 for rname
in ["r1", "r2", "r3", "r4"]:
235 compare_ted_json_output(tgen
, rname
, "ted_step5.json")
239 "Step6: Set delay and jitter for interface r4-eth0 on r4, remove use-bw \
240 for interface r2-eth3 on r2 and verify that corresponding Edges are \
241 updated in the TED on all routers"
243 tgen
= setup_testcase("Step6: Modify link parameters on r2 & r4")
245 tgen
.net
["r2"].cmd('vtysh -c "conf t" -c "interface r2-eth3" -c "link-params" -c "no use-bw"')
246 tgen
.net
["r4"].cmd('vtysh -c "conf t" -c "interface r4-eth0" -c "link-params" -c "delay 20000"')
247 tgen
.net
["r4"].cmd('vtysh -c "conf t" -c "interface r4-eth0" -c "link-params" -c "delay-variation 10000"')
249 for rname
in ["r1", "r2", "r3", "r4"]:
250 compare_ted_json_output(tgen
, rname
, "ted_step6.json")
253 def test_memory_leak():
254 "Run the memory leak test and report results."
257 if not tgen
.is_memleak_enabled():
258 pytest
.skip("Memory leak test/report is disabled")
260 tgen
.report_memory_leaks()
263 if __name__
== "__main__":
264 args
= ["-s"] + sys
.argv
[1:]
265 sys
.exit(pytest
.main(args
))