summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-05-08 14:24:37 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-05-18 19:20:22 +0300
commitcb13e66205717a8fcf69185ba350adab3438ffa0 (patch)
treee11ee60f94005936206daba10fb450ec54eb6f79 /scripts
parent89d643b96d9a86345ef1de8e80c801d1863002e8 (diff)
Latency stat python API work
Diffstat (limited to 'scripts')
-rw-r--r--scripts/automation/regression/stateless_tests/stl_rx_test.py33
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py3
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py5
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py31
4 files changed, 60 insertions, 12 deletions
diff --git a/scripts/automation/regression/stateless_tests/stl_rx_test.py b/scripts/automation/regression/stateless_tests/stl_rx_test.py
index 3b979744..a5bc115f 100644
--- a/scripts/automation/regression/stateless_tests/stl_rx_test.py
+++ b/scripts/automation/regression/stateless_tests/stl_rx_test.py
@@ -7,7 +7,7 @@ class STLRX_Test(CStlGeneral_Test):
"""Tests for RX feature"""
def setUp(self):
- per_driver_params = {"rte_vmxnet3_pmd": [1, 50], "rte_ixgbe_pmd": [30, 5000], "rte_i40e_pmd": [80, 5000],
+ per_driver_params = {"rte_vmxnet3_pmd": [1, 50], "rte_ixgbe_pmd": [10, 5000], "rte_i40e_pmd": [80, 5000],
"rte_igb_pmd": [80, 500], "rte_em_pmd": [1, 50], "rte_virtio_pmd": [1, 50]}
CStlGeneral_Test.setUp(self)
@@ -19,8 +19,9 @@ class STLRX_Test(CStlGeneral_Test):
port_info = self.c.get_port_info(ports = self.rx_port)[0]
cap = port_info['rx']['caps']
- if cap != 1:
- self.skip('port {0} does not support RX'.format(self.rx_port))
+# print cap; ????
+# if cap != 1:
+# self.skip('port {0} does not support RX'.format(self.rx_port))
self.rate_percent = per_driver_params[port_info['driver']][0]
self.total_pkts = per_driver_params[port_info['driver']][1]
@@ -36,14 +37,24 @@ class STLRX_Test(CStlGeneral_Test):
def __verify_flow (self, pg_id, total_pkts, pkt_len):
-
flow_stats = self.c.get_stats()['flow_stats'].get(pg_id)
+ latency_stats = self.c.get_stats()['latency'].get(pg_id)
+
if not flow_stats:
assert False, "no flow stats available"
tx_pkts = flow_stats['tx_pkts'].get(self.tx_port, 0)
tx_bytes = flow_stats['tx_bytes'].get(self.tx_port, 0)
rx_pkts = flow_stats['rx_pkts'].get(self.rx_port, 0)
+ drops = latency_stats['err_cntrs']['dropped']
+ ooo = latency_stats['err_cntrs']['out_of_order']
+ jitter = latency_stats['jitter']
+ latency = latency_stats['latency']
+
+ if drops != 0 or ooo != 0:
+ pprint.pprint(latency_stats)
+ tmp='Dropped or out of order packets - dropped: {0}, ooo: {1}'.format(drops, ooo)
+ assert False, tmp
if tx_pkts != total_pkts:
pprint.pprint(flow_stats)
@@ -78,7 +89,7 @@ class STLRX_Test(CStlGeneral_Test):
try:
s1 = STLStream(name = 'rx',
packet = self.pkt,
- flow_stats = STLFlowStats(pg_id = 5),
+ flow_stats = STLFlowLatencyStats(pg_id = 5),
mode = STLTXSingleBurst(total_pkts = total_pkts,
percentage = self.rate_percent
))
@@ -99,13 +110,11 @@ class STLRX_Test(CStlGeneral_Test):
# one simple stream on TX --> RX
def test_multiple_streams(self):
- num_streams = 10
+ num_streams = 128
total_pkts = int(self.total_pkts / num_streams)
if total_pkts == 0:
total_pkts = 1
- percent = int(self.rate_percent / num_streams)
- if percent == 0:
- percent = 1
+ percent = float(self.rate_percent) / num_streams
try:
streams = []
@@ -115,7 +124,7 @@ class STLRX_Test(CStlGeneral_Test):
streams.append(STLStream(name = 'rx {0}'.format(pg_id),
packet = self.pkt,
- flow_stats = STLFlowStats(pg_id = pg_id),
+ flow_stats = STLFlowLatencyStats(pg_id = pg_id),
mode = STLTXSingleBurst(total_pkts = total_pkts+pg_id, percentage = percent)))
exp.append({'pg_id': pg_id, 'total_pkts': total_pkts+pg_id, 'pkt_len': self.pkt.get_pkt_len()})
@@ -135,7 +144,7 @@ class STLRX_Test(CStlGeneral_Test):
try:
s1 = STLStream(name = 'rx',
packet = self.pkt,
- flow_stats = STLFlowStats(pg_id = 5),
+ flow_stats = STLFlowLatencyStats(pg_id = 5),
mode = STLTXSingleBurst(total_pkts = total_pkts,
percentage = self.rate_percent
))
@@ -143,7 +152,7 @@ class STLRX_Test(CStlGeneral_Test):
# add both streams to ports
self.c.add_streams([s1], ports = [self.tx_port])
- #print "\ninjecting {0} packets on port {1}\n".format(total_pkts, self.tx_port)
+ print "\ninjecting {0} packets on port {1}\n".format(total_pkts, self.tx_port)
exp = {'pg_id': 5, 'total_pkts': total_pkts, 'pkt_len': self.pkt.get_pkt_len()}
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
index 5c9faf0f..731ddb10 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_async_client.py
@@ -293,6 +293,9 @@ class CTRexAsyncClient():
elif name == "flow_stats":
self.event_handler.on_async_rx_stats_event(data, baseline)
+ elif name == "latency_stats":
+ self.event_handler.on_async_latency_stats_event(data, baseline)
+
else:
pass
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index e7b46aea..88c64e3c 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -187,6 +187,8 @@ class EventsHandler(object):
def on_async_rx_stats_event (self, data, baseline):
self.client.flow_stats.update(data, baseline)
+ def on_async_latency_stats_event (self, data, baseline):
+ self.client.latency_stats.update(data, baseline)
# handles an async stats update from the subscriber
def on_async_stats_update(self, dump_data, baseline):
@@ -551,6 +553,8 @@ class STLClient(object):
self.flow_stats = trex_stl_stats.CRxStats(self.ports)
+ self.latency_stats = trex_stl_stats.CLatencyStats(self.ports)
+
self.stats_generator = trex_stl_stats.CTRexInfoGenerator(self.global_stats,
self.ports,
self.flow_stats)
@@ -891,6 +895,7 @@ class STLClient(object):
stats['total'] = total
stats['flow_stats'] = self.flow_stats.get_stats()
+ stats['latency'] = self.latency_stats.get_stats()
return stats
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index e30da00e..a65ef9e0 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -831,6 +831,37 @@ class CPortStats(CTRexStats):
}
+class CLatencyStats(CTRexStats):
+ def __init__(self, ports):
+ super(CLatencyStats, self).__init__()
+
+ # for API
+ def get_stats (self):
+ return self.latest_stats
+
+ def process_snapshot (self, current):
+ output = {}
+
+ # we care only about the current active keys
+ pg_ids = list(filter(is_intable, current.keys()))
+
+ for pg_id in pg_ids:
+ current_pg = current.get(pg_id)
+ int_pg_id = int(pg_id)
+ output[int_pg_id] = {}
+ for field in ['err_cntrs', 'jitter', 'latency']:
+ output[int_pg_id][field] = current_pg[field]
+ return output
+
+ def update (self, snapshot, baseline):
+ # generate a new snapshot
+ if (snapshot is not None):
+ new_snapshot = self.process_snapshot(snapshot)
+ else:
+ return
+
+ self.latest_stats = new_snapshot
+ return True
# RX stats objects - COMPLEX :-(