diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index 69e03bee..8e2ecc6f 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -288,7 +288,7 @@ class LFRequest: print("----- Response: --------------------------------------------------------") LFUtils.debug_printer.pprint(myresponses[0].reason) print("------------------------------------------------------------------------") - if die_on_error_ == True: + if (error.code != 404) and (die_on_error_ == True): traceback.print_stack(limit=15) exit(1) except urllib.error.URLError as uerror: diff --git a/py-json/realm.py b/py-json/realm.py index 88ea650e..74a8197f 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -180,6 +180,8 @@ class Realm(LFCliBase): debug=debug_) def rm_port(self, port_eid, check_exists=True, debug_=False): + if port_eid is None: + raise ValueError("realm.rm_port: want a port eid like 1.1.eth1") debug_ |= self.debug req_url = "/cli-json/rm_vlan" eid = self.name_to_eid(port_eid) @@ -542,14 +544,14 @@ class Realm(LFCliBase): return LFUtils.name_to_eid(eid) def wait_for_ip(self, station_list=None, ipv4=True, ipv6=False, timeout_sec=360, debug=False): - if not (ipv4 ^ ipv6): - raise ValueError("wait_for_ip: ipv4 or ipv6 must be set!") + if not (ipv4 or ipv6): + raise ValueError("wait_for_ip: ipv4 and/or ipv6 must be set!") if timeout_sec >= 0: print("Waiting for ips, timeout: %i..." % timeout_sec) else: print("Determining wait time based on mean station association time of stations. " "Will not wait more that 60 seconds without single association") - stas_with_ips = [] + stas_with_ips = {} sec_elapsed = 0 time_extended = False # print(station_list) @@ -596,7 +598,7 @@ class Realm(LFCliBase): print("Waiting for port %s to get IPv4 Address." % (sta_eid)) else: if sta_eid not in stas_with_ips: - stas_with_ips.append(sta_eid) + stas_with_ips[sta_eid] = {'ipv4': v['ip']} if debug: print("Found IP: %s on port: %s" % (v['ip'], sta_eid)) @@ -606,7 +608,7 @@ class Realm(LFCliBase): if v['ipv6 address'] != 'DELETED' and not v['ipv6 address'].startswith('fe80') \ and v['ipv6 address'] != 'AUTO': if sta_eid not in stas_with_ips: - stas_with_ips.append(sta_eid) + stas_with_ips[sta_eid] = {'ipv6': v['ip']} if debug: print("Found IPv6: %s on port: %s" % (v['ipv6 address'], sta_eid)) else: diff --git a/py-json/vr_profile2.py b/py-json/vr_profile2.py index f2af73a0..a7760ea6 100644 --- a/py-json/vr_profile2.py +++ b/py-json/vr_profile2.py @@ -403,6 +403,16 @@ class VRProfile(BaseProfile): debug |= self.debug used_vrcx_area = self.get_occupied_area(resource=self.vr_eid[1], debug=debug) + def refresh_netsmith(self, resource=0, debug=False): + debug |= self.debug + if (resource is None) or (resource < 1): + raise ValueError("refresh_netsmith requires resource > 0") + + self.json_post("/cli-json/apply_vr_cfg", { + "shelf": 1, + "resource": resource + }, debug_=debug, suppress_related_commands_=True) + def create(self, vr_name=None, debug=False, diff --git a/py-scripts/.gitignore b/py-scripts/.gitignore new file mode 100644 index 00000000..74bc4406 --- /dev/null +++ b/py-scripts/.gitignore @@ -0,0 +1,2 @@ +regression_test.txt +regression_test.rc diff --git a/py-scripts/create_vr.py b/py-scripts/create_vr.py index b7f8bbd4..0623ccda 100755 --- a/py-scripts/create_vr.py +++ b/py-scripts/create_vr.py @@ -14,6 +14,7 @@ if sys.version_info[0] != 3: if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) from LANforge.lfcli_base import LFCliBase +from LANforge import LFUtils from realm import Realm import time from pprint import pprint @@ -76,6 +77,8 @@ class CreateVR(Realm): "resource": self.vr_name[1], "cx_name": "all" }, debug_=self.debug) + self.rm_port("1.1.rd90a", debug_=self.debug) + self.rm_port("1.1.rd90b", debug_=self.debug) def build(self): # self.redirect_profile @@ -117,11 +120,13 @@ class CreateVR(Realm): self.vr_profile.vrcx_list(resource=self.vr_name[1], do_refresh=True) vr_list = self.vr_profile.router_list(resource=self.vr_name[1], do_refresh=True) router = self.vr_profile.find_cached_router(resource=self.vr_name[1], router_name=self.vr_name[2]) - pprint(("cached router: ", router)) + pprint(("cached router 120: ", router)) + router_eid = LFUtils.name_to_eid(router) + pprint(("router eid 122: ", router_eid)) time.sleep(5) - full_router = self.json_get("/vr/1/%s/%s/%s" %(router, self.vr_name[2]), - debug_=True) + full_router = self.json_get("/vr/1/%s/%s/%s" %(router_eid[0], router_eid[1], self.vr_name[2]), debug_=True) pprint(("full router: ", full_router)) + time.sleep(5) if router is None: self._fail("Unable to find router after vrcx move "+self.vr_name) diff --git a/py-scripts/regression_test.rc.example b/py-scripts/regression_test.rc.example new file mode 100644 index 00000000..43a02160 --- /dev/null +++ b/py-scripts/regression_test.rc.example @@ -0,0 +1,17 @@ +# Example settings file for regression_test.sh # +# # +# Edit your own copy of regression_test.rc and regression # +# test.sh should use it. Please do not check in your # +# regression_test.rc file, That will break other people's settings. # +# # + +# Run tests against these AP credentials: +SSID_USED=ChickenNet +PASSWD_USED=ameliachicken +SECURITY=wpa3 + +# Point tests at this GUI: +MGR=localhost +MGR_PORT=8080 + +# diff --git a/py-scripts/regression_test.sh b/py-scripts/regression_test.sh index 018efb5c..f3971a62 100755 --- a/py-scripts/regression_test.sh +++ b/py-scripts/regression_test.sh @@ -6,25 +6,28 @@ HOMEPATH=$(realpath ~) NUM_STA=4 -FILESIZE1=$(echo ${#1}) -FILESIZE2=$(echo ${#2}) -if [[ $FILESIZE1 -gt 0 ]]; then - if [[ $FILESIZE2 -gt 0 ]]; then +if [[ ${#1} -gt 0 ]]; then + if [[ ${#2} -gt 0 ]]; then SSID_USED=$1 PASSWD_USED=$2 SECURITY=$3 MGR=$4 - FILENAME=$5 - mgrlen=$(echo ${#MGR}) - else + # FILENAME=$5 # this appears unused + elif [ -f "$1" ]; then source $1 + elif [ -f ./regression_test.rc ]; then + source ./regression_test.rc # this version is a better unix name + elif [ -f ./regression_test.txt ]; then + source ./regression_test.txt # this less unixy name was discussed earlier fi -else +else # these are jedway lab defaults SSID_USED="jedway-wpa2-x2048-5-3" PASSWD_USED="jedway-wpa2-x2048-5-3" SECURITY="wpa2" fi +mgrlen=$(echo ${#MGR}) RADIO_USED="wiphy0" +UPSTREAM_PORT="eth1" COL_NAMES="name,tx_bytes,rx_bytes,dropped" START_NUM=0 @@ -34,10 +37,20 @@ STOP_NUM=9 DATA_DIR="${TEST_DIR}" REPORT_DIR="${HOMEPATH}/html-reports" +if [ ! -d "$REPORT_DIR" ]; then + echo "Report directory [$REPORT_DIR] not found, bye." + exit 1 +fi +REPORT_DATA="${HOMEPATH}/report-data" +if [ ! -d "${REPORT_DATA}" ]; then + echo "Data directory [$REPORT_DATA] not found, bye." + exit 1 +fi +TEST_DIR="${REPORT_DATA}/${NOW}" #set -vex function run_l3_longevity { - ./test_l3_longevity.py --test_duration 15s --upstream_port eth1 --radio "radio==wiphy0 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --radio "radio==wiphy1 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" + ./test_l3_longevity.py --test_duration 15s --upstream_port $UPSTREAM_PORT --radio "radio==wiphy0 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --radio "radio==wiphy1 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" } function testgroup_list_groups { @@ -52,7 +65,7 @@ function testgroup_delete_group { #Test array if [[ $mgrlen -gt 0 ]]; then function run_l3_longevity { - ./test_l3_longevity.py --test_duration 15s --upstream_port eth1 --radio "radio==wiphy0 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --radio "radio==wiphy1 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --mgr $MGR + ./test_l3_longevity.py --test_duration 15s --upstream_port $UPSTREAM_PORT --radio "radio==wiphy0 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --radio "radio==wiphy1 stations==4 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY" --mgr $MGR } function testgroup_list_groups { @@ -67,7 +80,7 @@ if [[ $mgrlen -gt 0 ]]; then testCommands=( "./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug --mgr $MGR" "./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY --mgr $MGR" - #"./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --mgr $MGR" # Better tested on Kelly, where VRF is turned off + "./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --mgr $MGR" # Better tested on Kelly, where VRF is turned off "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --debug --mgr $MGR" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug --mgr $MGR" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug --mgr $MGR" @@ -76,14 +89,14 @@ if [[ $mgrlen -gt 0 ]]; then testgroup_list_groups testgroup_list_connections testgroup_delete_group - "./testgroup2.py --num_stations 4 --ssid lanforge --passwd password --security wpa2 --radio wiphy0 --group_name group0 --add_group --mgr $MGR" + #"./testgroup2.py --num_stations 4 --ssid lanforge --passwd password --security wpa2 --radio wiphy0 --group_name group0 --add_group --mgr $MGR" "./test_ipv4_connection.py --radio $RADIO_USED --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./test_ipv4_l4_urls_per_ten.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --num_tests 1 --requests_per_ten 600 --target_per_ten 600 --debug --mgr $MGR" "./test_ipv4_l4_wifi.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug --mgr $MGR" "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug --mgr $MGR" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format excel --layer3_cols $COL_NAMES --debug --mgr $MGR" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format csv --layer3_cols $COL_NAMES --debug --mgr $MGR" - "./test_ipv4_l4_ftp_upload.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug --mgr $MGR" + "./test_ipv4_l4_ftp_upload.py --upstream_port $UPSTREAM_PORT --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug --mgr $MGR" "./test_ipv6_connection.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./test_ipv6_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --cx_type tcp6 --debug --mgr $MGR" run_l3_longevity @@ -92,10 +105,10 @@ if [[ $mgrlen -gt 0 ]]; then "./test_status_msg.py --debug --mgr $MGR" #this is all which is needed to run #"./test_wanlink.py --debug --mgr $MGR" #"./ws_generic_monitor_test.py --mgr $MGR" - "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000 --debug --mgr $MGR" + "./create_bridge.py --radio wiphy1 --upstream_port $UPSTREAM_PORT --target_device sta0000 --debug --mgr $MGR" "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" - "./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug --mgr $MGR" + "./create_macvlan.py --radio wiphy1 --macvlan_parent $UPSTREAM_PORT --debug --mgr $MGR" "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR" "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $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 --mgr $MGR" @@ -111,7 +124,7 @@ else "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd 0123456789 --radio $RADIO_USED --security wep --debug" "./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3 --debug" "./sta_connect2.py --dut_ssid $SSID_USED --dut_passwd $PASSWD_USED --dut_security $SECURITY" - #"./test_fileio.py --macvlan_parent eth1 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1" # Better tested on Kelly, where VRF is turned off + "./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1" # Better tested on Kelly, where VRF is turned off "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --debug" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY --debug" "./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type iperf3 --debug" @@ -127,7 +140,7 @@ else "./test_ipv4_l4.py --radio $RADIO_USED --num_stations 4 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format excel --layer3_cols $COL_NAMES --debug" "./test_ipv4_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --output_format csv --layer3_cols $COL_NAMES --debug" - "./test_ipv4_l4_ftp_upload.py --upstream_port eth1 --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug" + "./test_ipv4_l4_ftp_upload.py --upstream_port $UPSTREAM_PORT --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug" "./test_ipv6_connection.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./test_ipv6_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --cx_type tcp6 --debug" run_l3_longevity @@ -137,10 +150,10 @@ else #"./test_wanlink.py --debug" #"./ws_generic_monitor_test.py" "../py-json/ws-sta-monitor.py --debug" - "./create_bridge.py --radio wiphy1 --upstream_port eth1 --target_device sta0000 --debug" + "./create_bridge.py --radio wiphy1 --upstream_port $UPSTREAM_PORT --target_device sta0000 --debug" "./create_l3.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./create_l4.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" - "./create_macvlan.py --radio wiphy1 --macvlan_parent eth1 --debug" + "./create_macvlan.py --radio wiphy1 --macvlan_parent $UPSTREAM_PORT --debug" "./create_station.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./create_vap.py --radio wiphy1 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug" "./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" @@ -220,12 +233,12 @@ function run_test() { if (( ${FILESIZE} > 0)); then results+=("