From 89d643b96d9a86345ef1de8e80c801d1863002e8 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Thu, 5 May 2016 11:52:11 +0300 Subject: Regression tests working. Still missing python API to parse latency json --- .../stl/trex_stl_lib/trex_stl_stats.py | 2 +- .../stl/trex_stl_lib/trex_stl_streams.py | 48 +++++++++++++++------- 2 files changed, 34 insertions(+), 16 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl') 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 eace5cf2..e30da00e 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 @@ -942,7 +942,7 @@ class CRxStats(CTRexStats): def calculate_bw_for_pg (self, pg_current, pg_prev = None, diff_sec = 0.0): # no previous values - if (pg_prev == None) or not (diff_sec > 0): + if (not pg_prev) or not (diff_sec > 0): pg_current['tx_pps'] = {} pg_current['tx_bps'] = {} pg_current['tx_bps_L1'] = {} diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index a7fd3026..6264c17f 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -210,25 +210,11 @@ STLStreamDstMAC_CFG_FILE=0 STLStreamDstMAC_PKT =1 STLStreamDstMAC_ARP =2 -# RX stats class -class STLFlowStats(object): - """ Define per stream stats - - .. code-block:: python - :caption: STLFlowStats Example - - flow_stats = STLFlowStats(pg_id = 7) - - """ - +class STLFlowStatsInterface(object): def __init__ (self, pg_id): self.fields = {} - self.fields['enabled'] = True self.fields['stream_id'] = pg_id - self.fields['seq_enabled'] = False - self.fields['latency_enabled'] = False - def to_json (self): """ Dump as json""" @@ -238,6 +224,37 @@ class STLFlowStats(object): def defaults (): return {'enabled' : False} + +class STLFlowStats(STLFlowStatsInterface): + """ Define per stream basic stats + + .. code-block:: python + :caption: STLFlowStats Example + + flow_stats = STLFlowStats(pg_id = 7) + + """ + + def __init__(self, pg_id): + super(STLFlowStats, self).__init__(pg_id) + self.fields['rule_type'] = 'stats' + + +class STLFlowLatencyStats(STLFlowStatsInterface): + """ Define per stream basic stats + latency, jitter, packet reorder/loss + + .. code-block:: python + :caption: STLFlowLatencyStats Example + + flow_stats = STLFlowLatencyStats(pg_id = 7) + + """ + + def __init__(self, pg_id): + super(STLFlowLatencyStats, self).__init__(pg_id) + self.fields['rule_type'] = 'latency' + + class STLStream(object): """ One stream object. Includes mode, Field Engine mode packet template and Rx stats @@ -320,6 +337,7 @@ class STLStream(object): # type checking validate_type('mode', mode, STLTXMode) validate_type('packet', packet, (type(None), CTrexPktBuilderInterface)) + validate_type('flow_stats', flow_stats, (type(None), STLFlowStatsInterface)) validate_type('enabled', enabled, bool) validate_type('self_start', self_start, bool) validate_type('isg', isg, (int, float)) -- cgit 1.2.3-korg