From a1bd29103c1cfcfd9ea24d03b9f81f9029ff5ebd Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Mon, 23 Sep 2019 15:00:00 +0200 Subject: 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 --- resources/tools/trex/trex_stateless_stop.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'resources/tools/trex/trex_stateless_stop.py') diff --git a/resources/tools/trex/trex_stateless_stop.py b/resources/tools/trex/trex_stateless_stop.py index 9421356bc1..b8b0212635 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) -- cgit 1.2.3-korg