diff options
author | 2016-03-30 13:58:11 +0300 | |
---|---|---|
committer | 2016-03-30 13:58:11 +0300 | |
commit | 422c7c52632ebb6fbc5d5ff638b6ef0e1bc56f6b (patch) | |
tree | 5794318455a66a03828f98a5d6e825f47df3084e /scripts/automation/trex_control_plane/stf/examples/stf_example.py | |
parent | 2ec326cbe088f3ee5634336e326ae8c3561c7461 (diff) | |
parent | b91c216db1aa10ca7cc81b8c74b04ab79df251fe (diff) |
Merge GA to Python API
Diffstat (limited to 'scripts/automation/trex_control_plane/stf/examples/stf_example.py')
-rwxr-xr-x | scripts/automation/trex_control_plane/stf/examples/stf_example.py | 53 |
1 files changed, 53 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) + |