Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 1 | class UP4: |
| 2 | |
| 3 | def __init__(self): |
| 4 | self.default = '' |
| 5 | |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 6 | def CASE1(self, main): |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 7 | main.case("Fabric UPF traffic terminated in the fabric") |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 8 | """ |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 9 | Program PDRs and FARs for UEs |
| 10 | Verify PDRs and FARs |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 11 | 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 Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 15 | Remove PDRs and FARs for UEs |
| 16 | Verify removed PDRs and FARs |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 17 | """ |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 18 | try: |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 19 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 20 | N_FLOWS_PER_UE |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 21 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 22 | Testcaselib as run |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 23 | except ImportError as e: |
| 24 | main.log.error("Import not found. Exiting the test") |
| 25 | main.log.error(e) |
| 26 | main.cleanAndExit() |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 27 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 28 | |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 29 | run.initTest(main) |
| 30 | main.log.info(main.Cluster.numCtrls) |
| 31 | main.Cluster.setRunningNode(3) |
| 32 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 33 | |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 34 | main.step("Start scapy and p4rt client") |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 35 | # Use the first available ONOS instance CLI |
| 36 | onos_cli = main.Cluster.active(0).CLI |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 37 | initial_flow_count = onos_cli.checkFlowCount() |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 38 | up4 = UP4() |
| 39 | # Get the P4RT client connected to UP4 in the first available ONOS instance |
| 40 | up4.setup(main.Cluster.active(0).p4rtUp4) |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 41 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 42 | main.step("Program and Verify PDRs and FARs via UP4") |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 43 | up4.attachUes() |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 44 | up4.verifyUp4Flow(onos_cli) |
| 45 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 46 | run.checkFlows( |
| 47 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 48 | minFlowCount=initial_flow_count + ( |
| 49 | len(up4.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 50 | ) |
| 51 | |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 52 | # ------- Test Upstream traffic (enb->pdn) |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 53 | main.step("Test upstream traffic") |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 54 | up4.testUpstreamTraffic() |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 55 | |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 56 | # ------- Test Downstream traffic (pdn->enb) |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 57 | main.step("Test downstream traffic") |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 58 | up4.testDownstreamTraffic() |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 59 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 60 | main.step("Remove and Verify PDRs and FARs via UP4") |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 61 | up4.detachUes() |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 62 | up4.verifyNoUesFlow(onos_cli) |
| 63 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 64 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 65 | |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 66 | main.step("Stop scapy and p4rt client") |
Daniele Moro | 8088956 | 2021-09-08 10:09:26 +0200 | [diff] [blame] | 67 | up4.teardown() |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 68 | |
| 69 | run.saveOnosDiagsIfFailure(main) |
Daniele Moro | 790cc10 | 2021-08-30 18:27:30 +0200 | [diff] [blame] | 70 | run.cleanup(main) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 71 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 72 | def CASE2(self, main): |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 73 | main.case("BESS traffic routed") |
| 74 | """ |
| 75 | Program PDRs and FARs for UEs managed via UP4 |
| 76 | Verify PDRs and FARs |
| 77 | Verify Upstream Traffic: eNB -> Fabric -> BESS (encapped) |
| 78 | Verify Upstream Traffic: BESS -> Fabric -> PDN (not encapped) |
| 79 | Verify Downstream Traffic: PDN -> Fabric -> BESS (not encapped) |
| 80 | Verify Downstream Traffic: BESS -> Fabric -> eNB (encapped) |
| 81 | Remove PDRs and FARs for UEs managed via UP4 |
| 82 | Verify removed PDRs and FARs |
| 83 | """ |
| 84 | BESS_TEID = 300 |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 85 | GPDU_PORT = 2152 |
| 86 | UE_PORT = 400 |
| 87 | PDN_PORT = 800 |
| 88 | try: |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 89 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 90 | N_FLOWS_PER_UE |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 91 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 92 | Testcaselib as run |
| 93 | except ImportError as e: |
| 94 | main.log.error("Import not found. Exiting the test") |
| 95 | main.log.error(e) |
| 96 | main.cleanAndExit() |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 97 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 98 | |
| 99 | run.initTest(main) |
| 100 | main.log.info(main.Cluster.numCtrls) |
| 101 | main.Cluster.setRunningNode(3) |
| 102 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 103 | |
| 104 | main.step("Start scapy and p4rt client + Scapy on BESS Host") |
| 105 | # Use the first available ONOS instance CLI |
| 106 | onos_cli = main.Cluster.active(0).CLI |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 107 | initial_flow_count = onos_cli.checkFlowCount() |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 108 | up4 = UP4() |
| 109 | # Get the P4RT client connected to UP4 in the first available ONOS instance |
| 110 | up4.setup(main.Cluster.active(0).p4rtUp4) |
| 111 | |
| 112 | # Setup the emulated BESS host and required parameters |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 113 | bess_host = getattr(main, main.params["BESS_UPF"]["bess_host"]) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 114 | bess_interface = bess_host.interfaces[0] |
| 115 | bess_s1u_address = bess_interface["ips"][0] |
| 116 | bess_host.startScapy(ifaceName=bess_interface["name"], enableGtp=True) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 117 | bess_ue_address = main.params["BESS_UPF"]["ue_address"] |
| 118 | enodeb_host = getattr(main, main.params["BESS_UPF"]["enodeb_host"]) |
| 119 | enodeb_address = main.params["BESS_UPF"]["enb_address"] |
| 120 | enodeb_interface = enodeb_host.interfaces[0]["name"] |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 121 | pdn_host = up4.pdn_host |
| 122 | pdn_interface = up4.pdn_interface |
| 123 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 124 | main.step("Program and Verify PDRs and FARs for UEs via UP4") |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 125 | up4.attachUes() |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 126 | up4.verifyUp4Flow(onos_cli) |
| 127 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 128 | run.checkFlows( |
| 129 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 130 | minFlowCount=initial_flow_count + ( |
| 131 | len(up4.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 132 | ) |
| 133 | |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 134 | # ------------------- UPSTREAM ------------------- |
| 135 | # ------- eNB -> fabric -> BESS (encapped) |
| 136 | main.step("Test upstream eNB -> fabric -> BESS") |
| 137 | # Start filter before sending packets, BESS should receive GTP encapped |
| 138 | # packets |
| 139 | pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % ( |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 140 | GPDU_PORT, GPDU_PORT, enodeb_address, bess_s1u_address) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 141 | main.log.info("Start listening on %s intf %s" % ( |
| 142 | bess_host.name, bess_interface["name"])) |
| 143 | main.log.debug("BPF Filter BESS Upstream: \n %s" % pkt_filter_upstream) |
| 144 | bess_host.startFilter(ifaceName=bess_interface["name"], |
| 145 | sniffCount=1, |
| 146 | pktFilter=pkt_filter_upstream) |
| 147 | # Send GTP Packet |
| 148 | UP4.buildGtpPacket(enodeb_host, |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 149 | src_ip_outer=enodeb_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 150 | dst_ip_outer=bess_s1u_address, |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 151 | src_ip_inner=bess_ue_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 152 | dst_ip_inner=pdn_interface["ips"][0], |
| 153 | src_udp_inner=UE_PORT, |
| 154 | dst_udp_inner=PDN_PORT, |
| 155 | teid=BESS_TEID) |
| 156 | enodeb_host.sendPacket() |
| 157 | |
| 158 | packets = UP4.checkFilterAndGetPackets(bess_host) |
| 159 | # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5) |
| 160 | n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ") |
| 161 | tot_packets = packets.count('Ether') |
| 162 | utilities.assert_equal(expect=True, |
| 163 | actual=n_packets == 1 and tot_packets == 1, |
| 164 | onpass="BESS correctly received 1 GTP encapped packet", |
| 165 | onfail="ERROR: BESS received %d GTP encapped packets and filter captured %d packets" % ( |
| 166 | n_packets, tot_packets)) |
| 167 | |
| 168 | # ------- BESS -> fabric -> PDN (not-encapped) |
| 169 | main.step("Test upstream BESS -> fabric -> PDN") |
| 170 | # Start filter before sending packets, PDN should receive non-GTP packet |
| 171 | pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % ( |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 172 | UE_PORT, PDN_PORT, bess_ue_address, pdn_interface["ips"][0]) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 173 | main.log.info("Start listening on %s intf %s" % ( |
| 174 | pdn_host.name, pdn_interface["name"])) |
| 175 | main.log.debug("BPF Filter PDN Upstream: \n %s" % pkt_filter_upstream) |
| 176 | pdn_host.startFilter(ifaceName=pdn_interface["name"], |
| 177 | sniffCount=1, |
| 178 | pktFilter=pkt_filter_upstream) |
| 179 | # Send UDP Packet |
| 180 | UP4.buildUdpPacket(bess_host, |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 181 | src_ip=bess_ue_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 182 | dst_ip=pdn_interface["ips"][0], |
| 183 | src_udp=UE_PORT, |
| 184 | dst_udp=PDN_PORT) |
| 185 | bess_host.sendPacket() |
| 186 | |
| 187 | packets = UP4.checkFilterAndGetPackets(pdn_host) |
| 188 | tot_packets = packets.count('Ether') |
| 189 | utilities.assert_equal(expect=True, |
| 190 | actual=tot_packets == 1, |
| 191 | onpass="PDN correctly received 1 packet", |
| 192 | onfail="ERROR: PDN received %d packets" % ( |
| 193 | tot_packets)) |
| 194 | # ------------------------------------------------ |
| 195 | |
| 196 | # ------------------ DOWNSTREAM ------------------ |
| 197 | # ------- PDN -> fabric -> BESS (not-encapped) |
| 198 | main.step("Test downstream PDN -> fabric -> BESS") |
| 199 | pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % ( |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 200 | PDN_PORT, UE_PORT, pdn_interface["ips"][0], bess_ue_address) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 201 | main.log.info("Start listening on %s intf %s" % ( |
| 202 | bess_host.name, bess_interface["name"])) |
| 203 | main.log.debug( |
| 204 | "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream) |
| 205 | bess_host.startFilter(ifaceName=bess_interface["name"], |
| 206 | sniffCount=1, |
| 207 | pktFilter=pkt_filter_downstream) |
| 208 | UP4.buildUdpPacket(pdn_host, |
| 209 | dst_eth=up4.router_mac, |
| 210 | src_ip=pdn_interface["ips"][0], |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 211 | dst_ip=bess_ue_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 212 | src_udp=PDN_PORT, |
| 213 | dst_udp=UE_PORT) |
| 214 | pdn_host.sendPacket() |
| 215 | |
| 216 | packets = UP4.checkFilterAndGetPackets(bess_host) |
| 217 | |
| 218 | tot_packets = packets.count('Ether') |
| 219 | utilities.assert_equal(expect=True, |
| 220 | actual=tot_packets == 1, |
| 221 | onpass="BESS correctly received 1 packet", |
| 222 | onfail="ERROR: BESS received %d packets" % ( |
| 223 | tot_packets)) |
| 224 | |
| 225 | # ------- BESS -> fabric -> eNB (encapped) |
| 226 | main.step("Test downstream BESS -> fabric -> eNB") |
| 227 | pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % ( |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 228 | GPDU_PORT, GPDU_PORT, bess_s1u_address, enodeb_address) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 229 | main.log.info("Start listening on %s intf %s" % ( |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 230 | enodeb_host.name, enodeb_interface)) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 231 | main.log.debug( |
| 232 | "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 233 | enodeb_host.startFilter(ifaceName=enodeb_interface, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 234 | sniffCount=1, |
| 235 | pktFilter=pkt_filter_downstream) |
| 236 | # Build GTP packet from BESS host |
| 237 | UP4.buildGtpPacket(bess_host, |
| 238 | src_ip_outer=bess_s1u_address, |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 239 | dst_ip_outer=enodeb_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 240 | src_ip_inner=pdn_interface["ips"][0], |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 241 | dst_ip_inner=bess_ue_address, |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 242 | src_udp_inner=PDN_PORT, |
| 243 | dst_udp_inner=UE_PORT, |
| 244 | teid=BESS_TEID) |
| 245 | bess_host.sendPacket() |
| 246 | |
| 247 | packets = UP4.checkFilterAndGetPackets(enodeb_host) |
| 248 | |
| 249 | # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5) |
| 250 | n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ") |
| 251 | tot_packets = packets.count('Ether') |
| 252 | utilities.assert_equal(expect=True, |
| 253 | actual=n_packets == 1 and tot_packets == 1, |
| 254 | onpass="eNodeB correctly received 1 GTP encapped packet", |
| 255 | onfail="ERROR: eNodeb received %d GTP encapped packets and filter captured %d packets" % ( |
| 256 | n_packets, tot_packets)) |
| 257 | # ------------------------------------------------ |
| 258 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 259 | main.step("Remove and Verify PDRs and FARs for UEs via UP4") |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 260 | up4.detachUes() |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 261 | up4.verifyNoUesFlow(onos_cli) |
| 262 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 263 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 264 | |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 265 | main.step("Stop scapy and p4rt client") |
| 266 | up4.teardown() |
| 267 | bess_host.stopScapy() |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 268 | |
| 269 | run.saveOnosDiagsIfFailure(main) |
Daniele Moro | bf53dec | 2021-09-13 18:11:56 +0200 | [diff] [blame] | 270 | run.cleanup(main) |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 271 | |
| 272 | def CASE3(self, main): |
| 273 | main.case("Verify UP4 from different ONOS instances") |
| 274 | """ |
| 275 | Program PDRs and FARs via UP4 on first ONOS instance |
| 276 | Repeat for all ONOS Instances: |
| 277 | Verify PDRs and FARs via P4RT |
| 278 | Disconnect P4RT client |
| 279 | Verify and delete PDRs and FARs via UP4 on the third ONOS instance |
| 280 | Repeat for all ONOS Instance: |
| 281 | Verify removed PDRs and FARs via P4RT |
| 282 | Disconnect P4RT client |
| 283 | """ |
| 284 | try: |
Daniele Moro | fbfdfbd | 2021-10-18 22:47:51 +0200 | [diff] [blame] | 285 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 286 | N_FLOWS_PER_UE |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 287 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 288 | Testcaselib as run |
| 289 | except ImportError as e: |
| 290 | main.log.error("Import not found. Exiting the test") |
| 291 | main.log.error(e) |
| 292 | main.cleanAndExit() |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 293 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 294 | |
| 295 | run.initTest(main) |
| 296 | main.log.info(main.Cluster.numCtrls) |
| 297 | main.Cluster.setRunningNode(3) |
| 298 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 299 | |
| 300 | onos_cli_0 = main.Cluster.active(0).CLI |
| 301 | onos_cli_1 = main.Cluster.active(1).CLI |
| 302 | onos_cli_2 = main.Cluster.active(2).CLI |
| 303 | up4_0 = UP4() |
| 304 | up4_1 = UP4() |
| 305 | up4_2 = UP4() |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 306 | initial_flow_count = onos_cli_0.checkFlowCount() |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 307 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 308 | main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0") |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 309 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 310 | up4_0.attachUes() |
| 311 | up4_0.verifyUp4Flow(onos_cli_0) |
| 312 | up4_0.teardown() |
| 313 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 314 | run.checkFlows( |
| 315 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 316 | minFlowCount=initial_flow_count + ( |
| 317 | len(up4_0.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 318 | ) |
| 319 | |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 320 | main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 1") |
| 321 | up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True) |
| 322 | utilities.assert_equal( |
| 323 | expect=True, |
| 324 | actual=up4_1.verifyUesFlowNumberP4rt(), |
| 325 | onpass="Correct number of PDRs and FARs", |
| 326 | onfail="Wrong number of PDRs and FARs" |
| 327 | ) |
| 328 | up4_1.teardown() |
| 329 | |
| 330 | main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2") |
| 331 | up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True) |
| 332 | utilities.assert_equal( |
| 333 | expect=True, |
| 334 | actual=up4_2.verifyUesFlowNumberP4rt(), |
| 335 | onpass="Correct number of PDRs and FARs", |
| 336 | onfail="Wrong number of PDRs and FARs" |
| 337 | ) |
| 338 | |
| 339 | main.step("Verify all ONOS instances have the same number of flows") |
| 340 | onos_0_flow_count = onos_cli_0.checkFlowCount() |
| 341 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 342 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 343 | utilities.assert_equal( |
| 344 | expect=True, |
| 345 | actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count, |
| 346 | onpass="All ONOS instances have the same number of flows", |
| 347 | onfail="ONOS instances have different number of flows: (%d, %d, %d)" % ( |
| 348 | onos_0_flow_count, onos_1_flow_count, onos_2_flow_count) |
| 349 | ) |
| 350 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 351 | main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2") |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 352 | up4_2.detachUes() |
| 353 | up4_2.verifyNoUesFlow(onos_cli_2) |
| 354 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 355 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 356 | |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 357 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2") |
| 358 | utilities.assert_equal( |
| 359 | expect=True, |
| 360 | actual=up4_2.verifyNoUesFlowNumberP4rt(), |
| 361 | onpass="No PDRs and FARs", |
| 362 | onfail="Stale PDRs and FARs" |
| 363 | ) |
| 364 | up4_2.teardown() |
| 365 | |
| 366 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 1") |
| 367 | up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True) |
| 368 | utilities.assert_equal( |
| 369 | expect=True, |
| 370 | actual=up4_1.verifyNoUesFlowNumberP4rt(), |
| 371 | onpass="No PDRs and FARs", |
| 372 | onfail="Stale PDRs and FARs" |
| 373 | ) |
| 374 | up4_1.teardown() |
| 375 | |
| 376 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0") |
| 377 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 378 | utilities.assert_equal( |
| 379 | expect=True, |
| 380 | actual=up4_0.verifyNoUesFlowNumberP4rt(), |
| 381 | onpass="No PDRs and FARs", |
| 382 | onfail="Stale PDRs and FARs" |
| 383 | ) |
| 384 | up4_0.teardown() |
| 385 | |
| 386 | main.step("Verify all ONOS instances have the same number of flows") |
| 387 | onos_0_flow_count = onos_cli_0.checkFlowCount() |
| 388 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 389 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 390 | utilities.assert_equal( |
| 391 | expect=True, |
| 392 | actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count, |
| 393 | onpass="All ONOS instances have the same number of flows", |
| 394 | onfail="ONOS instances have different number of flows: (%d, %d, %d)" % ( |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 395 | onos_0_flow_count, onos_1_flow_count, onos_2_flow_count) |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 396 | ) |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 397 | |
| 398 | run.saveOnosDiagsIfFailure(main) |
Daniele Moro | 954e228 | 2021-09-22 17:32:03 +0200 | [diff] [blame] | 399 | run.cleanup(main) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 400 | |
| 401 | def CASE4(self, main): |
| 402 | main.case("Verify UP4 wipe-out after ONOS reboot") |
| 403 | """ |
| 404 | Program PDRs/FARs |
| 405 | Kill ONOS POD |
| 406 | Verify PDRs/FARs from other ONOS instances |
| 407 | Remove PDRs/FARs |
| 408 | Wait/Verify ONOS is back |
| 409 | Verify no PDRs/FARs from rebooted instance |
| 410 | Re-program PDRs/FARs from rebooted instance |
| 411 | Verify all instances have same number of flows |
| 412 | Remove PDRs/FARs (cleanup) |
| 413 | """ |
| 414 | try: |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 415 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 416 | N_FLOWS_PER_UE |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 417 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 418 | Testcaselib as run |
Daniele Moro | 5d88e2a | 2021-11-12 17:47:55 +0100 | [diff] [blame] | 419 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import \ |
| 420 | SRStagingTest |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 421 | except ImportError as e: |
| 422 | main.log.error("Import not found. Exiting the test") |
| 423 | main.log.error(e) |
| 424 | main.cleanAndExit() |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 425 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 426 | |
| 427 | run.initTest(main) |
| 428 | main.log.info(main.Cluster.numCtrls) |
| 429 | main.Cluster.setRunningNode(3) |
| 430 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 431 | |
| 432 | onos_cli_0 = main.Cluster.active(0).CLI |
| 433 | onos_cli_1 = main.Cluster.active(1).CLI |
| 434 | onos_cli_2 = main.Cluster.active(2).CLI |
Daniele Moro | 5d88e2a | 2021-11-12 17:47:55 +0100 | [diff] [blame] | 435 | ctrl_0 = main.Cluster.active(0) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 436 | |
| 437 | up4_0 = UP4() |
| 438 | up4_1 = UP4() |
| 439 | up4_2 = UP4() |
| 440 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 441 | initial_flow_count = onos_cli_0.checkFlowCount() |
| 442 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 443 | main.step("Program and Verify PDRs and FARs via UP4 on ONOS 0") |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 444 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 445 | up4_0.attachUes() |
| 446 | up4_0.verifyUp4Flow(onos_cli_0) |
| 447 | up4_0.teardown() |
| 448 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 449 | run.checkFlows( |
| 450 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 451 | minFlowCount=initial_flow_count + ( |
| 452 | len(up4_0.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 453 | ) |
| 454 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 455 | onosPod = main.params["UP4_delete_pod"] |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 456 | |
| 457 | # Save ONOS diags of the POD we are killing otherwise we lose ONOS logs |
| 458 | main.ONOSbench.onosDiagnosticsK8s( |
| 459 | [onosPod], |
| 460 | main.logdir, |
| 461 | "-CASE%d-%s_BeforeKill" % (main.CurrentTestCaseNumber, onosPod) |
| 462 | ) |
| 463 | |
Daniele Moro | 5d88e2a | 2021-11-12 17:47:55 +0100 | [diff] [blame] | 464 | onosK8sNode = SRStagingTest.onosDown(main, ctrl_0, preventRestart=True) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 465 | |
| 466 | main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2") |
| 467 | up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True) |
| 468 | utilities.assert_equal( |
| 469 | expect=True, |
| 470 | actual=up4_2.verifyUesFlowNumberP4rt(), |
| 471 | onpass="Correct number of PDRs and FARs", |
| 472 | onfail="Wrong number of PDRs and FARs" |
| 473 | ) |
| 474 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 475 | main.step("Remove and Verify PDRs and FARs via UP4 on ONOS 2") |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 476 | up4_2.detachUes() |
| 477 | up4_2.verifyNoUesFlow(onos_cli_2) |
| 478 | |
| 479 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2") |
| 480 | utilities.assert_equal( |
| 481 | expect=True, |
| 482 | actual=up4_2.verifyNoUesFlowNumberP4rt(), |
| 483 | onpass="No PDRs and FARs", |
| 484 | onfail="Stale PDRs and FARs" |
| 485 | ) |
| 486 | up4_2.teardown() |
| 487 | |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 488 | main.step( |
| 489 | "Verify all active ONOS instances have the same number of flows") |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 490 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 491 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 492 | utilities.assert_equal( |
| 493 | expect=True, |
| 494 | actual=onos_1_flow_count == onos_2_flow_count, |
| 495 | onpass="All ONOS instances have the same number of flows", |
| 496 | onfail="ONOS instances have different number of flows: (%d, %d)" % ( |
| 497 | onos_1_flow_count, onos_2_flow_count) |
| 498 | ) |
| 499 | |
Daniele Moro | 5d88e2a | 2021-11-12 17:47:55 +0100 | [diff] [blame] | 500 | SRStagingTest.onosUp(main, onosK8sNode, ctrl_0) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 501 | |
| 502 | main.step("Verify ONOS cluster is in good shape") |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 503 | onosNodesStatus = utilities.retry( |
| 504 | f=main.Cluster.nodesCheck, |
| 505 | retValue=False, |
| 506 | sleep=5, |
| 507 | attempts=10 |
| 508 | ) |
| 509 | utilities.assert_equal( |
| 510 | expect=True, |
| 511 | actual=onosNodesStatus, |
| 512 | onpass="ONOS nodes status correct", |
| 513 | onfail="Wrong ONOS nodes status" |
| 514 | ) |
| 515 | |
| 516 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0") |
| 517 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 518 | utilities.assert_equal( |
| 519 | expect=True, |
| 520 | actual=up4_0.verifyNoUesFlowNumberP4rt(), |
| 521 | onpass="No PDRs and FARs", |
| 522 | onfail="Stale PDRs and FARs" |
| 523 | ) |
| 524 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 525 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 526 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 527 | main.step("Re-program PDRs and FARs via UP4 on ONOS 0 after restart") |
| 528 | up4_0.attachUes() |
| 529 | up4_0.verifyUp4Flow(onos_cli_0) |
| 530 | up4_0.teardown() |
| 531 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 532 | run.checkFlows( |
| 533 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 534 | minFlowCount=initial_flow_count + ( |
| 535 | len(up4_0.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 536 | ) |
| 537 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 538 | main.step("Verify PDRs and FARs via UP4 on ONOS 1") |
| 539 | up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True) |
| 540 | up4_1.verifyUp4Flow(onos_cli_1) |
| 541 | |
| 542 | main.step("Verify all ONOS instances have the same number of flows") |
| 543 | onos_0_flow_count = onos_cli_0.checkFlowCount() |
| 544 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 545 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 546 | utilities.assert_equal( |
| 547 | expect=True, |
| 548 | actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count, |
| 549 | onpass="All ONOS instances have the same number of flows", |
| 550 | onfail="ONOS instances have different number of flows: (%d, %d, %d)" % ( |
| 551 | onos_0_flow_count, onos_1_flow_count, onos_2_flow_count) |
| 552 | ) |
| 553 | |
| 554 | main.step("Cleanup PDRs and FARs via UP4 on ONOS 1") |
| 555 | up4_1.detachUes() |
Daniele Moro | 6dfbfef | 2021-09-28 22:44:19 +0200 | [diff] [blame] | 556 | up4_1.verifyNoUesFlow(onos_cli_1) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 557 | up4_1.teardown() |
| 558 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 559 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 560 | |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 561 | run.saveOnosDiagsIfFailure(main) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 562 | run.cleanup(main) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 563 | |
| 564 | def CASE5(self, main): |
| 565 | main.case("UP4 Data Plane Failure Test") |
| 566 | """ |
| 567 | Program PDRs/FARs |
| 568 | Kill one switch |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 569 | Set label on switch K8S node to prevent K8S to redeploy stratum |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 570 | Verify that traffic from eNodebs that are connected to that switch fails |
| 571 | Verify that traffic from other eNodeBs is being forwarded |
| 572 | Wait for the switch to be up again |
| 573 | Check flows |
| 574 | Remove PDRs/FARs (cleanup) |
| 575 | """ |
| 576 | try: |
| 577 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 578 | N_FLOWS_PER_UE |
| 579 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 580 | Testcaselib as run |
| 581 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import \ |
| 582 | SRStagingTest |
| 583 | import time |
| 584 | import itertools |
| 585 | except ImportError as e: |
| 586 | main.log.error("Import not found. Exiting the test") |
| 587 | main.log.error(e) |
| 588 | main.cleanAndExit() |
| 589 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 590 | switch_to_kill = main.params["UP4"]["UP4_dataplane_fail"]["switch_to_kill"] |
| 591 | k8s_switch_node = main.params["UP4"]["UP4_dataplane_fail"]["k8s_switch_node"] |
| 592 | k8s_label = main.params["UP4"]["UP4_dataplane_fail"]["k8s_label"] |
| 593 | k8s_label_value_test = main.params["UP4"]["UP4_dataplane_fail"]["k8s_label_value_test"] |
| 594 | k8s_label_value_normal = main.params["UP4"]["UP4_dataplane_fail"]["k8s_label_value_normal"] |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 595 | |
| 596 | run.initTest(main) |
| 597 | main.log.info(main.Cluster.numCtrls) |
| 598 | main.Cluster.setRunningNode(3) |
| 599 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 600 | |
| 601 | onos_cli = main.Cluster.active(0).CLI |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 602 | kubectl = main.Cluster.active(0).Bench |
| 603 | kubeconfig = main.Cluster.active(0).k8s.kubeConfig |
| 604 | namespace = main.params['kubernetes']['namespace'] |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 605 | |
| 606 | up4 = UP4() |
| 607 | |
| 608 | initial_flow_count = onos_cli.checkFlowCount() |
| 609 | |
| 610 | main.step("Program and Verify PDRs and FARs via UP4") |
| 611 | up4.setup(main.Cluster.active(0).p4rtUp4) |
| 612 | up4.attachUes() |
| 613 | up4.verifyUp4Flow(onos_cli) |
| 614 | |
| 615 | run.checkFlows( |
| 616 | main, |
| 617 | minFlowCount=initial_flow_count+(len(up4.emulated_ues)*4*n_switches) |
| 618 | ) |
| 619 | |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 620 | main.step("Set label to switch k8s node and kill switch") |
| 621 | # K8s node name correspond to the switch name in lowercase |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 622 | utilities.assert_equal( |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 623 | expect=main.TRUE, |
| 624 | actual=kubectl.kubectlSetLabel( |
| 625 | nodeName=k8s_switch_node, |
| 626 | label=k8s_label, |
| 627 | value=k8s_label_value_test, |
| 628 | kubeconfig=kubeconfig, |
| 629 | namespace=namespace, |
| 630 | ), |
| 631 | onpass="Label has been set correctly on node %s" % k8s_switch_node, |
| 632 | onfail="Label has not been set on node %s" % k8s_switch_node |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 633 | ) |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 634 | try: |
| 635 | def checkNumberStratumPods(n_value): |
| 636 | pods = kubectl.kubectlGetPodNames( |
| 637 | kubeconfig=kubeconfig, |
| 638 | namespace=namespace, |
| 639 | name="stratum" |
| 640 | ) |
| 641 | main.log.info("PODS: " + str(pods)) |
| 642 | return n_value == len(pods) if pods is not main.FALSE else False |
| 643 | # Execute the following in try/except/finally to be sure to restore the |
| 644 | # k8s label even in case of unhandled exception. |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 645 | |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 646 | # Wait for stratum pod to be removed from the switch |
| 647 | removed = utilities.retry(checkNumberStratumPods, |
| 648 | False, |
| 649 | args=[n_switches-1], |
| 650 | attempts=50 |
| 651 | ) |
| 652 | main.log.info("Stratum has been removed from the switch? %s" % removed) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 653 | |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 654 | switch_component = getattr(main, switch_to_kill) |
| 655 | switch_component.handle.sendline("sudo reboot") |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 656 | |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 657 | sleepTime = 20 |
| 658 | main.log.info("Sleeping %s seconds for Fabric to react" % sleepTime) |
| 659 | time.sleep(sleepTime) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 660 | |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 661 | available = utilities.retry(SRStagingTest.switchIsConnected, |
| 662 | True, |
| 663 | args=[switch_component], |
| 664 | attempts=300, |
| 665 | getRetryingTime=True) |
| 666 | main.log.info("Switch %s is available in ONOS? %s" % ( |
| 667 | switch_to_kill, available)) |
| 668 | utilities.assert_equal( |
| 669 | expect=True, |
| 670 | actual=not available and removed, |
| 671 | onpass="Switch was rebooted (ONL reboot) successfully and stratum" + |
| 672 | " removed from switch k8s node", |
| 673 | onfail="Switch was not rebooted (ONL reboot) successfully or stratum " + |
| 674 | "not removed from switch k8s node" |
| 675 | ) |
| 676 | |
| 677 | enodebs_fail = main.params["UP4"]["UP4_dataplane_fail"]["enodebs_fail"].split(",") |
| 678 | enodebs_no_fail = list(set(up4.enodebs.keys()) - set(enodebs_fail)) |
| 679 | |
| 680 | # ------- Test Upstream traffic (enbs->pdn) |
| 681 | main.step("Test upstream traffic FAIL") |
| 682 | up4.testUpstreamTraffic(enb_names=enodebs_fail, shouldFail=True) |
| 683 | main.step("Test upstream traffic NO FAIL") |
| 684 | up4.testUpstreamTraffic(enb_names=enodebs_no_fail, shouldFail=False) |
| 685 | |
| 686 | # ------- Test Downstream traffic (pdn->enbs) |
| 687 | main.step("Test downstream traffic FAIL") |
| 688 | up4.testDownstreamTraffic(enb_names=enodebs_fail, shouldFail=True) |
| 689 | main.step("Test downstream traffic NO FAIL") |
| 690 | up4.testDownstreamTraffic(enb_names=enodebs_no_fail, shouldFail=False) |
| 691 | except Exception as e: |
| 692 | main.log.error("Unhandled exception!") |
| 693 | main.log.error(e) |
| 694 | finally: |
| 695 | utilities.assert_equal( |
| 696 | expect=main.TRUE, |
| 697 | actual=kubectl.kubectlSetLabel( |
| 698 | nodeName=k8s_switch_node, |
| 699 | label=k8s_label, |
| 700 | value=k8s_label_value_normal, |
| 701 | kubeconfig=kubeconfig, |
| 702 | namespace=namespace, |
| 703 | ), |
| 704 | onpass="Label has been set correctly on node %s" % k8s_switch_node, |
| 705 | onfail="Label has not been set on node %s" % k8s_switch_node |
| 706 | ) |
| 707 | # Reconnect to the switch |
| 708 | connect = utilities.retry(switch_component.connect, |
| 709 | main.FALSE, |
| 710 | attempts=30, |
| 711 | getRetryingTime=True) |
| 712 | main.log.info("Connected to the switch %s? %s" % ( |
| 713 | switch_to_kill, connect)) |
| 714 | |
| 715 | # Wait for stratum pod to be re-deployed on the switch |
| 716 | deployed = utilities.retry(checkNumberStratumPods, |
| 717 | False, |
| 718 | args=[n_switches], |
| 719 | attempts=50 |
| 720 | ) |
| 721 | main.log.info("Stratum has been redeployed on the switch? %s" % deployed) |
| 722 | |
| 723 | # Wait switch to be back in ONOS |
| 724 | available = utilities.retry(SRStagingTest.switchIsConnected, |
| 725 | False, |
| 726 | args=[switch_component], |
| 727 | attempts=300, |
| 728 | getRetryingTime=True) |
| 729 | main.log.info("Switch %s is available in ONOS? %s" % ( |
| 730 | switch_to_kill, available)) |
| 731 | utilities.assert_equal( |
| 732 | expect=True, |
| 733 | actual=available and connect == main.TRUE and deployed, |
| 734 | onpass="Switch is back available in ONOS and stratum has been redeployed", |
| 735 | onfail="Switch is not available in ONOS, may influence subsequent tests!" |
| 736 | ) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame] | 737 | |
| 738 | main.step("Test upstream traffic AFTER switch reboot") |
| 739 | up4.testUpstreamTraffic() |
| 740 | |
| 741 | main.step("Cleanup PDRs and FARs via UP4") |
| 742 | up4.detachUes() |
| 743 | up4.verifyNoUesFlow(onos_cli) |
| 744 | up4.teardown() |
| 745 | |
| 746 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 747 | |
| 748 | # Teardown |
| 749 | run.cleanup(main) |
Daniele Moro | 80271cb | 2021-11-11 20:08:51 +0100 | [diff] [blame] | 750 | |