summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stf/examples
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-30 11:29:11 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-30 11:29:11 +0300
commitb91c216db1aa10ca7cc81b8c74b04ab79df251fe (patch)
treebd2184c2ea54c2e8d6554e082dd0b37e99a1e0e7 /scripts/automation/trex_control_plane/stf/examples
parent935b711d82845514c30249b8cdd2e9ed6aa11526 (diff)
add to run_functional_tests --python2 and --python3 flags
make stateful tree similar to stl : stf/trex_stf_lib and stf/examples change trex_client package: add profiles, use full stl dir. stl examples: now use stl_path.STL_PROFILES_PATH variable regression: add higher timeout to rsync.
Diffstat (limited to 'scripts/automation/trex_control_plane/stf/examples')
-rwxr-xr-xscripts/automation/trex_control_plane/stf/examples/stf_example.py53
-rwxr-xr-xscripts/automation/trex_control_plane/stf/examples/stf_path.py4
2 files changed, 57 insertions, 0 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, "../")