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 |
Daniele Moro | 5458124 | 2022-02-25 19:56:02 +0100 | [diff] [blame] | 4 | from tests.USECASE.SegmentRouting.dependencies.up4 import UP4 |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 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 |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 19 | up4 = UP4() |
| 20 | trex = Trex() |
| 21 | # 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] | 22 | up4.setup(main.Cluster.active(0).p4rtUp4, no_host=True) |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 23 | trex.setup(main.TRexClient) |
| 24 | |
Daniele Moro | 49a843c | 2022-01-05 14:36:32 +0100 | [diff] [blame] | 25 | main.step("Program UPF entities via UP4") |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 26 | up4.attachUes() |
| 27 | up4.verifyUp4Flow(onos_cli) |
| 28 | |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 29 | # Load traffic config for the current test case |
| 30 | main.step("Load test JSON config") |
| 31 | cfgFile = main.configPath + "/tests/" + "CASE_%d.json" % test_idx |
| 32 | with open(cfgFile) as cfg: |
| 33 | testCfg = json.load(cfg) |
| 34 | |
| 35 | main.step("Send traffic with TRex") |
| 36 | for flow in testCfg["flows"]: |
| 37 | trex.createFlow(flow) |
| 38 | results = trex.sendAndReceiveTraffic(testCfg["duration"]) |
| 39 | trex.verifyCongestion( |
| 40 | results, |
| 41 | multiplier=float(testCfg.get("multiplier", "1")) |
| 42 | ) |
| 43 | |
| 44 | main.step("Log port and flow stats") |
| 45 | trex.logPortStats() |
| 46 | for flow in testCfg["flows"]: |
| 47 | trex.logFlowStats(flow) |
| 48 | |
| 49 | # Assert Flow Stats |
| 50 | for flow in testCfg["flows"]: |
| 51 | if trex.isFlowStats(flow): |
| 52 | main.step("{}: Assert RX Packets".format(flow)) |
| 53 | trex.assertRxPackets(flow) |
| 54 | main.step("{}: Assert Dropped Packets".format(flow)) |
| 55 | trex.assertDroppedPacket(flow) |
| 56 | main.step("{}: Assert 90 Percentile Latency".format(flow)) |
| 57 | trex.assert90PercentileLatency(flow) |
| 58 | main.step("{}: Assert 99.9 Percentile Latency".format(flow)) |
| 59 | trex.assert99_9PercentileLatency(flow) |
| 60 | |
Daniele Moro | 49a843c | 2022-01-05 14:36:32 +0100 | [diff] [blame] | 61 | main.step("Remove UPF entities via UP4") |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 62 | up4.detachUes() |
| 63 | up4.verifyNoUesFlow(onos_cli) |
| 64 | |
Daniele Moro | f811f9f | 2021-09-21 19:07:52 +0200 | [diff] [blame] | 65 | main.step("Teardown") |
| 66 | trex.teardown() |
| 67 | up4.teardown() |
| 68 | run.cleanup(main) |