aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2019-09-23 15:00:00 +0200
committerVratko Polak <vrpolak@cisco.com>2019-09-24 07:47:06 +0000
commitbab0b570345ceb6ffeaec9e47a50e62d7303387e (patch)
tree4ddb29534d9dd1048d1561cc0b93474323c6705b /resources/tools
parentc7c31d5a09cd56ac5faab8d6f690aea00fa9e051 (diff)
Reconf tests: Fix async measurements
TRex does not zero the server counters. It copies the values to use as reference, and subtracts them when asked for results. But the reference is stored in the client (not the server). And CSIT uses different scripts to start and stop async traffic, which means different clients. This patch introduces a workaround. Async start will return xstats objects to use as reference, and async stop will use the objects to compute the correct results. The xstats objects are stored in TrafficGenerator instance. Sync measurement does not export the counters, to shorten logs. Other improvements: + Make stop_traffic_on_tg return measurement results directly. + Rename --async to --async_start as "async" is reserved in Python 3.7 + Minor pylint, docstring and typo fixes. Change-Id: I5fc56a0763afb7d62cfa7c0651f96b6867de3e15 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/tools')
-rwxr-xr-xresources/tools/trex/trex_stateless_profile.py17
-rwxr-xr-xresources/tools/trex/trex_stateless_stop.py21
2 files changed, 32 insertions, 6 deletions
diff --git a/resources/tools/trex/trex_stateless_profile.py b/resources/tools/trex/trex_stateless_profile.py
index 2837778f7a..15a0225911 100755
--- a/resources/tools/trex/trex_stateless_profile.py
+++ b/resources/tools/trex/trex_stateless_profile.py
@@ -18,9 +18,9 @@ the profile and sends the traffic. At the end, it measures the packet loss and
latency.
"""
-import sys
import argparse
import json
+import sys
sys.path.insert(0, "/opt/trex-core-2.61/scripts/automation/"
"trex_control_plane/interactive/")
@@ -186,7 +186,14 @@ def simple_burst(profile_file, duration, framesize, rate, warmup_time, port_0,
# Choose rate and start traffic:
client.start(ports=ports, mult=rate, duration=duration)
- if not async_start:
+ if async_start:
+ # For async stop, we need to export the current snapshot.
+ xsnap0 = client.ports[0].get_xstats().reference_stats
+ print("Xstats snapshot 0: {s!r}".format(s=xsnap0))
+ if traffic_directions > 1:
+ xsnap1 = client.ports[1].get_xstats().reference_stats
+ print("Xstats snapshot 1: {s!r}".format(s=xsnap1))
+ else:
# Block until done:
client.wait_on_traffic(ports=ports, timeout=duration+30)
@@ -228,7 +235,7 @@ def simple_burst(profile_file, duration, framesize, rate, warmup_time, port_0,
p_0=port_0, p_1=port_1, v=lost_a))
if traffic_directions > 1:
print("packets lost from {p_1} --> {p_0}: {v} pkts".format(
- p_0=port_0, p_1=port_1, v=lost_b))
+ p_0=port_0, p_1=port_1, v=lost_b))
except STLError as ex_error:
print(ex_error, file=sys.stderr)
@@ -281,7 +288,7 @@ def main():
required=True,
type=int,
help="Port 1 on the traffic generator.")
- parser.add_argument("--async",
+ parser.add_argument("--async_start",
action="store_true",
default=False,
help="Non-blocking call of the script.")
@@ -309,7 +316,7 @@ def main():
port_0=args.port_0,
port_1=args.port_1,
latency=args.latency,
- async_start=args.async,
+ async_start=args.async_start,
traffic_directions=args.traffic_directions)
diff --git a/resources/tools/trex/trex_stateless_stop.py b/resources/tools/trex/trex_stateless_stop.py
index e8b6fdf96c..3fc599a5a4 100755
--- a/resources/tools/trex/trex_stateless_stop.py
+++ b/resources/tools/trex/trex_stateless_stop.py
@@ -23,8 +23,12 @@ Requirements:
Functionality:
1. Stop any running traffic
+2. Optionally restore reference counter values.
+3. Return conter differences.
"""
+import argparse
+from collections import OrderedDict # Needed to parse xstats representation.
import sys
import json
@@ -35,6 +39,13 @@ from trex.stl.api import *
def main():
"""Stop traffic if any is running. Report xstats."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--xstat0", type=str, default="", help="Reference xstat object if any.")
+ parser.add_argument(
+ "--xstat1", type=str, default="", help="Reference xstat object if any.")
+ args = parser.parse_args()
+
client = STLClient()
try:
# connect to server
@@ -44,7 +55,15 @@ def main():
# TODO: Support unidirection.
client.stop(ports=[0, 1])
- # read the stats after the test
+ # Read the stats after the test,
+ # we need to update values before the last trial started.
+ if args.xstat0:
+ snapshot = eval(args.xstat0)
+ client.ports[0].get_xstats().reference_stats = snapshot
+ if args.xstat1:
+ snapshot = eval(args.xstat1)
+ client.ports[1].get_xstats().reference_stats = snapshot
+ # Now we can call the official method to get differences.
xstats0 = client.get_xstats(0)
xstats1 = client.get_xstats(1)