blob: 13956718f3f06c38bac71e0aca146895748653a0 [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 Moro9ba5cf02021-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 Moro9ba5cf02021-10-08 18:00:56 +020044 run.checkFlows(
45 main,
46 minFlowCount=initial_flow_count+(len(up4.emulated_ues)*2)
47 )
48
Daniele Moro80889562021-09-08 10:09:26 +020049 # ------- Test Upstream traffic (enb->pdn)
Daniele Moro790cc102021-08-30 18:27:30 +020050 main.step("Test upstream traffic")
Daniele Moro80889562021-09-08 10:09:26 +020051 up4.testUpstreamTraffic()
Daniele Moro790cc102021-08-30 18:27:30 +020052
Daniele Moro80889562021-09-08 10:09:26 +020053 # ------- Test Downstream traffic (pdn->enb)
Daniele Moro790cc102021-08-30 18:27:30 +020054 main.step("Test downstream traffic")
Daniele Moro80889562021-09-08 10:09:26 +020055 up4.testDownstreamTraffic()
Daniele Moro790cc102021-08-30 18:27:30 +020056
Daniele Moro93feb022021-10-04 16:26:23 +020057 main.step("Remove and Verify PDRs and FARs via UP4")
Daniele Moro80889562021-09-08 10:09:26 +020058 up4.detachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +020059 up4.verifyNoUesFlow(onos_cli)
60
Daniele Moro9ba5cf02021-10-08 18:00:56 +020061 run.checkFlows(main, minFlowCount=initial_flow_count)
62
Daniele Moro790cc102021-08-30 18:27:30 +020063 main.step("Stop scapy and p4rt client")
Daniele Moro80889562021-09-08 10:09:26 +020064 up4.teardown()
Daniele Moro790cc102021-08-30 18:27:30 +020065 run.cleanup(main)
Daniele Morobf53dec2021-09-13 18:11:56 +020066
Daniele Moro9ba5cf02021-10-08 18:00:56 +020067 def CASE2(self, main):
Daniele Morobf53dec2021-09-13 18:11:56 +020068 main.case("BESS traffic routed")
69 """
70 Program PDRs and FARs for UEs managed via UP4
71 Verify PDRs and FARs
72 Verify Upstream Traffic: eNB -> Fabric -> BESS (encapped)
73 Verify Upstream Traffic: BESS -> Fabric -> PDN (not encapped)
74 Verify Downstream Traffic: PDN -> Fabric -> BESS (not encapped)
75 Verify Downstream Traffic: BESS -> Fabric -> eNB (encapped)
76 Remove PDRs and FARs for UEs managed via UP4
77 Verify removed PDRs and FARs
78 """
79 BESS_TEID = 300
80 BESS_UE_ADDR = "10.241.0.1"
81 GPDU_PORT = 2152
82 UE_PORT = 400
83 PDN_PORT = 800
84 try:
85 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
86 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
87 Testcaselib as run
88 except ImportError as e:
89 main.log.error("Import not found. Exiting the test")
90 main.log.error(e)
91 main.cleanAndExit()
92
93 run.initTest(main)
94 main.log.info(main.Cluster.numCtrls)
95 main.Cluster.setRunningNode(3)
96 run.installOnos(main, skipPackage=True, cliSleep=5)
97
98 main.step("Start scapy and p4rt client + Scapy on BESS Host")
99 # Use the first available ONOS instance CLI
100 onos_cli = main.Cluster.active(0).CLI
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200101 initial_flow_count = onos_cli.checkFlowCount()
Daniele Morobf53dec2021-09-13 18:11:56 +0200102 up4 = UP4()
103 # Get the P4RT client connected to UP4 in the first available ONOS instance
104 up4.setup(main.Cluster.active(0).p4rtUp4)
105
106 # Setup the emulated BESS host and required parameters
107 bess_host = main.Compute2 # FIXME: Parametrize?
108 bess_interface = bess_host.interfaces[0]
109 bess_s1u_address = bess_interface["ips"][0]
110 bess_host.startScapy(ifaceName=bess_interface["name"], enableGtp=True)
111 enodeb_host = up4.enodeb_host
112 enodeb_interface = up4.enodeb_interface
113 pdn_host = up4.pdn_host
114 pdn_interface = up4.pdn_interface
115
Daniele Moro93feb022021-10-04 16:26:23 +0200116 main.step("Program and Verify PDRs and FARs for UEs via UP4")
Daniele Morobf53dec2021-09-13 18:11:56 +0200117 up4.attachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +0200118 up4.verifyUp4Flow(onos_cli)
119
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200120 run.checkFlows(
121 main,
122 minFlowCount=initial_flow_count+(len(up4.emulated_ues)*2)
123 )
124
Daniele Morobf53dec2021-09-13 18:11:56 +0200125 # ------------------- UPSTREAM -------------------
126 # ------- eNB -> fabric -> BESS (encapped)
127 main.step("Test upstream eNB -> fabric -> BESS")
128 # Start filter before sending packets, BESS should receive GTP encapped
129 # packets
130 pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
131 GPDU_PORT, GPDU_PORT, up4.enb_address, bess_s1u_address)
132 main.log.info("Start listening on %s intf %s" % (
133 bess_host.name, bess_interface["name"]))
134 main.log.debug("BPF Filter BESS Upstream: \n %s" % pkt_filter_upstream)
135 bess_host.startFilter(ifaceName=bess_interface["name"],
136 sniffCount=1,
137 pktFilter=pkt_filter_upstream)
138 # Send GTP Packet
139 UP4.buildGtpPacket(enodeb_host,
140 src_ip_outer=up4.enb_address,
141 dst_ip_outer=bess_s1u_address,
142 src_ip_inner=BESS_UE_ADDR,
143 dst_ip_inner=pdn_interface["ips"][0],
144 src_udp_inner=UE_PORT,
145 dst_udp_inner=PDN_PORT,
146 teid=BESS_TEID)
147 enodeb_host.sendPacket()
148
149 packets = UP4.checkFilterAndGetPackets(bess_host)
150 # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
151 n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
152 tot_packets = packets.count('Ether')
153 utilities.assert_equal(expect=True,
154 actual=n_packets == 1 and tot_packets == 1,
155 onpass="BESS correctly received 1 GTP encapped packet",
156 onfail="ERROR: BESS received %d GTP encapped packets and filter captured %d packets" % (
157 n_packets, tot_packets))
158
159 # ------- BESS -> fabric -> PDN (not-encapped)
160 main.step("Test upstream BESS -> fabric -> PDN")
161 # Start filter before sending packets, PDN should receive non-GTP packet
162 pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
163 UE_PORT, PDN_PORT, BESS_UE_ADDR, pdn_interface["ips"][0])
164 main.log.info("Start listening on %s intf %s" % (
165 pdn_host.name, pdn_interface["name"]))
166 main.log.debug("BPF Filter PDN Upstream: \n %s" % pkt_filter_upstream)
167 pdn_host.startFilter(ifaceName=pdn_interface["name"],
168 sniffCount=1,
169 pktFilter=pkt_filter_upstream)
170 # Send UDP Packet
171 UP4.buildUdpPacket(bess_host,
172 src_ip=BESS_UE_ADDR,
173 dst_ip=pdn_interface["ips"][0],
174 src_udp=UE_PORT,
175 dst_udp=PDN_PORT)
176 bess_host.sendPacket()
177
178 packets = UP4.checkFilterAndGetPackets(pdn_host)
179 tot_packets = packets.count('Ether')
180 utilities.assert_equal(expect=True,
181 actual=tot_packets == 1,
182 onpass="PDN correctly received 1 packet",
183 onfail="ERROR: PDN received %d packets" % (
184 tot_packets))
185 # ------------------------------------------------
186
187 # ------------------ DOWNSTREAM ------------------
188 # ------- PDN -> fabric -> BESS (not-encapped)
189 main.step("Test downstream PDN -> fabric -> BESS")
190 pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
191 PDN_PORT, UE_PORT, pdn_interface["ips"][0], BESS_UE_ADDR)
192 main.log.info("Start listening on %s intf %s" % (
193 bess_host.name, bess_interface["name"]))
194 main.log.debug(
195 "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
196 bess_host.startFilter(ifaceName=bess_interface["name"],
197 sniffCount=1,
198 pktFilter=pkt_filter_downstream)
199 UP4.buildUdpPacket(pdn_host,
200 dst_eth=up4.router_mac,
201 src_ip=pdn_interface["ips"][0],
202 dst_ip=BESS_UE_ADDR,
203 src_udp=PDN_PORT,
204 dst_udp=UE_PORT)
205 pdn_host.sendPacket()
206
207 packets = UP4.checkFilterAndGetPackets(bess_host)
208
209 tot_packets = packets.count('Ether')
210 utilities.assert_equal(expect=True,
211 actual=tot_packets == 1,
212 onpass="BESS correctly received 1 packet",
213 onfail="ERROR: BESS received %d packets" % (
214 tot_packets))
215
216 # ------- BESS -> fabric -> eNB (encapped)
217 main.step("Test downstream BESS -> fabric -> eNB")
218 pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
219 GPDU_PORT, GPDU_PORT, bess_s1u_address, up4.enb_address)
220 main.log.info("Start listening on %s intf %s" % (
221 enodeb_host.name, enodeb_interface["name"]))
222 main.log.debug(
223 "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
224 enodeb_host.startFilter(ifaceName=enodeb_interface["name"],
225 sniffCount=1,
226 pktFilter=pkt_filter_downstream)
227 # Build GTP packet from BESS host
228 UP4.buildGtpPacket(bess_host,
229 src_ip_outer=bess_s1u_address,
230 dst_ip_outer=up4.enb_address,
231 src_ip_inner=pdn_interface["ips"][0],
232 dst_ip_inner=BESS_UE_ADDR,
233 src_udp_inner=PDN_PORT,
234 dst_udp_inner=UE_PORT,
235 teid=BESS_TEID)
236 bess_host.sendPacket()
237
238 packets = UP4.checkFilterAndGetPackets(enodeb_host)
239
240 # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
241 n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
242 tot_packets = packets.count('Ether')
243 utilities.assert_equal(expect=True,
244 actual=n_packets == 1 and tot_packets == 1,
245 onpass="eNodeB correctly received 1 GTP encapped packet",
246 onfail="ERROR: eNodeb received %d GTP encapped packets and filter captured %d packets" % (
247 n_packets, tot_packets))
248 # ------------------------------------------------
249
Daniele Moro93feb022021-10-04 16:26:23 +0200250 main.step("Remove and Verify PDRs and FARs for UEs via UP4")
Daniele Morobf53dec2021-09-13 18:11:56 +0200251 up4.detachUes()
Daniele Morobf53dec2021-09-13 18:11:56 +0200252 up4.verifyNoUesFlow(onos_cli)
253
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200254 run.checkFlows(main, minFlowCount=initial_flow_count)
255
Daniele Morobf53dec2021-09-13 18:11:56 +0200256 main.step("Stop scapy and p4rt client")
257 up4.teardown()
258 bess_host.stopScapy()
259 run.cleanup(main)
Daniele Moro954e2282021-09-22 17:32:03 +0200260
261 def CASE3(self, main):
262 main.case("Verify UP4 from different ONOS instances")
263 """
264 Program PDRs and FARs via UP4 on first ONOS instance
265 Repeat for all ONOS Instances:
266 Verify PDRs and FARs via P4RT
267 Disconnect P4RT client
268 Verify and delete PDRs and FARs via UP4 on the third ONOS instance
269 Repeat for all ONOS Instance:
270 Verify removed PDRs and FARs via P4RT
271 Disconnect P4RT client
272 """
273 try:
274 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
275 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
276 Testcaselib as run
277 except ImportError as e:
278 main.log.error("Import not found. Exiting the test")
279 main.log.error(e)
280 main.cleanAndExit()
281
282 run.initTest(main)
283 main.log.info(main.Cluster.numCtrls)
284 main.Cluster.setRunningNode(3)
285 run.installOnos(main, skipPackage=True, cliSleep=5)
286
287 onos_cli_0 = main.Cluster.active(0).CLI
288 onos_cli_1 = main.Cluster.active(1).CLI
289 onos_cli_2 = main.Cluster.active(2).CLI
290 up4_0 = UP4()
291 up4_1 = UP4()
292 up4_2 = UP4()
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200293 initial_flow_count = onos_cli_0.checkFlowCount()
Daniele Moro954e2282021-09-22 17:32:03 +0200294
Daniele Moro93feb022021-10-04 16:26:23 +0200295 main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0")
Daniele Moro954e2282021-09-22 17:32:03 +0200296 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
297 up4_0.attachUes()
298 up4_0.verifyUp4Flow(onos_cli_0)
299 up4_0.teardown()
300
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200301 run.checkFlows(
302 main,
303 minFlowCount=initial_flow_count+(len(up4_0.emulated_ues)*2)
304 )
305
Daniele Moro954e2282021-09-22 17:32:03 +0200306 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 1")
307 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
308 utilities.assert_equal(
309 expect=True,
310 actual=up4_1.verifyUesFlowNumberP4rt(),
311 onpass="Correct number of PDRs and FARs",
312 onfail="Wrong number of PDRs and FARs"
313 )
314 up4_1.teardown()
315
316 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2")
317 up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True)
318 utilities.assert_equal(
319 expect=True,
320 actual=up4_2.verifyUesFlowNumberP4rt(),
321 onpass="Correct number of PDRs and FARs",
322 onfail="Wrong number of PDRs and FARs"
323 )
324
325 main.step("Verify all ONOS instances have the same number of flows")
326 onos_0_flow_count = onos_cli_0.checkFlowCount()
327 onos_1_flow_count = onos_cli_1.checkFlowCount()
328 onos_2_flow_count = onos_cli_2.checkFlowCount()
329 utilities.assert_equal(
330 expect=True,
331 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
332 onpass="All ONOS instances have the same number of flows",
333 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
334 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
335 )
336
Daniele Moro93feb022021-10-04 16:26:23 +0200337 main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2")
Daniele Moro954e2282021-09-22 17:32:03 +0200338 up4_2.detachUes()
339 up4_2.verifyNoUesFlow(onos_cli_2)
340
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200341 run.checkFlows(main, minFlowCount=initial_flow_count)
342
Daniele Moro954e2282021-09-22 17:32:03 +0200343 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2")
344 utilities.assert_equal(
345 expect=True,
346 actual=up4_2.verifyNoUesFlowNumberP4rt(),
347 onpass="No PDRs and FARs",
348 onfail="Stale PDRs and FARs"
349 )
350 up4_2.teardown()
351
352 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 1")
353 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
354 utilities.assert_equal(
355 expect=True,
356 actual=up4_1.verifyNoUesFlowNumberP4rt(),
357 onpass="No PDRs and FARs",
358 onfail="Stale PDRs and FARs"
359 )
360 up4_1.teardown()
361
362 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0")
363 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
364 utilities.assert_equal(
365 expect=True,
366 actual=up4_0.verifyNoUesFlowNumberP4rt(),
367 onpass="No PDRs and FARs",
368 onfail="Stale PDRs and FARs"
369 )
370 up4_0.teardown()
371
372 main.step("Verify all ONOS instances have the same number of flows")
373 onos_0_flow_count = onos_cli_0.checkFlowCount()
374 onos_1_flow_count = onos_cli_1.checkFlowCount()
375 onos_2_flow_count = onos_cli_2.checkFlowCount()
376 utilities.assert_equal(
377 expect=True,
378 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
379 onpass="All ONOS instances have the same number of flows",
380 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200381 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
Daniele Moro954e2282021-09-22 17:32:03 +0200382 )
383 run.cleanup(main)
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200384
385 def CASE4(self, main):
386 main.case("Verify UP4 wipe-out after ONOS reboot")
387 """
388 Program PDRs/FARs
389 Kill ONOS POD
390 Verify PDRs/FARs from other ONOS instances
391 Remove PDRs/FARs
392 Wait/Verify ONOS is back
393 Verify no PDRs/FARs from rebooted instance
394 Re-program PDRs/FARs from rebooted instance
395 Verify all instances have same number of flows
396 Remove PDRs/FARs (cleanup)
397 """
398 try:
399 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
400 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
401 Testcaselib as run
402 except ImportError as e:
403 main.log.error("Import not found. Exiting the test")
404 main.log.error(e)
405 main.cleanAndExit()
406
407 run.initTest(main)
408 main.log.info(main.Cluster.numCtrls)
409 main.Cluster.setRunningNode(3)
410 run.installOnos(main, skipPackage=True, cliSleep=5)
411
412 onos_cli_0 = main.Cluster.active(0).CLI
413 onos_cli_1 = main.Cluster.active(1).CLI
414 onos_cli_2 = main.Cluster.active(2).CLI
415 kubectl_0 = main.Cluster.active(0).k8s
416
417 up4_0 = UP4()
418 up4_1 = UP4()
419 up4_2 = UP4()
420
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200421 initial_flow_count = onos_cli_0.checkFlowCount()
422
Daniele Moro93feb022021-10-04 16:26:23 +0200423 main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0")
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200424 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
425 up4_0.attachUes()
426 up4_0.verifyUp4Flow(onos_cli_0)
427 up4_0.teardown()
428
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200429 run.checkFlows(
430 main,
431 minFlowCount=initial_flow_count+(len(up4_0.emulated_ues)*2)
432 )
433
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200434 onosPod = main.params["UP4_delete_pod"]
435 # Exit from previous port forwarding, because we need to restore
436 # port-forwarding after ONOS reboot.
437 kubectl_0.clearBuffer()
438 kubectl_0.exitFromProcess()
439 main.step("Kill " + onosPod)
440 utilities.assert_equal(
441 expect=main.TRUE,
442 actual=kubectl_0.kubectlDeletePod(
443 podName=onosPod,
444 kubeconfig=kubectl_0.kubeConfig,
445 namespace=main.params['kubernetes']['namespace']
446 ),
447 onpass="%s pod correctly deleted" % onosPod,
448 onfail="%s pod has not been deleted" % onosPod
449 )
450
451 main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2")
452 up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True)
453 utilities.assert_equal(
454 expect=True,
455 actual=up4_2.verifyUesFlowNumberP4rt(),
456 onpass="Correct number of PDRs and FARs",
457 onfail="Wrong number of PDRs and FARs"
458 )
459
Daniele Moro93feb022021-10-04 16:26:23 +0200460 main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2")
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200461 up4_2.detachUes()
462 up4_2.verifyNoUesFlow(onos_cli_2)
463
464 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2")
465 utilities.assert_equal(
466 expect=True,
467 actual=up4_2.verifyNoUesFlowNumberP4rt(),
468 onpass="No PDRs and FARs",
469 onfail="Stale PDRs and FARs"
470 )
471 up4_2.teardown()
472
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200473 main.step("Verify all active ONOS instances have the same number of flows")
474 onos_1_flow_count = onos_cli_1.checkFlowCount()
475 onos_2_flow_count = onos_cli_2.checkFlowCount()
476 utilities.assert_equal(
477 expect=True,
478 actual=onos_1_flow_count == onos_2_flow_count,
479 onpass="All ONOS instances have the same number of flows",
480 onfail="ONOS instances have different number of flows: (%d, %d)" % (
481 onos_1_flow_count, onos_2_flow_count)
482 )
483
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200484 main.step("Verify ONOS 0 has restarted correctly")
485 onosStarted = utilities.retry(
486 f=kubectl_0.kubectlCheckPodReady,
487 retValue=main.FALSE,
488 kwargs={
489 "podName": onosPod,
490 "kubeconfig": kubectl_0.kubeConfig,
491 "namespace": main.params['kubernetes']['namespace']
492 },
493 sleep=10,
494 attempts=10
495 )
496 utilities.assert_equal(
497 expect=main.TRUE,
498 actual=onosStarted,
499 onpass="%s pod correctly restarted" % onosPod,
500 onfail="%s pod haven't restarted correctly" % onosPod
501 )
502
503 main.step("Verify ONOS cluster is in good shape")
504 # A bug in kubectl port forwarding doesn't terminate port-forwarding
505 # when the container changed, nor reconnect correctly to the restarted
506 # container.
507 # See: https://github.com/kubernetes/kubectl/issues/686
508 # Re-build the port-list for port forwarding
509 portList = "%s:%s " % (main.Cluster.active(0).CLI.karafPort, 8101)
510 portList += "%s:%s " % (main.Cluster.active(0).REST.port, 8181)
511 portList += "%s:%s " % (main.Cluster.active(0).p4rtUp4.p4rtPort,
512 main.ONOScell.up4Port)
513 kubectl_0.clearBuffer()
514 kubectl_0.kubectlPortForward(
515 onosPod,
516 portList,
517 kubectl_0.kubeConfig,
518 main.params['kubernetes']['namespace']
519 )
520 onos_cli_0.clearBuffer() # Trigger ONOS CLI reconnection
521 onosNodesStatus = utilities.retry(
522 f=main.Cluster.nodesCheck,
523 retValue=False,
524 sleep=5,
525 attempts=10
526 )
527 utilities.assert_equal(
528 expect=True,
529 actual=onosNodesStatus,
530 onpass="ONOS nodes status correct",
531 onfail="Wrong ONOS nodes status"
532 )
533
534 main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0")
535 up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
536 utilities.assert_equal(
537 expect=True,
538 actual=up4_0.verifyNoUesFlowNumberP4rt(),
539 onpass="No PDRs and FARs",
540 onfail="Stale PDRs and FARs"
541 )
542
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200543 run.checkFlows(main, minFlowCount=initial_flow_count)
544
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200545 main.step("Re-program PDRs and FARs via UP4 on ONOS 0 after restart")
546 up4_0.attachUes()
547 up4_0.verifyUp4Flow(onos_cli_0)
548 up4_0.teardown()
549
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200550 run.checkFlows(
551 main,
552 minFlowCount=initial_flow_count+(len(up4_0.emulated_ues)*2)
553 )
554
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200555 main.step("Verify PDRs and FARs via UP4 on ONOS 1")
556 up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True)
557 up4_1.verifyUp4Flow(onos_cli_1)
558
559 main.step("Verify all ONOS instances have the same number of flows")
560 onos_0_flow_count = onos_cli_0.checkFlowCount()
561 onos_1_flow_count = onos_cli_1.checkFlowCount()
562 onos_2_flow_count = onos_cli_2.checkFlowCount()
563 utilities.assert_equal(
564 expect=True,
565 actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count,
566 onpass="All ONOS instances have the same number of flows",
567 onfail="ONOS instances have different number of flows: (%d, %d, %d)" % (
568 onos_0_flow_count, onos_1_flow_count, onos_2_flow_count)
569 )
570
571 main.step("Cleanup PDRs and FARs via UP4 on ONOS 1")
572 up4_1.detachUes()
Daniele Moro6dfbfef2021-09-28 22:44:19 +0200573 up4_1.verifyNoUesFlow(onos_cli_1)
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200574 up4_1.teardown()
575
Daniele Moro9ba5cf02021-10-08 18:00:56 +0200576 run.checkFlows(main, minFlowCount=initial_flow_count)
577
Daniele Moroe1d05eb2021-09-23 19:52:30 +0200578 run.cleanup(main)