blob: 1b20ce807ee360d666a7a08afec669869d94cdf1 [file] [log] [blame]
Daniele Moro80889562021-09-08 10:09:26 +02001class QOS:
2
3 def __init__(self):
4 self.default = ''
5
6 def CASE1(self, main):
Daniele Moro812daee2021-10-04 16:28:26 +02007 main.case("Leaf-Edge with Mobile Traffic Classification")
Daniele Moro80889562021-09-08 10:09:26 +02008 # Leaf-Edge-Mobile
9 # Attach 2 UEs with different QFI
10 # Generate traffic with Trex for the two UEs
11 # --> no packet drop on RT flow, reasonable latency on RT flow
12 try:
13 from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
14 from tests.USECASE.SegmentRouting.dependencies.trex import Trex
15 from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
16 Testcaselib as run
17 import json
18 except ImportError as e:
19 main.log.error("Import not found. Exiting the test")
20 main.log.error(e)
21 main.cleanAndExit()
22
23 run.initTest(main)
24 main.log.info(main.Cluster.numCtrls)
25 main.Cluster.setRunningNode(3)
26 run.installOnos(main, skipPackage=True, cliSleep=5)
27
28 main.step("Start P4rt client and setup TRex")
Daniele Morobf53dec2021-09-13 18:11:56 +020029 # Use the first available ONOS instance CLI
30 onos_cli = main.Cluster.active(0).CLI
Daniele Moro9ba5cf02021-10-08 18:00:56 +020031 initial_flow_count = onos_cli.checkFlowCount()
Daniele Moro80889562021-09-08 10:09:26 +020032 up4 = UP4()
33 trex = Trex()
34 # Get the P4RT client connected to UP4 in the first available ONOS instance
35 up4.setup(main.Cluster.active(0).p4rtUp4)
36 trex.setup(main.TRexClient)
37
Daniele Morobf53dec2021-09-13 18:11:56 +020038 main.step("Program PDRs and FARs via UP4")
Daniele Moro80889562021-09-08 10:09:26 +020039 up4.attachUes()
40
Daniele Morobf53dec2021-09-13 18:11:56 +020041 main.step("Verify PDRs and FARs in ONOS")
42 up4.verifyUp4Flow(onos_cli)
43
Daniele Moro9ba5cf02021-10-08 18:00:56 +020044 run.checkFlows(
45 main,
46 minFlowCount=initial_flow_count+(len(up4.emulated_ues)*2)
47 )
48
Daniele Moro80889562021-09-08 10:09:26 +020049 # Load traffic config for the current test case
50 main.step("Load test JSON config")
51 cfgFile = main.configPath + "/tests/" + "leaf_edge_mobile.json"
52 with open(cfgFile) as cfg:
53 testCfg = json.load(cfg)
54
55 main.step("Send traffic with TRex")
56 for flow in testCfg["flows"]:
57 trex.createFlow(flow)
58 trex.sendAndReceiveTraffic(testCfg["duration"])
59
60 main.step("Log port and flow stats")
61 trex.logPortStats()
62 for flow in testCfg["flows"]:
63 trex.logFlowStats(flow)
64
65 # Assert Flow Stats
66 for flow in testCfg["flows"]:
67 if trex.isFlowStats(flow):
68 main.step("{}: Assert RX Packets".format(flow))
69 trex.assertRxPackets(flow)
70 main.step("{}: Assert Dropped Packets".format(flow))
71 trex.assertDroppedPacket(flow)
72 main.step("{}: Assert 99.9 Percentile Latency".format(flow))
73 trex.assert99_9PercentileLatency(flow)
74
Daniele Morobf53dec2021-09-13 18:11:56 +020075 main.step("Remove PDRs and FARs via UP4")
Daniele Moro80889562021-09-08 10:09:26 +020076 up4.detachUes()
77
Daniele Morobf53dec2021-09-13 18:11:56 +020078 main.step("Verify removed PDRs and FARs from ONOS")
79 up4.verifyNoUesFlow(onos_cli)
80
Daniele Moro9ba5cf02021-10-08 18:00:56 +020081 run.checkFlows(main, minFlowCount=initial_flow_count)
82
Daniele Moro80889562021-09-08 10:09:26 +020083 main.step("Teardown")
84 trex.teardown()
85 up4.teardown()
86 run.cleanup(main)