mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -58,7 +58,14 @@ class StaConnect(LFCliBase):
|
||||
self.station_names = []
|
||||
if _sta_name is not None:
|
||||
self.station_names = [ _sta_name ]
|
||||
self.localrealm = Realm(lfclient_host=host, lfclient_port=port)
|
||||
# self.localrealm :Realm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6
|
||||
self.localrealm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6
|
||||
self.resulting_stations = {}
|
||||
self.resulting_endpoints = {}
|
||||
|
||||
# def get_realm(self) -> Realm: # py > 3.6
|
||||
def get_realm(self):
|
||||
return self.localrealm
|
||||
|
||||
def get_station_url(self, sta_name_=None):
|
||||
if sta_name_ is None:
|
||||
@@ -86,8 +93,6 @@ class StaConnect(LFCliBase):
|
||||
for name in self.station_names:
|
||||
LFUtils.removePort(self.resource, name, self.lfclient_url)
|
||||
|
||||
|
||||
|
||||
def num_associated(self, bssid):
|
||||
counter = 0
|
||||
# print("there are %d results" % len(self.station_results))
|
||||
@@ -104,6 +109,12 @@ class StaConnect(LFCliBase):
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
return counter
|
||||
|
||||
def clear_test_results(self):
|
||||
self.resulting_stations = {}
|
||||
self.resulting_endpoints = {}
|
||||
super().clear_test_results()
|
||||
#super(StaConnect, self).clear_test_results().test_results.clear()
|
||||
|
||||
def run(self):
|
||||
self.clear_test_results()
|
||||
self.check_connect()
|
||||
@@ -207,9 +218,13 @@ class StaConnect(LFCliBase):
|
||||
}
|
||||
self.json_post("/cli-json/nc_show_ports", data)
|
||||
|
||||
# make a copy of the connected stations for test records
|
||||
|
||||
|
||||
for sta_name in self.station_names:
|
||||
sta_url = self.get_station_url(sta_name)
|
||||
station_info = self.json_get(sta_url + "?fields=port,ip,ap")
|
||||
station_info = self.json_get(sta_url) # + "?fields=port,ip,ap")
|
||||
self.resulting_stations[sta_url] = station_info
|
||||
ap = station_info["interface"]["ap"]
|
||||
ip = station_info["interface"]["ip"]
|
||||
if (ap != "") and (ap != "Not-Associated"):
|
||||
@@ -385,11 +400,19 @@ class StaConnect(LFCliBase):
|
||||
for cx_name in cx_names.keys():
|
||||
|
||||
try:
|
||||
ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["a"])
|
||||
# ?fields=tx+bytes,rx+bytes
|
||||
endp_url = "/endp/%s" % cx_names[cx_name]["a"]
|
||||
ptest = self.json_get(endp_url)
|
||||
self.resulting_endpoints[endp_url] = ptest
|
||||
|
||||
ptest_a_tx = ptest['endpoint']['tx bytes']
|
||||
ptest_a_rx = ptest['endpoint']['rx bytes']
|
||||
|
||||
ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"])
|
||||
#ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"])
|
||||
endp_url = "/endp/%s" % cx_names[cx_name]["b"]
|
||||
ptest = self.json_get(endp_url)
|
||||
self.resulting_endpoints[endp_url] = ptest
|
||||
|
||||
ptest_b_tx = ptest['endpoint']['tx bytes']
|
||||
ptest_b_rx = ptest['endpoint']['rx bytes']
|
||||
|
||||
@@ -402,21 +425,21 @@ class StaConnect(LFCliBase):
|
||||
except Exception as e:
|
||||
self.error(e)
|
||||
|
||||
# print("\n")
|
||||
# Examples of what happens when you add test results that do not begin with PASS
|
||||
# self.test_results.append("Neutral message will fail")
|
||||
# self.test_results.append("FAILED message will fail")
|
||||
|
||||
# print("\n")
|
||||
|
||||
# remove all endpoints and cxs
|
||||
for sta_name in self.station_names:
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
|
||||
endp_names = []
|
||||
removeCX(self.lfclient_url, cx_names.keys())
|
||||
for cx_name in cx_names:
|
||||
endp_names.append(cx_names[cx_name]["a"])
|
||||
endp_names.append(cx_names[cx_name]["b"])
|
||||
removeEndps(self.lfclient_url, endp_names)
|
||||
if self.cleanup_on_exit:
|
||||
for sta_name in self.station_names:
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
|
||||
endp_names = []
|
||||
removeCX(self.lfclient_url, cx_names.keys())
|
||||
for cx_name in cx_names:
|
||||
endp_names.append(cx_names[cx_name]["a"])
|
||||
endp_names.append(cx_names[cx_name]["b"])
|
||||
removeEndps(self.lfclient_url, endp_names)
|
||||
|
||||
# ~class
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ if 'py-json' not in sys.path:
|
||||
sys.path.append('../py-json')
|
||||
|
||||
# if you lack __init__.py in this directory you will not find sta_connect module
|
||||
import pprint
|
||||
from pprint import pprint
|
||||
import sta_connect
|
||||
from sta_connect import *
|
||||
import realm
|
||||
@@ -21,7 +23,7 @@ from LANforge import LFUtils
|
||||
|
||||
def main():
|
||||
# create multiple OPEN stations
|
||||
station_names = LFUtils.port_name_series(start_id=10, end_id=19)
|
||||
station_names = LFUtils.port_name_series(start_id=0, end_id=1)
|
||||
|
||||
test = StaConnect("localhost", 8080, _debugOn=False, _exit_on_error=True,
|
||||
_cleanup_on_exit=False, _runtime_sec=360, _exit_on_fail=True)
|
||||
@@ -34,11 +36,21 @@ def main():
|
||||
test.dut_ssid = "jedway-open"
|
||||
test.dut_passwd = "[BLANK]"
|
||||
test.station_names = station_names
|
||||
test.runtime_secs = 500
|
||||
test.cleanup_on_exit = False
|
||||
|
||||
test.runtime_secs = 5
|
||||
test.cleanup_on_exit = True
|
||||
test.run()
|
||||
is_passing = test.passes()
|
||||
|
||||
# recorded stations and endpoints can be retrieved this way:
|
||||
'''
|
||||
for sta_name in test.resulting_stations:
|
||||
print("** recorded: "+sta_name)
|
||||
pprint.pprint(test.resulting_stations[sta_name])
|
||||
|
||||
for endp_name in test.resulting_endpoints:
|
||||
print("** endp: "+endp_name)
|
||||
pprint.pprint(test.resulting_endpoints[endp_name])
|
||||
'''
|
||||
if is_passing == False:
|
||||
# run_results = staConnect.get_failed_result_list()
|
||||
fail_message = test.get_fail_message()
|
||||
|
||||
Reference in New Issue
Block a user