1. Fix circular import error in LFRequest

2. add import re to lfcli_base
3. add debug output to l3_cxprofile, so it is how it used to be
4. add help options to regression_test so we can test how the help flags are working
5. Make test_ip_variable_time work better when it is imported directly by moving most of the logic to a function under IPVariableTime
6. Add init.py file to the LANforge directory and fix archiving in the to_pip.py script

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-09-23 14:36:49 -07:00
parent de62fbd041
commit 65808d21fa
6 changed files with 319 additions and 178 deletions

View File

@@ -5,7 +5,7 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
import sys import sys
import os import os
import importlib import pprint
import urllib import urllib
from urllib import request from urllib import request
import json import json
@@ -17,8 +17,7 @@ if sys.version_info[0] != 3:
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../"))) sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
LFUtils = importlib.import_module("py-json.LANforge.LFUtils") debug_printer = pprint.PrettyPrinter(indent=2)
class LFRequest: class LFRequest:
Default_Base_URL = "http://localhost:8080" Default_Base_URL = "http://localhost:8080"
@@ -180,7 +179,7 @@ class LFRequest:
print("----- LFRequest::json_post:128 debug: --------------------------------------------") print("----- LFRequest::json_post:128 debug: --------------------------------------------")
print("URL: %s :%d "% (self.requested_url, resp.status)) print("URL: %s :%d "% (self.requested_url, resp.status))
if resp.status != 200: if resp.status != 200:
LFUtils.debug_printer.pprint(resp.getheaders()) debug_printer.pprint(resp.getheaders())
print("----- resp_data:128 -------------------------------------------------") print("----- resp_data:128 -------------------------------------------------")
print(resp_data) print(resp_data)
print("-------------------------------------------------") print("-------------------------------------------------")
@@ -191,7 +190,7 @@ class LFRequest:
j = json.loads(resp_data) j = json.loads(resp_data)
if debug: if debug:
print("----- LFRequest::json_post:140 debug: --------------------------------------------") print("----- LFRequest::json_post:140 debug: --------------------------------------------")
LFUtils.debug_printer.pprint(j) debug_printer.pprint(j)
print("-------------------------------------------------") print("-------------------------------------------------")
response_json_list_.append(j) response_json_list_.append(j)
return responses[0] return responses[0]
@@ -348,7 +347,7 @@ def plain_get(url_=None, debug_=False, die_on_error_=False, proxies_=None):
def print_diagnostics(url_=None, request_=None, responses_=None, error_=None, error_list_=None, debug_=False): def print_diagnostics(url_=None, request_=None, responses_=None, error_=None, error_list_=None, debug_=False):
if debug_: if debug_:
print("LFRequest::print_diagnostics: error_.__class__: %s"%error_.__class__) print("LFRequest::print_diagnostics: error_.__class__: %s"%error_.__class__)
LFUtils.debug_printer.pprint(error_) debug_printer.pprint(error_)
if url_ is None: if url_ is None:
print("WARNING LFRequest::print_diagnostics: url_ is None") print("WARNING LFRequest::print_diagnostics: url_ is None")
@@ -402,7 +401,7 @@ def print_diagnostics(url_=None, request_=None, responses_=None, error_=None, er
if hasattr(request_, "data") and (request_.data is not None): if hasattr(request_, "data") and (request_.data is not None):
print(" Data:") print(" Data:")
LFUtils.debug_printer.pprint(request_.data) debug_printer.pprint(request_.data)
elif debug_: elif debug_:
print(" <no request data>") print(" <no request data>")
@@ -414,7 +413,7 @@ def print_diagnostics(url_=None, request_=None, responses_=None, error_=None, er
if len(responses_) > 0: if len(responses_) > 0:
print("----- Response: --------------------------------------------------------") print("----- Response: --------------------------------------------------------")
LFUtils.debug_printer.pprint(responses_[0].reason) debug_printer.pprint(responses_[0].reason)
if debug_: if debug_:
print("------------------------------------------------------------------------") print("------------------------------------------------------------------------")
return return

View File

@@ -10,6 +10,7 @@ import random
import string import string
import datetime import datetime
import argparse import argparse
import re
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
print("This script requires Python 3") print("This script requires Python 3")

View File

@@ -14,10 +14,12 @@ Help()
echo "MGR is the IP address of the device which has LANforge installed, if different from the system you are using." echo "MGR is the IP address of the device which has LANforge installed, if different from the system you are using."
echo "A is used to call to test a specific command based on" echo "A is used to call to test a specific command based on"
echo "F is used to pass in an RC file which can store the credentials for running regression multiple times on your system" echo "F is used to pass in an RC file which can store the credentials for running regression multiple times on your system"
echo "H is used to test the help feature of each script, to make sure it renders properly."
echo "Example command: ./regression_test.sh -s SSID -p PASSWD -w SECURITY -m MGR" echo "Example command: ./regression_test.sh -s SSID -p PASSWD -w SECURITY -m MGR"
echo "If using the help flag, put the H flag at the end of the command after other flags."
} }
while getopts ":h:s:p:w:m:A:r:F:B:U:" option; do while getopts ":h:s:p:w:m:A:r:F:B:U:H:" option; do
case "${option}" in case "${option}" in
h) # display Help h) # display Help
Help Help
@@ -48,7 +50,10 @@ while getopts ":h:s:p:w:m:A:r:F:B:U:" option; do
BSSID=${OPTARG} BSSID=${OPTARG}
;; ;;
U) U)
UPSTREAM=$OPTARG UPSTREAM=${OPTARG}
;;
H)
HELP=1
;; ;;
*) *)
@@ -129,13 +134,107 @@ function testgroup_delete_group() {
./testgroup.py --group_name group1 --add_group --add_cx cx0000,cx0001,cx0002 --remove_cx cx0003 ./testgroup.py --group_name group1 --add_group --add_cx cx0000,cx0001,cx0002 --remove_cx cx0003
./testgroup.py --group_name group1--del_group --debug --mgr "$MGR" ./testgroup.py --group_name group1--del_group --debug --mgr "$MGR"
} }
if [[ $MGRLEN -gt 0 ]]; then if [[ $HELP -eq 1 ]]; then
testCommands=(
"./create_bond.py --help --mgr $MGR"
"./create_bridge.py --help --mgr $MGR"
"./create_chamberview.py --help -m $MGR"
"./create_chamberview_dut.py --help --lfmgr $MGR"
"./create_l3.py --help --mgr $MGR"
"./create_l4.py --help --mgr $MGR"
"./create_macvlan.py --help --mgr $MGR"
"./create_qvlan.py --help --mgr $MGR"
"./create_station.py --help --mgr $MGR"
"./create_vap.py --help --mgr $MGR"
"./create_vr.py --help --mgr $MGR"
"./create_wanlink.py --help --mgr $MGR"
"./csv_convert.py --help --mgr $MGR"
"./csv_processor.py --help --mgr $MGR"
"./csv_to_grafana.py --help --mgr $MGR"
"./csv_to_influx.py --help --mgr $MGR"
"./cv_manager.py --help --mgr $MGR"
"./cv_to_grafana.py --help --mgr $MGR"
"./docstrings.py --help --mgr $MGR"
"./event_breaker --help --mgr $MGR"
"./event_flood --help --mgr $MGR"
"./example_security_connection.py --help --mgr $MGR"
"./ftp_html.py --help --mgr $MGR"
"./ghost_profile.py --help --mgr $MGR"
"./grafana_profile.py --help --mgr $MGR"
"./html_template.py --help --mgr $MGR"
"./influx.py --help --mgr $MGR"
"./layer3_test.py --help --mgr $MGR"
"./layer4_test.py --help --mgr $MGR"
"./lf_ap_auto_test.py --help --mgr $MGR"
"./lf_atten_mod_test.py --help --mgr $MGR"
"./lf_csv.py --help --mgr $MGR"
"./lf_dataplane_config.py --help --mgr $MGR"
"./lf_dataplane_test.py --help --mgr $MGR"
"./lf_dfs_test.py --help --mgr $MGR"
"./lf_dut_sta_vap_test.py --help --mgr $MGR"
"./lf_ftp.py --help --mgr $MGR"
"./lf_ftp_test.py --help --mgr $MGR"
"./lf_graph.py --help --mgr $MGR"
"./lf_mesh_test.py --help --mgr $MGR"
"./lf_multipsk.py --help --mgr $MGR"
"./lf_report.py --help --mgr $MGR"
"./lf_report_test.py --help --mgr $MGR"
"./lf_rvr_test.py --help --mgr $MGR"
"./lf_rx_sensitivity_test.py --help --mgr $MGR"
"./lf_sniff_radio.py --help --mgr $MGR"
"./lf_snp_test.py -0-help --mgr $MGR"
"./lf_tr398_test.py --help --mgr $MGR"
"./lf_webpage.py --help --mgr $MGR"
"./lf_wifi_capacity_test.py --help --mgr $MGR"
"./measure_station_time_up.py --help --mgr $MGR"
"./modify_station.py --help --mgr $MGR"
"./modify_vap.py --help --mgr $MGR"
"./recordinflux.py --help --mgr $MGR"
"./run_cv_scenario.py --help --mgr $MGR"
"./rvr_scenario.py --help --mgr $MGR"
"./scenario.py --help --mgr $MGR"
"./sta_connect.py --help --mgr $MGR"
"./sta_connect2.py --help --mgr $MGR"
"./sta_connect_bssid_mac.py --help --mgr $MGR"
"./sta_connect_example.py --help --mgr $MGR"
"./sta_connect_multi_example.py --help --mgr $MGR"
"./sta_scan_test.py --help --mgr $MGR"
"./station_layer3.py --help --mgr $MGR"
"./stations_connected.py --help --mgr $MGR"
"./test_1k_clients_jedtest.py --help --mgr $MGR"
"./test_client_admission.py --help --mgr $MGR"
"./test_fileio.py --help --mgr $MGR"
"./test_generic.py --help --mgr $MGR"
"./test_ip_connection.py --help --mgr $MGR"
"./test_ip_variable_time.py --help --mgr $MGR"
"./test_ipv4_ps.py --help --mgr $MGR"
"./test_ipv4_ttls.py --help --mgr $MGR"
"./test_l3_WAN_LAN.py --help --mgr $MGR"
"./test_l3_longevity.py --help --mgr $MGR"
"./test_l3_scenario_throughput.py -h -m $MGR"
"./test_l3_unicast_traffic_gen.py --help --mgr $MGR"
"./test_l4.py --help --mgr $MGR"
"./test_status_msg.py --help --mgr $MGR"
"./test_wanlink.py --help --mgr $MGR"
"./test_wpa_passphrases.py --help --mgr $MGR"
"./testgroup.py --help --mgr $MGR"
"./testgroup2.py --help --mgr $MGR"
"./testgroup_delete_group --mgr $MGR"
"./testgroup_list_connections --help --mgr $MGR"
"./testgroup_list_groups.py --help --mgr $MGR"
"./tip_station_powersave.py --help --mgr $MGR"
"./video_rates.py --help --mgr $MGR"
"./wlan_capacity_calculator.py -h --mgr $MGR"
"./ws_generic_monitor_test.py --help --mgr $MGR"
)
elif [[ $MGRLEN -gt 0 ]]; then
testCommands=( testCommands=(
#"./create_bond.py --network_dev_list eth0,eth1 --debug --mgr $MGR" #"./create_bond.py --network_dev_list eth0,eth1 --debug --mgr $MGR"
#"./create_bridge.py --radio $RADIO_USED --upstream_port eth1 --target_device sta0000 --debug --mgr $MGR" #"./create_bridge.py --radio $RADIO_USED --upstream_port eth1 --target_device sta0000 --debug --mgr $MGR"
"./create_chamberview.py -m $MGR -cs \"regression_test\" --line \"Resource=1.1 Profile=STA-AC Amount=1 Uses-1 $RADIO_USED Freq=-1 DUT=TEST DUT_RADIO=$RADIO_USED Traffic=http\" --line \"Resource=1.1 Profile=upstream Amount=1 Uses-1=eth1 Uses-2=AUTO Freq=-1 DUT=Test DUT_RADIO=$RADIO_USED Traffic=http\"" "./create_chamberview.py -m $MGR -cs \"regression_test\" --line \"Resource=1.1 Profile=STA-AC Amount=1 Uses-1 $RADIO_USED Freq=-1 DUT=TEST DUT_RADIO=$RADIO_USED Traffic=http\" --line \"Resource=1.1 Profile=upstream Amount=1 Uses-1=eth1 Uses-2=AUTO Freq=-1 DUT=Test DUT_RADIO=$RADIO_USED Traffic=http\""
"./create_chamberview_dut.py --lfmgr $MGR --dut_name regression_dut --ssid \"ssid_idx=0 ssid=$SSID_USED security=$SECURITY password=$PASSWD_USED bssid=04:f0:21:2c:41:84\"" "./create_chamberview_dut.py --lfmgr $MGR --dut_name regression_dut \
#"./create_l3.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR" --ssid \"ssid_idx=0 ssid=\"$SSID_USED\" security=\"$SECURITY\" password=\"$PASSWD_USED\" bssid=04:f0:21:2c:41:84\""
"./create_l3.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
#"./create_l4.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR" #"./create_l4.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
#"./create_macvlan.py --radio 1.$RADIO_USED --macvlan_parent eth1 --debug --mgr $MGR" #"./create_macvlan.py --radio 1.$RADIO_USED --macvlan_parent eth1 --debug --mgr $MGR"
#"./create_qvlan.py --first_qvlan_ip 192.168.1.50 --mgr $MGR" #"./create_qvlan.py --first_qvlan_ip 192.168.1.50 --mgr $MGR"
@@ -152,7 +251,8 @@ if [[ $MGRLEN -gt 0 ]]; then
#"./docstrings.py --mgr $MGR" #"./docstrings.py --mgr $MGR"
#"./event_breaker --mgr $MGR" #"./event_breaker --mgr $MGR"
#"./event_flood --mgr $MGR" #"./event_flood --mgr $MGR"
"./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug --mgr $MGR" "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED \
--passwd $PASSWD_USED --radio 1.1.$RADIO_USED --security wpa2 --debug --mgr $MGR"
#./ftp_html.py #./ftp_html.py
#./ghost_profile #./ghost_profile
#./grafana_profile #./grafana_profile
@@ -182,10 +282,6 @@ if [[ $MGRLEN -gt 0 ]]; then
--instance_name dataplane-instance --config_name test_con --upstream 1.1.$UPSTREAM \ --instance_name dataplane-instance --config_name test_con --upstream 1.1.$UPSTREAM \
--dut linksys-8450 --duration 15s --station 1.1.sta01500 \ --dut linksys-8450 --duration 15s --station 1.1.sta01500 \
--download_speed 85% --upload_speed 0 \ --download_speed 85% --upload_speed 0 \
--raw_line \"pkts: Custom;60;142;256;512;1024;MTU\" \
--raw_line \"cust_pkt_sz: 88 1200\" \
--raw_line \"directions: DUT Transmit;DUT Receive\" \
--raw_line \"traffic_types: UDP;TCP\" \
--test_rig Testbed-01 --pull_report \ --test_rig Testbed-01 --pull_report \
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \ --influx_host c7-graphana --influx_port 8086 --influx_org Candela \
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \ --influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
@@ -195,7 +291,7 @@ if [[ $MGRLEN -gt 0 ]]; then
#./lf_dut_sta_vap_test #./lf_dut_sta_vap_test
#"./lf_ftp.py --mgr $MGR --mgr_port 8080 --upstream_port $UPSTREAM --ssid $SSID --security $SECURITY --passwd $PASSWD_USED \ #"./lf_ftp.py --mgr $MGR --mgr_port 8080 --upstream_port $UPSTREAM --ssid $SSID --security $SECURITY --passwd $PASSWD_USED \
# --ap_name WAC505 --ap_ip 192.168.213.90 --bands Both --directions Download --twog_radio wiphy1 --fiveg_radio wiphy0 --file_size 2MB --num_stations 40 --Both_duration 1 --traffic_duration 2 --ssh_port 22_" # --ap_name WAC505 --ap_ip 192.168.213.90 --bands Both --directions Download --twog_radio wiphy1 --fiveg_radio wiphy0 --file_size 2MB --num_stations 40 --Both_duration 1 --traffic_duration 2 --ssh_port 22_"
"./lf_ftp_test.py --mgr $MGR --ssid $SSID --passwd $PASSWD_USED --security $SECURITY --bands 5G --direction Download \ "./lf_ftp_test.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --bands 5G --direction Download \
--file_size 2MB --num_stations 2" --file_size 2MB --num_stations 2"
"./lf_graph.py --mgr $MGR" "./lf_graph.py --mgr $MGR"
#"./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID'" #"./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID'"
@@ -210,8 +306,8 @@ if [[ $MGRLEN -gt 0 ]]; then
#./lf_webpage #./lf_webpage
"./lf_wifi_capacity_test.py --mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \ "./lf_wifi_capacity_test.py --mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \
--instance_name this_inst --config_name test_con --upstream 1.1.eth2 --batch_size 1,5,25,50,100 --loop_iter 1 \ --instance_name this_inst --config_name test_con --upstream 1.1.eth2 --batch_size 1,5,25,50,100 --loop_iter 1 \
--protocol UDP-IPv4 --duration 6000 --pull_report \ --protocol UDP-IPv4 --duration 6000 --pull_report --ssid $SSID_USED --paswd $PASSWD_USED --security $SECURITY\
--test_rig Testbed-01" --test_rig Testbed-01 --create_stations --stations 1.1.sta0000,1.1.sta0001"
#--influx_host c7-graphana --influx_port 8086 --influx_org Candela \ #--influx_host c7-graphana --influx_port 8086 --influx_org Candela \
#--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \ #--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
#--influx_bucket ben \ #--influx_bucket ben \
@@ -266,7 +362,6 @@ if [[ $MGRLEN -gt 0 ]]; then
#"./test_wanlink.py --name my_wanlink4 --latency_A 20 --latency_B 69 --rate 1000 --jitter_A 53 --jitter_B 73 --jitter_freq 6 --drop_A 12 --drop_B 11 --debug --mgr $MGR" #"./test_wanlink.py --name my_wanlink4 --latency_A 20 --latency_B 69 --rate 1000 --jitter_A 53 --jitter_B 73 --jitter_freq 6 --drop_A 12 --drop_B 11 --debug --mgr $MGR"
#./test_wpa_passphrases #./test_wpa_passphrases
#./tip_station_powersave #./tip_station_powersave
#./vap_stations_example
#./video_rates #./video_rates
"./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes -m $MGR" "./wlan_capacity_calculator.py -sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes -m $MGR"
"./wlan_capacity_calculator.py -sta 11n -t Voice -d 17 -ch 40 -gu 800 -high 9 -e WEP -q Yes -ip 5 -mc 42 -b 6 9 12 24 -m 1538 -co G.729 -pl Greenfield -cw 15 -r Yes -c Yes -m $MGR" "./wlan_capacity_calculator.py -sta 11n -t Voice -d 17 -ch 40 -gu 800 -high 9 -e WEP -q Yes -ip 5 -mc 42 -b 6 9 12 24 -m 1538 -co G.729 -pl Greenfield -cw 15 -r Yes -c Yes -m $MGR"
@@ -463,11 +558,13 @@ function test() {
chmod 664 "${TEST_DIR}/${NAME}.txt" chmod 664 "${TEST_DIR}/${NAME}.txt"
FILESIZE=$(stat -c%s "${TEST_DIR}/${NAME}_stderr.txt") || 0 FILESIZE=$(stat -c%s "${TEST_DIR}/${NAME}_stderr.txt") || 0
if (( FILESIZE > 0)); then if (( FILESIZE > 0)); then
echo "Errors detected"
results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td> results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td>
<td class='failure'>Failure</td> <td class='failure'>Failure</td>
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td> <td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>
<td><a href=\"${URL2}/${NAME}_stderr.txt\" target=\"_blank\">STDERR</a></td></tr>") <td><a href=\"${URL2}/${NAME}_stderr.txt\" target=\"_blank\">STDERR</a></td></tr>")
else else
echo "No errors detected"
results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td> results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td>
<td class='success'>Success</td> <td class='success'>Success</td>
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td> <td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>

View File

@@ -33,7 +33,6 @@ if sys.version_info[0] != 3:
print("This script requires Python 3") print("This script requires Python 3")
exit(1) exit(1)
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
LFUtils = importlib.import_module("py-json.LANforge.LFUtils") LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
@@ -56,11 +55,21 @@ class IPVariableTime(Realm):
mode=0, mode=0,
ap=None, ap=None,
traffic_type=None, traffic_type=None,
side_a_min_rate=56, side_a_max_rate=0, side_a_min_rate=256000, side_a_max_rate=0,
side_b_min_rate=56, side_b_max_rate=0, side_b_min_rate=256000, side_b_max_rate=0,
number_template="00000", number_template="00000",
test_duration="5m", test_duration="5m",
use_ht160=False, use_ht160=False,
report_file=None,
output_format=None,
layer3_cols=['name', 'tx bytes', 'rx bytes', 'tx rate', 'rx rate'],
monitor_interval='10s',
influx_host=None,
influx_port=None,
influx_org=None,
influx_token=None,
influx_bucket=None,
compared_report=None,
ipv6=False, ipv6=False,
_debug_on=False, _debug_on=False,
_exit_on_error=False, _exit_on_error=False,
@@ -109,6 +118,16 @@ class IPVariableTime(Realm):
self.cx_profile.host = self.host self.cx_profile.host = self.host
self.cx_profile.port = self.port self.cx_profile.port = self.port
self.ipv6 = ipv6 self.ipv6 = ipv6
self.report_file = report_file
self.output_format = output_format
self.layer3_cols = layer3_cols
self.monitor_interval = monitor_interval
self.influx_host = influx_host
self.influx_port = influx_port
self.influx_org = influx_org
self.influx_token = influx_token
self.influx_bucket = influx_bucket
self.compared_report = compared_report
self.cx_profile.name_prefix = self.name_prefix self.cx_profile.name_prefix = self.name_prefix
self.cx_profile.side_a_min_bps = side_a_min_rate self.cx_profile.side_a_min_bps = side_a_min_rate
self.cx_profile.side_a_max_bps = side_a_max_rate self.cx_profile.side_a_max_bps = side_a_max_rate
@@ -161,6 +180,144 @@ class IPVariableTime(Realm):
side_b=self.upstream, side_b=self.upstream,
sleep_time=0) sleep_time=0)
def run(self):
if self.report_file is None:
new_file_path = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-h-%M-m-%S-s")).replace(':',
'-') + '_test_ip_variable_time' # create path name
try:
path = os.path.join('/home/lanforge/report-data/', new_file_path)
os.mkdir(path)
except:
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path = os.path.join(curr_dir_path, new_file_path)
os.mkdir(path)
systeminfopath = str(path) + '/systeminfo.txt'
if self.output_format in ['csv', 'json', 'html', 'hdf', 'stata', 'pickle', 'pdf', 'png', 'parquet',
'xlsx']:
report_f = str(path) + '/data.' + self.output_format
output = self.output_format
else:
print(
'Not supporting this report format or cannot find report format provided. Defaulting to csv data file '
'output type, naming it data.csv.')
report_f = str(path) + '/data.csv'
output = 'csv'
else:
systeminfopath = str(self.report_file).split('/')[-1]
report_f = self.report_file
if self.output_format is None:
output = str(self.report_file).split('.')[-1]
else:
output = self.output_format
self.pre_cleanup()
self.build()
# exit()
if self.create_sta:
if not self.passes():
print(self.get_fail_message())
self.exit_fail()
try:
layer3connections = ','.join([[*x.keys()][0] for x in self.json_get('endp')['endpoint']])
except:
raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port')
if type(self.layer3_cols) is not list:
layer3_cols = list(self.layer3_cols.split(","))
# send col names here to file to reformat
else:
layer3_cols = self.layer3_cols
# send col names here to file to reformat
#if type(self.port_mgr_cols) is not list:
#port_mgr_cols = list(self.port_mgr_cols.split(","))
# send col names here to file to reformat
#else:
#port_mgr_cols = self.port_mgr_cols
# send col names here to file to reformat
if self.debug:
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
#print(port_mgr_cols)
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
#print(port_mgr_cols)
try:
monitor_interval = Realm.parse_time(self.monitor_interval).total_seconds()
except ValueError as error:
print(str(error))
print(ValueError(
"The time string provided for monitor_interval argument is invalid. Please see supported time stamp increments and inputs for monitor_interval in --help. "))
exit(1)
self.start(False, False)
# if self.influx_mgr is None:
# manager = self.mgr
# else:
# manager = self.influx_mgr
if self.influx_org is not None:
from InfluxRequest import RecordInflux
grapher = RecordInflux(_influx_host=self.influx_host,
_influx_port=self.influx_port,
_influx_org=self.influx_org,
_influx_token=self.influx_token,
_influx_bucket=self.influx_bucket)
devices = [station.split('.')[-1] for station in station_list]
tags = dict()
tags['script'] = 'test_ip_variable_time'
try:
for k in self.influx_tag:
tags[k[0]] = k[1]
except:
pass
grapher.monitor_port_data(longevity=Realm.parse_time(self.test_duration).total_seconds(),
devices=devices,
monitor_interval=Realm.parse_time(self.monitor_interval).total_seconds(),
tags=tags)
# Retrieve last data file
compared_rept = None
if self.compared_report:
compared_report_format = self.compared_report.split('.')[-1]
# if compared_report_format not in ['csv', 'json', 'dta', 'pkl','html','xlsx','parquet','h5']:
if compared_report_format != 'csv':
print(ValueError("Cannot process this file type. Please select a different file and re-run script."))
exit(1)
else:
compared_rept = self.compared_report
self.cx_profile.monitor(layer3_cols=layer3_cols,
sta_list=self.sta_list,
# port_mgr_cols=port_mgr_cols,
report_file=report_f,
systeminfopath=systeminfopath,
duration_sec=Realm.parse_time(self.test_duration).total_seconds(),
monitor_interval_ms=monitor_interval,
created_cx=layer3connections,
output_format=output,
compared_report=compared_rept,
script_name='test_ip_variable_time',
debug=self.debug)
self.stop()
if self.create_sta:
if not self.passes():
print(self.get_fail_message())
self.exit_fail()
LFUtils.wait_until_ports_admin_up(port_list=self.sta_list)
if self.passes():
self.success()
self.cleanup()
print("IP Variable Time Test Report Data: {}".format(report_f))
def main(): def main():
parser = Realm.create_basic_argparse( parser = Realm.create_basic_argparse(
@@ -324,62 +481,18 @@ python3 ./test_ip_variable_time.py
num_sta = 2 num_sta = 2
if (args.num_stations is not None) and (int(args.num_stations) > 0): if (args.num_stations is not None) and (int(args.num_stations) > 0):
num_sta = int(args.num_stations) num_sta = int(args.num_stations)
if args.create_sta:
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1,
padding_number_=10000,
radio=args.radio)
else:
station_list = args.sta_names.split(",")
# Create directory # Create directory
# if file path with output file extension is not given... # if file path with output file extension is not given...
# check if home/lanforge/report-data exists. if not, save # check if home/lanforge/report-data exists. if not, save
# in new folder based in current file's directory # in new folder based in current file's directory
if args.report_file is None:
new_file_path = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-h-%M-m-%S-s")).replace(':',
'-') + '_test_ip_variable_time' # create path name
try:
path = os.path.join('/home/lanforge/report-data/', new_file_path)
os.mkdir(path)
except:
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path = os.path.join(curr_dir_path, new_file_path)
os.mkdir(path)
systeminfopath = str(path) + '/systeminfo.txt'
if args.output_format in ['csv', 'json', 'html', 'hdf', 'stata', 'pickle', 'pdf', 'png', 'parquet',
'xlsx']:
report_f = str(path) + '/data.' + args.output_format
output = args.output_format
else:
print(
'Not supporting this report format or cannot find report format provided. Defaulting to csv data file '
'output type, naming it data.csv.')
report_f = str(path) + '/data.csv'
output = 'csv'
else:
systeminfopath = str(args.report_file).split('/')[-1]
report_f = args.report_file
if args.output_format is None:
output = str(args.report_file).split('.')[-1]
else:
output = args.output_format
print("IP Test Report Data: {}".format(report_f))
# Retrieve last data file
compared_rept = None
if args.compared_report:
compared_report_format = args.compared_report.split('.')[-1]
# if compared_report_format not in ['csv', 'json', 'dta', 'pkl','html','xlsx','parquet','h5']:
if compared_report_format != 'csv':
print(ValueError("Cannot process this file type. Please select a different file and re-run script."))
exit(1)
else:
compared_rept = args.compared_report
if create_sta:
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000,
radio=args.radio)
else:
station_list = args.sta_names.split(",")
CX_TYPES = ("tcp", "udp", "lf_tcp", "lf_udp") CX_TYPES = ("tcp", "udp", "lf_tcp", "lf_udp")
if (args.traffic_type is None) or (args.traffic_type not in CX_TYPES): if (args.traffic_type is None) or (args.traffic_type not in CX_TYPES):
@@ -414,106 +527,21 @@ python3 ./test_ip_variable_time.py
side_b_min_rate=args.b_min, side_b_min_rate=args.b_min,
mode=args.mode, mode=args.mode,
ap=args.ap, ap=args.ap,
report_file=args.report_file,
output_format=args.output_format,
layer3_cols=args.layer3_cols,
monitor_interval=args.monitor_interval,
influx_host=args.influx_host,
influx_port=args.influx_port,
influx_org=args.influx_org,
influx_token=args.influx_token,
influx_bucket=args.influx_bucket,
compared_report=args.compared_report,
ipv6=args.ipv6, ipv6=args.ipv6,
traffic_type=args.traffic_type, traffic_type=args.traffic_type,
_debug_on=args.debug) _debug_on=args.debug)
ip_var_test.pre_cleanup() ip_var_test.run()
ip_var_test.build()
# exit()
if create_sta:
if not ip_var_test.passes():
print(ip_var_test.get_fail_message())
ip_var_test.exit_fail()
try:
layer3connections = ','.join([[*x.keys()][0] for x in ip_var_test.json_get('endp')['endpoint']])
except:
raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port')
if type(args.layer3_cols) is not list:
layer3_cols = list(args.layer3_cols.split(","))
# send col names here to file to reformat
else:
layer3_cols = args.layer3_cols
# send col names here to file to reformat
if type(args.port_mgr_cols) is not list:
port_mgr_cols = list(args.port_mgr_cols.split(","))
# send col names here to file to reformat
else:
port_mgr_cols = args.port_mgr_cols
# send col names here to file to reformat
if args.debug:
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
print(port_mgr_cols)
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
print(port_mgr_cols)
try:
monitor_interval = Realm.parse_time(args.monitor_interval).total_seconds()
except ValueError as error:
print(str(error))
print(ValueError(
"The time string provided for monitor_interval argument is invalid. Please see supported time stamp increments and inputs for monitor_interval in --help. "))
exit(1)
ip_var_test.start(False, False)
# if args.influx_mgr is None:
# manager = args.mgr
# else:
# manager = args.influx_mgr
if args.influx_org is not None:
from InfluxRequest import RecordInflux
grapher = RecordInflux(_influx_host=args.influx_host,
_influx_port=args.influx_port,
_influx_org=args.influx_org,
_influx_token=args.influx_token,
_influx_bucket=args.influx_bucket)
devices = [station.split('.')[-1] for station in station_list]
tags = dict()
tags['script'] = 'test_ip_variable_time'
try:
for k in args.influx_tag:
tags[k[0]] = k[1]
except:
pass
grapher.monitor_port_data(longevity=Realm.parse_time(args.test_duration).total_seconds(),
devices=devices,
monitor_interval=Realm.parse_time(args.monitor_interval).total_seconds(),
tags=tags)
ip_var_test.cx_profile.monitor(layer3_cols=layer3_cols,
sta_list=station_list,
# port_mgr_cols=port_mgr_cols,
report_file=report_f,
systeminfopath=systeminfopath,
duration_sec=Realm.parse_time(args.test_duration).total_seconds(),
monitor_interval_ms=monitor_interval,
created_cx=layer3connections,
output_format=output,
compared_report=compared_rept,
script_name='test_ip_variable_time',
arguments=args,
debug=args.debug)
ip_var_test.stop()
if create_sta:
if not ip_var_test.passes():
print(ip_var_test.get_fail_message())
ip_var_test.exit_fail()
LFUtils.wait_until_ports_admin_up(port_list=station_list)
if ip_var_test.passes():
ip_var_test.success()
ip_var_test.cleanup()
print("IP Variable Time Test Report Data: {}".format(report_f))
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -8,8 +8,15 @@ Help()
echo "ip_var=lanforge_scripts.IPVariableTime(host='192.168.1.239',port='8080',radio='wiphy0',sta_list=['1.1.sta0000','1.1.sta0001'],ssid='lanforge',password='password',security='wpa2',upstream='eth1',name_prefix='VT',traffic_type='lf_udp',_debug_on=True)" echo "ip_var=lanforge_scripts.IPVariableTime(host='192.168.1.239',port='8080',radio='wiphy0',sta_list=['1.1.sta0000','1.1.sta0001'],ssid='lanforge',password='password',security='wpa2',upstream='eth1',name_prefix='VT',traffic_type='lf_udp',_debug_on=True)"
echo "ip_var.build()" echo "ip_var.build()"
echo "ip_var.start(False,False)" echo "ip_var.start(False,False)"
echo ""
echo "EXPORT TO TAR FILE"
echo "./to_pip.sh -a -t TARGET_DIR"
echo "The 't' flag tells to_pip where to store the tar file, -a tells it to make a tar file."
} }
ARCHIVE=0
TARGET_DIR='..'
while getopts ":h:a:t:" option; do while getopts ":h:a:t:" option; do
case "${option}" in case "${option}" in
h) #display help h) #display help
@@ -357,6 +364,14 @@ sed -i -- 's/from create_station/from ..py_scripts.create_station/g' *.py
sed -i -- 's/from cv_test_reports/from .cv_test_reports/g' *.py sed -i -- 's/from cv_test_reports/from .cv_test_reports/g' *.py
cd LANforge cd LANforge
echo "
from .add_dut import dut_params, dut_flags
from .add_file_endp import fe_fstype, fe_payload_list, fe_fio_flags, fe_base_endpoint_types
from .lf_json_autogen import LFJsonGet, LFJsonPost
from .lfcli_base import LFCliBase
from .LFRequest import LFRequest
from .LFUtils import *
from .pandas_extensions import pandas_extensions" > __init__.py
sed -i -- 's/from LFRequest import LFRequest/from .LFRequest import LFRequest/g' *.py sed -i -- 's/from LFRequest import LFRequest/from .LFRequest import LFRequest/g' *.py
sed -i -- 's/from LFRequest/from .LFRequest/g' *.py sed -i -- 's/from LFRequest/from .LFRequest/g' *.py
sed -i -- 's/from LANforge import LFRequest/import .LFRequest/g' LFUtils.py sed -i -- 's/from LANforge import LFRequest/import .LFRequest/g' LFUtils.py
@@ -382,11 +397,12 @@ sed -i -- 's/GrafanaRequest = importlib.import_module("py-dashboard.GrafanaReque
sed -i -- 's/InfluxRequest = importlib.import_module("py-dashboard.InfluxRequest")/from .InfluxRequest import RecordInflux/g' *.py sed -i -- 's/InfluxRequest = importlib.import_module("py-dashboard.InfluxRequest")/from .InfluxRequest import RecordInflux/g' *.py
sed -i -- 's/RecordInflux = InfluxRequest.RecordInflux/ /g' *.py sed -i -- 's/RecordInflux = InfluxRequest.RecordInflux/ /g' *.py
if [[ ${ARCHIVE} -eq 0 ]]; then echo "${ARCHIVE}"
Archive() if [[ $ARCHIVE -eq 1 ]]; then
{ echo "Saving archive to ${TARGET_DIR}"
cd ../.. cd ../
tar cvzf lanforge_scripts.tar.gz ${TARGET_DIR} tar cvzf ${TARGET_DIR}/lanforge_scripts.tar.gz .
zip lanforge_scripts.zip ${TARGET_DIR} zip ${TARGET_DIR}/lanforge_scripts.zip .
} else
echo "Not saving archive"
fi fi