blob: 46f0cc8bc465830c8bfbe7e34d638808217fcadc [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
4from tests.USECASE.SegmentRouting.dependencies.up4 import UP4, N_FLOWS_PER_UE
5import 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
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 Moro9b2d08a2021-10-21 11:46:32 +020023 up4.setup(main.Cluster.active(0).p4rtUp4, no_host=True)
Daniele Morof811f9f2021-09-21 19:07:52 +020024 trex.setup(main.TRexClient)
25
Daniele Moro49a843c2022-01-05 14:36:32 +010026 main.step("Program UPF entities via UP4")
Daniele Morof811f9f2021-09-21 19:07:52 +020027 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 Moro49a843c2022-01-05 14:36:32 +010068 main.step("Remove UPF entities via UP4")
Daniele Morof811f9f2021-09-21 19:07:52 +020069 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)