blob: 9acdd861067435325f13b9ea2b578ae507df9d30 [file] [log] [blame]
Daniele Moro790cc102021-08-30 18:27:30 +02001class UP4:
2
3 def __init__(self):
4 self.default = ''
5
Daniele Moro790cc102021-08-30 18:27:30 +02006 def CASE1(self, main):
Daniele Morobf53dec2021-09-13 18:11:56 +02007 main.case("Fabric UPF traffic terminated in the fabric")
Daniele Moro790cc102021-08-30 18:27:30 +02008 """
Daniele Morobf53dec2021-09-13 18:11:56 +02009 Program PDRs and FARs for UEs
10 Verify PDRs and FARs
Daniele Moro790cc102021-08-30 18:27:30 +020011 Generate traffic from UE to PDN
12 Verify traffic received from PDN
13 Generate traffic from PDN to UE
14 Verify traffic received from UE
Daniele Morobf53dec2021-09-13 18:11:56 +020015 Remove PDRs and FARs for UEs
16 Verify removed PDRs and FARs
Daniele Moro790cc102021-08-30 18:27:30 +020017 """
Daniele Moro790cc102021-08-30 18:27:30 +020018 try:
Daniele Moro80889562021-09-08 10:09:26 +020019 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
Daniele Moro790cc102021-08-30 18:27:30 +020020 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
21 Testcaselib as run
Daniele Moro790cc102021-08-30 18:27:30 +020022 except ImportError as e:
23 main.log.error("Import not found. Exiting the test")
24 main.log.error(e)
25 main.cleanAndExit()
26
Daniele Moro790cc102021-08-30 18:27:30 +020027 run.initTest(main)
28 main.log.info(main.Cluster.numCtrls)
29 main.Cluster.setRunningNode(3)
30 run.installOnos(main, skipPackage=True, cliSleep=5)
31
Daniele Moro790cc102021-08-30 18:27:30 +020032 main.step("Start scapy and p4rt client")
Daniele Morobf53dec2021-09-13 18:11:56 +020033 # Use the first available ONOS instance CLI
34 onos_cli = main.Cluster.active(0).CLI
Daniele Moroa804a402021-10-08 18:00:56 +020035 initial_flow_count = onos_cli.checkFlowCount()
Daniele Moro80889562021-09-08 10:09:26 +020036 up4 = UP4()
37 # Get the P4RT client connected to UP4 in the first available ONOS instance
38 up4.setup(main.Cluster.active(0).p4rtUp4)
Daniele Moro790cc102021-08-30 18:27:30 +020039
Daniele Moro93feb022021-10-04 16:26:23 +020040 main.step("Program and Verify PDRs and FARs via UP4")
Daniele Moro80889562021-09-08 10:09:26 +020041 up4.attachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +020042 up4.verifyUp4Flow(onos_cli)
43
Daniele Moroa804a402021-10-08 18:00:56 +020044 run.checkFlows(main, minFlowCount=initial_flow_count+(up4.emulated_ues*2))
45
Daniele Moro80889562021-09-08 10:09:26 +020046 # ------- Test Upstream traffic (enb->pdn)
Daniele Moro790cc102021-08-30 18:27:30 +020047 main.step("Test upstream traffic")
Daniele Moro80889562021-09-08 10:09:26 +020048 up4.testUpstreamTraffic()
Daniele Moro790cc102021-08-30 18:27:30 +020049
Daniele Moro80889562021-09-08 10:09:26 +020050 # ------- Test Downstream traffic (pdn->enb)
Daniele Moro790cc102021-08-30 18:27:30 +020051 main.step("Test downstream traffic")
Daniele Moro80889562021-09-08 10:09:26 +020052 up4.testDownstreamTraffic()
Daniele Moro790cc102021-08-30 18:27:30 +020053
Daniele Moro93feb022021-10-04 16:26:23 +020054 main.step("Remove and Verify PDRs and FARs via UP4")
Daniele Moro80889562021-09-08 10:09:26 +020055 up4.detachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +020056 up4.verifyNoUesFlow(onos_cli)
57
Daniele Moroa804a402021-10-08 18:00:56 +020058 run.checkFlows(main, minFlowCount=initial_flow_count)
59
Daniele Moro790cc102021-08-30 18:27:30 +020060 main.step("Stop scapy and p4rt client")
Daniele Moro80889562021-09-08 10:09:26 +020061 up4.teardown()
Daniele Moro790cc102021-08-30 18:27:30 +020062 run.cleanup(main)
Daniele Morobf53dec2021-09-13 18:11:56 +020063
Daniele Moroa804a402021-10-08 18:00:56 +020064 def CASE2(self, main):
Daniele Morobf53dec2021-09-13 18:11:56 +020065 main.case("BESS traffic routed")
66 """
67 Program PDRs and FARs for UEs managed via UP4
68 Verify PDRs and FARs
69 Verify Upstream Traffic: eNB -> Fabric -> BESS (encapped)
70 Verify Upstream Traffic: BESS -> Fabric -> PDN (not encapped)
71 Verify Downstream Traffic: PDN -> Fabric -> BESS (not encapped)
72 Verify Downstream Traffic: BESS -> Fabric -> eNB (encapped)
73 Remove PDRs and FARs for UEs managed via UP4
74 Verify removed PDRs and FARs
75 """
76 BESS_TEID = 300
77 BESS_UE_ADDR = "10.241.0.1"
78 GPDU_PORT = 2152
79 UE_PORT = 400
80 PDN_PORT = 800
81 try:
82 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
83 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
84 Testcaselib as run
85 except ImportError as e:
86 main.log.error("Import not found. Exiting the test")
87 main.log.error(e)
88 main.cleanAndExit()
89
90 run.initTest(main)
91 main.log.info(main.Cluster.numCtrls)
92 main.Cluster.setRunningNode(3)
93 run.installOnos(main, skipPackage=True, cliSleep=5)
94
95 main.step("Start scapy and p4rt client + Scapy on BESS Host")
96 # Use the first available ONOS instance CLI
97 onos_cli = main.Cluster.active(0).CLI
Daniele Moroa804a402021-10-08 18:00:56 +020098 initial_flow_count = onos_cli.checkFlowCount()
Daniele Morobf53dec2021-09-13 18:11:56 +020099 up4 = UP4()
100 # Get the P4RT client connected to UP4 in the first available ONOS instance
101 up4.setup(main.Cluster.active(0).p4rtUp4)
102
103 # Setup the emulated BESS host and required parameters
104 bess_host = main.Compute2 # FIXME: Parametrize?
105 bess_interface = bess_host.interfaces[0]
106 bess_s1u_address = bess_interface["ips"][0]
107 bess_host.startScapy(ifaceName=bess_interface["name"], enableGtp=True)
108 enodeb_host = up4.enodeb_host
109 enodeb_interface = up4.enodeb_interface
110 pdn_host = up4.pdn_host
111 pdn_interface = up4.pdn_interface
112
Daniele Moro93feb022021-10-04 16:26:23 +0200113 main.step("Program and Verify PDRs and FARs for UEs via UP4")
Daniele Morobf53dec2021-09-13 18:11:56 +0200114 up4.attachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +0200115 up4.verifyUp4Flow(onos_cli)
116
Daniele Moroa804a402021-10-08 18:00:56 +0200117 run.checkFlows(main, minFlowCount=initial_flow_count+(up4.emulated_ues*2))
118
Daniele Morobf53dec2021-09-13 18:11:56 +0200119 # ------------------- UPSTREAM -------------------
120 # ------- eNB -> fabric -> BESS (encapped)
121 main.step("Test upstream eNB -> fabric -> BESS")
122 # Start filter before sending packets, BESS should receive GTP encapped
123 # packets
124 pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
125 GPDU_PORT, GPDU_PORT, up4.enb_address, bess_s1u_address)
126 main.log.info("Start listening on %s intf %s" % (
127 bess_host.name, bess_interface["name"]))
128 main.log.debug("BPF Filter BESS Upstream: \n %s" % pkt_filter_upstream)
129 bess_host.startFilter(ifaceName=bess_interface["name"],
130 sniffCount=1,
131 pktFilter=pkt_filter_upstream)
132 # Send GTP Packet
133 UP4.buildGtpPacket(enodeb_host,
134 src_ip_outer=up4.enb_address,
135 dst_ip_outer=bess_s1u_address,
136 src_ip_inner=BESS_UE_ADDR,
137 dst_ip_inner=pdn_interface["ips"][0],
138 src_udp_inner=UE_PORT,
139 dst_udp_inner=PDN_PORT,
140 teid=BESS_TEID)
141 enodeb_host.sendPacket()
142
143 packets = UP4.checkFilterAndGetPackets(bess_host)
144 # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
145 n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
146 tot_packets = packets.count('Ether')
147 utilities.assert_equal(expect=True,
148 actual=n_packets == 1 and tot_packets == 1,
149 onpass="BESS correctly received 1 GTP encapped packet",
150 onfail="ERROR: BESS received %d GTP encapped packets and filter captured %d packets" % (
151 n_packets, tot_packets))
152
153 # ------- BESS -> fabric -> PDN (not-encapped)
154 main.step("Test upstream BESS -> fabric -> PDN")
155 # Start filter before sending packets, PDN should receive non-GTP packet
156 pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
157 UE_PORT, PDN_PORT, BESS_UE_ADDR, pdn_interface["ips"][0])
158 main.log.info("Start listening on %s intf %s" % (
159 pdn_host.name, pdn_interface["name"]))
160 main.log.debug("BPF Filter PDN Upstream: \n %s" % pkt_filter_upstream)
161 pdn_host.startFilter(ifaceName=pdn_interface["name"],
162 sniffCount=1,
163 pktFilter=pkt_filter_upstream)
164 # Send UDP Packet
165 UP4.buildUdpPacket(bess_host,
166 src_ip=BESS_UE_ADDR,
167 dst_ip=pdn_interface["ips"][0],
168 src_udp=UE_PORT,
169 dst_udp=PDN_PORT)
170 bess_host.sendPacket()
171
172 packets = UP4.checkFilterAndGetPackets(pdn_host)
173 tot_packets = packets.count('Ether')
174 utilities.assert_equal(expect=True,
175 actual=tot_packets == 1,
176 onpass="PDN correctly received 1 packet",
177 onfail="ERROR: PDN received %d packets" % (
178 tot_packets))
179 # ------------------------------------------------
180
181 # ------------------ DOWNSTREAM ------------------
182 # ------- PDN -> fabric -> BESS (not-encapped)
183 main.step("Test downstream PDN -> fabric -> BESS")
184 pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
185 PDN_PORT, UE_PORT, pdn_interface["ips"][0], BESS_UE_ADDR)
186 main.log.info("Start listening on %s intf %s" % (
187 bess_host.name, bess_interface["name"]))
188 main.log.debug(
189 "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
190 bess_host.startFilter(ifaceName=bess_interface["name"],
191 sniffCount=1,
192 pktFilter=pkt_filter_downstream)
193 UP4.buildUdpPacket(pdn_host,
194 dst_eth=up4.router_mac,
195 src_ip=pdn_interface["ips"][0],
196 dst_ip=BESS_UE_ADDR,
197 src_udp=PDN_PORT,
198 dst_udp=UE_PORT)
199 pdn_host.sendPacket()
200
201 packets = UP4.checkFilterAndGetPackets(bess_host)
202
203 tot_packets = packets.count('Ether')
204 utilities.assert_equal(expect=True,
205 actual=tot_packets == 1,
206 onpass="BESS correctly received 1 packet",
207 onfail="ERROR: BESS received %d packets" % (
208 tot_packets))
209
210 # ------- BESS -> fabric -> eNB (encapped)
211 main.step("Test downstream BESS -> fabric -> eNB")
212 pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
213 GPDU_PORT, GPDU_PORT, bess_s1u_address, up4.enb_address)
214 main.log.info("Start listening on %s intf %s" % (
215 enodeb_host.name, enodeb_interface["name"]))
216 main.log.debug(
217 "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
218 enodeb_host.startFilter(ifaceName=enodeb_interface["name"],
219 sniffCount=1,
220 pktFilter=pkt_filter_downstream)
221 # Build GTP packet from BESS host
222 UP4.buildGtpPacket(bess_host,
223 src_ip_outer=bess_s1u_address,
224 dst_ip_outer=up4.enb_address,
225 src_ip_inner=pdn_interface["ips"][0],
226 dst_ip_inner=BESS_UE_ADDR,
227 src_udp_inner=PDN_PORT,
228 dst_udp_inner=UE_PORT,
229 teid=BESS_TEID)
230 bess_host.sendPacket()
231
232 packets = UP4.checkFilterAndGetPackets(enodeb_host)
233
234 # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
235 n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
236 tot_packets = packets.count('Ether')
237 utilities.assert_equal(expect=True,
238 actual=n_packets == 1 and tot_packets == 1,
239 onpass="eNodeB correctly received 1 GTP encapped packet",
240 onfail="ERROR: eNodeb received %d GTP encapped packets and filter captured %d packets" % (
241 n_packets, tot_packets))
242 # ------------------------------------------------
243
Daniele Moro93feb022021-10-04 16:26:23 +0200244 main.step("Remove and Verify PDRs and FARs for UEs via UP4")
Daniele Morobf53dec2021-09-13 18:11:56 +0200245 up4.detachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +0200246 up4.verifyNoUesFlow(onos_cli)
247
Daniele Moroa804a402021-10-08 18:00:56 +0200248 run.checkFlows(main, minFlowCount=initial_flow_count)
249
Daniele Morobf53dec2021-09-13 18:11:56 +0200250 main.step("Stop scapy and p4rt client")
251 up4.teardown()
252 bess_host.stopScapy()
253 run.cleanup(main)
Daniele Moro954e2282021-09-22 17:32:03 +0200254
255 def CASE3(self, main):
256 main.case("Verify UP4 from different ONOS instances")
257 """
258 Program PDRs and FARs via UP4 on first ONOS instance
259 Repeat for all ONOS Instances:
260 Verify PDRs and FARs via P4RT
261 Disconnect P4RT client
262 Verify and delete PDRs and FARs via UP4 on the third ONOS instance
263 Repeat for all ONOS Instance:
264 Verify removed PDRs and FARs via P4RT
265 Disconnect P4RT client
266 """
267 try:
268 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
269 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
270 Testcaselib as run
271 except ImportError as e:
272 main.log.error("Import not found. Exiting the test")
273 main.log.error(e)
274 main.cleanAndExit()
275
276 run.initTest(main)
277 main.log.info(main.Cluster.numCtrls)
278 main.Cluster.setRunningNode(3)
279 run.installOnos(main, skipPackage=True, cliSleep=5)
280
281 onos_cli_0 = main.Cluster.active(0).CLI
282 onos_cli_1 = main.Cluster.active(1).CLI
283 onos_cli_2 = main.Cluster.active(2).CLI
284 up4_0 = UP4()
285 up4_1 = UP4()
286 up4_2 = UP4()
Daniele Moroa804a402021-10-08 18:00:56 +0200287 initial_flow_count = onos_cli_0.checkFlowCount()
Daniele Moro954e2282021-09-22 17:32:03 +0200288
Daniele Moro93feb022021-10-04 16:26:23 +0200289 main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0")
Daniele Moro954e2282021-09-22 17:32:03 +0200290 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
291 up4_0.attachUes()
292 up4_0.verifyUp4Flow(onos_cli_0)
293 up4_0.teardown()
294
Daniele Moroa804a402021-10-08 18:00:56 +0200295 run.checkFlows(main, minFlowCount=initial_flow_count+(up4_0.emulated_ues*2))
296
Daniele Moro954e2282021-09-22 17:32:03 +0200297 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 1")
298 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
299 utilities.assert_equal(
300 expect=True,
301 actual=up4_1.verifyUesFlowNumberP4rt(),
302 onpass="Correct number of PDRs and FARs",
303 onfail="Wrong number of PDRs and FARs"
304 )
305 up4_1.teardown()
306
307 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2")
308 up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True)
309 utilities.assert_equal(
310 expect=True,
311 actual=up4_2.verifyUesFlowNumberP4rt(),
312 onpass="Correct number of PDRs and FARs",
313 onfail="Wrong number of PDRs and FARs"
314 )
315
316 main.step("Verify all ONOS instances have the same number of flows")
317 onos_0_flow_count = onos_cli_0.checkFlowCount()
318 onos_1_flow_count = onos_cli_1.checkFlowCount()
319 onos_2_flow_count = onos_cli_2.checkFlowCount()
320 utilities.assert_equal(
321 expect=True,
322 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
323 onpass="All ONOS instances have the same number of flows",
324 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
325 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
326 )
327
Daniele Moro93feb022021-10-04 16:26:23 +0200328 main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2")
Daniele Moro954e2282021-09-22 17:32:03 +0200329 up4_2.detachUes()
330 up4_2.verifyNoUesFlow(onos_cli_2)
331
Daniele Moroa804a402021-10-08 18:00:56 +0200332 run.checkFlows(main, minFlowCount=initial_flow_count)
333
Daniele Moro954e2282021-09-22 17:32:03 +0200334 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2")
335 utilities.assert_equal(
336 expect=True,
337 actual=up4_2.verifyNoUesFlowNumberP4rt(),
338 onpass="No PDRs and FARs",
339 onfail="Stale PDRs and FARs"
340 )
341 up4_2.teardown()
342
343 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 1")
344 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
345 utilities.assert_equal(
346 expect=True,
347 actual=up4_1.verifyNoUesFlowNumberP4rt(),
348 onpass="No PDRs and FARs",
349 onfail="Stale PDRs and FARs"
350 )
351 up4_1.teardown()
352
353 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0")
354 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
355 utilities.assert_equal(
356 expect=True,
357 actual=up4_0.verifyNoUesFlowNumberP4rt(),
358 onpass="No PDRs and FARs",
359 onfail="Stale PDRs and FARs"
360 )
361 up4_0.teardown()
362
363 main.step("Verify all ONOS instances have the same number of flows")
364 onos_0_flow_count = onos_cli_0.checkFlowCount()
365 onos_1_flow_count = onos_cli_1.checkFlowCount()
366 onos_2_flow_count = onos_cli_2.checkFlowCount()
367 utilities.assert_equal(
368 expect=True,
369 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
370 onpass="All ONOS instances have the same number of flows",
371 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200372 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
Daniele Moro954e2282021-09-22 17:32:03 +0200373 )
374 run.cleanup(main)
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200375
376 def CASE4(self, main):
377 main.case("Verify UP4 wipe-out after ONOS reboot")
378 """
379 Program PDRs/FARs
380 Kill ONOS POD
381 Verify PDRs/FARs from other ONOS instances
382 Remove PDRs/FARs
383 Wait/Verify ONOS is back
384 Verify no PDRs/FARs from rebooted instance
385 Re-program PDRs/FARs from rebooted instance
386 Verify all instances have same number of flows
387 Remove PDRs/FARs (cleanup)
388 """
389 try:
390 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
391 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
392 Testcaselib as run
393 except ImportError as e:
394 main.log.error("Import not found. Exiting the test")
395 main.log.error(e)
396 main.cleanAndExit()
397
398 run.initTest(main)
399 main.log.info(main.Cluster.numCtrls)
400 main.Cluster.setRunningNode(3)
401 run.installOnos(main, skipPackage=True, cliSleep=5)
402
403 onos_cli_0 = main.Cluster.active(0).CLI
404 onos_cli_1 = main.Cluster.active(1).CLI
405 onos_cli_2 = main.Cluster.active(2).CLI
406 kubectl_0 = main.Cluster.active(0).k8s
407
408 up4_0 = UP4()
409 up4_1 = UP4()
410 up4_2 = UP4()
411
Daniele Moroa804a402021-10-08 18:00:56 +0200412 initial_flow_count = onos_cli_0.checkFlowCount()
413
Daniele Moro93feb022021-10-04 16:26:23 +0200414 main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0")
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200415 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
416 up4_0.attachUes()
417 up4_0.verifyUp4Flow(onos_cli_0)
418 up4_0.teardown()
419
Daniele Moroa804a402021-10-08 18:00:56 +0200420 run.checkFlows(main, minFlowCount=initial_flow_count+(up4_0.emulated_ues*2))
421
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200422 onosPod = main.params["UP4_delete_pod"]
423 # Exit from previous port forwarding, because we need to restore
424 # port-forwarding after ONOS reboot.
425 kubectl_0.clearBuffer()
426 kubectl_0.exitFromProcess()
427 main.step("Kill " + onosPod)
428 utilities.assert_equal(
429 expect=main.TRUE,
430 actual=kubectl_0.kubectlDeletePod(
431 podName=onosPod,
432 kubeconfig=kubectl_0.kubeConfig,
433 namespace=main.params['kubernetes']['namespace']
434 ),
435 onpass="%s pod correctly deleted" % onosPod,
436 onfail="%s pod has not been deleted" % onosPod
437 )
438
439 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2")
440 up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True)
441 utilities.assert_equal(
442 expect=True,
443 actual=up4_2.verifyUesFlowNumberP4rt(),
444 onpass="Correct number of PDRs and FARs",
445 onfail="Wrong number of PDRs and FARs"
446 )
447
Daniele Moro93feb022021-10-04 16:26:23 +0200448 main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2")
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200449 up4_2.detachUes()
450 up4_2.verifyNoUesFlow(onos_cli_2)
451
Daniele Moroa804a402021-10-08 18:00:56 +0200452 run.checkFlows(main, minFlowCount=initial_flow_count)
453
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200454 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2")
455 utilities.assert_equal(
456 expect=True,
457 actual=up4_2.verifyNoUesFlowNumberP4rt(),
458 onpass="No PDRs and FARs",
459 onfail="Stale PDRs and FARs"
460 )
461 up4_2.teardown()
462
463 main.step("Verify ONOS 0 has restarted correctly")
464 onosStarted = utilities.retry(
465 f=kubectl_0.kubectlCheckPodReady,
466 retValue=main.FALSE,
467 kwargs={
468 "podName": onosPod,
469 "kubeconfig": kubectl_0.kubeConfig,
470 "namespace": main.params['kubernetes']['namespace']
471 },
472 sleep=10,
473 attempts=10
474 )
475 utilities.assert_equal(
476 expect=main.TRUE,
477 actual=onosStarted,
478 onpass="%s pod correctly restarted" % onosPod,
479 onfail="%s pod haven't restarted correctly" % onosPod
480 )
481
482 main.step("Verify ONOS cluster is in good shape")
483 # A bug in kubectl port forwarding doesn't terminate port-forwarding
484 # when the container changed, nor reconnect correctly to the restarted
485 # container.
486 # See: https://github.com/kubernetes/kubectl/issues/686
487 # Re-build the port-list for port forwarding
488 portList = "%s:%s " % (main.Cluster.active(0).CLI.karafPort, 8101)
489 portList += "%s:%s " % (main.Cluster.active(0).REST.port, 8181)
490 portList += "%s:%s " % (main.Cluster.active(0).p4rtUp4.p4rtPort,
491 main.ONOScell.up4Port)
492 kubectl_0.clearBuffer()
493 kubectl_0.kubectlPortForward(
494 onosPod,
495 portList,
496 kubectl_0.kubeConfig,
497 main.params['kubernetes']['namespace']
498 )
499 onos_cli_0.clearBuffer() # Trigger ONOS CLI reconnection
500 onosNodesStatus = utilities.retry(
501 f=main.Cluster.nodesCheck,
502 retValue=False,
503 sleep=5,
504 attempts=10
505 )
506 utilities.assert_equal(
507 expect=True,
508 actual=onosNodesStatus,
509 onpass="ONOS nodes status correct",
510 onfail="Wrong ONOS nodes status"
511 )
512
513 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0")
514 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
515 utilities.assert_equal(
516 expect=True,
517 actual=up4_0.verifyNoUesFlowNumberP4rt(),
518 onpass="No PDRs and FARs",
519 onfail="Stale PDRs and FARs"
520 )
521
522 main.step("Re-program PDRs and FARs via UP4 on ONOS 0 after restart")
523 up4_0.attachUes()
524 up4_0.verifyUp4Flow(onos_cli_0)
525 up4_0.teardown()
526
Daniele Moroa804a402021-10-08 18:00:56 +0200527 run.checkFlows(main, minFlowCount=initial_flow_count+(up4_0.emulated_ues*2))
528
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200529 main.step("Verify PDRs and FARs via UP4 on ONOS 1")
530 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
531 up4_1.verifyUp4Flow(onos_cli_1)
532
533 main.step("Verify all ONOS instances have the same number of flows")
534 onos_0_flow_count = onos_cli_0.checkFlowCount()
535 onos_1_flow_count = onos_cli_1.checkFlowCount()
536 onos_2_flow_count = onos_cli_2.checkFlowCount()
537 utilities.assert_equal(
538 expect=True,
539 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
540 onpass="All ONOS instances have the same number of flows",
541 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
542 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
543 )
544
545 main.step("Cleanup PDRs and FARs via UP4 on ONOS 1")
546 up4_1.detachUes()
Daniele Moro6dfbfef2021-09-28 22:44:19 +0200547 up4_1.verifyNoUesFlow(onos_cli_1)
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200548 up4_1.teardown()
549
Daniele Moroa804a402021-10-08 18:00:56 +0200550 run.checkFlows(main, minFlowCount=initial_flow_count)
551
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200552 run.cleanup(main)