X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Ftrex%2Ftrex_stateless_profile.py;h=edb0b8d8cfc84be44840cb94277d677a8734193f;hb=eb774c3e205a538262aef928bfbed17cd5be7b25;hp=9233f6a5f159717666c48c9f6858a13f5d6fd5b3;hpb=d68951ac245150eeefa6e0f4156e4c1b5c9e9325;p=csit.git diff --git a/resources/tools/trex/trex_stateless_profile.py b/resources/tools/trex/trex_stateless_profile.py index 9233f6a5f1..edb0b8d8cf 100755 --- a/resources/tools/trex/trex_stateless_profile.py +++ b/resources/tools/trex/trex_stateless_profile.py @@ -21,9 +21,10 @@ latency. import argparse import json import sys +import time sys.path.insert( - 0, "/opt/trex-core-2.61/scripts/automation/trex_control_plane/interactive/" + 0, u"/opt/trex-core-2.73/scripts/automation/trex_control_plane/interactive/" ) from trex.stl.api import * @@ -60,7 +61,7 @@ def fmt_latency(lat_min, lat_avg, lat_max, hdrh): def simple_burst( profile_file, duration, framesize, rate, warmup_time, port_0, port_1, - latency, async_start=False, traffic_directions=2): + latency, async_start=False, traffic_directions=2, force=False): """Send traffic and measure packet loss and latency. Procedure: @@ -88,6 +89,7 @@ def simple_burst( :param latency: With latency stats. :param async_start: Start the traffic and exit. :param traffic_directions: Bidirectional (2) or unidirectional (1) traffic. + :param force: Force start regardless of ports state. :type profile_file: str :type framesize: int or str :type duration: float @@ -98,6 +100,7 @@ def simple_burst( :type latency: bool :type async_start: bool :type traffic_directions: int + :type force: bool """ client = None total_rcvd = 0 @@ -158,10 +161,14 @@ def simple_burst( client.clear_stats() # Choose rate and start traffic: - client.start(ports=ports, mult=rate, duration=warmup_time) + time_start = time.time() + client.start(ports=ports, mult=rate, duration=warmup_time, + force=force) # Block until done: client.wait_on_traffic(ports=ports, timeout=warmup_time+30) + time_stop = time.time() + print(f"Warmup traffic took {time_stop - time_start} seconds.") if client.get_warnings(): for warning in client.get_warnings(): @@ -187,7 +194,8 @@ def simple_burst( lost_b = 0 # Choose rate and start traffic: - client.start(ports=ports, mult=rate, duration=duration) + time_start = time.time() + client.start(ports=ports, mult=rate, duration=duration, force=force) if async_start: # For async stop, we need to export the current snapshot. @@ -199,6 +207,8 @@ def simple_burst( else: # Block until done: client.wait_on_traffic(ports=ports, timeout=duration+30) + time_stop = time.time() + print(f"Main traffic took {time_stop - time_start} seconds.") if client.get_warnings(): for warning in client.get_warnings(): @@ -304,6 +314,10 @@ def main(): u"--traffic_directions", type=int, default=2, help=u"Send bi- (2) or uni- (1) directional traffic." ) + parser.add_argument( + u"--force", action=u"store_true", default=False, + help=u"Force start regardless of ports state." + ) args = parser.parse_args() @@ -316,7 +330,7 @@ def main(): profile_file=args.profile, duration=args.duration, framesize=framesize, rate=args.rate, warmup_time=args.warmup_time, port_0=args.port_0, port_1=args.port_1, latency=args.latency, async_start=args.async_start, - traffic_directions=args.traffic_directions + traffic_directions=args.traffic_directions, force=args.force )