Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 1 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \ |
| 2 | Testcaselib as run |
| 3 | from tests.USECASE.SegmentRouting.dependencies.trex import Trex |
| 4 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, N_FLOWS_PER_UE |
| 5 | import json |
| 6 | |
| 7 | |
| 8 | class QOSTest: |
| 9 | |
| 10 | def runTest(self, main, test_idx, n_switches): |
| 11 | run.initTest(main) |
| 12 | main.log.info(main.Cluster.numCtrls) |
| 13 | main.Cluster.setRunningNode(3) |
| 14 | run.installOnos(main, skipPackage=True, cliSleep=5) |
| 15 | |
| 16 | main.step("Start P4rt client and setup TRex") |
| 17 | # Use the first available ONOS instance CLI |
| 18 | onos_cli = main.Cluster.active(0).CLI |
| 19 | initial_flow_count = onos_cli.checkFlowCount() |
| 20 | up4 = UP4() |
| 21 | trex = Trex() |
| 22 | # Get the P4RT client connected to UP4 in the first available ONOS instance |
Daniele Moro | 9b2d08a | 2021-10-21 11:46:32 +0200 | [diff] [blame] | 23 | up4.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 24 | trex.setup(main.TRexClient) |
| 25 | |
Daniele Moro | 49a843c | 2022-01-05 14:36:32 +0100 | [diff] [blame^] | 26 | main.step("Program UPF entities via UP4") |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 27 | up4.attachUes() |
| 28 | up4.verifyUp4Flow(onos_cli) |
| 29 | |
| 30 | run.checkFlows( |
| 31 | main, |
| 32 | minFlowCount=initial_flow_count + ( |
| 33 | len(up4.emulated_ues) * N_FLOWS_PER_UE * n_switches) |
| 34 | ) |
| 35 | |
| 36 | # Load traffic config for the current test case |
| 37 | main.step("Load test JSON config") |
| 38 | cfgFile = main.configPath + "/tests/" + "CASE_%d.json" % test_idx |
| 39 | with open(cfgFile) as cfg: |
| 40 | testCfg = json.load(cfg) |
| 41 | |
| 42 | main.step("Send traffic with TRex") |
| 43 | for flow in testCfg["flows"]: |
| 44 | trex.createFlow(flow) |
| 45 | results = trex.sendAndReceiveTraffic(testCfg["duration"]) |
| 46 | trex.verifyCongestion( |
| 47 | results, |
| 48 | multiplier=float(testCfg.get("multiplier", "1")) |
| 49 | ) |
| 50 | |
| 51 | main.step("Log port and flow stats") |
| 52 | trex.logPortStats() |
| 53 | for flow in testCfg["flows"]: |
| 54 | trex.logFlowStats(flow) |
| 55 | |
| 56 | # Assert Flow Stats |
| 57 | for flow in testCfg["flows"]: |
| 58 | if trex.isFlowStats(flow): |
| 59 | main.step("{}: Assert RX Packets".format(flow)) |
| 60 | trex.assertRxPackets(flow) |
| 61 | main.step("{}: Assert Dropped Packets".format(flow)) |
| 62 | trex.assertDroppedPacket(flow) |
| 63 | main.step("{}: Assert 90 Percentile Latency".format(flow)) |
| 64 | trex.assert90PercentileLatency(flow) |
| 65 | main.step("{}: Assert 99.9 Percentile Latency".format(flow)) |
| 66 | trex.assert99_9PercentileLatency(flow) |
| 67 | |
Daniele Moro | 49a843c | 2022-01-05 14:36:32 +0100 | [diff] [blame^] | 68 | main.step("Remove UPF entities via UP4") |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 69 | up4.detachUes() |
| 70 | up4.verifyNoUesFlow(onos_cli) |
| 71 | |
| 72 | run.checkFlows(main, minFlowCount=initial_flow_count) |
| 73 | |
| 74 | main.step("Teardown") |
| 75 | trex.teardown() |
| 76 | up4.teardown() |
| 77 | run.cleanup(main) |