summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/hltapi_example.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/regression/hltapi_example.py')
-rwxr-xr-xscripts/automation/regression/hltapi_example.py69
1 files changed, 45 insertions, 24 deletions
diff --git a/scripts/automation/regression/hltapi_example.py b/scripts/automation/regression/hltapi_example.py
index 2a30d08c..0040219a 100755
--- a/scripts/automation/regression/hltapi_example.py
+++ b/scripts/automation/regression/hltapi_example.py
@@ -56,45 +56,66 @@ if __name__ == "__main__":
print('Connected.')
print('Create single_burst 100 packets rate_pps=100 on port 0')
- res = check_res(hlt_client.traffic_config('create', port_handle = port_handle[0], transmit_mode = 'single_burst', pkts_per_burst = 100, rate_pps = 100))
- save_streams_id(res, streams_id_arr)
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[0], transmit_mode = 'single_burst', pkts_per_burst = 100, rate_pps = 100))
+ #save_streams_id(res, streams_id_arr)
+
+ # playground - creating various streams on port 1
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[1], save_to_yaml = '/tmp/hlt2.yaml',
+ tcp_src_port_mode = 'decrement',
+ tcp_src_port_count = 10, tcp_dst_port_count = 10, tcp_dst_port_mode = 'random'))
+
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[1], save_to_yaml = '/tmp/hlt3.yaml',
+ l4_protocol = 'udp',
+ udp_src_port_mode = 'decrement',
+ udp_src_port_count = 10, udp_dst_port_count = 10, udp_dst_port_mode = 'random'))
+
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[1], save_to_yaml = '/tmp/hlt4.yaml',
+ length_mode = 'increment',
+ #ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5,
+ ip_dst_addr = '5.5.5.5', ip_dst_mode = 'random', ip_dst_count = 2))
+
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[1], save_to_yaml = '/tmp/hlt5.yaml',
+ length_mode = 'decrement', frame_size_min = 100, frame_size_max = 3000,
+ #ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5,
+ #ip_dst_addr = '5.5.5.5', ip_dst_mode = 'random', ip_dst_count = 2
+ ))
+ # remove the playground
+ check_res(hlt_client.traffic_config(mode = 'reset', port_handle = port_handle[1]))
print('Create continuous stream for port 1, rate_pps = 1')
- res = check_res(hlt_client.traffic_config('create', port_handle = port_handle[1]))
- save_streams_id(res, streams_id_arr)
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[1], save_to_yaml = '/tmp/hlt1.yaml',
+ #length_mode = 'increment', l3_length_min = 200,
+ ip_src_addr = '192.168.1.1', ip_src_mode = 'increment', ip_src_count = 5,
+ ip_dst_addr = '5.5.5.5', ip_dst_mode = 'random', ip_dst_count = 2))
- print('Run traffic on both ports for 20s')
- check_res(hlt_client.traffic_control(action = 'run', port_handle = port_handle, mul = {'type': 'raw', 'op': 'abs', 'value': 1}, duration = 20))
- wait_with_progress(5)
-
- print('All available HLT stats after 5s')
+ check_res(hlt_client.traffic_control(action = 'run', port_handle = port_handle))
+ wait_with_progress(1)
+ print('Sample after 1 seconds (only packets count)')
res = check_res(hlt_client.traffic_stats(mode = 'all', port_handle = port_handle))
- pprint(res)
+ print_brief_stats(res)
+ print ''
- # delete the single_burst
- print('Port 0 has finished the burst, delete it and put continuous with rate 1000. No stopping of other ports.')
- check_res(hlt_client.traffic_config('reset', port_handle = port_handle[0]))
- res = check_res(hlt_client.traffic_config('create', port_handle = port_handle[0], rate_pps = 1000))
+ print('Port 0 has finished the burst, put continuous instead with rate 1000. No stopping of other ports.')
+ check_res(hlt_client.traffic_control(action = 'stop', port_handle = port_handle[0]))
+ check_res(hlt_client.traffic_config(mode = 'reset', port_handle = port_handle[0]))
+ res = check_res(hlt_client.traffic_config(mode = 'create', port_handle = port_handle[0], rate_pps = 1000))
save_streams_id(res, streams_id_arr)
- check_res(hlt_client.traffic_control(action = 'run', port_handle = port_handle[0], mul = {'type': 'raw', 'op': 'abs', 'value': 1}, duration = 15))
+ check_res(hlt_client.traffic_control(action = 'run', port_handle = port_handle[0]))
wait_with_progress(5)
- print('Sample after another %s seconds (only packets count)' % 5)
+ print('Sample after another 5 seconds (only packets count)')
res = check_res(hlt_client.traffic_stats(mode = 'aggregate', port_handle = port_handle))
print_brief_stats(res)
-
- #print('Stop the traffic on port 1')
- #res = check_res(hlt_client.traffic_control('stop', port_handle = port_handle[1]))
- #wait_with_progress(sample_duration)
- #print('Sample after another %s seconds (only packets count)' % sample_duration)
- #res = check_res(hlt_client.traffic_stats(mode = 'all', port_handle = port_handle))
- #print_brief_stats(res)
+ print ''
print('Stop traffic at port 1')
- res = check_res(hlt_client.traffic_control('stop', port_handle = port_handle[1]))
+ res = check_res(hlt_client.traffic_control(action = 'stop', port_handle = port_handle[1]))
wait_with_progress(5)
print('Sample after another %s seconds (only packets count)' % 5)
res = check_res(hlt_client.traffic_stats(mode = 'aggregate', port_handle = port_handle))
print_brief_stats(res)
+ print ''
+ print('Full HLT stats:')
+ pprint(res)
check_res(hlt_client.cleanup_session())
except Exception as e: