blob: 801e30a2c4e2ec7069cdfb0d10f8f6bc48934fb2 [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 Morob8404e82022-02-25 00:17:28 +010025 try:
26 main.step("Program UPF entities via UP4")
27 up4.attachUes()
28 up4.verifyUp4Flow(onos_cli)
Daniele Morof811f9f2021-09-21 19:07:52 +020029
Daniele Morob8404e82022-02-25 00:17:28 +010030 # Load traffic config for the current test case
31 main.step("Load test JSON config")
32 cfgFile = main.configPath + "/tests/" + "CASE_%d.json" % test_idx
33 with open(cfgFile) as cfg:
34 testCfg = json.load(cfg)
Daniele Morof811f9f2021-09-21 19:07:52 +020035
Daniele Morob8404e82022-02-25 00:17:28 +010036 for flow in testCfg["flows"]:
37 trex.createFlow(flow)
38 results = trex.sendAndReceiveTraffic(testCfg["duration"])
39 main.step("Verify congestion")
40 trex.verifyCongestion(
41 results,
42 multiplier=float(testCfg.get("multiplier", "1"))
43 )
Daniele Morof811f9f2021-09-21 19:07:52 +020044
Daniele Morob8404e82022-02-25 00:17:28 +010045 main.step("Log port and flow stats")
46 trex.logPortStats()
47 for flow in testCfg["flows"]:
48 trex.logFlowStats(flow)
Daniele Morof811f9f2021-09-21 19:07:52 +020049
Daniele Morob8404e82022-02-25 00:17:28 +010050 # Assert Flow Stats
51 for flow in testCfg["flows"]:
52 if trex.isFlowStats(flow):
53 main.step("{}: Assert RX Packets".format(flow))
54 trex.assertRxPackets(flow)
55 main.step("{}: Assert Dropped Packets".format(flow))
56 trex.assertDroppedPacket(flow)
57 main.step("{}: Assert 90 Percentile Latency".format(flow))
58 trex.assert90PercentileLatency(flow)
59 main.step("{}: Assert 99.9 Percentile Latency".format(flow))
60 trex.assert99_9PercentileLatency(flow)
61 finally:
62 main.step("Remove UPF entities via UP4")
63 up4.detachUes()
64 up4.verifyNoUesFlow(onos_cli)
Daniele Morof811f9f2021-09-21 19:07:52 +020065
Daniele Morob8404e82022-02-25 00:17:28 +010066 main.step("Teardown")
67 trex.teardown()
68 up4.teardown()
69 run.cleanup(main)