@@ -105,6 +105,105 @@ def teardown_module(_mod):
105
105
tgen .stop_topology ()
106
106
107
107
108
+ def test_v6_rtadv_ ():
109
+ failures = 0
110
+ tgen = get_topogen ()
111
+ print ("Shutdown r1-eth200" )
112
+ tgen .gears ["r1" ].vtysh_cmd (
113
+ """
114
+ configure terminal
115
+ interface r1-eth200
116
+ shutdown
117
+ """
118
+ )
119
+
120
+ # Take two snap shots for RA status, it should not change
121
+ # Give enough time, RA adv timer to expire
122
+ sleep (2 )
123
+ rtadv_output1 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
124
+ sleep (2 )
125
+ rtadv_output2 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
126
+ if rtadv_output1 != rtadv_output2 :
127
+ sys .stderr .write (
128
+ f"RA state should not have changed: got { rtadv_output1 } , expected { rtadv_output2 } \n "
129
+ )
130
+ failures += 1
131
+
132
+ logger .info ("Do no shutdown for r1-eth200" )
133
+ tgen .gears ["r1" ].vtysh_cmd (
134
+ """
135
+ configure terminal
136
+ interface r1-eth200
137
+ no shutdown
138
+ """
139
+ )
140
+
141
+ sleep (2 )
142
+ rtadv_output1 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
143
+ sleep (2 )
144
+ rtadv_output2 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
145
+ if rtadv_output1 == rtadv_output2 :
146
+ sys .stderr .write (
147
+ f"RA state didn't change: got { rtadv_output1 } , previous { rtadv_output2 } \n "
148
+ )
149
+ failures += 1
150
+
151
+ logger .info ("Remove r1-eth200" )
152
+ existing_config = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200" )
153
+ tgen .gears ["r1" ].cmd (
154
+ """
155
+ sudo ip link set dev r1-eth200 down
156
+ """
157
+ )
158
+
159
+ sleep (2 )
160
+ rtadv_output1 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
161
+ pattern1 = '"administrativeStatus":"down"'
162
+
163
+ if pattern1 not in rtadv_output1 :
164
+ sys .stderr .write (f"Interface state not down yet:: got { rtadv_output1 } \n " )
165
+ failures += 1
166
+
167
+ # Parse the JSON string into a Python dictionary
168
+ rtadv_output1 = json .loads (rtadv_output1 )
169
+ sent_count1 = rtadv_output1 .get ("r1-eth200" , {}).get (
170
+ "ndRouterAdvertisementsSent"
171
+ )
172
+
173
+ if sent_count1 is not None :
174
+ # Wait 2 seconds
175
+ sleep (2 )
176
+
177
+ # Get second output
178
+ rtadv_output2 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
179
+
180
+ rtadv_output2 = json .loads (rtadv_output2 )
181
+ sent_count2 = rtadv_output2 .get ("r1-eth200" , {}).get (
182
+ "ndRouterAdvertisementsSent"
183
+ )
184
+
185
+ # Verify counts are the same
186
+ if sent_count1 is not None and sent_count2 is not None :
187
+ if sent_count1 != sent_count2 :
188
+ sys .stderr .write (
189
+ f"RA count changed from { sent_count1 } to { sent_count2 } within 2 seconds\n "
190
+ )
191
+ failures += 1
192
+
193
+ tgen .gears ["r1" ].cmd (
194
+ """
195
+ sudo ip link set dev r1-eth200 up
196
+ """
197
+ )
198
+
199
+ pattern1 = '"administrativeStatus":"up"'
200
+ rtadv_output1 = tgen .gears ["r1" ].vtysh_cmd ("show interface r1-eth200 json" )
201
+ if pattern1 not in rtadv_output1 :
202
+ sys .stderr .write (f"Interface state not up yet:: got { rtadv_output1 } \n " )
203
+ failures += 1
204
+ assert failures == 0 , f"Test failed with { failures } failures"
205
+
206
+
108
207
def test_bgp_route_cleanup ():
109
208
failures = 0
110
209
net = get_topogen ().net
0 commit comments