blob: 217f6391de60e323e98e9b309349e0a83e61267c [file] [log] [blame]
Daniele Morof811f9f2021-09-21 19:07:52 +02001from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
2 Testcaselib as run
3from tests.USECASE.SegmentRouting.dependencies.trex import Trex
Daniele Moro54581242022-02-25 19:56:02 +01004from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
Daniele Morof811f9f2021-09-21 19:07:52 +02005import json
6
7
8class 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 Morof811f9f2021-09-21 19:07:52 +020019 up4 = UP4()
20 trex = Trex()
21 # Get the P4RT client connected to UP4 in the first available ONOS instance
Daniele Moro9b2d08a2021-10-21 11:46:32 +020022 up4.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
Daniele Morof811f9f2021-09-21 19:07:52 +020023 trex.setup(main.TRexClient)
24
Daniele Moro49a843c2022-01-05 14:36:32 +010025 main.step("Program UPF entities via UP4")
Daniele Morof811f9f2021-09-21 19:07:52 +020026 up4.attachUes()
27 up4.verifyUp4Flow(onos_cli)
28
Daniele Morof811f9f2021-09-21 19:07:52 +020029 # 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 Moro49a843c2022-01-05 14:36:32 +010061 main.step("Remove UPF entities via UP4")
Daniele Morof811f9f2021-09-21 19:07:52 +020062 up4.detachUes()
63 up4.verifyNoUesFlow(onos_cli)
64
Daniele Morof811f9f2021-09-21 19:07:52 +020065 main.step("Teardown")
66 trex.teardown()
67 up4.teardown()
68 run.cleanup(main)