From 3159743120d9e1033c5ed809c1031b814204fd8f Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Wed, 3 Aug 2016 16:18:50 +0300 Subject: set default stateful duration 1 hour, forbid duration in stateless add "add_profile"stateless Python API command fix trex_perf.py --- .../stl/examples/using_rpc_proxy.py | 31 ++++++++++++++++++++-- .../stl/trex_stl_lib/trex_stl_client.py | 28 ++++++++++++++++++- scripts/automation/trex_perf.py | 5 ++-- 3 files changed, 59 insertions(+), 5 deletions(-) (limited to 'scripts/automation') diff --git a/scripts/automation/trex_control_plane/stl/examples/using_rpc_proxy.py b/scripts/automation/trex_control_plane/stl/examples/using_rpc_proxy.py index 065f4284..d2fcdff3 100755 --- a/scripts/automation/trex_control_plane/stl/examples/using_rpc_proxy.py +++ b/scripts/automation/trex_control_plane/stl/examples/using_rpc_proxy.py @@ -4,6 +4,7 @@ import argparse import sys import os from time import sleep +from pprint import pprint # ext libs ext_libs = os.path.join(os.pardir, os.pardir, os.pardir, os.pardir, 'external_libs') @@ -74,14 +75,40 @@ if __name__ == '__main__': print('Sending pcap to ports %s' % ports) verify(server.push_remote(pcap_filename = 'stl/sample.pcap')) + sleep(3) print('Getting stats') res = verify(server.get_stats()) - print('Stats: %s' % res[1]) + pprint(res[1]) print('Resetting all ports') verify(server.reset()) + imix_path_1 = '../../../../stl/imix.py' + imix_path_2 = '../../stl/imix.py' + if os.path.exists(imix_path_1): + imix_path = imix_path_1 + elif os.path.exists(imix_path_2): + imix_path = imix_path_2 + else: + print('Could not find path of imix profile, skipping') + imix_path = None + + if imix_path: + print('Adding profile %s' % imix_path) + verify(server.native_method(func_name = 'add_profile', filename = imix_path)) + + print('Start traffic for 5 sec') + verify(server.native_method('start')) + sleep(5) + + print('Getting stats') + res = verify(server.get_stats()) + pprint(res[1]) + + print('Resetting all ports') + verify(server.reset()) + print('Deleting Native Client instance') verify(server.native_proxy_del()) @@ -116,7 +143,7 @@ if __name__ == '__main__': print('Getting stats') res = verify_hlt(server.traffic_stats(mode = 'aggregate', port_handle = ports[:2])) - print(res) + pprint(res) print('Deleting HLTAPI Client instance') verify_hlt(server.hltapi_proxy_del()) 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 4e3d3092..4799b2fc 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 @@ -1536,7 +1536,6 @@ class STLClient(object): @__api_check(False) def connect (self): """ - def connect(self): Connects to the TRex server @@ -1829,6 +1828,33 @@ class STLClient(object): # return the stream IDs return rc.data() + @__api_check(True) + def add_profile(self, filename, ports = None, **kwargs): + """ | Add streams from profile by its type. Supported types are: + | .py + | .yaml + | .pcap file that converted to profile automatically + + :parameters: + filename : string + filename (with path) of the profile + ports : list + list of ports to add the profile (default: all acquired) + kwargs : dict + forward those key-value pairs to the profile (tunables) + + :returns: + List of stream IDs in order of the stream list + + :raises: + + :exc:`STLError` + + """ + + validate_type('filename', filename, basestring) + profile = STLProfile.load(filename, **kwargs) + return self.add_streams(profile.get_streams(), ports) + @__api_check(True) def remove_streams (self, stream_id_list, ports = None): diff --git a/scripts/automation/trex_perf.py b/scripts/automation/trex_perf.py index 61874765..08d15caf 100755 --- a/scripts/automation/trex_perf.py +++ b/scripts/automation/trex_perf.py @@ -2,13 +2,14 @@ import h_avc -from trex_control_plane.client.trex_client import CTRexClient import ConfigParser import threading import time,signal import argparse import sys import os +sys.path.append(os.path.join('trex_control_plane', 'stf', 'trex_stf_lib')) +from trex_client import CTRexClient import subprocess from time import sleep import signal @@ -54,7 +55,7 @@ class TrexRunException(Exception): def verify_glibc_version (): x = subprocess.check_output("/usr/bin/ldd --version", shell=True) - m = re.match("ldd \(GNU libc\) (.*)", x) + m = re.match("^ldd \([^\)]+\) (.*)", x) if not m: raise Exception("Cannot determine LDD version") current_version = m.group(1) -- cgit 1.2.3-korg