diff options
Diffstat (limited to 'scripts/automation/trex_control_plane/stf')
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/examples/stf_example.py | 53 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/examples/stf_path.py | 4 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/CCustomLogger.py (renamed from scripts/automation/trex_control_plane/stf/CCustomLogger.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/__init__.py (renamed from scripts/automation/trex_control_plane/stf/__init__.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/external_packages.py (renamed from scripts/automation/trex_control_plane/stf/external_packages.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/general_utils.py (renamed from scripts/automation/trex_control_plane/stf/general_utils.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/outer_packages.py (renamed from scripts/automation/trex_control_plane/stf/outer_packages.py) | 10 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/text_opts.py (renamed from scripts/automation/trex_control_plane/stf/text_opts.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py (renamed from scripts/automation/trex_control_plane/stf/trex_client.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_daemon_server.py (renamed from scripts/automation/trex_control_plane/stf/trex_daemon_server.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_exceptions.py (renamed from scripts/automation/trex_control_plane/stf/trex_exceptions.py) | 0 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status.py (renamed from scripts/automation/trex_control_plane/stf/trex_status.py) | 0 | ||||
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status_e.py (renamed from scripts/automation/trex_control_plane/stf/trex_status_e.py) | 0 |
13 files changed, 62 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/stf/examples/stf_example.py b/scripts/automation/trex_control_plane/stf/examples/stf_example.py new file mode 100755 index 00000000..f6ebffe7 --- /dev/null +++ b/scripts/automation/trex_control_plane/stf/examples/stf_example.py @@ -0,0 +1,53 @@ +import argparse +import stf_path +from trex_stf_lib.trex_client import CTRexClient + +# sample TRex stateless run +# assuming server daemon is running. + +def minimal_stateful_test(server): + print('Connecting to %s' % server) + trex_client = CTRexClient(server) + + print('Connected, start TRex') + trex_client.start_trex( + c = 1, + m = 700, + f = 'cap2/http_simple.yaml', + d = 5, + l = 1000, + trex_development = True, + ) + + print('Sample until end') + result = trex_client.sample_to_run_finish() + + print('Test results:') + print(result) + + print('TX by ports:') + tx_ptks_dict = result.get_last_value('trex-global.data', 'opackets-*') + print(' | '.join(['%s: %s' % (k.split('-')[-1], tx_ptks_dict[k]) for k in sorted(tx_ptks_dict.keys())])) + + print('RX by ports:') + rx_ptks_dict = result.get_last_value('trex-global.data', 'ipackets-*') + print(' | '.join(['%s: %s' % (k.split('-')[-1], rx_ptks_dict[k]) for k in sorted(rx_ptks_dict.keys())])) + + print('CPU utilization:') + print(result.get_value_list('trex-global.data.m_cpu_util')) + + #print('Dump of *latest* result sample, uncomment to see it all') + #print(result.get_latest_dump()) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Example for TRex Stateful, assuming server daemon is running.") + parser.add_argument('-s', '--server', + dest='server', + help='Remote trex address', + default='127.0.0.1', + type = str) + args = parser.parse_args() + + minimal_stateful_test(args.server) + diff --git a/scripts/automation/trex_control_plane/stf/examples/stf_path.py b/scripts/automation/trex_control_plane/stf/examples/stf_path.py new file mode 100755 index 00000000..bb401148 --- /dev/null +++ b/scripts/automation/trex_control_plane/stf/examples/stf_path.py @@ -0,0 +1,4 @@ +import sys + +# FIXME to the write path for trex_stf_lib +sys.path.insert(0, "../") diff --git a/scripts/automation/trex_control_plane/stf/CCustomLogger.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/CCustomLogger.py index ecf7d519..ecf7d519 100755 --- a/scripts/automation/trex_control_plane/stf/CCustomLogger.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/CCustomLogger.py diff --git a/scripts/automation/trex_control_plane/stf/__init__.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/__init__.py index 5a1da046..5a1da046 100755 --- a/scripts/automation/trex_control_plane/stf/__init__.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/__init__.py diff --git a/scripts/automation/trex_control_plane/stf/external_packages.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/external_packages.py index 7353c397..7353c397 100755 --- a/scripts/automation/trex_control_plane/stf/external_packages.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/external_packages.py diff --git a/scripts/automation/trex_control_plane/stf/general_utils.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/general_utils.py index d2521f02..d2521f02 100755 --- a/scripts/automation/trex_control_plane/stf/general_utils.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/general_utils.py diff --git a/scripts/automation/trex_control_plane/stf/outer_packages.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/outer_packages.py index 5e29f8d6..f8d50ce6 100755 --- a/scripts/automation/trex_control_plane/stf/outer_packages.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/outer_packages.py @@ -5,8 +5,8 @@ import os CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) -PARENT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, 'external_libs')) -SCRIPTS_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, os.pardir, os.pardir, 'external_libs')) +PACKAGE_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, os.pardir, 'external_libs')) +SCRIPTS_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, os.pardir, os.pardir, os.pardir, 'external_libs')) CLIENT_MODULES = ['enum34-1.0.4', 'jsonrpclib-pelix-0.2.5', @@ -22,9 +22,9 @@ def import_module_list(ext_libs_path): raise Exception('Library %s is absent in path %s' % (p, ext_libs_path)) sys.path.insert(1, full_path) -if os.path.exists(PARENT_PATH): - import_module_list(PARENT_PATH) +if os.path.exists(PACKAGE_PATH): + import_module_list(PACKAGE_PATH) elif os.path.exists(SCRIPTS_PATH): import_module_list(SCRIPTS_PATH) else: - raise Exception('Could not find external libs in path: %s' % [PARENT_PATH, SCRIPTS_PATH]) + raise Exception('Could not find external libs in path: %s' % [PACKAGE_PATH, SCRIPTS_PATH]) diff --git a/scripts/automation/trex_control_plane/stf/text_opts.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/text_opts.py index 78a0ab1f..78a0ab1f 100755 --- a/scripts/automation/trex_control_plane/stf/text_opts.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/text_opts.py diff --git a/scripts/automation/trex_control_plane/stf/trex_client.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py index 919253d1..919253d1 100755 --- a/scripts/automation/trex_control_plane/stf/trex_client.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py diff --git a/scripts/automation/trex_control_plane/stf/trex_daemon_server.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_daemon_server.py index 9784d42a..9784d42a 100755 --- a/scripts/automation/trex_control_plane/stf/trex_daemon_server.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_daemon_server.py diff --git a/scripts/automation/trex_control_plane/stf/trex_exceptions.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_exceptions.py index 0de38411..0de38411 100755 --- a/scripts/automation/trex_control_plane/stf/trex_exceptions.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_exceptions.py diff --git a/scripts/automation/trex_control_plane/stf/trex_status.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status.py index f132720c..f132720c 100644 --- a/scripts/automation/trex_control_plane/stf/trex_status.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status.py diff --git a/scripts/automation/trex_control_plane/stf/trex_status_e.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status_e.py index 79a25acc..79a25acc 100755 --- a/scripts/automation/trex_control_plane/stf/trex_status_e.py +++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_status_e.py |