Skip to content

Commit 914dee7

Browse files
committed
test: Add test case to verify RA adv
Added test cases with interface down/up/shutdown to verify RA state of an interface Signed-off-by: Soumya Roy <[email protected]>
1 parent 77eac26 commit 914dee7

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

tests/topotests/high_ecmp/test_high_ecmp_unnumbered.py

+78
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,84 @@ def teardown_module(_mod):
104104
# This function tears down the whole topology.
105105
tgen.stop_topology()
106106

107+
def test_v6_rtadv_():
108+
failures = 0
109+
net = get_topogen().net
110+
print("Shutdown r1-eth200")
111+
net["r1"].cmd(
112+
'vtysh -c "config t" -c "interface r1-eth200" '
113+
' -c "shutdown" '
114+
)
115+
116+
sleep(2)
117+
rtadv_output1 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
118+
sleep(2)
119+
rtadv_output2 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
120+
if rtadv_output1 != rtadv_output2:
121+
sys.stderr.write(
122+
f"RA state should not have changed: got {rtadv_output1}, expected {rtadv_output2}\n"
123+
)
124+
failures += 1
125+
else:
126+
print("RA state verified successfully for interface shut")
127+
128+
print("Do no shutdown for r1-eth200")
129+
net["r1"].cmd(
130+
'vtysh -c "config t" -c "interface r1-eth200" '
131+
' -c "no shutdown" '
132+
)
133+
134+
sleep(2)
135+
rtadv_output1 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
136+
sleep(2)
137+
rtadv_output2 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
138+
if rtadv_output1 == rtadv_output2:
139+
sys.stderr.write(
140+
f"RA state didn't change: got {rtadv_output1}, previous {rtadv_output2}\n"
141+
)
142+
failures += 1
143+
else:
144+
print("RA state verified successfully for interface unshut")
145+
146+
147+
print("Remove r1-eth200")
148+
existing_config = net["r1"].cmd("vtysh -c 'show interface r1-eth200'")
149+
net["r1"].cmd("sudo ip link delete r1-eth200")
150+
sleep(2)
151+
rtadv_output1 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
152+
pattern1 = '"administrativeStatus":"down"'
153+
154+
if pattern1 in rtadv_output1:
155+
print("Interface is down verified successfully")
156+
else:
157+
sys.stderr.write(
158+
f"Interface state not down yet:: got {rtadv_output1}\n"
159+
)
160+
failures += 1
161+
162+
pattern2 = '"ndRouterAdvertisementsSent"'
163+
if pattern2 in rtadv_output1:
164+
sys.stderr.write(
165+
f"RA state still present :: got {rtadv_output1}\n"
166+
)
167+
failures += 1
168+
else:
169+
print("RA state verified successfully")
170+
171+
net["r1"].cmd("sudo ip link add r1-eth200 type veth")
172+
sleep(1)
173+
net["r1"].cmd("sudo ip link set dev r1-eth200 up")
174+
sleep(2)
175+
pattern1 = '"administrativeStatus":"up"'
176+
rtadv_output1 = net["r1"].cmd("vtysh -c 'show interface r1-eth200 json'")
177+
if pattern1 in rtadv_output1:
178+
print("Interface is up verified successfully")
179+
else:
180+
sys.stderr.write(
181+
f"Interface state not up yet:: got {rtadv_output1}\n"
182+
)
183+
failures += 1
184+
assert failures == 0, f"Test failed with {failures} failures"
107185

108186
def test_bgp_route_cleanup():
109187
failures = 0

0 commit comments

Comments
 (0)