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 |
| 419 | except ImportError as e: |
| 420 | main.log.error("Import not found. Exiting the test") |
| 421 | main.log.error(e) |
| 422 | main.cleanAndExit() |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 423 | n_switches = int(main.params["TOPO"]["switchNum"]) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 424 | |
| 425 | run.initTest(main) |
| 426 | main.log.info(main.Cluster.numCtrls) |
| 427 | main.Cluster.setRunningNode(3) |
| 428 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 429 | |
| 430 | onos_cli_0 = main.Cluster.active(0).CLI |
| 431 | onos_cli_1 = main.Cluster.active(1).CLI |
| 432 | onos_cli_2 = main.Cluster.active(2).CLI |
| 433 | kubectl_0 = main.Cluster.active(0).k8s |
| 434 | |
| 435 | up4_0 = UP4() |
| 436 | up4_1 = UP4() |
| 437 | up4_2 = UP4() |
| 438 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 439 | initial_flow_count = onos_cli_0.checkFlowCount() |
| 440 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 441 | 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] | 442 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 443 | up4_0.attachUes() |
| 444 | up4_0.verifyUp4Flow(onos_cli_0) |
| 445 | up4_0.teardown() |
| 446 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 447 | run.checkFlows( |
| 448 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 449 | minFlowCount=initial_flow_count + ( |
| 450 | len(up4_0.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 451 | ) |
| 452 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 453 | onosPod = main.params["UP4_delete_pod"] |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 454 | |
| 455 | # Save ONOS diags of the POD we are killing otherwise we lose ONOS logs |
| 456 | main.ONOSbench.onosDiagnosticsK8s( |
| 457 | [onosPod], |
| 458 | main.logdir, |
| 459 | "-CASE%d-%s_BeforeKill" % (main.CurrentTestCaseNumber, onosPod) |
| 460 | ) |
| 461 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 462 | # Exit from previous port forwarding, because we need to restore |
| 463 | # port-forwarding after ONOS reboot. |
| 464 | kubectl_0.clearBuffer() |
| 465 | kubectl_0.exitFromProcess() |
| 466 | main.step("Kill " + onosPod) |
| 467 | utilities.assert_equal( |
| 468 | expect=main.TRUE, |
| 469 | actual=kubectl_0.kubectlDeletePod( |
| 470 | podName=onosPod, |
| 471 | kubeconfig=kubectl_0.kubeConfig, |
| 472 | namespace=main.params['kubernetes']['namespace'] |
| 473 | ), |
| 474 | onpass="%s pod correctly deleted" % onosPod, |
| 475 | onfail="%s pod has not been deleted" % onosPod |
| 476 | ) |
| 477 | |
| 478 | main.step("Verify PDRs and FARs number via UP4 P4RT on ONOS 2") |
| 479 | up4_2.setup(main.Cluster.active(2).p4rtUp4, no_host=True) |
| 480 | utilities.assert_equal( |
| 481 | expect=True, |
| 482 | actual=up4_2.verifyUesFlowNumberP4rt(), |
| 483 | onpass="Correct number of PDRs and FARs", |
| 484 | onfail="Wrong number of PDRs and FARs" |
| 485 | ) |
| 486 | |
Daniele Moro | 93feb02 | 2021-10-04 16:26:23 +0200 | [diff] [blame] | 487 | 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] | 488 | up4_2.detachUes() |
| 489 | up4_2.verifyNoUesFlow(onos_cli_2) |
| 490 | |
| 491 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 2") |
| 492 | utilities.assert_equal( |
| 493 | expect=True, |
| 494 | actual=up4_2.verifyNoUesFlowNumberP4rt(), |
| 495 | onpass="No PDRs and FARs", |
| 496 | onfail="Stale PDRs and FARs" |
| 497 | ) |
| 498 | up4_2.teardown() |
| 499 | |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 500 | main.step( |
| 501 | "Verify all active ONOS instances have the same number of flows") |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 502 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 503 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 504 | utilities.assert_equal( |
| 505 | expect=True, |
| 506 | actual=onos_1_flow_count == onos_2_flow_count, |
| 507 | onpass="All ONOS instances have the same number of flows", |
| 508 | onfail="ONOS instances have different number of flows: (%d, %d)" % ( |
| 509 | onos_1_flow_count, onos_2_flow_count) |
| 510 | ) |
| 511 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 512 | main.step("Verify ONOS 0 has restarted correctly") |
| 513 | onosStarted = utilities.retry( |
| 514 | f=kubectl_0.kubectlCheckPodReady, |
| 515 | retValue=main.FALSE, |
| 516 | kwargs={ |
| 517 | "podName": onosPod, |
| 518 | "kubeconfig": kubectl_0.kubeConfig, |
| 519 | "namespace": main.params['kubernetes']['namespace'] |
| 520 | }, |
| 521 | sleep=10, |
| 522 | attempts=10 |
| 523 | ) |
| 524 | utilities.assert_equal( |
| 525 | expect=main.TRUE, |
| 526 | actual=onosStarted, |
| 527 | onpass="%s pod correctly restarted" % onosPod, |
| 528 | onfail="%s pod haven't restarted correctly" % onosPod |
| 529 | ) |
| 530 | |
| 531 | main.step("Verify ONOS cluster is in good shape") |
| 532 | # A bug in kubectl port forwarding doesn't terminate port-forwarding |
| 533 | # when the container changed, nor reconnect correctly to the restarted |
| 534 | # container. |
| 535 | # See: https://github.com/kubernetes/kubectl/issues/686 |
| 536 | # Re-build the port-list for port forwarding |
| 537 | portList = "%s:%s " % (main.Cluster.active(0).CLI.karafPort, 8101) |
| 538 | portList += "%s:%s " % (main.Cluster.active(0).REST.port, 8181) |
| 539 | portList += "%s:%s " % (main.Cluster.active(0).p4rtUp4.p4rtPort, |
| 540 | main.ONOScell.up4Port) |
| 541 | kubectl_0.clearBuffer() |
| 542 | kubectl_0.kubectlPortForward( |
| 543 | onosPod, |
| 544 | portList, |
| 545 | kubectl_0.kubeConfig, |
| 546 | main.params['kubernetes']['namespace'] |
| 547 | ) |
| 548 | onos_cli_0.clearBuffer() # Trigger ONOS CLI reconnection |
| 549 | onosNodesStatus = utilities.retry( |
| 550 | f=main.Cluster.nodesCheck, |
| 551 | retValue=False, |
| 552 | sleep=5, |
| 553 | attempts=10 |
| 554 | ) |
| 555 | utilities.assert_equal( |
| 556 | expect=True, |
| 557 | actual=onosNodesStatus, |
| 558 | onpass="ONOS nodes status correct", |
| 559 | onfail="Wrong ONOS nodes status" |
| 560 | ) |
| 561 | |
| 562 | main.step("Verify no PDRs and FARs via UP4 P4RT on ONOS 0") |
| 563 | up4_0.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
| 564 | utilities.assert_equal( |
| 565 | expect=True, |
| 566 | actual=up4_0.verifyNoUesFlowNumberP4rt(), |
| 567 | onpass="No PDRs and FARs", |
| 568 | onfail="Stale PDRs and FARs" |
| 569 | ) |
| 570 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 571 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 572 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 573 | main.step("Re-program PDRs and FARs via UP4 on ONOS 0 after restart") |
| 574 | up4_0.attachUes() |
| 575 | up4_0.verifyUp4Flow(onos_cli_0) |
| 576 | up4_0.teardown() |
| 577 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 578 | run.checkFlows( |
| 579 | main, |
Daniele Moro | c6811a8 | 2021-10-12 11:29:41 +0200 | [diff] [blame] | 580 | minFlowCount=initial_flow_count + ( |
| 581 | len(up4_0.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 582 | ) |
| 583 | |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 584 | main.step("Verify PDRs and FARs via UP4 on ONOS 1") |
| 585 | up4_1.setup(main.Cluster.active(1).p4rtUp4, no_host=True) |
| 586 | up4_1.verifyUp4Flow(onos_cli_1) |
| 587 | |
| 588 | main.step("Verify all ONOS instances have the same number of flows") |
| 589 | onos_0_flow_count = onos_cli_0.checkFlowCount() |
| 590 | onos_1_flow_count = onos_cli_1.checkFlowCount() |
| 591 | onos_2_flow_count = onos_cli_2.checkFlowCount() |
| 592 | utilities.assert_equal( |
| 593 | expect=True, |
| 594 | actual=onos_0_flow_count == onos_1_flow_count == onos_2_flow_count, |
| 595 | onpass="All ONOS instances have the same number of flows", |
| 596 | onfail="ONOS instances have different number of flows: (%d, %d, %d)" % ( |
| 597 | onos_0_flow_count, onos_1_flow_count, onos_2_flow_count) |
| 598 | ) |
| 599 | |
| 600 | main.step("Cleanup PDRs and FARs via UP4 on ONOS 1") |
| 601 | up4_1.detachUes() |
Daniele Moro | 6dfbfef | 2021-09-28 22:44:19 +0200 | [diff] [blame] | 602 | up4_1.verifyNoUesFlow(onos_cli_1) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 603 | up4_1.teardown() |
| 604 | |
Daniele Moro | 9ba5cf0 | 2021-10-08 18:00:56 +0200 | [diff] [blame] | 605 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 606 | |
Daniele Moro | c99bf82 | 2021-10-11 23:21:15 +0200 | [diff] [blame] | 607 | run.saveOnosDiagsIfFailure(main) |
Daniele Moro | e1d05eb | 2021-09-23 19:52:30 +0200 | [diff] [blame] | 608 | run.cleanup(main) |
Daniele Moro | 522023c | 2021-10-15 17:30:33 +0200 | [diff] [blame^] | 609 | |
| 610 | def CASE5(self, main): |
| 611 | main.case("UP4 Data Plane Failure Test") |
| 612 | """ |
| 613 | Program PDRs/FARs |
| 614 | Kill one switch |
| 615 | Verify that traffic from eNodebs that are connected to that switch fails |
| 616 | Verify that traffic from other eNodeBs is being forwarded |
| 617 | Wait for the switch to be up again |
| 618 | Check flows |
| 619 | Remove PDRs/FARs (cleanup) |
| 620 | """ |
| 621 | try: |
| 622 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, \ |
| 623 | N_FLOWS_PER_UE |
| 624 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 625 | Testcaselib as run |
| 626 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import \ |
| 627 | SRStagingTest |
| 628 | import time |
| 629 | import itertools |
| 630 | except ImportError as e: |
| 631 | main.log.error("Import not found. Exiting the test") |
| 632 | main.log.error(e) |
| 633 | main.cleanAndExit() |
| 634 | n_switches = int(main.params["TOPO"]["switchNum"]) |
| 635 | switch_to_kill = main.params["UP4"]["switch_to_kill"] |
| 636 | |
| 637 | run.initTest(main) |
| 638 | main.log.info(main.Cluster.numCtrls) |
| 639 | main.Cluster.setRunningNode(3) |
| 640 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 641 | |
| 642 | onos_cli = main.Cluster.active(0).CLI |
| 643 | |
| 644 | up4 = UP4() |
| 645 | |
| 646 | initial_flow_count = onos_cli.checkFlowCount() |
| 647 | |
| 648 | main.step("Program and Verify PDRs and FARs via UP4") |
| 649 | up4.setup(main.Cluster.active(0).p4rtUp4) |
| 650 | up4.attachUes() |
| 651 | up4.verifyUp4Flow(onos_cli) |
| 652 | |
| 653 | run.checkFlows( |
| 654 | main, |
| 655 | minFlowCount=initial_flow_count+(len(up4.emulated_ues)*4*n_switches) |
| 656 | ) |
| 657 | |
| 658 | main.step("Kill switch") |
| 659 | switch_component = getattr(main, switch_to_kill) |
| 660 | switch_component.handle.sendline("sudo reboot") |
| 661 | |
| 662 | sleepTime = 20 |
| 663 | main.log.info("Sleeping %s seconds for Fabric to react" % sleepTime) |
| 664 | time.sleep(sleepTime) |
| 665 | |
| 666 | available = utilities.retry(SRStagingTest.switchIsConnected, |
| 667 | True, |
| 668 | args=[switch_component], |
| 669 | attempts=300, |
| 670 | getRetryingTime=True) |
| 671 | main.log.info("Switch %s is available in ONOS? %s" % ( |
| 672 | switch_to_kill, available)) |
| 673 | utilities.assert_equal( |
| 674 | expect=False, |
| 675 | actual=available, |
| 676 | onpass="Switch was rebooted (ONL reboot) successfully", |
| 677 | onfail="Switch was not rebooted (ONL reboot) successfully" |
| 678 | ) |
| 679 | |
| 680 | enodebs_fail = main.params["UP4"]["enodebs_fail"].split(",") |
| 681 | enodebs_no_fail = list(set(up4.enodebs.keys()) - set(enodebs_fail)) |
| 682 | |
| 683 | # ------- Test Upstream traffic (enbs->pdn) |
| 684 | main.step("Test upstream traffic FAIL") |
| 685 | up4.testUpstreamTraffic(enb_names=enodebs_fail, shouldFail=True) |
| 686 | main.step("Test upstream traffic NO FAIL") |
| 687 | up4.testUpstreamTraffic(enb_names=enodebs_no_fail, shouldFail=False) |
| 688 | |
| 689 | # ------- Test Downstream traffic (pdn->enbs) |
| 690 | main.step("Test downstream traffic FAIL") |
| 691 | up4.testDownstreamTraffic(enb_names=enodebs_fail, shouldFail=True) |
| 692 | main.step("Test downstream traffic NO FAIL") |
| 693 | up4.testDownstreamTraffic(enb_names=enodebs_no_fail, shouldFail=False) |
| 694 | |
| 695 | # Reconnect to the switch |
| 696 | connect = utilities.retry(switch_component.connect, |
| 697 | main.FALSE, |
| 698 | attempts=30, |
| 699 | getRetryingTime=True) |
| 700 | main.log.info("Connected to the switch %s? %s" % ( |
| 701 | switch_to_kill, connect)) |
| 702 | # Wait switch to be back in ONOS |
| 703 | available = utilities.retry(SRStagingTest.switchIsConnected, |
| 704 | False, |
| 705 | args=[switch_component], |
| 706 | attempts=300, |
| 707 | getRetryingTime=True) |
| 708 | main.log.info("Switch %s is available in ONOS? %s" % ( |
| 709 | switch_to_kill, available)) |
| 710 | utilities.assert_equal( |
| 711 | expect=True, |
| 712 | actual=available and connect == main.TRUE, |
| 713 | onpass="Switch is back available in ONOS", |
| 714 | onfail="Switch is not available in ONOS, may influence subsequent tests!" |
| 715 | ) |
| 716 | |
| 717 | main.step("Test upstream traffic AFTER switch reboot") |
| 718 | up4.testUpstreamTraffic() |
| 719 | |
| 720 | main.step("Cleanup PDRs and FARs via UP4") |
| 721 | up4.detachUes() |
| 722 | up4.verifyNoUesFlow(onos_cli) |
| 723 | up4.teardown() |
| 724 | |
| 725 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 726 | |
| 727 | # Teardown |
| 728 | run.cleanup(main) |