mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
vap-profile: Improve logging and use some base class code.
More changes all around regression test logic related to the vap profile. Move some open-coded admin_up/admin_down calls to base class. regression test takes the .rc file as primary input, and cmd-line args will override that. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -183,12 +183,12 @@ def port_dhcp_up_request(resource_id, port_name, debug_on=False):
|
||||
logger.debug(debug_printer.pformat(data))
|
||||
return data
|
||||
|
||||
|
||||
# Return json request object, does not actually attempt to admin up a port
|
||||
def portUpRequest(resource_id, port_name, debug_on=False):
|
||||
return port_up_request(resource_id, port_name, debug_on)
|
||||
return port_up_request(resource_id, port_name, debug_on=debug_on)
|
||||
|
||||
|
||||
# port_name cannot be in eid syntax in this method at this time.
|
||||
# Return json request object, does not actually attempt to admin up a port
|
||||
def port_up_request(resource_id, port_name, debug_on=False):
|
||||
"""
|
||||
See http://localhost:8080/help/set_port
|
||||
@@ -197,6 +197,13 @@ def port_up_request(resource_id, port_name, debug_on=False):
|
||||
:param port_name:
|
||||
:return:
|
||||
"""
|
||||
|
||||
if port_name:
|
||||
eid = name_to_eid(port_name)
|
||||
if resource_id == None:
|
||||
resource_id = eid[1];
|
||||
port_name = eid[2]
|
||||
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": resource_id,
|
||||
@@ -624,7 +631,7 @@ def wait_until_ports_disappear(base_url="http://localhost:8080", port_list=(), d
|
||||
remove_port(port[1], port[2], base_url)
|
||||
sleep(1) # check for ports once per second
|
||||
|
||||
logger.critical('%s stations were still found' % found_stations)
|
||||
logger.critical('%s ports were still found' % found_stations)
|
||||
return False
|
||||
|
||||
|
||||
@@ -705,7 +712,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu
|
||||
if debug:
|
||||
logger.debug("Waiting until ports appear...")
|
||||
existing_stations = LFRequest.LFRequest(base_url, '/ports', debug_=debug)
|
||||
logger.debug('existing stations')
|
||||
# logger.debug('existing ports')
|
||||
# logger.debug(pprint.pformat(existing_stations)) # useless
|
||||
port_url = "/port/1"
|
||||
show_url = "/cli-json/show_ports"
|
||||
@@ -748,13 +755,13 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu
|
||||
lf_r.jsonPost()
|
||||
if len(found_stations) < len(port_list):
|
||||
sleep(2)
|
||||
logger.info('Found %s out of %s stations in %s out of %s tries in wait_until_ports_appear' % (len(found_stations), len(port_list), attempt, timeout/2))
|
||||
logger.info('Found %s out of %s ports in %s out of %s tries in wait_until_ports_appear' % (len(found_stations), len(port_list), attempt, timeout/2))
|
||||
else:
|
||||
logger.info('All %s stations appeared' % len(found_stations))
|
||||
logger.info('All %s ports appeared' % len(found_stations))
|
||||
return True
|
||||
if debug:
|
||||
logger.debug("These stations appeared: " + ", ".join(found_stations))
|
||||
logger.debug("These stations did not appear: " + ",".join(set(port_list) - set(found_stations)))
|
||||
logger.debug("These ports appeared: " + ", ".join(found_stations))
|
||||
logger.debug("These ports did not appear: " + ",".join(set(port_list) - set(found_stations)))
|
||||
logger.debug(pprint.pformat(LFRequest.LFRequest("%s/ports" % base_url)))
|
||||
return False
|
||||
|
||||
|
||||
@@ -266,10 +266,11 @@ class Realm(LFCliBase):
|
||||
# logger.info("192.admin_up request: resource: %s port_name %s"%(resource, port))
|
||||
dbg_param = ""
|
||||
if logger.getEffectiveLevel() == logging.DEBUG:
|
||||
#logger.info("enabling url debugging")
|
||||
dbg_param = "?__debug=1"
|
||||
collected_responses = list()
|
||||
self.json_post("/cli-json/set_port%s" % dbg_param, request, debug_=self.debug,
|
||||
response_json_list_=collected_responses)
|
||||
response_json_list_=collected_responses)
|
||||
# TODO: when doing admin-up ath10k radios, want a LF complaint about a license exception
|
||||
# if len(collected_responses) > 0: ...
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ import sys
|
||||
import os
|
||||
import importlib
|
||||
from pprint import pprint
|
||||
from pprint import pformat
|
||||
import time
|
||||
import logging
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
@@ -13,7 +15,7 @@ LFRequest = importlib.import_module("py-json.LANforge.LFRequest")
|
||||
add_vap = importlib.import_module("py-json.LANforge.add_vap")
|
||||
set_port = importlib.import_module("py-json.LANforge.set_port")
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class VAPProfile(LFCliBase):
|
||||
def __init__(self, lfclient_host, lfclient_port, local_realm,
|
||||
@@ -93,21 +95,14 @@ class VAPProfile(LFCliBase):
|
||||
self.wifi_extra_data["domain"] = domain
|
||||
self.wifi_extra_data["hessid"] = hessid
|
||||
|
||||
# TODO: remove 'resource' so we can just use EIDs
|
||||
def admin_up(self, resource):
|
||||
set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug)
|
||||
req_json = LFUtils.portUpRequest(resource, None, debug_on=self.debug)
|
||||
req_json["port"] = LFUtils.name_to_eid(self.vap_name)[2]
|
||||
set_port_r.addPostData(req_json)
|
||||
set_port_r.jsonPost(self.debug)
|
||||
time.sleep(0.03)
|
||||
eid = "%s.%s.%s" % (1, resource, LFUtils.name_to_eid(self.vap_name)[2])
|
||||
self.local_realm.admin_up(eid)
|
||||
|
||||
def admin_down(self, resource):
|
||||
set_port_r = LFRequest.LFRequest(self.lfclient_url, "/cli-json/set_port", debug_=self.debug)
|
||||
req_json = LFUtils.port_down_request(resource, None, debug_on=self.debug)
|
||||
req_json["port"] = LFUtils.name_to_eid(self.vap_name)[2]
|
||||
set_port_r.addPostData(req_json)
|
||||
set_port_r.jsonPost(self.debug)
|
||||
time.sleep(0.03)
|
||||
eid = "%s.%s.%s" % (1, resource, LFUtils.name_to_eid(self.vap_name)[2])
|
||||
self.local_realm.admin_down(eid)
|
||||
|
||||
def use_security(self, security_type, ssid=None, passwd=None):
|
||||
types = {"wep": "wep_enable", "wpa": "wpa_enable", "wpa2": "wpa2_enable", "wpa3": "use-wpa3", "open": "[BLANK]"}
|
||||
|
||||
@@ -46,8 +46,7 @@ class CreateVAP(Realm):
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False,
|
||||
_dhcp=True):
|
||||
super().__init__(_host,
|
||||
_port)
|
||||
super().__init__(_host, _port, debug_=_debug_on)
|
||||
self.host = _host
|
||||
self.port = _port
|
||||
self.ssid = _ssid
|
||||
@@ -91,7 +90,7 @@ class CreateVAP(Realm):
|
||||
self.vap_profile.use_security(
|
||||
self.security, self.ssid, passwd=self.password)
|
||||
|
||||
print("Creating VAPs")
|
||||
logger.info("Creating VAPs")
|
||||
# TODO: Add cmd line arguments to control the various options of the VAP profile.
|
||||
if self.vap_profile.create(resource=self.resource,
|
||||
radio=self.radio,
|
||||
@@ -195,7 +194,7 @@ Command example:
|
||||
_country_code=args.country_code,
|
||||
_proxy_str=args.proxy,
|
||||
_debug_on=args.debug)
|
||||
print('Creating VAP')
|
||||
logger.info('Creating VAP')
|
||||
if create_vap.build():
|
||||
create_vap._pass("VAP %s created." % (vap))
|
||||
else:
|
||||
@@ -217,7 +216,7 @@ Command example:
|
||||
_country_code=args.country_code,
|
||||
_proxy_str=args.proxy,
|
||||
_debug_on=args.debug)
|
||||
print('Creating VAP')
|
||||
logger.info('Creating VAP')
|
||||
if create_vap.build():
|
||||
create_vap._pass("VAP %s created." % (vap))
|
||||
else:
|
||||
|
||||
@@ -8,16 +8,19 @@ Help()
|
||||
echo "OPTION ONE: ./regression_test.sh : this command runs all the scripts in the array \"testCommands\""
|
||||
echo "OPTION TWO: ./regression_test.sh 4 5 : this command runs py-script commands (in testCommands array) that include the py-script options beginning with 4 and 5 (inclusive) in case function ret_case_num."
|
||||
echo "Optional Variables:"
|
||||
echo "SSID is the name of the network you are testing against"
|
||||
echo "s is the SSID of the 5g network you are testing against. This is treated as the main ssid for tests that take one SSID"
|
||||
echo "u is the SSID of the 2g network you are testing against"
|
||||
echo "PASSWD is the password of said network"
|
||||
echo "SECURITY is the security protocol of the network"
|
||||
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 "b is 2g BSSID"
|
||||
echo "B is 5g BSSID"
|
||||
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 "L is used to give the IP address of the LANforge device which is under test"
|
||||
echo "D is DUT5 string, used in ap-auto and similar chamber-view tests."
|
||||
echo "2 is DUT2 string, used in ap-auto and similar chamber-view tests."
|
||||
echo "D is DUT5 name."
|
||||
echo "2 is DUT2 name."
|
||||
echo "r is 5Ghz radio, default is 1.1.wiphy1"
|
||||
echo "M is 2.4Ghz radio, default is 1.1.wiphy0"
|
||||
echo "Example command: ./regression_test.sh -s SSID -p PASSWD -w SECURITY -m MGR"
|
||||
@@ -31,13 +34,25 @@ REPORT_DIR="${HOMEPATH}/html-reports"
|
||||
TESTBED=UNKNOWN
|
||||
NOW=$(date +"%Y-%m-%d-%H-%M")
|
||||
NOW="${NOW/:/-}"
|
||||
DUT2=
|
||||
DUT5=
|
||||
DUT2_NAME=regression_dut
|
||||
DUT5_NAME=regression_dut
|
||||
RADIO_USED="1.1.wiphy1"
|
||||
RADIO5=$RADIO_USED
|
||||
RADIO2="1.1.wiphy0"
|
||||
SSID_USED=
|
||||
SSID_USED2=
|
||||
BSSID=
|
||||
BSSID2=
|
||||
|
||||
while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:2:H:M:C:e:V:E:T:" option; do
|
||||
# Load config file
|
||||
if [ -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
|
||||
|
||||
# cmd line arguments take precedence over config file, so they are processed here.
|
||||
while getopts ":h:s:S:p:w:m:r:R:F:b:B:u:U:D:2:H:M:C:e:u:V:E:T:" option; do
|
||||
case "${option}" in
|
||||
h) # display Help
|
||||
Help
|
||||
@@ -46,6 +61,9 @@ while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:2:H:M:C:e:V:E:T:" option; do
|
||||
s)
|
||||
SSID_USED=${OPTARG}
|
||||
;;
|
||||
u)
|
||||
SSID_USED2=${OPTARG}
|
||||
;;
|
||||
S)
|
||||
SHORT="yes"
|
||||
;;
|
||||
@@ -77,6 +95,9 @@ while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:2:H:M:C:e:V:E:T:" option; do
|
||||
B)
|
||||
BSSID=${OPTARG}
|
||||
;;
|
||||
b)
|
||||
BSSID2=${OPTARG}
|
||||
;;
|
||||
u)
|
||||
# like eth0
|
||||
UPSTREAM_BARE=${OPTARG}
|
||||
@@ -86,10 +107,10 @@ while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:2:H:M:C:e:V:E:T:" option; do
|
||||
UPSTREAM=${OPTARG}
|
||||
;;
|
||||
D)
|
||||
DUT5=${OPTARG}
|
||||
DUT5_NAME=${OPTARG}
|
||||
;;
|
||||
2)
|
||||
DUT2=${OPTARG}
|
||||
DUT2_NAME=${OPTARG}
|
||||
;;
|
||||
H)
|
||||
./lf_help_check.bash
|
||||
@@ -112,6 +133,16 @@ while getopts ":h:s:S:p:w:m:r:R:F:B:u:U:D:2:H:M:C:e:V:E:T:" option; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "_$BSSID2" != "_" ]
|
||||
then
|
||||
DUT2="$DUT2_NAME $SSID_USED2 $BSSID2 (1)"
|
||||
fi
|
||||
|
||||
if [ "_$BSSID" != "_" ]
|
||||
then
|
||||
DUT5="$DUT5_NAME $SSID_USED5 $BSSID (1)"
|
||||
fi
|
||||
|
||||
if [[ ${#MGR} -eq 0 ]]; then # Allow the user to change the radio they test against
|
||||
MGR="localhost"
|
||||
fi
|
||||
@@ -184,13 +215,6 @@ if test -f "$FILE"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ${#SSID_USED} -gt 0 ]]; then
|
||||
if [ -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
|
||||
fi
|
||||
NUM_STA=${NUM_STA:-4}
|
||||
TEST_HTTP_IP=${TEST_HTTP_IP:-10.40.0.1}
|
||||
COL_NAMES="name,tx_bytes,rx_bytes,dropped"
|
||||
@@ -237,8 +261,6 @@ function create_station_and_dataplane() {
|
||||
--local_lf_report_dir ~/html-reports/dataplane_${NOW}
|
||||
set +x
|
||||
}
|
||||
function create_dut_and_chamberview() {
|
||||
}
|
||||
|
||||
function create_station_and_sensitivity {
|
||||
set -x
|
||||
|
||||
Reference in New Issue
Block a user