mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
fixed merge conflicts
Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
@@ -368,8 +368,8 @@ td.scriptdetails span.copybtn {
|
||||
}
|
||||
td.scriptdetails:hover span.copybtn {
|
||||
display: inline-block;
|
||||
padding: 5px;
|
||||
font-size: 12px;
|
||||
padding: 2px;
|
||||
font-size:10px;
|
||||
float: left;
|
||||
color: #050;
|
||||
background: white;
|
||||
|
||||
179
py-scripts/asus_ap.py
Normal file
179
py-scripts/asus_ap.py
Normal file
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
'''
|
||||
NAME:
|
||||
asus_ap.py
|
||||
|
||||
PURPOSE:
|
||||
Generic AP library that will work for the ASUS ap's
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
./asus_ap.py --ap_port '/dev/ttyUSB0' --ap_baud '115200' --ap_cmd "wl -i wl1 bs_data"
|
||||
|
||||
./asus_ap.py --ap_port '/dev/ttyUSB0' --ap_baud '115200' --ap_cmd "wl -i wl1 bs_data" --ap_file 'ap_file.txt'
|
||||
|
||||
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
|
||||
'''
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
|
||||
import argparse
|
||||
import pexpect
|
||||
import serial
|
||||
from pexpect_serial import SerialSpawn
|
||||
|
||||
|
||||
# see https://stackoverflow.com/a/13306095/11014343
|
||||
class FileAdapter(object):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
def write(self, data):
|
||||
# NOTE: data can be a partial line, multiple lines
|
||||
data = data.strip() # ignore leading/trailing whitespace
|
||||
if data: # non-blank
|
||||
self.logger.info(data)
|
||||
def flush(self):
|
||||
pass # leave it to logging to flush properly
|
||||
|
||||
|
||||
class lf_ap():
|
||||
def __init__(self,
|
||||
_ap_test_mode = False,
|
||||
_ap_2G_interface = "wl0",
|
||||
_ap_5G_interface = "wl1",
|
||||
_ap_6G_interface = "wl2",
|
||||
_ap_scheme = 'serial',
|
||||
_ap_serial_port = '/dev/ttyUSB0',
|
||||
_ap_ssh_port = "22",
|
||||
_ap_telnet_port = "23",
|
||||
_ap_serial_baud = '115200',
|
||||
_ap_report_dir = "",
|
||||
_ap_log_file = ""):
|
||||
self.ap_test_mode = _ap_test_mode
|
||||
self.ap_2G_interface = _ap_2G_interface
|
||||
self.ap_5G_interface = _ap_5G_interface
|
||||
self.ap_6G_interface = _ap_6G_interface
|
||||
self.ap_scheme = _ap_scheme
|
||||
self.ap_serial_port = _ap_serial_port
|
||||
self.ap_telnet_port = _ap_ssh_port
|
||||
self.ap_telnet = _ap_telnet_port
|
||||
self.ap_serial_baud = _ap_serial_baud
|
||||
self.ap_report_dir = _ap_report_dir
|
||||
self.ap_log_file = _ap_log_file
|
||||
|
||||
def ap_action(self):
|
||||
|
||||
print("ap_cmd: {}".format(self.ap_cmd))
|
||||
try:
|
||||
ser = serial.Serial(self.ap_port, int(self.ap_baud), timeout=5)
|
||||
ss = SerialSpawn(ser)
|
||||
ss.sendline(str(self.ap_cmd))
|
||||
ss.expect([pexpect.TIMEOUT], timeout=2) # do not detete line, waits for output
|
||||
ap_results = ss.before.decode('utf-8','ignore')
|
||||
print("ap_results {}".format(ap_results))
|
||||
except:
|
||||
ap_results = "exception on accessing {} Command: {}\r\n".format(self.ap_port,self.ap_cmd)
|
||||
print("{}".format(ap_results))
|
||||
|
||||
if(self.ap_file != None):
|
||||
ap_file = open(str(self.ap_file),"a")
|
||||
ap_file.write(ap_results)
|
||||
ap_file.close()
|
||||
print("ap file written {}".format(str(self.ap_file)))
|
||||
|
||||
# ASUS
|
||||
def ap_clear_stats(self,band):
|
||||
pass
|
||||
|
||||
# ASUS bs_data
|
||||
def ap_ul_data(self,band):
|
||||
pass
|
||||
|
||||
# ASUS rx_report
|
||||
def ap_dl_data(self,band):
|
||||
pass
|
||||
|
||||
# ASUS chanel info (channel utilization)
|
||||
def ap_chanim(self,band):
|
||||
pass
|
||||
|
||||
def ap_ul_stats(self,band):
|
||||
pass
|
||||
|
||||
def ap_dl_stats(self,band):
|
||||
pass
|
||||
|
||||
def ap_store_dl_scheduler_stats(self,band):
|
||||
if band is "6G":
|
||||
pass
|
||||
|
||||
def ap_store_ul_scheduler_stats(self,band):
|
||||
pass
|
||||
|
||||
|
||||
def ap_ofdma_stats(self,band):
|
||||
pass
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_ap.py',
|
||||
#formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Useful Information:
|
||||
1. Useful Information goes here
|
||||
''',
|
||||
|
||||
description='''\
|
||||
lf_ap.py:
|
||||
--------------------
|
||||
Summary :
|
||||
----------
|
||||
This file is used for verification
|
||||
|
||||
Commands: (wl2 == 6GHz wl1 == 5GHz , wl0 == 24ghz)
|
||||
|
||||
read ap data:: 'wl -i wl1 bs_data'
|
||||
reset scheduler's counters:: 'wl -i wl1 dump_clear'
|
||||
UL scheduler statistics:: 'wl -i wl1 dump umsched'
|
||||
DL scheduler statistics:: 'wl -i wl1 dump msched'
|
||||
|
||||
Generic command layout:
|
||||
-----------------------
|
||||
|
||||
''')
|
||||
parser.add_argument('--ap_test_mode', help='--ap_mode ',default=True)
|
||||
parser.add_argument('--ap_port', help='--ap_port \'/dev/ttyUSB0\'',default='/dev/ttyUSB0')
|
||||
parser.add_argument('--ap_baud', help='--ap_baud \'115200\'',default='115200')
|
||||
parser.add_argument('--ap_cmd', help='--ap_cmd \'wl -i wl1 bs_data\'',default='wl -i wl1 bs_data')
|
||||
parser.add_argument('--ap_file', help='--ap_file \'ap_file.txt\'')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
__ap_port = args.ap_port
|
||||
__ap_baud = args.ap_baud
|
||||
__ap_cmd = args.ap_cmd
|
||||
__ap_file = args.ap_file
|
||||
|
||||
ap_dut = lf_ap(
|
||||
_ap_port = __ap_port,
|
||||
_ap_baud = __ap_baud,
|
||||
_ap_cmd = __ap_cmd ,
|
||||
_ap_file = __ap_file)
|
||||
|
||||
ap_dut.ap_action()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -5,13 +5,6 @@ import pandas as pd
|
||||
import argparse
|
||||
|
||||
|
||||
def get_tag(x, tag):
|
||||
try:
|
||||
return x[tag]
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="check_argparse.py",
|
||||
@@ -29,7 +22,7 @@ def main():
|
||||
text = open(os.path.join(args.path, file)).read()
|
||||
results_file = dict()
|
||||
results_file['argparse'] = 'argparse.' in text
|
||||
if results_file['argparse'] is True:
|
||||
if results_file['argparse']:
|
||||
results_file['create_basic'] = 'create_basic_argparse' in text
|
||||
results_file['create_bare'] = 'create_bare_argparse' in text
|
||||
results_file['prog'] = 'prog=' in text
|
||||
@@ -48,7 +41,9 @@ def main():
|
||||
'description',
|
||||
'epilog',
|
||||
'usage']:
|
||||
df[tag] = [get_tag(x, tag) for x in df['results']]
|
||||
for result in df['results']:
|
||||
if tag in result:
|
||||
df[tag] = df['results'][tag]
|
||||
df['details'] = df['description'] + df['epilog'] + df['usage']
|
||||
df.to_csv(args.output + '.csv', index=False)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -58,7 +58,8 @@ class CreateBond(LFCliBase):
|
||||
"resource": self.resource,
|
||||
"port": "bond0000",
|
||||
"current_flags": 0x80000000,
|
||||
"interest": 0x4000 # (0x2 + 0x4000 + 0x800000) # current, dhcp, down
|
||||
# (0x2 + 0x4000 + 0x800000) # current, dhcp, down
|
||||
"interest": 0x4000
|
||||
}
|
||||
self.json_post("cli-json/set_port", bond_set_port)
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -24,7 +23,7 @@ Realm = realm.Realm
|
||||
|
||||
|
||||
class CreateBridge(Realm):
|
||||
def __init__(self,sta_list,resource,target_device,radio,
|
||||
def __init__(self, sta_list, resource, target_device, radio,
|
||||
_ssid=None,
|
||||
_security=None,
|
||||
_password=None,
|
||||
@@ -54,7 +53,6 @@ class CreateBridge(Realm):
|
||||
pprint.pprint(self.sta_list)
|
||||
print("---- ~bridge List ----- ----- ----- ----- ----- ----- \n")
|
||||
|
||||
|
||||
def build(self):
|
||||
# Build bridges
|
||||
|
||||
@@ -71,13 +69,12 @@ class CreateBridge(Realm):
|
||||
"resource": self.resource,
|
||||
"port": "br0",
|
||||
"current_flags": 0x80000000,
|
||||
"interest": 0x4000 # (0x2 + 0x4000 + 0x800000) # current, dhcp, down
|
||||
# (0x2 + 0x4000 + 0x800000) # current, dhcp, down
|
||||
"interest": 0x4000
|
||||
}
|
||||
self.json_post("cli-json/set_port", bridge_set_port)
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='create_bridge.py',
|
||||
@@ -101,17 +98,19 @@ Command example:
|
||||
--debug
|
||||
''')
|
||||
required = parser.add_argument_group('required arguments')
|
||||
required.add_argument('--target_device', help='Where the bridges should be connecting', required=True)
|
||||
#required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
||||
required.add_argument(
|
||||
'--target_device', help='Where the bridges should be connecting', required=True)
|
||||
# required.add_argument('--security', help='WiFi Security protocol: < open | wep | wpa | wpa2 | wpa3 >', required=True)
|
||||
|
||||
optional = parser.add_argument_group('optional arguments')
|
||||
optional.add_argument('--num_bridges', help='Number of bridges to Create', required=False)
|
||||
optional.add_argument(
|
||||
'--num_bridges', help='Number of bridges to Create', required=False)
|
||||
args = parser.parse_args()
|
||||
#if args.debug:
|
||||
# if args.debug:
|
||||
# pprint.pprint(args)
|
||||
# time.sleep(5)
|
||||
if (args.radio is None):
|
||||
raise ValueError("--radio required")
|
||||
if args.radio is None:
|
||||
raise ValueError("--radio required")
|
||||
|
||||
num_bridge = 2
|
||||
if (args.num_bridges is not None) and (int(args.num_bridges) > 0):
|
||||
@@ -119,25 +118,26 @@ Command example:
|
||||
num_bridge = num_bridges_converted
|
||||
|
||||
bridge_list = LFUtils.port_name_series(prefix="bridge",
|
||||
start_id=0,
|
||||
end_id=num_bridge-1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
start_id=0,
|
||||
end_id=num_bridge - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
|
||||
create_bridge = CreateBridge(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_bridge_list=bridge_list,
|
||||
radio=args.radio,
|
||||
_debug_on=args.debug,
|
||||
sta_list=bridge_list,
|
||||
resource=1,
|
||||
target_device=args.target_device)
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_bridge_list=bridge_list,
|
||||
radio=args.radio,
|
||||
_debug_on=args.debug,
|
||||
sta_list=bridge_list,
|
||||
resource=1,
|
||||
target_device=args.target_device)
|
||||
|
||||
create_bridge.build()
|
||||
print('Created %s bridges' % num_bridge)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -41,7 +41,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
@@ -52,28 +51,31 @@ class CreateChamberview(cv):
|
||||
def __init__(self,
|
||||
lfmgr="localhost",
|
||||
port="8080",
|
||||
):
|
||||
):
|
||||
super().__init__(
|
||||
lfclient_host=lfmgr,
|
||||
lfclient_port=port,
|
||||
lfclient_host=lfmgr,
|
||||
lfclient_port=port,
|
||||
)
|
||||
self.lfmgr = lfmgr
|
||||
self.port = port
|
||||
|
||||
def clean_cv_scenario(self,type="Network-Connectivity",scenario_name=None):
|
||||
self.rm_cv_text_blob(type,scenario_name)
|
||||
def clean_cv_scenario(
|
||||
self,
|
||||
cv_type="Network-Connectivity",
|
||||
scenario_name=None):
|
||||
self.rm_cv_text_blob(cv_type, scenario_name)
|
||||
|
||||
def setup(self,
|
||||
create_scenario="",
|
||||
line="",
|
||||
raw_line=[]):
|
||||
create_scenario="",
|
||||
line="",
|
||||
raw_line=None):
|
||||
|
||||
if raw_line:
|
||||
print("creating %s scenario" % create_scenario)
|
||||
for create_lines in raw_line:
|
||||
self.pass_raw_lines_to_cv(create_scenario,create_lines[0])
|
||||
self.pass_raw_lines_to_cv(create_scenario, create_lines[0])
|
||||
|
||||
#check for lines
|
||||
# check for lines
|
||||
if line:
|
||||
scenario_name = create_scenario
|
||||
line = line
|
||||
@@ -88,85 +90,80 @@ class CreateChamberview(cv):
|
||||
Freq = "-1"
|
||||
VLAN = ""
|
||||
|
||||
for i in range(len(line)):
|
||||
if " " in line[i][0]:
|
||||
line[i][0] = (re.split(' ', line[i][0]))
|
||||
elif "," in line[i][0]:
|
||||
line[i][0] = (re.split(',', line[i][0]))
|
||||
elif ", " in line[i][0]:
|
||||
line[i][0] = (re.split(',', line[i][0]))
|
||||
elif " ," in line[i][0]:
|
||||
line[i][0] = (re.split(',', line[i][0]))
|
||||
for item in line:
|
||||
if " " in item[0]:
|
||||
item[0] = (re.split(' ', item[0]))
|
||||
elif "," in item[0]:
|
||||
item[0] = (re.split(',', item[0]))
|
||||
else:
|
||||
print("Wrong arguments entered !")
|
||||
exit(1)
|
||||
|
||||
print("creating %s scenario" % scenario_name)
|
||||
for j in range(len(line[i][0])):
|
||||
line[i][0][j] = line[i][0][j].split("=")
|
||||
for k in range(len(line[i][0][j])):
|
||||
name = line[i][0][j][k]
|
||||
if str(name) == "Resource" or str(name) == "Res" or str(name) == "R":
|
||||
Resource = line[i][0][j][k + 1]
|
||||
elif str(name) == "Profile" or str(name) == "Prof" or str(name) == "P":
|
||||
Profile = line[i][0][j][k + 1]
|
||||
elif str(name) == "Amount" or str(name) == "Sta" or str(name) == "A":
|
||||
Amount = line[i][0][j][k + 1]
|
||||
elif str(name) == "Uses-1" or str(name) == "U1" or str(name) == "U-1":
|
||||
Uses1 = line[i][0][j][k + 1]
|
||||
elif str(name) == "Uses-2" or str(name) == "U2" or str(name) == "U-2":
|
||||
Uses2 = line[i][0][j][k + 1]
|
||||
elif str(name) == "Freq" or str(name) == "Freq" or str(name) == "F":
|
||||
Freq = line[i][0][j][k + 1]
|
||||
elif str(name) == "DUT" or str(name) == "dut" or str(name) == "D":
|
||||
DUT = line[i][0][j][k + 1]
|
||||
elif str(name) == "DUT_Radio" or str(name) == "dr" or str(name) == "DR":
|
||||
DUT_Radio = line[i][0][j][k + 1]
|
||||
elif str(name) == "Traffic" or str(name) == "Traf" or str(name) == "T":
|
||||
Traffic = line[i][0][j][k + 1]
|
||||
elif str(name) == "VLAN" or str(name) == "Vlan" or str(name) == "V":
|
||||
VLAN = line[i][0][j][k + 1]
|
||||
else:
|
||||
continue
|
||||
for sub_item in item[0]:
|
||||
sub_item = sub_item.split("=")
|
||||
if sub_item[0] == "Resource" or str(
|
||||
sub_item[0]) == "Res" or sub_item[0] == "R":
|
||||
Resource = sub_item[1]
|
||||
elif sub_item[0] == "Profile" or sub_item[0] == "Prof" or sub_item[0] == "P":
|
||||
Profile = sub_item[1]
|
||||
elif sub_item[0] == "Amount" or sub_item[0] == "Sta" or sub_item[0] == "A":
|
||||
Amount = sub_item[1]
|
||||
elif sub_item[0] == "Uses-1" or sub_item[0] == "U1" or sub_item[0] == "U-1":
|
||||
Uses1 = sub_item[1]
|
||||
elif sub_item[0] == "Uses-2" or sub_item[0] == "U2" or sub_item[0] == "U-2":
|
||||
Uses2 = sub_item[1]
|
||||
elif sub_item[0] == "Freq" or sub_item[0] == "Freq" or sub_item[0] == "F":
|
||||
Freq = sub_item[1]
|
||||
elif sub_item[0] == "DUT" or sub_item[0] == "dut" or sub_item[0] == "D":
|
||||
DUT = sub_item[1]
|
||||
elif sub_item[0] == "DUT_Radio" or sub_item[0] == "dr" or sub_item[0] == "DR":
|
||||
DUT_Radio = sub_item[1]
|
||||
elif sub_item[0] == "Traffic" or sub_item[0] == "Traf" or sub_item[0] == "T":
|
||||
Traffic = sub_item[1]
|
||||
elif sub_item[0] == "VLAN" or sub_item[0] == "Vlan" or sub_item[0] == "V":
|
||||
VLAN = sub_item[1]
|
||||
else:
|
||||
continue
|
||||
|
||||
self.add_text_blob_line(scenario_name,
|
||||
Resource,
|
||||
Profile,
|
||||
Amount,
|
||||
DUT,
|
||||
DUT_Radio,
|
||||
Uses1,
|
||||
Uses2,
|
||||
Traffic,
|
||||
Freq,
|
||||
VLAN
|
||||
); # To manage scenario
|
||||
Resource,
|
||||
Profile,
|
||||
Amount,
|
||||
DUT,
|
||||
DUT_Radio,
|
||||
Uses1,
|
||||
Uses2,
|
||||
Traffic,
|
||||
Freq,
|
||||
VLAN
|
||||
) # To manage scenario
|
||||
if not line and not raw_line:
|
||||
raise Exception("scenario creation failed")
|
||||
|
||||
return True
|
||||
|
||||
def build(self,scenario_name):
|
||||
def build(self, scenario_name):
|
||||
self.sync_cv() # chamberview sync
|
||||
time.sleep(2)
|
||||
self.apply_cv_scenario(scenario_name) # Apply scenario
|
||||
self.show_text_blob(None, None, False) # Show changes on GUI
|
||||
self.show_text_blob(None, None, False) # Show changes on GUI
|
||||
self.apply_cv_scenario(scenario_name) # Apply scenario
|
||||
self.build_cv_scenario() # build scenario
|
||||
tries = 0
|
||||
while (True):
|
||||
while True:
|
||||
self.get_popup_info_and_close()
|
||||
if not self.get_cv_is_built():
|
||||
# It can take a while to build a large scenario, so wait-time
|
||||
# is currently max of 5 minutes.
|
||||
print("Waiting %i/300 for Chamber-View to be built." % (tries))
|
||||
print("Waiting %i/300 for Chamber-View to be built." % tries)
|
||||
tries += 1
|
||||
if (tries > 300):
|
||||
if tries > 300:
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
break
|
||||
print("completed building %s scenario" %scenario_name)
|
||||
print("completed building %s scenario" % scenario_name)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -177,36 +174,53 @@ def main():
|
||||
For Two line scenario use --line twice as shown in example, for multi line scenario
|
||||
use --line argument to create multiple lines
|
||||
\n
|
||||
create_chamberview.py -m "localhost" -o "8080" -cs "scenario_name"
|
||||
--line "Resource=1.1 Profile=STA-AC Amount=1 Uses-1=wiphy0 Uses-2=AUTO Freq=-1
|
||||
DUT=Test DUT_Radio=Radio-1 Traffic=http VLAN="
|
||||
--line "Resource=1.1 Profile=upstream Amount=1 Uses-1=eth1 Uses-2=AUTO Freq=-1
|
||||
create_chamberview.py -m "localhost" -o "8080" -cs "scenario_name"
|
||||
--line "Resource=1.1 Profile=STA-AC Amount=1 Uses-1=wiphy0 Uses-2=AUTO Freq=-1
|
||||
DUT=Test DUT_Radio=Radio-1 Traffic=http VLAN="
|
||||
******************************** OR ********************************
|
||||
--line "Resource=1.1 Profile=upstream Amount=1 Uses-1=eth1 Uses-2=AUTO Freq=-1
|
||||
DUT=Test DUT_Radio=Radio-1 Traffic=http VLAN="
|
||||
******************************** OR ********************************
|
||||
create_chamberview.py -m "localhost" -o "8080" -cs "scenario_name"
|
||||
--raw_line "profile_link 1.1 STA-AC 10 'DUT: temp Radio-1' tcp-dl-6m-vi wiphy0,AUTO -1"
|
||||
--raw_line "profile_link 1.1 upstream 1 'DUT: temp Radio-1' tcp-dl-6m-vi eth1,AUTO -1"
|
||||
|
||||
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str,
|
||||
help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int, default=8080,
|
||||
help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-cs", "--create_scenario", "--create_lf_scenario", type=str,
|
||||
help="name of scenario to be created")
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
"--lfmgr",
|
||||
type=str,
|
||||
help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--port",
|
||||
type=int,
|
||||
default=8080,
|
||||
help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument(
|
||||
"-cs",
|
||||
"--create_scenario",
|
||||
"--create_lf_scenario",
|
||||
type=str,
|
||||
help="name of scenario to be created")
|
||||
parser.add_argument("-l", "--line", action='append', nargs='+',
|
||||
help="line number", default=[])
|
||||
parser.add_argument("-rl", "--raw_line", action='append', nargs=1,
|
||||
help="raw lines", default=[])
|
||||
parser.add_argument("-ds", "--delete_scenario", default=False, action='store_true',
|
||||
help="delete scenario (by default: False)")
|
||||
parser.add_argument(
|
||||
"-ds",
|
||||
"--delete_scenario",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="delete scenario (by default: False)")
|
||||
args = parser.parse_args()
|
||||
|
||||
Create_Chamberview = CreateChamberview(lfmgr=args.lfmgr,
|
||||
port=args.port,
|
||||
)
|
||||
if args.delete_scenario:
|
||||
Create_Chamberview.clean_cv_scenario(type="Network-Connectivity", scenario_name=args.create_scenario)
|
||||
Create_Chamberview.clean_cv_scenario(
|
||||
cv_type="Network-Connectivity",
|
||||
scenario_name=args.create_scenario)
|
||||
|
||||
Create_Chamberview.setup(create_scenario=args.create_scenario,
|
||||
line=args.line,
|
||||
|
||||
@@ -54,7 +54,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
# from cv_dut_profile import cv_dut as dut
|
||||
@@ -70,7 +69,7 @@ class DUT(dut):
|
||||
lfmgr="localhost",
|
||||
port="8080",
|
||||
dut_name="DUT",
|
||||
ssid=[],
|
||||
ssid=None,
|
||||
sw_version="NA",
|
||||
hw_version="NA",
|
||||
serial_num="NA",
|
||||
@@ -87,12 +86,13 @@ class DUT(dut):
|
||||
desired_dut_flags=dut_flags,
|
||||
desired_dut_flags_mask=dut_flags
|
||||
)
|
||||
if ssid is None:
|
||||
ssid = []
|
||||
self.cv_dut_name = dut_name
|
||||
self.cv_test = cvtest(lfmgr, port)
|
||||
self.dut_name = dut_name
|
||||
self.ssid = ssid
|
||||
|
||||
|
||||
def setup(self):
|
||||
self.create_dut()
|
||||
|
||||
@@ -115,16 +115,14 @@ class DUT(dut):
|
||||
d[item[0].lower()] = item[1]
|
||||
self.ssid[j] = d
|
||||
self.ssid[j]['flag'] = []
|
||||
self.ssid[j].keys
|
||||
|
||||
flag=0x0
|
||||
flag = 0x0
|
||||
if 'security' in self.ssid[j].keys():
|
||||
self.ssid[j]['security'] = self.ssid[j]['security'].split('|')
|
||||
self.ssid[j]['security'] = self.ssid[j]['security'].split(
|
||||
'|')
|
||||
for security in self.ssid[j]['security']:
|
||||
try:
|
||||
if security.lower() in flags:
|
||||
flag |= flags[security.lower()]
|
||||
except:
|
||||
pass
|
||||
self.ssid[j]['flag'] = flag
|
||||
|
||||
if 'bssid' not in self.ssid[j].keys():
|
||||
@@ -148,34 +146,55 @@ def main():
|
||||
prog='create_chamberview_dut.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
./create_chamberview_dut -m "localhost" -o "8080" -d "dut_name"
|
||||
--ssid "ssid_idx=0 ssid=NET1 security=WPA|WEP|11r|EAP-PEAP bssid=78:d2:94:bf:16:41"
|
||||
./create_chamberview_dut -m "localhost" -o "8080" -d "dut_name"
|
||||
--ssid "ssid_idx=0 ssid=NET1 security=WPA|WEP|11r|EAP-PEAP bssid=78:d2:94:bf:16:41"
|
||||
--ssid "ssid_idx=1 ssid=NET1 security=WPA password=test bssid=78:d2:94:bf:16:40"
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str, default="localhost",
|
||||
help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=str, default="8080",
|
||||
help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
"--lfmgr",
|
||||
type=str,
|
||||
default="localhost",
|
||||
help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--port",
|
||||
type=str,
|
||||
default="8080",
|
||||
help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-d", "--dut_name", type=str, default="DUT",
|
||||
help="set dut name")
|
||||
parser.add_argument("-s", "--ssid", action='append', nargs=1,
|
||||
help="SSID", default=[])
|
||||
|
||||
parser.add_argument("--sw_version", default="NA", help="DUT Software version.")
|
||||
parser.add_argument("--hw_version", default="NA", help="DUT Hardware version.")
|
||||
parser.add_argument("--serial_num", default="NA", help="DUT Serial number.")
|
||||
parser.add_argument(
|
||||
"--sw_version",
|
||||
default="NA",
|
||||
help="DUT Software version.")
|
||||
parser.add_argument(
|
||||
"--hw_version",
|
||||
default="NA",
|
||||
help="DUT Hardware version.")
|
||||
parser.add_argument(
|
||||
"--serial_num",
|
||||
default="NA",
|
||||
help="DUT Serial number.")
|
||||
parser.add_argument("--model_num", default="NA", help="DUT Model Number.")
|
||||
parser.add_argument('--dut_flag', help='station flags to add', default=None, action='append')
|
||||
parser.add_argument(
|
||||
'--dut_flag',
|
||||
help='station flags to add',
|
||||
default=None,
|
||||
action='append')
|
||||
|
||||
args = parser.parse_args()
|
||||
new_dut = DUT(lfmgr=args.lfmgr,
|
||||
port=args.port,
|
||||
dut_name=args.dut_name,
|
||||
ssid=args.ssid,
|
||||
sw_version = args.sw_version,
|
||||
hw_version = args.hw_version,
|
||||
serial_num = args.serial_num,
|
||||
model_num = args.model_num,
|
||||
sw_version=args.sw_version,
|
||||
hw_version=args.hw_version,
|
||||
serial_num=args.serial_num,
|
||||
model_num=args.model_num,
|
||||
dut_flags=args.dut_flag
|
||||
)
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LANforge = importlib.import_module("py-json.LANforge")
|
||||
@@ -46,10 +45,12 @@ class CreateL3(Realm):
|
||||
self.endp_a = endp_a
|
||||
self.mode = mode
|
||||
self.name_prefix = name_prefix
|
||||
self.station_profile = self.new_station_profile()
|
||||
# self.station_profile = self.new_station_profile()
|
||||
# self.station_profile.lfclient_url = self.lfclient_url
|
||||
# self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0,
|
||||
# end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user
|
||||
# defined variable from terminal.
|
||||
self.cx_profile = self.new_l3_cx_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user defined variable from terminal.
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
self.cx_profile.name_prefix = self.name_prefix
|
||||
@@ -66,47 +67,16 @@ class CreateL3(Realm):
|
||||
side_a=self.endp_a,
|
||||
side_b=self.endp_b,
|
||||
sleep_time=0)
|
||||
# self.cx_profile.start_cx()
|
||||
self._pass("PASS: Cross-connect build finished")
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='create_l3.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Generate traffic between ports
|
||||
''',
|
||||
description='''\
|
||||
''')
|
||||
def main(args):
|
||||
|
||||
required_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args = group
|
||||
break
|
||||
if required_args is not None:
|
||||
required_args.add_argument('--min_rate_a', help='--min_rate_a bps rate minimum for side_a', default=56000)
|
||||
required_args.add_argument('--min_rate_b', help='--min_rate_b bps rate minimum for side_b', default=56000)
|
||||
required_args.add_argument('--endp_a', help='--endp_a station list', default=["eth1"], action="append")
|
||||
required_args.add_argument('--endp_b', help='--upstream port', default="eth2")
|
||||
num_sta = 0
|
||||
# if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
# num_sta = int(args.num_stations)
|
||||
|
||||
optional_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args = group
|
||||
break;
|
||||
if optional_args is not None:
|
||||
optional_args.add_argument('--mode', help='Used to force mode of stations', default=0)
|
||||
optional_args.add_argument('--ap', help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000', default=0000)
|
||||
args = parser.parse_args()
|
||||
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
num_sta = int(args.num_stations)
|
||||
|
||||
# station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=int(args.number_template), end_id_=num_sta+int(args.number_template) - 1, padding_number_=10000,
|
||||
# radio=args.radio)
|
||||
ip_var_test = CreateL3(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
name_prefix="VT",
|
||||
@@ -117,13 +87,53 @@ def main():
|
||||
mode=args.mode,
|
||||
_debug_on=args.debug)
|
||||
|
||||
ip_var_test.pre_cleanup()
|
||||
# ip_var_test.pre_cleanup()
|
||||
ip_var_test.build()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
ip_var_test.exit_fail()
|
||||
print('Created %s stations and connections' % num_sta)
|
||||
print(f'Created {num_sta} stations and connections')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='create_l3.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Generate traffic between ports
|
||||
''',
|
||||
description='''\
|
||||
''')
|
||||
parser.add_argument(
|
||||
'--min_rate_a',
|
||||
help='--min_rate_a bps rate minimum for side_a',
|
||||
default=56000)
|
||||
parser.add_argument(
|
||||
'--min_rate_b',
|
||||
help='--min_rate_b bps rate minimum for side_b',
|
||||
default=56000)
|
||||
parser.add_argument(
|
||||
'--endp_a',
|
||||
help='--endp_a station list',
|
||||
default=[],
|
||||
action="append",
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'--endp_b',
|
||||
help='--upstream port',
|
||||
default="eth2",
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'--mode',
|
||||
help='Used to force mode of stations',
|
||||
default=0)
|
||||
parser.add_argument(
|
||||
'--ap',
|
||||
help='Used to force a connection to a particular AP')
|
||||
parser.add_argument(
|
||||
'--number_template',
|
||||
help='Start the station numbering with a particular number. Default is 0000',
|
||||
default=0000)
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
Example script:
|
||||
'./create_l3_stations.py --radio wiphy0 --ssid lanforge --password password --security wpa2'
|
||||
'./create_l3_stations.py --station_list sta00,sta01 --radio wiphy0 --ssid lanforge --password password --security wpa2'
|
||||
'./create_l3_stations.py --station_list sta00 sta01 --radio wiphy0 --ssid lanforge --password password --security wpa2'
|
||||
"""
|
||||
|
||||
import sys
|
||||
@@ -24,15 +26,28 @@ from realm import Realm
|
||||
|
||||
|
||||
class CreateL3(Realm):
|
||||
def __init__(self,
|
||||
ssid, security, password, sta_list, name_prefix, upstream, radio,
|
||||
host="localhost", port=8080, mode=0, ap=None,
|
||||
side_a_min_rate=56, side_a_max_rate=0,
|
||||
side_b_min_rate=56, side_b_max_rate=0,
|
||||
number_template="00000", use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
def __init__(
|
||||
self,
|
||||
ssid,
|
||||
security,
|
||||
password,
|
||||
sta_list,
|
||||
name_prefix,
|
||||
upstream,
|
||||
radio,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
mode=0,
|
||||
ap=None,
|
||||
side_a_min_rate=56,
|
||||
side_a_max_rate=0,
|
||||
side_b_min_rate=56,
|
||||
side_b_max_rate=0,
|
||||
number_template="00000",
|
||||
use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port)
|
||||
self.upstream = upstream
|
||||
self.host = host
|
||||
@@ -61,7 +76,9 @@ class CreateL3(Realm):
|
||||
self.station_profile.mode = mode
|
||||
if self.ap is not None:
|
||||
self.station_profile.set_command_param("add_sta", "ap", self.ap)
|
||||
# self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user defined variable from terminal.
|
||||
# self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0,
|
||||
# end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user
|
||||
# defined variable from terminal.
|
||||
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
@@ -74,7 +91,7 @@ class CreateL3(Realm):
|
||||
def pre_cleanup(self):
|
||||
self.cx_profile.cleanup_prefix()
|
||||
for sta in self.sta_list:
|
||||
self.rm_port(sta, check_exists=True)
|
||||
self.rm_port(sta, check_exists=True, debug_=False)
|
||||
|
||||
def build(self):
|
||||
|
||||
@@ -83,8 +100,10 @@ class CreateL3(Realm):
|
||||
self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag(
|
||||
"add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param(
|
||||
"set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio,
|
||||
sta_names_=self.sta_list,
|
||||
@@ -108,7 +127,7 @@ def main():
|
||||
create_l3_stations.py:
|
||||
--------------------
|
||||
Generic command layout:
|
||||
|
||||
|
||||
python3 ./create_l3_stations.py
|
||||
--upstream_port eth1
|
||||
--radio wiphy0
|
||||
@@ -136,39 +155,92 @@ def main():
|
||||
--ap "00:0e:8e:78:e1:76"
|
||||
--number_template 0000
|
||||
--debug
|
||||
|
||||
python3 ./create_l3_stations.py
|
||||
--upstream_port eth1
|
||||
--radio wiphy0
|
||||
--station_list sta00,sta01
|
||||
--security {open|wep|wpa|wpa2|wpa3} \\
|
||||
--mode 1
|
||||
{"auto" : "0",
|
||||
"a" : "1",
|
||||
"b" : "2",
|
||||
"g" : "3",
|
||||
"abg" : "4",
|
||||
"abgn" : "5",
|
||||
"bgn" : "6",
|
||||
"bg" : "7",
|
||||
"abgnAC" : "8",
|
||||
"anAC" : "9",
|
||||
"an" : "10",
|
||||
"bgnAC" : "11",
|
||||
"abgnAX" : "12",
|
||||
"bgnAX" : "13",
|
||||
--ssid netgear
|
||||
--password admin123
|
||||
--a_min 1000
|
||||
--b_min 1000
|
||||
--ap "00:0e:8e:78:e1:76"
|
||||
--number_template 0000
|
||||
--debug
|
||||
''')
|
||||
|
||||
required_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args = group
|
||||
break;
|
||||
break
|
||||
if required_args is not None:
|
||||
required_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
required_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
required_args.add_argument(
|
||||
'--a_min',
|
||||
help='--a_min bps rate minimum for side_a',
|
||||
default=256000)
|
||||
required_args.add_argument(
|
||||
'--b_min',
|
||||
help='--b_min bps rate minimum for side_b',
|
||||
default=256000)
|
||||
|
||||
optional_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args = group
|
||||
break;
|
||||
if optional_args is not None:
|
||||
optional_args.add_argument('--mode', help='Used to force mode of stations')
|
||||
optional_args.add_argument('--ap', help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument('--number_template', help='Start the station numbering with a particular number. Default is 0000', default=0000)
|
||||
optional_args.add_argument('--station_list', help='Optional: User defined station names', action='append',default=None)
|
||||
break
|
||||
if optional_args:
|
||||
optional_args.add_argument(
|
||||
'--mode', help='Used to force mode of stations')
|
||||
optional_args.add_argument(
|
||||
'--ap', help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument(
|
||||
'--number_template',
|
||||
help='Start the station numbering with a particular number. Default is 0000',
|
||||
default=0000)
|
||||
optional_args.add_argument(
|
||||
'--station_list',
|
||||
help='Optional: User defined station names, can be a comma or space separated list',
|
||||
nargs='+',
|
||||
default=None)
|
||||
optional_args.add_argument(
|
||||
'--no_cleanup',
|
||||
help="Optional: Don't cleanup existing stations",
|
||||
action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
num_sta = int(args.num_stations)
|
||||
|
||||
if args.station_list is None:
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=int(args.number_template), end_id_=num_sta+int(args.number_template) - 1, padding_number_=10000,
|
||||
radio=args.radio)
|
||||
if not args.station_list:
|
||||
station_list = LFUtils.portNameSeries(
|
||||
prefix_="sta", start_id_=int(
|
||||
args.number_template), end_id_=num_sta + int(
|
||||
args.number_template) - 1, padding_number_=10000, radio=args.radio)
|
||||
else:
|
||||
station_list = args.station_list
|
||||
|
||||
if ',' in args.station_list[0]:
|
||||
station_list = args.station_list[0].split(',')
|
||||
elif ' ' in args.station_list[0]:
|
||||
station_list = args.station_list[0].split()
|
||||
else:
|
||||
station_list = args.station_list
|
||||
ip_var_test = CreateL3(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
number_template=str(args.number_template),
|
||||
@@ -186,7 +258,8 @@ def main():
|
||||
ap=args.ap,
|
||||
_debug_on=args.debug)
|
||||
|
||||
ip_var_test.pre_cleanup()
|
||||
if not args.no_cleanup:
|
||||
ip_var_test.pre_cleanup()
|
||||
ip_var_test.build()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
|
||||
@@ -13,7 +13,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -25,15 +24,28 @@ TestGroupProfile = realm.TestGroupProfile
|
||||
|
||||
|
||||
class CreateL4(Realm):
|
||||
def __init__(self,
|
||||
ssid, security, password, sta_list, name_prefix, upstream, radio,
|
||||
host="localhost", port=8080, mode = 0, ap=None,
|
||||
side_a_min_rate=56, side_a_max_rate=0,
|
||||
side_b_min_rate=56, side_b_max_rate=0,
|
||||
number_template="00000", use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
def __init__(
|
||||
self,
|
||||
ssid,
|
||||
security,
|
||||
password,
|
||||
sta_list,
|
||||
name_prefix,
|
||||
upstream,
|
||||
radio,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
mode=0,
|
||||
ap=None,
|
||||
side_a_min_rate=56,
|
||||
side_a_max_rate=0,
|
||||
side_b_min_rate=56,
|
||||
side_b_max_rate=0,
|
||||
number_template="00000",
|
||||
use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port)
|
||||
self.upstream = upstream
|
||||
self.host = host
|
||||
@@ -43,8 +55,8 @@ class CreateL4(Realm):
|
||||
self.security = security
|
||||
self.password = password
|
||||
self.radio = radio
|
||||
self.mode= mode
|
||||
self.ap=ap
|
||||
self.mode = mode
|
||||
self.ap = ap
|
||||
self.number_template = number_template
|
||||
self.debug = _debug_on
|
||||
self.name_prefix = name_prefix
|
||||
@@ -61,9 +73,10 @@ class CreateL4(Realm):
|
||||
self.station_profile.mode = 9
|
||||
self.station_profile.mode = mode
|
||||
if self.ap is not None:
|
||||
self.station_profile.set_command_param("add_sta", "ap",self.ap)
|
||||
#self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user defined variable from terminal.
|
||||
|
||||
self.station_profile.set_command_param("add_sta", "ap", self.ap)
|
||||
# self.station_list= LFUtils.portNameSeries(prefix_="sta", start_id_=0,
|
||||
# end_id_=2, padding_number_=10000, radio='wiphy0') #Make radio a user
|
||||
# defined variable from terminal.
|
||||
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
@@ -76,22 +89,34 @@ class CreateL4(Realm):
|
||||
def cleanup(self):
|
||||
self.cx_profile.cleanup()
|
||||
self.station_profile.cleanup()
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url,
|
||||
port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
LFUtils.wait_until_ports_disappear(
|
||||
base_url=self.lfclient_url,
|
||||
port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
|
||||
def build(self):
|
||||
# Build stations
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.use_security(
|
||||
self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag(
|
||||
"add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param(
|
||||
"set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.station_profile.create(
|
||||
radio=self.radio,
|
||||
sta_names_=self.sta_list,
|
||||
debug=self.debug)
|
||||
self._pass("PASS: Station build finished")
|
||||
|
||||
self.cx_profile.create(ports=self.station_profile.station_names, sleep_time=.5, debug_=self.debug, suppress_related_commands_=True)
|
||||
self.cx_profile.create(
|
||||
ports=self.station_profile.station_names,
|
||||
sleep_time=.5,
|
||||
debug_=self.debug,
|
||||
suppress_related_commands_=True)
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
@@ -134,46 +159,61 @@ python3 ./layer4.py
|
||||
--debug
|
||||
''')
|
||||
|
||||
required_args=None
|
||||
required_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args=group
|
||||
break;
|
||||
required_args = group
|
||||
break
|
||||
if required_args is not None:
|
||||
required_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
required_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
required_args.add_argument(
|
||||
'--a_min',
|
||||
help='--a_min bps rate minimum for side_a',
|
||||
default=256000)
|
||||
required_args.add_argument(
|
||||
'--b_min',
|
||||
help='--b_min bps rate minimum for side_b',
|
||||
default=256000)
|
||||
|
||||
optional_args=None
|
||||
optional_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args=group
|
||||
break;
|
||||
optional_args = group
|
||||
break
|
||||
if optional_args is not None:
|
||||
optional_args.add_argument('--mode',help='Used to force mode of stations', default=0)
|
||||
optional_args.add_argument('--ap',help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument(
|
||||
'--mode',
|
||||
help='Used to force mode of stations',
|
||||
default=0)
|
||||
optional_args.add_argument(
|
||||
'--ap', help='Used to force a connection to a particular AP')
|
||||
args = parser.parse_args()
|
||||
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
num_sta = int(args.num_stations)
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000, radio=args.radio)
|
||||
station_list = LFUtils.portNameSeries(
|
||||
prefix_="sta",
|
||||
start_id_=0,
|
||||
end_id_=num_sta - 1,
|
||||
padding_number_=10000,
|
||||
radio=args.radio)
|
||||
ip_var_test = CreateL4(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
number_template="0000",
|
||||
sta_list=station_list,
|
||||
name_prefix="VT",
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
security=args.security,
|
||||
use_ht160=False,
|
||||
side_a_min_rate=args.a_min,
|
||||
side_b_min_rate=args.b_min,
|
||||
mode=args.mode,
|
||||
ap=args.ap,
|
||||
_debug_on=args.debug)
|
||||
port=args.mgr_port,
|
||||
number_template="0000",
|
||||
sta_list=station_list,
|
||||
name_prefix="VT",
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
security=args.security,
|
||||
use_ht160=False,
|
||||
side_a_min_rate=args.a_min,
|
||||
side_b_min_rate=args.b_min,
|
||||
mode=args.mode,
|
||||
ap=args.ap,
|
||||
_debug_on=args.debug)
|
||||
|
||||
ip_var_test.cleanup()
|
||||
ip_var_test.build()
|
||||
|
||||
@@ -8,7 +8,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -29,7 +28,7 @@ class CreateMacVlan(Realm):
|
||||
netmask=None,
|
||||
gateway=None,
|
||||
dhcp=True,
|
||||
port_list=[],
|
||||
port_list=None,
|
||||
ip_list=None,
|
||||
connections_per_port=1,
|
||||
_debug_on=False,
|
||||
@@ -51,7 +50,6 @@ class CreateMacVlan(Realm):
|
||||
|
||||
self.mvlan_profile = self.new_mvlan_profile()
|
||||
|
||||
|
||||
self.mvlan_profile.num_macvlans = int(num_ports)
|
||||
self.mvlan_profile.desired_macvlans = self.port_list
|
||||
self.mvlan_profile.macvlan_parent = self.macvlan_parent
|
||||
@@ -65,10 +63,14 @@ class CreateMacVlan(Realm):
|
||||
def build(self):
|
||||
# Build stations
|
||||
print("Creating MACVLANs")
|
||||
self.mvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug)
|
||||
self.mvlan_profile.create(
|
||||
admin_down=False,
|
||||
sleep_time=.5,
|
||||
debug=self.debug)
|
||||
self._pass("PASS: MACVLAN build finished")
|
||||
self.created_ports += self.mvlan_profile.created_macvlans
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog='create_macvlan.py',
|
||||
@@ -80,7 +82,7 @@ def main():
|
||||
create_macvlan.py:
|
||||
--------------------
|
||||
Generic command layout:
|
||||
./create_macvlan.py --macvlan_parent <port> --num_ports <num ports>
|
||||
./create_macvlan.py --macvlan_parent <port> --num_ports <num ports>
|
||||
--first_mvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr>
|
||||
|
||||
./create_macvlan.py --macvlan_parent eth2 --num_ports 3 --first_mvlan_ip 192.168.92.13
|
||||
@@ -97,25 +99,58 @@ Generic command layout:
|
||||
--use_ports eth1#0=10.40.3.103,eth1#1,eth1#2 --connections_per_port 2
|
||||
--netmask 255.255.240.0 --gateway 10.40.0.1
|
||||
|
||||
You can only add MAC-VLANs to Ethernet, Bonding, Redir, and 802.1Q VLAN devices.
|
||||
|
||||
''')
|
||||
parser.add_argument('--num_stations', help='Number of stations to create', default=0)
|
||||
parser.add_argument(
|
||||
'--num_stations',
|
||||
help='Number of stations to create',
|
||||
default=0)
|
||||
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||
parser.add_argument('-u', '--upstream_port',
|
||||
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
|
||||
default='1.eth1')
|
||||
parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None)
|
||||
parser.add_argument('--first_port', help='specifies name of first port to be used', default=None)
|
||||
parser.add_argument('--num_ports', help='number of ports to create', default=1)
|
||||
parser.add_argument('--connections_per_port', help='specifies number of connections to be used per port', default=1,
|
||||
type=int)
|
||||
parser.add_argument('--use_ports', help='list of comma separated ports to use with ips, \'=\' separates name and ip'
|
||||
'{ port_name1=ip_addr1,port_name1=ip_addr2 }. '
|
||||
'Ports without ips will be left alone', default=None)
|
||||
parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', default=None)
|
||||
parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None)
|
||||
parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None)
|
||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
|
||||
, default=None)
|
||||
parser.add_argument(
|
||||
'-u',
|
||||
'--upstream_port',
|
||||
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
|
||||
default='1.eth1')
|
||||
parser.add_argument(
|
||||
'--macvlan_parent',
|
||||
help='specifies parent port for macvlan creation',
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'--first_port',
|
||||
help='specifies name of first port to be used',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--num_ports',
|
||||
help='number of ports to create',
|
||||
default=1)
|
||||
parser.add_argument(
|
||||
'--connections_per_port',
|
||||
help='specifies number of connections to be used per port',
|
||||
default=1,
|
||||
type=int)
|
||||
parser.add_argument(
|
||||
'--use_ports',
|
||||
help='list of comma separated ports to use with ips, \'=\' separates name and ip'
|
||||
'{ port_name1=ip_addr1,port_name1=ip_addr2 }. '
|
||||
'Ports without ips will be left alone',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--first_mvlan_ip',
|
||||
help='specifies first static ip address to be used or dhcp',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--netmask',
|
||||
help='specifies netmask to be used with static ip addresses',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--gateway',
|
||||
help='specifies default gateway to be used with static addressing',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--cxs',
|
||||
help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group',
|
||||
default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
port_list = []
|
||||
@@ -125,27 +160,38 @@ Generic command layout:
|
||||
if (args.num_ports is not None) and (int(args.num_ports) > 0):
|
||||
start_num = int(args.first_port[3:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix="sta",
|
||||
start_id=start_num,
|
||||
end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \
|
||||
and args.macvlan_parent in args.first_port:
|
||||
start_num = int(args.first_port[args.first_port.index('#') + 1:])
|
||||
if (args.num_ports is not None) and args.macvlan_parent is not None and (
|
||||
int(args.num_ports) > 0) and args.macvlan_parent in args.first_port:
|
||||
start_num = int(
|
||||
args.first_port[args.first_port.index('#') + 1:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=start_num,
|
||||
end_id=start_num + num_ports - 1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=args.macvlan_parent + "#",
|
||||
start_id=start_num,
|
||||
end_id=start_num + num_ports - 1,
|
||||
padding_number=100000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
raise ValueError("Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n"
|
||||
"first_port must contain parent port and num_ports must be greater than 0"
|
||||
% (args.num_ports, args.macvlan_parent, args.first_port))
|
||||
raise ValueError(
|
||||
"Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n"
|
||||
"first_port must contain parent port and num_ports must be greater than 0" %
|
||||
(args.num_ports, args.macvlan_parent, args.first_port))
|
||||
else:
|
||||
if args.use_ports is None:
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0,
|
||||
end_id=num_ports - 1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=args.macvlan_parent + "#",
|
||||
start_id=0,
|
||||
end_id=num_ports - 1,
|
||||
padding_number=100000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
temp_list = args.use_ports.split(',')
|
||||
for port in temp_list:
|
||||
@@ -156,7 +202,8 @@ Generic command layout:
|
||||
ip_list.append(0)
|
||||
|
||||
if len(port_list) != len(ip_list):
|
||||
raise ValueError(temp_list, " ports must have matching ip addresses!")
|
||||
raise ValueError(
|
||||
temp_list, " ports must have matching ip addresses!")
|
||||
|
||||
if args.first_mvlan_ip is not None:
|
||||
if args.first_mvlan_ip.lower() == "dhcp":
|
||||
|
||||
@@ -8,7 +8,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -29,11 +29,15 @@ class CreateQVlan(Realm):
|
||||
netmask=None,
|
||||
first_qvlan_ip=None,
|
||||
gateway=None,
|
||||
port_list=[],
|
||||
ip_list=[],
|
||||
port_list=None,
|
||||
ip_list=None,
|
||||
exit_on_error=False,
|
||||
debug=False):
|
||||
super().__init__(host, port)
|
||||
if port_list is None:
|
||||
port_list = []
|
||||
if ip_list is None:
|
||||
ip_list = []
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.qvlan_parent = qvlan_parent
|
||||
@@ -54,7 +58,8 @@ class CreateQVlan(Realm):
|
||||
|
||||
def build(self):
|
||||
print("Creating QVLAN stations")
|
||||
self.qvlan_profile.create(admin_down=False, sleep_time=.5, debug=self.debug)
|
||||
self.qvlan_profile.create(
|
||||
sleep_time=.5)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -68,21 +73,50 @@ def main():
|
||||
---------------------
|
||||
Generic command ''')
|
||||
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2')
|
||||
parser.add_argument('--qvlan_parent', help='specifies parent port for qvlan creation', default=None)
|
||||
parser.add_argument('--first_port', help='specifies name of first port to be used', default=None)
|
||||
parser.add_argument('--num_ports', help='number of ports to create', default=1)
|
||||
parser.add_argument('--first_qvlan_ip', help='specifies first static ip address to be used or dhcp', default=None)
|
||||
parser.add_argument('--netmask', help='specifies netmask to be used with static ip addresses', default=None)
|
||||
parser.add_argument('--gateway', help='specifies default gateway to be used with static addressing', default=None)
|
||||
parser.add_argument('--use_ports',
|
||||
help='list of comma separated ports to use with ips, \'=\' separates name and ip { port_name1=ip_addr1,port_name1=ip_addr2 }. Ports without ips will be left alone',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--qvlan_parent',
|
||||
help='specifies parent port for qvlan creation',
|
||||
default=None,
|
||||
required=True)
|
||||
parser.add_argument(
|
||||
'--first_port',
|
||||
help='specifies name of first port to be used',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--num_ports',
|
||||
type=int,
|
||||
help='number of ports to create',
|
||||
default=1)
|
||||
parser.add_argument(
|
||||
'--first_qvlan_ip',
|
||||
help='specifies first static ip address to be used or dhcp',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--netmask',
|
||||
help='specifies netmask to be used with static ip addresses',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--gateway',
|
||||
help='specifies default gateway to be used with static addressing',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--use_ports',
|
||||
help='list of comma separated ports to use with ips, \'=\' separates name and ip { port_name1=ip_addr1,port_name1=ip_addr2 }. Ports without ips will be left alone',
|
||||
default=None)
|
||||
tg_group = parser.add_mutually_exclusive_group()
|
||||
tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None)
|
||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
|
||||
, default=None)
|
||||
parser.add_argument('--use_qvlans', help='will create qvlans', action='store_true', default=False)
|
||||
|
||||
tg_group.add_argument(
|
||||
'--add_to_group',
|
||||
help='name of test group to add cxs to',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--cxs',
|
||||
help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group',
|
||||
default=None)
|
||||
parser.add_argument(
|
||||
'--use_qvlans',
|
||||
help='will create qvlans',
|
||||
action='store_true',
|
||||
default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -100,34 +134,44 @@ def main():
|
||||
update_group_args['cxs'] = args.cxs
|
||||
port_list = []
|
||||
ip_list = []
|
||||
if args.first_port is not None and args.use_ports is not None:
|
||||
if args.first_port and args.use_ports:
|
||||
if args.first_port.startswith("sta"):
|
||||
if (args.num_ports is not None) and (int(args.num_ports) > 0):
|
||||
if args.num_ports and args.num_ports > 0:
|
||||
start_num = int(args.first_port[3:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix="sta",
|
||||
start_id=start_num,
|
||||
end_id=start_num + args.num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(1)
|
||||
else:
|
||||
if (args.num_ports is not None) and args.qvlan_parent is not None and (int(args.num_ports) > 0) \
|
||||
and args.qvlan_parent in args.first_port:
|
||||
start_num = int(args.first_port[args.first_port.index('#') + 1:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=args.qvlan_parent + "#", start_id=start_num,
|
||||
end_id=start_num + num_ports - 1, padding_number=10000,
|
||||
radio=args.radio)
|
||||
if args.num_ports and args.qvlan_parent and (args.num_ports > 0) and args.qvlan_parent in args.first_port:
|
||||
start_num = int(
|
||||
args.first_port[args.first_port.index('#') + 1:])
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=str(
|
||||
args.qvlan_parent) + "#",
|
||||
start_id=start_num,
|
||||
end_id=start_num + args.num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(2)
|
||||
else:
|
||||
raise ValueError("Invalid values for num_ports [%s], qvlan_parent [%s], and/or first_port [%s].\n"
|
||||
"first_port must contain parent port and num_ports must be greater than 0"
|
||||
% (args.num_ports, args.qvlan_parent, args.first_port))
|
||||
raise ValueError(
|
||||
"Invalid values for num_ports [%s], qvlan_parent [%s], and/or first_port [%s].\n"
|
||||
"first_port must contain parent port and num_ports must be greater than 0" %
|
||||
(args.num_ports, args.qvlan_parent, args.first_port))
|
||||
else:
|
||||
if args.use_ports is None:
|
||||
if not args.use_ports:
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=args.qvlan_parent + "#", start_id=1,
|
||||
end_id=num_ports, padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(
|
||||
prefix=str(
|
||||
args.qvlan_parent) + "#",
|
||||
start_id=1,
|
||||
end_id=num_ports,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
print(3)
|
||||
else:
|
||||
temp_list = args.use_ports.split(',')
|
||||
@@ -139,7 +183,8 @@ def main():
|
||||
ip_list.append(0)
|
||||
|
||||
if len(port_list) != len(ip_list):
|
||||
raise ValueError(temp_list, " ports must have matching ip addresses!")
|
||||
raise ValueError(
|
||||
temp_list, " ports must have matching ip addresses!")
|
||||
|
||||
print(port_list)
|
||||
print(ip_list)
|
||||
@@ -155,7 +200,8 @@ def main():
|
||||
ip_list=ip_list,
|
||||
debug=args.debug)
|
||||
create_qvlan.build()
|
||||
print('Created %s QVLAN stations' % num_ports)
|
||||
print('Created %s QVLAN stations' % args.num_ports)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -12,7 +12,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -74,23 +74,31 @@ class CreateStation(Realm):
|
||||
|
||||
def build(self):
|
||||
# Build stations
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.use_security(
|
||||
self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag(
|
||||
"add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param(
|
||||
"set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
if self.set_txo_data is not None:
|
||||
self.station_profile.set_wifi_txo(txo_ena=self.set_txo_data["txo_enable"],
|
||||
tx_power=self.set_txo_data["txpower"],
|
||||
pream=self.set_txo_data["pream"],
|
||||
mcs=self.set_txo_data["mcs"],
|
||||
nss=self.set_txo_data["nss"],
|
||||
bw=self.set_txo_data["bw"],
|
||||
retries=self.set_txo_data["retries"],
|
||||
sgi=self.set_txo_data["sgi"], )
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.station_profile.set_wifi_txo(
|
||||
txo_ena=self.set_txo_data["txo_enable"],
|
||||
tx_power=self.set_txo_data["txpower"],
|
||||
pream=self.set_txo_data["pream"],
|
||||
mcs=self.set_txo_data["mcs"],
|
||||
nss=self.set_txo_data["nss"],
|
||||
bw=self.set_txo_data["bw"],
|
||||
retries=self.set_txo_data["retries"],
|
||||
sgi=self.set_txo_data["sgi"],
|
||||
)
|
||||
self.station_profile.create(
|
||||
radio=self.radio,
|
||||
sta_names_=self.sta_list,
|
||||
debug=self.debug)
|
||||
if self.up:
|
||||
self.station_profile.admin_up()
|
||||
|
||||
@@ -98,7 +106,7 @@ class CreateStation(Realm):
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse( # see create_basic_argparse in ../py-json/LANforge/lfcli_base.py
|
||||
parser = LFCliBase.create_basic_argparse( # see create_basic_argparse in ../py-json/LANforge/lfcli_base.py
|
||||
prog='create_station.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
@@ -119,21 +127,32 @@ def main():
|
||||
--debug
|
||||
''')
|
||||
required = parser.add_argument_group('required arguments')
|
||||
required.add_argument('--start_id', help='--start_id <value> default 0', default=0)
|
||||
required.add_argument(
|
||||
'--start_id',
|
||||
help='--start_id <value> default 0',
|
||||
default=0)
|
||||
|
||||
optional = parser.add_argument_group('Optional arguments')
|
||||
optional.add_argument('--mode', help='Mode for your station (as a number)',default=0)
|
||||
optional.add_argument('--station_flag', help='station flags to add', required=False, default=None, action='append')
|
||||
optional.add_argument(
|
||||
'--mode',
|
||||
help='Mode for your station (as a number)',
|
||||
default=0)
|
||||
optional.add_argument(
|
||||
'--station_flag',
|
||||
help='station flags to add',
|
||||
required=False,
|
||||
default=None,
|
||||
action='append')
|
||||
|
||||
args = parser.parse_args()
|
||||
# if args.debug:
|
||||
# pprint.pprint(args)
|
||||
# time.sleep(5)
|
||||
if (args.radio is None):
|
||||
if args.radio is None:
|
||||
raise ValueError("--radio required")
|
||||
|
||||
start_id = 0
|
||||
if (args.start_id != 0):
|
||||
if args.start_id != 0:
|
||||
start_id = int(args.start_id)
|
||||
|
||||
num_sta = 2
|
||||
@@ -148,16 +167,6 @@ def main():
|
||||
radio=args.radio)
|
||||
|
||||
print("station_list {}".format(station_list))
|
||||
set_txo_data={
|
||||
"txo_enable": 1,
|
||||
"txpower": 255,
|
||||
"pream": 0,
|
||||
"mcs": 0,
|
||||
"nss": 0,
|
||||
"bw": 3,
|
||||
"retries": 1,
|
||||
"sgi": 0
|
||||
}
|
||||
|
||||
create_station = CreateStation(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
@@ -175,5 +184,6 @@ def main():
|
||||
create_station.build()
|
||||
print('Created %s stations' % num_sta)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -13,7 +13,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -62,7 +61,6 @@ class CreateStation(Realm):
|
||||
pprint.pprint(self.sta_list)
|
||||
print("---- ~Station List ----- ----- ----- ----- ----- ----- \n")
|
||||
|
||||
|
||||
def build(self):
|
||||
# Build stations
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
@@ -80,8 +78,6 @@ class CreateStation(Realm):
|
||||
|
||||
|
||||
def main():
|
||||
required=[]
|
||||
required.append({'name':'--df','help':'Which file you want to build stations off of?'})
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='create_station_from_df.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
@@ -99,29 +95,29 @@ def main():
|
||||
--ssid netgear
|
||||
--passwd BLANK
|
||||
--debug
|
||||
''',
|
||||
more_required=required)
|
||||
|
||||
''')
|
||||
required = parser.add_argument_group('required arguments')
|
||||
required.add_argument('df', help='Which file do you want to build stations off of?', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
df=pd.read_csv(args.df)
|
||||
unique=df[['radio','ssid','passwd','security']].drop_duplicates().reset_index(drop=True)
|
||||
df = pd.read_csv(args.df)
|
||||
unique = df[['radio', 'ssid', 'passwd', 'security']].drop_duplicates().reset_index(drop=True)
|
||||
for item in unique.index:
|
||||
uniquedf=unique.iloc[item]
|
||||
df1=df.merge(pd.DataFrame(uniquedf).transpose(),on=['radio','ssid','passwd','security'])
|
||||
try:
|
||||
radio=uniquedf['radio']
|
||||
except:
|
||||
radio=args.radio
|
||||
station_list=df1['station']
|
||||
try:
|
||||
ssid=uniquedf['ssid']
|
||||
passwd=uniquedf['passwd']
|
||||
security=uniquedf['security']
|
||||
except:
|
||||
ssid=args.ssid
|
||||
passwd=args.passwd
|
||||
security=args.security
|
||||
uniquedf = unique.iloc[item]
|
||||
df1 = df.merge(pd.DataFrame(uniquedf).transpose(), on=['radio', 'ssid', 'passwd', 'security'])
|
||||
if uniquedf['radio']:
|
||||
radio = uniquedf['radio']
|
||||
else:
|
||||
radio = args.radio
|
||||
station_list = df1['station']
|
||||
if uniquedf['ssid']:
|
||||
ssid = uniquedf['ssid']
|
||||
passwd = uniquedf['passwd']
|
||||
security = uniquedf['security']
|
||||
else:
|
||||
ssid = args.ssid
|
||||
passwd = args.passwd
|
||||
security = args.security
|
||||
create_station = CreateStation(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=ssid,
|
||||
@@ -135,5 +131,6 @@ def main():
|
||||
create_station.build()
|
||||
print('Created %s stations' % len(unique.index))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -12,7 +12,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -55,7 +55,10 @@ class CreateVAP(Realm):
|
||||
self.vap_list = _vap_list
|
||||
self.resource = _resource
|
||||
if _vap_flags is None:
|
||||
self.vap_flags = ["wpa2_enable", "80211u_enable", "create_admin_down"]
|
||||
self.vap_flags = [
|
||||
"wpa2_enable",
|
||||
"80211u_enable",
|
||||
"create_admin_down"]
|
||||
else:
|
||||
self.vap_flags = _vap_flags
|
||||
self.mode = _mode
|
||||
@@ -74,8 +77,10 @@ class CreateVAP(Realm):
|
||||
self.vap_profile.ssid_pass = self.password
|
||||
self.vap_profile.dhcp = self.dhcp
|
||||
self.vap_profile.mode = self.mode
|
||||
self.vap_profile.desired_add_vap_flags = self.vap_flags + ["wpa2_enable", "80211u_enable", "create_admin_down"]
|
||||
self.vap_profile.desired_add_vap_flags_mask = self.vap_flags + ["wpa2_enable", "80211u_enable", "create_admin_down"]
|
||||
self.vap_profile.desired_add_vap_flags = self.vap_flags + \
|
||||
["wpa2_enable", "80211u_enable", "create_admin_down"]
|
||||
self.vap_profile.desired_add_vap_flags_mask = self.vap_flags + \
|
||||
["wpa2_enable", "80211u_enable", "create_admin_down"]
|
||||
if self.debug:
|
||||
print("----- VAP List ----- ----- ----- ----- ----- ----- \n")
|
||||
pprint.pprint(self.vap_list)
|
||||
@@ -83,19 +88,19 @@ class CreateVAP(Realm):
|
||||
|
||||
def build(self):
|
||||
# Build VAPs
|
||||
self.vap_profile.use_security(self.security, self.ssid, passwd=self.password)
|
||||
self.vap_profile.use_security(
|
||||
self.security, self.ssid, passwd=self.password)
|
||||
|
||||
print("Creating VAPs")
|
||||
self.vap_profile.create(resource = self.resource,
|
||||
radio = self.radio,
|
||||
channel = self.channel,
|
||||
country=self.country_code,
|
||||
up_ = True,
|
||||
debug = False,
|
||||
self.vap_profile.create(resource=self.resource,
|
||||
radio=self.radio,
|
||||
channel=self.channel,
|
||||
up_=True,
|
||||
debug=False,
|
||||
use_ht40=True,
|
||||
use_ht80=True,
|
||||
use_ht160=False,
|
||||
suppress_related_commands_ = True,
|
||||
suppress_related_commands_=True,
|
||||
use_radius=False,
|
||||
hs20_enable=False,
|
||||
bridge=self.bridge)
|
||||
@@ -125,57 +130,73 @@ Command example:
|
||||
''')
|
||||
|
||||
optional = parser.add_argument_group('optional arguments')
|
||||
optional.add_argument('--num_vaps', help='Number of VAPs to Create', required=False, default=1)
|
||||
optional.add_argument('--vap_flag', help='VAP flags to add', required=False, default=None, action='append')
|
||||
optional.add_argument('--bridge', help='Create a bridge connecting the VAP to a port', required=False, default=False)
|
||||
optional.add_argument('--mac', help='Custom mac address', default="xx:xx:xx:xx:*:xx")
|
||||
optional.add_argument(
|
||||
'--num_vaps',
|
||||
help='Number of VAPs to Create',
|
||||
required=False,
|
||||
default=1)
|
||||
optional.add_argument(
|
||||
'--vap_flag',
|
||||
help='VAP flags to add',
|
||||
required=False,
|
||||
default=None,
|
||||
action='append')
|
||||
optional.add_argument(
|
||||
'--bridge',
|
||||
help='Create a bridge connecting the VAP to a port',
|
||||
required=False,
|
||||
default=False)
|
||||
optional.add_argument(
|
||||
'--mac',
|
||||
help='Custom mac address',
|
||||
default="xx:xx:xx:xx:*:xx")
|
||||
optional.add_argument('--mode', default='AUTO')
|
||||
optional.add_argument('--channel', default=36)
|
||||
optional.add_argument('--country_code', default=0)
|
||||
optional.add_argument('--nss', default=False)
|
||||
optional.add_argument('--resource', default=1)
|
||||
optional.add_argument('--start_id', default=0)
|
||||
optional.add_argument('--vap_name',default=None)
|
||||
optional.add_argument('--vap_name', default=None)
|
||||
args = parser.parse_args()
|
||||
#if args.debug:
|
||||
# if args.debug:
|
||||
# pprint.pprint(args)
|
||||
# time.sleep(5)
|
||||
if (args.radio is None):
|
||||
raise ValueError("--radio required")
|
||||
if args.radio is None:
|
||||
raise ValueError("--radio required")
|
||||
|
||||
num_vap = int(args.num_vaps)
|
||||
|
||||
vap_list = LFUtils.port_name_series(prefix="vap",
|
||||
start_id=int(args.start_id),
|
||||
end_id=num_vap-1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
#print(args.passwd)
|
||||
#print(args.ssid)
|
||||
start_id=int(args.start_id),
|
||||
end_id=num_vap - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
# print(args.passwd)
|
||||
# print(args.ssid)
|
||||
|
||||
if args.vap_name is None:
|
||||
for vap in vap_list:
|
||||
create_vap = CreateVAP(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_mode=args.mode,
|
||||
_vap_list=vap,
|
||||
_vap_list=vap,
|
||||
_resource=args.resource,
|
||||
_vap_flags=args.vap_flag,
|
||||
_radio=args.radio,
|
||||
_radio=args.radio,
|
||||
_channel=args.channel,
|
||||
_country_code=args.country_code,
|
||||
_nss=args.nss,
|
||||
_proxy_str=args.proxy,
|
||||
_proxy_str=args.proxy,
|
||||
_bridge=args.bridge,
|
||||
_debug_on=args.debug)
|
||||
_debug_on=args.debug)
|
||||
print('Creating VAP')
|
||||
|
||||
create_vap.build()
|
||||
else:
|
||||
vap_name = "vap"+args.vap_name
|
||||
vap_name = "vap" + args.vap_name
|
||||
create_vap = CreateVAP(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
@@ -196,5 +217,6 @@ Command example:
|
||||
|
||||
create_vap.build()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -12,7 +12,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -50,7 +50,8 @@ class CreateVR(Realm):
|
||||
self.vr_profile = self.new_vr_profile()
|
||||
|
||||
def clean(self):
|
||||
if (self.vr_name is None) or (self.vr_profile.vr_eid is None) and (self.vr_profile.vr_eid) == "":
|
||||
if (self.vr_name is None) or (self.vr_profile.vr_eid is None) and (
|
||||
self.vr_profile.vr_eid) == "":
|
||||
print("No vr_eid to clean")
|
||||
return
|
||||
self.rm_port("1.1.rd90a", debug_=self.debug)
|
||||
@@ -59,13 +60,13 @@ class CreateVR(Realm):
|
||||
debug_=self.debug)
|
||||
|
||||
if (self.vr_profile.vr_eid is not None) \
|
||||
and (self.vr_profile.vr_eid[1] is not None) \
|
||||
and (self.vr_profile.vr_eid[2] is not None):
|
||||
and (self.vr_profile.vr_eid[1] is not None) \
|
||||
and (self.vr_profile.vr_eid[2] is not None):
|
||||
self.vr_profile.cleanup(debug=self.debug)
|
||||
|
||||
if (self.vr_name is not None) \
|
||||
and (self.vr_name[1] is not None) \
|
||||
and (self.vr_name[2] is not None):
|
||||
and (self.vr_name[1] is not None) \
|
||||
and (self.vr_name[2] is not None):
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": self.vr_name[1],
|
||||
@@ -84,9 +85,9 @@ class CreateVR(Realm):
|
||||
"cx_name": "all"
|
||||
}, debug_=self.debug)
|
||||
|
||||
|
||||
def build(self):
|
||||
self.vr_profile.apply_netsmith(self.vr_name[1], delay=5, debug=self.debug)
|
||||
self.vr_profile.apply_netsmith(
|
||||
self.vr_name[1], delay=5, debug=self.debug)
|
||||
self.json_post("/cli-json/add_rdd", {
|
||||
"shelf": 1,
|
||||
"resource": self.vr_name[1],
|
||||
@@ -101,10 +102,17 @@ class CreateVR(Realm):
|
||||
"peer_ifname": "rd90a",
|
||||
"report_timer": "3000"
|
||||
})
|
||||
self.wait_until_ports_appear(sta_list=["1.1.rd90a", "1.1.rd90b"], debug_=self.debug)
|
||||
self.vr_profile.vrcx_list(resource=self.vr_name[1], do_sync=True) # do_sync
|
||||
self.wait_until_ports_appear(
|
||||
sta_list=[
|
||||
"1.1.rd90a",
|
||||
"1.1.rd90b"],
|
||||
debug_=self.debug)
|
||||
self.vr_profile.vrcx_list(
|
||||
resource=self.vr_name[1],
|
||||
do_sync=True) # do_sync
|
||||
self.vr_profile.create(vr_name=self.vr_name, debug=self.debug)
|
||||
self.vr_profile.sync_netsmith(resource=self.vr_name[1], debug=self.debug)
|
||||
self.vr_profile.sync_netsmith(
|
||||
resource=self.vr_name[1], debug=self.debug)
|
||||
self._pass("created router")
|
||||
|
||||
def start(self):
|
||||
@@ -113,25 +121,39 @@ class CreateVR(Realm):
|
||||
:return: void
|
||||
"""
|
||||
# move rd90a into router
|
||||
self.vr_profile.refresh_netsmith(resource=self.vr_name[1], debug=self.debug)
|
||||
self.vr_profile.refresh_netsmith(
|
||||
resource=self.vr_name[1], debug=self.debug)
|
||||
if self.debug:
|
||||
pprint(("vr_eid", self.vr_name))
|
||||
self.vr_profile.wait_until_vrcx_appear(resource=self.vr_name[1], name_list=["rd90a", "rd90b"])
|
||||
self.vr_profile.add_vrcx(vr_eid=self.vr_name, connection_name_list="rd90a", debug=True)
|
||||
self.vr_profile.wait_until_vrcx_appear(
|
||||
resource=self.vr_name[1], name_list=[
|
||||
"rd90a", "rd90b"])
|
||||
self.vr_profile.add_vrcx(
|
||||
vr_eid=self.vr_name,
|
||||
connection_name_list="rd90a",
|
||||
debug=True)
|
||||
|
||||
self.vr_profile.refresh_netsmith(resource=self.vr_name[1], debug=self.debug)
|
||||
self.vr_profile.refresh_netsmith(
|
||||
resource=self.vr_name[1], debug=self.debug)
|
||||
# test to make sure that vrcx is inside vr we expect
|
||||
self.vr_profile.vrcx_list(resource=self.vr_name[1], do_sync=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])
|
||||
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 120: ", router))
|
||||
router_eid = LFUtils.name_to_eid(router["eid"])
|
||||
pprint(("router eid 122: ", router_eid))
|
||||
full_router = self.json_get("/vr/1/%s/%s/%s" %(router_eid[0], router_eid[1], 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)
|
||||
self._fail("Unable to find router after vrcx move " + self.vr_name)
|
||||
self.exit_fail()
|
||||
|
||||
def stop(self):
|
||||
@@ -146,8 +168,8 @@ def main():
|
||||
--------------------
|
||||
Command example:
|
||||
{f} --vr_name 1.vr0 --ports 1.br0,1.rdd0a --services 1.br0=dhcp,nat --services 1.vr0=radvd
|
||||
{f} --vr_name 2.vr0 --ports 2.br0,2.vap2 --services
|
||||
|
||||
{f} --vr_name 2.vr0 --ports 2.br0,2.vap2 --services
|
||||
|
||||
--debug
|
||||
""".format(f=__file__))
|
||||
required = parser.add_argument_group('required arguments')
|
||||
@@ -156,8 +178,11 @@ Command example:
|
||||
|
||||
optional = parser.add_argument_group('optional arguments')
|
||||
|
||||
optional.add_argument('--ports', default=None, required=False,
|
||||
help='Comma separated list of ports to add to virtual router')
|
||||
optional.add_argument(
|
||||
'--ports',
|
||||
default=None,
|
||||
required=False,
|
||||
help='Comma separated list of ports to add to virtual router')
|
||||
optional.add_argument('--services', default=None, required=False,
|
||||
help='Add router services to a port, "br0=nat,dhcp"')
|
||||
|
||||
@@ -175,10 +200,11 @@ Command example:
|
||||
create_vr.build()
|
||||
create_vr.start()
|
||||
create_vr.monitor()
|
||||
#create_vr.stop()
|
||||
#create_vr.clean()
|
||||
# create_vr.stop()
|
||||
# create_vr.clean()
|
||||
print('Created Virtual Router')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
"""
|
||||
|
||||
Create and modify WAN Links Using LANforge JSON AP : http://www.candelatech.com/cookbook.php?vol=cli&book=JSON:+Managing+WANlinks+using+JSON+and+Python
|
||||
Written by Candela Technologies Inc.
|
||||
Updated by: Erin Grimes
|
||||
|
||||
"""
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
|
||||
from time import sleep
|
||||
import urllib
|
||||
import pprint
|
||||
|
||||
sys.path.append("../py-json")
|
||||
from LANforge import LFRequest
|
||||
from LANforge import LFUtils
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
|
||||
j_printer = pprint.PrettyPrinter(indent=2)
|
||||
# todo: this needs to change
|
||||
resource_id = 1
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse()
|
||||
args = parser.parse_args()
|
||||
base_url = 'http://%s:%s' % (args.mgr, args.mgr_port)
|
||||
print(base_url)
|
||||
json_post = ""
|
||||
json_response = ""
|
||||
num_wanlinks = -1
|
||||
|
||||
# force a refresh on the ports and wanlinks
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/nc_show_ports", debug_=True)
|
||||
lf_r.addPostData({
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "all",
|
||||
})
|
||||
json_response = lf_r.jsonPost(debug=True)
|
||||
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/nc_show_endpoints", debug_=True)
|
||||
lf_r.addPostData({
|
||||
"endpoint": "all"
|
||||
})
|
||||
json_response = lf_r.jsonPost(debug=True)
|
||||
|
||||
sleep(1)
|
||||
|
||||
# see if there are old wanlinks to remove
|
||||
lf_r = LFRequest.LFRequest(base_url+"/wl_ep/list", debug_=True)
|
||||
json_reponse = lf_r.get_as_json()
|
||||
|
||||
endpA = args['name']+"-A"
|
||||
endpB = args['name']+"-B"
|
||||
|
||||
# count the number of wanlink endpoints
|
||||
if "endpoint" in json_response:
|
||||
endpoint_map = LFUtils.list_to_alias_map(json_list=json_reponse, from_element="endpoint")
|
||||
if endpA in endpoint_map:
|
||||
num_wanlinks += 1
|
||||
if endpB in endpoint_map:
|
||||
num_wanlinks += 1
|
||||
|
||||
# remove old wanlinks
|
||||
if (num_wanlinks > 0):
|
||||
print("Removing old wanlinks...")
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/rm_cx", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'test_mgr': 'all',
|
||||
'cx_name': args['name']
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/rm_endp", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'endp_name': endpA
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/rm_endp", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'endp_name': endpB
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
sleep(1)
|
||||
|
||||
# check to see if we have ports
|
||||
lf_r = LFRequest.LFRequest(base_url+"/ports/1/1/list", debug_=True)
|
||||
port_response = lf_r.getAsJson()
|
||||
|
||||
if "interfaces" not in port_response:
|
||||
print("No interfaces in port_response!")
|
||||
pprint.pprint(port_response)
|
||||
exit(1)
|
||||
|
||||
if "interfaces" in port_response:
|
||||
port_map = LFUtils.list_to_alias_map(json_list=port_response, from_element="interfaces")
|
||||
ports_created = 0
|
||||
if args["port_A"] not in port_map:
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/add_rdd", debug_=True)
|
||||
lf_r.addPostData({
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": args["port_A"],
|
||||
"peer_ifname": args["port_A"]+"b",
|
||||
})
|
||||
json_reponse = lf_r.jsonPost(debug=True)
|
||||
if not json_response:
|
||||
print("could not create port "+args["port_A"])
|
||||
exit(1)
|
||||
sleep(0.1)
|
||||
ports_created += 1
|
||||
if args["port_B"] not in port_map:
|
||||
lf_r.addPostData({
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": args["port_B"],
|
||||
"peer_ifname": args["port_B"]+"b",
|
||||
})
|
||||
json_reponse = lf_r.jsonPost(debug=True)
|
||||
if not json_response:
|
||||
print("could not create port " + args["port_B"])
|
||||
exit(1)
|
||||
ports_created += 1
|
||||
sleep(0.1)
|
||||
if ports_created > 0:
|
||||
LFUtils.wait_until_ports_appear(base_url=base_url,
|
||||
port_list=(args["port_A"], args["port_B"]),
|
||||
debug=True)
|
||||
print("Created {} ports".format(ports_created))
|
||||
|
||||
# create wanlink endpoint A
|
||||
print("Adding WL Endpoints...", end='')
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/add_wl_endp", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'alias': endpA,
|
||||
'shelf': 1,
|
||||
'resource': '1',
|
||||
'port': args['port_A'],
|
||||
'latency': args['latency_A'],
|
||||
'max_rate': args['rate_A'],
|
||||
})
|
||||
json_response = lf_r.jsonPost(debug=True)
|
||||
if not json_response:
|
||||
print("Unable to create "+endpA)
|
||||
else:
|
||||
print("A, ", end='')
|
||||
# create wanlink endpoint B
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/add_wl_endp", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'alias': endpB,
|
||||
'shelf': 1,
|
||||
'resource': '1',
|
||||
'port': args['port_B'],
|
||||
'latency': args['latency_B'],
|
||||
'max_rate': args['rate_B'],
|
||||
})
|
||||
json_response = lf_r.jsonPost()
|
||||
if not json_response:
|
||||
print("Unable to create "+endpB)
|
||||
else:
|
||||
print("B")
|
||||
sleep(1)
|
||||
|
||||
# create cx
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/add_cx", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'alias': args['name'],
|
||||
'test_mgr': 'default_tm',
|
||||
'tx_endp': endpA,
|
||||
'rx_endp': endpB
|
||||
})
|
||||
lf_r.jsonPost(debug=True)
|
||||
sleep(0.5)
|
||||
|
||||
# modify wanlink endpoint A
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/set_wanlink_info", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'name': endpA,
|
||||
'max_jitter': args['jitter_A'],
|
||||
'jitter_freq': args['jitter_freq_A'],
|
||||
'drop_freq': args['drop_A']
|
||||
})
|
||||
lf_r.jsonPost(debug=True)
|
||||
|
||||
# modify wanlink endpoint B
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/set_wanlink_info", debug_=True)
|
||||
lf_r.addPostData({
|
||||
'name': endpB,
|
||||
'max_jitter': args['jitter_B'],
|
||||
'jitter_freq': args['jitter_freq_B'],
|
||||
'drop_freq': args['drop_B']
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
|
||||
# start wanlink once we see it
|
||||
seen = 0
|
||||
print("Looking for {} and {}: ".format(endpA, endpB), end='')
|
||||
while (seen < 2):
|
||||
sleep(1)
|
||||
lf_r = LFRequest.LFRequest(base_url+"/wl_ep/list?fields=name,eid")
|
||||
try:
|
||||
json_response = lf_r.getAsJson()
|
||||
if json_response is None:
|
||||
print(".", end="")
|
||||
continue
|
||||
LFUtils.debug_printer.pprint(json_response)
|
||||
if "endpoint" not in json_response:
|
||||
print("-", end="")
|
||||
continue
|
||||
|
||||
endpoint_map = LFUtils.list_to_alias_map(json_list=json_response["endpoint"],
|
||||
from_element="endpoint")
|
||||
if endpA in endpoint_map:
|
||||
seen += 1
|
||||
print("+", end="")
|
||||
if endpB in endpoint_map:
|
||||
seen += 1
|
||||
print("+", end="")
|
||||
|
||||
except urllib.error.HTTPError as error:
|
||||
print("Error code {}".format(error.code))
|
||||
continue
|
||||
print("")
|
||||
print("Starting wanlink:")
|
||||
# print("the latency is {laten}".format(laten=latency))
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/set_cx_state")
|
||||
lf_r.addPostData({
|
||||
'test_mgr': 'all',
|
||||
'cx_name': args['name'],
|
||||
'cx_state': 'RUNNING'
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
|
||||
running = 0
|
||||
while (running < 1):
|
||||
sleep(1)
|
||||
lf_r = LFRequest.LFRequest(base_url+"/wl/"+args['name']+"?fields=name,state,_links")
|
||||
try:
|
||||
json_response = lf_r.getAsJson()
|
||||
if (json_response is None):
|
||||
continue
|
||||
for key, value in json_response.items():
|
||||
if (isinstance(value, dict)):
|
||||
if ("_links" in value):
|
||||
if (value["name"] == args['name']):
|
||||
if (value["state"].startswith("Run")):
|
||||
LFUtils.debug_printer.pprint(json_response)
|
||||
running = 1
|
||||
|
||||
except urllib.error.HTTPError as error:
|
||||
print("Error code {}".format(error.code))
|
||||
continue
|
||||
|
||||
print("Wanlink is running")
|
||||
|
||||
# stop wanlink
|
||||
lf_r = LFRequest.LFRequest(base_url+"/cli-json/set_cx_state")
|
||||
lf_r.addPostData({
|
||||
'test_mgr': 'all',
|
||||
'cx_name': args['name'],
|
||||
'cx_state': 'STOPPED'
|
||||
})
|
||||
lf_r.jsonPost()
|
||||
running = 1
|
||||
while (running > 0):
|
||||
sleep(1)
|
||||
lf_r = LFRequest.LFRequest(base_url+"/wl/"+args['name']+"?fields=name,eid,state,_links")
|
||||
LFUtils.debug_printer.pprint(json_response)
|
||||
try:
|
||||
json_response = lf_r.getAsJson()
|
||||
if (json_response is None):
|
||||
continue
|
||||
for key, value in json_response.items():
|
||||
if (isinstance(value, dict)):
|
||||
if ("_links" in value):
|
||||
if (value["name"] == args['name']):
|
||||
if (value["state"].startswith("Stop")):
|
||||
LFUtils.debug_printer.pprint(json_response)
|
||||
running = 0
|
||||
|
||||
except urllib.error.HTTPError as error:
|
||||
print("Error code {}".format(error.code))
|
||||
continue
|
||||
|
||||
print("Wanlink is stopped.")
|
||||
|
||||
# print("Wanlink info:")
|
||||
# lf_r = LFRequest.LFRequest(base_url+"/wl/wl_eg1")
|
||||
# json_response = lf_r.getAsJson()
|
||||
# LFUtils.debug_printer.pprint(json_response)
|
||||
|
||||
# lf_r = LFRequest.LFRequest(base_url+"/wl_ep/wl_eg1-A")
|
||||
# json_response = lf_r.getAsJson()
|
||||
# LFUtils.debug_printer.pprint(json_response)
|
||||
|
||||
# lf_r = LFRequest.LFRequest(base_url+"/wl_ep/wl_eg1-B")
|
||||
# json_response = lf_r.getAsJson()
|
||||
# LFUtils.debug_printer.pprint(json_response)
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -23,14 +23,12 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
|
||||
class CSVParcer():
|
||||
def __init__(self,csv_infile=None,csv_outfile=None):
|
||||
class CSVParcer:
|
||||
def __init__(self, csv_infile=None, csv_outfile=None):
|
||||
|
||||
idx = 0
|
||||
i_atten = -1
|
||||
i_rotation = -1
|
||||
i_rxbps = -1
|
||||
@@ -46,34 +44,33 @@ class CSVParcer():
|
||||
x = line.split(",")
|
||||
cni = 0
|
||||
for cn in x:
|
||||
if (cn == "Attenuation [dB]"):
|
||||
if cn == "Attenuation [dB]":
|
||||
i_atten = cni
|
||||
if (cn == "Position [Deg]"):
|
||||
if cn == "Position [Deg]":
|
||||
i_rotation = cni
|
||||
if (cn == "Throughput [Mbps]"):
|
||||
if cn == "Throughput [Mbps]":
|
||||
i_rxbps = cni
|
||||
if (cn == "Beacon RSSI [dBm]"):
|
||||
if cn == "Beacon RSSI [dBm]":
|
||||
i_beacon_rssi = cni
|
||||
if (cn == "Data RSSI [dBm]"):
|
||||
if cn == "Data RSSI [dBm]":
|
||||
i_data_rssi = cni
|
||||
cni += 1
|
||||
|
||||
# Write out out header for the new file.
|
||||
fpo.write("Test Run,Position [Deg],Attenuation 1 [dB],Pal Stats Endpoint 1 Control Rssi [dBm],Pal Stats Endpoint 1 Data Rssi [dBm]\n")
|
||||
fpo.write(
|
||||
"Test Run,Position [Deg],Attenuation 1 [dB],Pal Stats Endpoint 1 Control Rssi [dBm],Pal Stats Endpoint 1 Data Rssi [dBm]\n")
|
||||
|
||||
# Read rest of the input lines, processing one at a time. Covert the columns as
|
||||
# needed, and write out new data to the output file.
|
||||
line = fp.readline()
|
||||
|
||||
bottom_half="Step Index,Position [Deg],Attenuation [dB],Traffic Pair 1 Throughput [Mbps]\n"
|
||||
bottom_half = "Step Index,Position [Deg],Attenuation [dB],Traffic Pair 1 Throughput [Mbps]\n"
|
||||
|
||||
test_run="1"
|
||||
test_run = "1"
|
||||
|
||||
step_i = 0
|
||||
while line:
|
||||
x = line.split(",")
|
||||
#print(x)
|
||||
#print([test_run, x[i_rotation], x[i_atten], x[i_beacon_rssi], x[i_data_rssi]])
|
||||
fpo.write("%s,%s,%s,%s,%s" % (test_run, x[i_rotation], x[i_atten], x[i_beacon_rssi], x[i_data_rssi]))
|
||||
bottom_half += ("%s,%s,%s,%s\n" % (step_i, x[i_rotation], x[i_atten], x[i_rxbps]))
|
||||
line = fp.readline()
|
||||
@@ -83,37 +80,36 @@ class CSVParcer():
|
||||
fpo.write("\n\n# RvRvO Data\n\n")
|
||||
fpo.write(bottom_half)
|
||||
|
||||
def main():
|
||||
|
||||
#debug_on = False
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='csv_convert.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Useful Information:
|
||||
''',
|
||||
|
||||
|
||||
description='''
|
||||
csv_convert.py:
|
||||
converts the candela brief csv into the data for specific customer,
|
||||
''')
|
||||
|
||||
# for testing parser.add_argument('-i','--infile', help="input file of csv data", default='text-csv-0-candela.csv')
|
||||
parser.add_argument('-i','--infile', help="input file of csv data", required=True)
|
||||
parser.add_argument('-o','--outfile', help="output file in .csv format", default='outfile.csv')
|
||||
|
||||
parser.add_argument('-i', '--infile', help="input file of csv data", required=True)
|
||||
parser.add_argument('-o', '--outfile', help="output file in .csv format", default='outfile.csv')
|
||||
|
||||
args = parser.parse_args()
|
||||
csv_outfile_name = None
|
||||
csv_infile_name = None
|
||||
|
||||
if args.infile:
|
||||
csv_infile_name = args.infile
|
||||
if args.outfile:
|
||||
csv_outfile_name = args.outfile
|
||||
|
||||
print("infile: %s outfile: %s"%(csv_infile_name, csv_outfile_name))
|
||||
print("infile: %s outfile: %s" % (csv_infile_name, csv_outfile_name))
|
||||
|
||||
CSVParcer(csv_infile_name, csv_outfile_name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
0
py-scripts/cv_examples/ap_auto_example.bash
Normal file
0
py-scripts/cv_examples/ap_auto_example.bash
Normal file
@@ -8,7 +8,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
@@ -29,6 +28,7 @@ class CVManager(cv_test):
|
||||
self.apply_cv_scenario(self.scenario)
|
||||
self.build_cv_scenario()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='cv_manager.py',
|
||||
@@ -45,5 +45,6 @@ def main():
|
||||
lfclient_host=args.mgr)
|
||||
manager.apply_and_build_scenario()
|
||||
|
||||
if __name__ =="__main__":
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
"""
|
||||
This script loads and builds a Chamber View Scenario, runs WiFi Capacity Test, runs Dataplane Test,
|
||||
and posts the results to Influx.
|
||||
There are optional arguments which will create a Grafana dashboard which will import the data posted to
|
||||
@@ -59,7 +59,7 @@ AP Auto test has the following argument:
|
||||
DUT syntax is somewhat tricky: DUT-name SSID BSID (bssid-idx), example: linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)
|
||||
* radio2: Specify 2.4Ghz radio. May be specified multiple times.
|
||||
* radio5: Specify 5Ghz radio. May be specified multiple times.
|
||||
'''
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
@@ -70,20 +70,24 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lf_wifi_capacity_test = importlib.import_module("py-scripts.lf_wifi_capacity_test")
|
||||
WiFiCapacityTest = lf_wifi_capacity_test.WiFiCapacityTest
|
||||
cv_test_manager = importlib.import_module("py-scripts.cv_test_manager")
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
create_chamberview = importlib.import_module("py-scripts.create_chamberview")
|
||||
CreateChamberview = create_chamberview.CreateChamberview
|
||||
DUT = create_chamberview.DUT
|
||||
create_chamberview_dut = importlib.import_module("py-scripts.create_chamberview_dut")
|
||||
DUT = create_chamberview_dut.DUT
|
||||
lf_dataplane_test = importlib.import_module("py-scripts.lf_dataplane_test")
|
||||
DataplaneTest = lf_dataplane_test.DataplaneTest
|
||||
grafana_profile = importlib.import_module("py-scripts.grafana_profile")
|
||||
UseGrafana = grafana_profile.UseGrafana
|
||||
lf_ap_auto_test = importlib.import_module("py-scripts.lf_ap_auto_test")
|
||||
ApAutoTest = lf_ap_auto_test.ApAutoTest
|
||||
|
||||
cv_add_base_parser = cv_test_manager.cv_add_base_parser
|
||||
cv_base_adjust_parser = cv_add_base_parser.cv_base_adjust_parser
|
||||
|
||||
|
||||
def main():
|
||||
@@ -169,7 +173,7 @@ def main():
|
||||
parser.add_argument('--grafana_port', help='Grafana port if different from 3000', default=3000)
|
||||
parser.add_argument('--grafana_host', help='Grafana host', default='localhost')
|
||||
|
||||
#Flags for AP-Auto Test config
|
||||
# Flags for AP-Auto Test config
|
||||
|
||||
parser.add_argument("--max_stations_2", type=int, default=-1,
|
||||
help="Specify maximum 2.4Ghz stations")
|
||||
@@ -187,14 +191,15 @@ def main():
|
||||
parser.add_argument("--radio5", action='append', nargs=1, default=[],
|
||||
help="Specify 5Ghz radio. May be specified multiple times.")
|
||||
|
||||
#Flags for Grafana
|
||||
# Flags for Grafana
|
||||
|
||||
parser.add_argument('--dashboard_title', help='Titles of dashboards', default=None, action='append')
|
||||
parser.add_argument('--scripts', help='Scripts to graph in Grafana', default=None, action='append')
|
||||
parser.add_argument('--title', help='title of your Grafana Dashboard', default=None)
|
||||
parser.add_argument('--testbed', help='Which testbed you want to query', default=None)
|
||||
parser.add_argument('--graph_groups_file', help='File which determines how you want to filter your graphs on your dashboard',
|
||||
default=None)
|
||||
parser.add_argument('--graph_groups_file',
|
||||
help='File which determines how you want to filter your graphs on your dashboard',
|
||||
default=None)
|
||||
parser.add_argument('--kpi', help='KPI file(s) which you want to graph form', action='append', default=None)
|
||||
parser.add_argument('--datasource', help='Name of Influx database if different from InfluxDB', default='InfluxDB')
|
||||
parser.add_argument('--from_date', help='Date you want to start your Grafana dashboard from', default='now-1y')
|
||||
|
||||
@@ -8,7 +8,7 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -19,7 +19,7 @@ Realm = realm.Realm
|
||||
|
||||
|
||||
class IPv4Test(LFCliBase):
|
||||
def __init__(self, ssid, security, password, sta_list=None, ap=None, mode = 0, number_template="00000", host="localhost", port=8080,radio = "wiphy0",_debug_on=False,
|
||||
def __init__(self, ssid, security, password, sta_list=None, ap=None, mode=0, number_template="00000", host="localhost", port=8080, radio="wiphy0", _debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
@@ -35,43 +35,49 @@ class IPv4Test(LFCliBase):
|
||||
self.timeout = 120
|
||||
self.number_template = number_template
|
||||
self.debug = _debug_on
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.local_realm = realm.Realm(
|
||||
lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_profile.ssid = self.ssid
|
||||
self.station_profile.ssid_pass = self.password
|
||||
self.station_profile.mode =self.mode
|
||||
self.station_profile.mode = self.mode
|
||||
self.station_profile.security = self.security
|
||||
self.station_profile.number_template_ = self.number_template
|
||||
self.station_profile.mode = mode
|
||||
if self.ap is not None:
|
||||
self.station_profile.set_command_param("add_sta", "ap",self.ap)
|
||||
self.station_profile.set_command_param("add_sta", "ap", self.ap)
|
||||
|
||||
def build(self):
|
||||
# Build stations
|
||||
#print("We've gotten into the build stations function")
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.use_security(
|
||||
self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag(
|
||||
"add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param(
|
||||
"set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.station_profile.create(
|
||||
radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.station_profile.admin_up()
|
||||
if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30):
|
||||
self._pass("Station build finished")
|
||||
self.exit_success()
|
||||
else:
|
||||
self._fail("Stations not able to acquire IP. Please check network input.")
|
||||
self._fail(
|
||||
"Stations not able to acquire IP. Please check network input.")
|
||||
self.exit_fail()
|
||||
|
||||
|
||||
def cleanup(self, sta_list):
|
||||
self.station_profile.cleanup(sta_list)
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list,
|
||||
debug=self.debug)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
@@ -97,18 +103,19 @@ def main():
|
||||
--passwd admin123-wpa3
|
||||
--debug
|
||||
''')
|
||||
required=None
|
||||
required = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
#if required is not None:
|
||||
# if required is not None:
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
optional = agroup
|
||||
if optional is not None:
|
||||
optional.add_argument('--mode',help=LFCliBase.Help_Mode)
|
||||
optional.add_argument('--ap',help='Add BSSID of access point to connect to')
|
||||
optional.add_argument('--mode', help=LFCliBase.Help_Mode)
|
||||
optional.add_argument(
|
||||
'--ap', help='Add BSSID of access point to connect to')
|
||||
|
||||
args = parser.parse_args()
|
||||
num_sta = 2
|
||||
@@ -117,18 +124,19 @@ def main():
|
||||
num_sta = num_stations_converted
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta",
|
||||
start_id_=0,
|
||||
end_id_=num_sta-1,
|
||||
padding_number_=10000,
|
||||
radio=args.radio)
|
||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
||||
ssid=args.ssid, password=args.passwd,
|
||||
radio=args.radio, mode= args.mode,
|
||||
security=args.security, sta_list=station_list,
|
||||
ap=args.ap)
|
||||
start_id_=0,
|
||||
end_id_=num_sta-1,
|
||||
padding_number_=10000,
|
||||
radio=args.radio)
|
||||
ip_test = IPv4Test(host=args.mgr, port=args.mgr_port,
|
||||
ssid=args.ssid, password=args.passwd,
|
||||
radio=args.radio, mode=args.mode,
|
||||
security=args.security, sta_list=station_list,
|
||||
ap=args.ap)
|
||||
ip_test.cleanup(station_list)
|
||||
ip_test.timeout = 60
|
||||
ip_test.build()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -172,13 +172,13 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
cvtest = cv_test_manager.cv_test
|
||||
cv_add_base_parser = cv_test_manager.cv_add_base_parser
|
||||
cv_base_adjust_parser = cv_test_manager.cv_base_adjust_parser
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
|
||||
|
||||
class ApAutoTest(cvtest):
|
||||
@@ -188,10 +188,11 @@ class ApAutoTest(cvtest):
|
||||
lf_user="lanforge",
|
||||
lf_password="lanforge",
|
||||
ssh_port=22,
|
||||
local_lf_report_dir="",
|
||||
local_lf_report_dir=None,
|
||||
lf_report_dir=None,
|
||||
instance_name="ap_auto_instance",
|
||||
config_name="ap_auto_config",
|
||||
upstream="1.1.eth1",
|
||||
upstream=None,
|
||||
pull_report=False,
|
||||
dut5_0="NA",
|
||||
dut2_0="NA",
|
||||
@@ -199,21 +200,33 @@ class ApAutoTest(cvtest):
|
||||
max_stations_2=100,
|
||||
max_stations_5=100,
|
||||
max_stations_dual=200,
|
||||
radio2=[],
|
||||
radio5=[],
|
||||
enables=[],
|
||||
disables=[],
|
||||
raw_lines=[],
|
||||
radio2=None,
|
||||
radio5=None,
|
||||
enables=None,
|
||||
disables=None,
|
||||
raw_lines=None,
|
||||
raw_lines_file="",
|
||||
sets=[],
|
||||
sets=None,
|
||||
graph_groups=None
|
||||
):
|
||||
super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
|
||||
|
||||
if radio2 is None:
|
||||
radio2 = []
|
||||
if radio5 is None:
|
||||
radio5 = []
|
||||
if enables is None:
|
||||
enables = []
|
||||
if disables is None:
|
||||
disables = []
|
||||
if raw_lines is None:
|
||||
raw_lines = []
|
||||
if sets is None:
|
||||
sets = []
|
||||
self.lf_host = lf_host
|
||||
self.lf_port = lf_port
|
||||
self.lf_user = lf_user
|
||||
self.lf_password =lf_password
|
||||
self.lf_password = lf_password
|
||||
self.instance_name = instance_name
|
||||
self.config_name = config_name
|
||||
self.upstream = upstream
|
||||
@@ -234,19 +247,19 @@ class ApAutoTest(cvtest):
|
||||
self.sets = sets
|
||||
self.ssh_port = ssh_port
|
||||
self.graph_groups = graph_groups
|
||||
self.lf_report_dir = lf_report_dir
|
||||
self.local_lf_report_dir = local_lf_report_dir
|
||||
|
||||
def setup(self):
|
||||
# Nothing to do at this time.
|
||||
return
|
||||
|
||||
|
||||
def run(self):
|
||||
self.sync_cv()
|
||||
time.sleep(2)
|
||||
self.sync_cv()
|
||||
|
||||
blob_test = "%s-"%(self.test_name)
|
||||
blob_test = "%s-" % self.test_name
|
||||
|
||||
self.rm_text_blob(self.config_name, blob_test) # To delete old config with same name
|
||||
self.show_text_blob(None, None, False)
|
||||
@@ -256,19 +269,19 @@ class ApAutoTest(cvtest):
|
||||
|
||||
ridx = 0
|
||||
for r in self.radio2:
|
||||
cfg_options.append("radio2-%i: %s"%(ridx, r[0]))
|
||||
cfg_options.append("radio2-%i: %s" % (ridx, r[0]))
|
||||
ridx += 1
|
||||
|
||||
ridx = 0
|
||||
for r in self.radio5:
|
||||
cfg_options.append("radio5-%i: %s"%(ridx, r[0]))
|
||||
cfg_options.append("radio5-%i: %s" % (ridx, r[0]))
|
||||
ridx += 1
|
||||
|
||||
self.apply_cfg_options(cfg_options, self.enables, self.disables, self.raw_lines, self.raw_lines_file)
|
||||
|
||||
# Command line args take precedence.
|
||||
if self.upstream != "":
|
||||
cfg_options.append("upstream_port: " + self.upstream)
|
||||
if self.upstream:
|
||||
cfg_options.append("upstream-port: %s" % self.upstream)
|
||||
if self.dut5_0 != "":
|
||||
cfg_options.append("dut5-0: " + self.dut5_0)
|
||||
if self.dut2_0 != "":
|
||||
@@ -294,7 +307,6 @@ class ApAutoTest(cvtest):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_ap_auto_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
@@ -302,28 +314,28 @@ def main():
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
./lf_ap_auto_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name ap-auto-instance --config_name test_con --upstream 1.1.eth2 \
|
||||
--dut5_0 'linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)' \
|
||||
--dut2_0 'linksys-8450 Default-SSID-2g c4:41:1e:f5:3f:24 (1)' \
|
||||
--max_stations_2 100 --max_stations_5 100 --max_stations_dual 200 \
|
||||
--radio2 1.1.wiphy0 --radio2 1.1.wiphy2 \
|
||||
--radio5 1.1.wiphy1 --radio5 1.1.wiphy3 --radio5 1.1.wiphy4 \
|
||||
--radio5 1.1.wiphy5 --radio5 1.1.wiphy6 --radio5 1.1.wiphy7 \
|
||||
--set 'Basic Client Connectivity' 1 --set 'Multi Band Performance' 1 \
|
||||
--set 'Skip 2.4Ghz Tests' 1 --set 'Skip 5Ghz Tests' 1 \
|
||||
--set 'Throughput vs Pkt Size' 0 --set 'Capacity' 0 --set 'Stability' 0 --set 'Band-Steering' 0 \
|
||||
--set 'Multi-Station Throughput vs Pkt Size' 0 --set 'Long-Term' 0 \
|
||||
--test_rig Testbed-01 --test_tag ATH10K --pull_report \
|
||||
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
--influx_bucket ben \
|
||||
./lf_ap_auto_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \\
|
||||
--instance_name ap-auto-instance --config_name test_con --upstream 1.1.eth2 \\
|
||||
--dut5_0 'linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)' \\
|
||||
--dut2_0 'linksys-8450 Default-SSID-2g c4:41:1e:f5:3f:24 (1)' \\
|
||||
--max_stations_2 100 --max_stations_5 100 --max_stations_dual 200 \\
|
||||
--radio2 1.1.wiphy0 --radio2 1.1.wiphy2 \\
|
||||
--radio5 1.1.wiphy1 --radio5 1.1.wiphy3 --radio5 1.1.wiphy4 \\
|
||||
--radio5 1.1.wiphy5 --radio5 1.1.wiphy6 --radio5 1.1.wiphy7 \\
|
||||
--set 'Basic Client Connectivity' 1 --set 'Multi Band Performance' 1 \\
|
||||
--set 'Skip 2.4Ghz Tests' 1 --set 'Skip 5Ghz Tests' 1 \\
|
||||
--set 'Throughput vs Pkt Size' 0 --set 'Capacity' 0 --set 'Stability' 0 --set 'Band-Steering' 0 \\
|
||||
--set 'Multi-Station Throughput vs Pkt Size' 0 --set 'Long-Term' 0 \\
|
||||
--test_rig Testbed-01 --test_tag ATH10K --pull_report \\
|
||||
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \\
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \\
|
||||
--influx_bucket ben \\
|
||||
--influx_tag testbed Ferndale-01
|
||||
"""
|
||||
)
|
||||
)
|
||||
cv_add_base_parser(parser) # see cv_test_manager.py
|
||||
|
||||
parser.add_argument("-u", "--upstream", type=str, default="",
|
||||
parser.add_argument("-u", "--upstream", type=str, default=None,
|
||||
help="Upstream port for wifi capacity test ex. 1.1.eth1")
|
||||
|
||||
parser.add_argument("--max_stations_2", type=int, default=-1,
|
||||
@@ -341,39 +353,46 @@ def main():
|
||||
help="Specify 2.4Ghz radio. May be specified multiple times.")
|
||||
parser.add_argument("--radio5", action='append', nargs=1, default=[],
|
||||
help="Specify 5Ghz radio. May be specified multiple times.")
|
||||
parser.add_argument("--local_lf_report_dir", help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from",default="")
|
||||
parser.add_argument("--local_lf_report_dir",
|
||||
help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from",
|
||||
default="")
|
||||
parser.add_argument("--lf_report_dir",
|
||||
help="--lf_report_dir <where to pull reports from> default '' put where dataplane script run from",
|
||||
default="")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
cv_base_adjust_parser(args)
|
||||
|
||||
CV_Test = ApAutoTest(lf_host = args.mgr,
|
||||
lf_port = args.port,
|
||||
lf_user = args.lf_user,
|
||||
lf_password = args.lf_password,
|
||||
instance_name = args.instance_name,
|
||||
config_name = args.config_name,
|
||||
upstream = args.upstream,
|
||||
pull_report = args.pull_report,
|
||||
local_lf_report_dir = args.local_lf_report_dir,
|
||||
dut5_0 = args.dut5_0,
|
||||
dut2_0 = args.dut2_0,
|
||||
load_old_cfg = args.load_old_cfg,
|
||||
max_stations_2 = args.max_stations_2,
|
||||
max_stations_5 = args.max_stations_5,
|
||||
max_stations_dual = args.max_stations_dual,
|
||||
radio2 = args.radio2,
|
||||
radio5 = args.radio5,
|
||||
enables = args.enable,
|
||||
disables = args.disable,
|
||||
raw_lines = args.raw_line,
|
||||
raw_lines_file = args.raw_lines_file,
|
||||
sets = args.set
|
||||
CV_Test = ApAutoTest(lf_host=args.mgr,
|
||||
lf_port=args.port,
|
||||
lf_user=args.lf_user,
|
||||
lf_password=args.lf_password,
|
||||
instance_name=args.instance_name,
|
||||
config_name=args.config_name,
|
||||
upstream=args.upstream,
|
||||
pull_report=args.pull_report,
|
||||
local_lf_report_dir=args.local_lf_report_dir,
|
||||
lf_report_dir=args.lf_report_dir,
|
||||
dut5_0=args.dut5_0,
|
||||
dut2_0=args.dut2_0,
|
||||
load_old_cfg=args.load_old_cfg,
|
||||
max_stations_2=args.max_stations_2,
|
||||
max_stations_5=args.max_stations_5,
|
||||
max_stations_dual=args.max_stations_dual,
|
||||
radio2=args.radio2,
|
||||
radio5=args.radio5,
|
||||
enables=args.enable,
|
||||
disables=args.disable,
|
||||
raw_lines=args.raw_line,
|
||||
raw_lines_file=args.raw_lines_file,
|
||||
sets=args.set
|
||||
)
|
||||
CV_Test.setup()
|
||||
CV_Test.run()
|
||||
|
||||
CV_Test.check_influx_kpi(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
38
py-scripts/lf_csv.py
Normal file → Executable file
38
py-scripts/lf_csv.py
Normal file → Executable file
@@ -42,39 +42,9 @@ class lf_csv:
|
||||
print(csv_df)
|
||||
csv_df.to_csv(self.filename, index=False, encoding='utf-8', na_rep='NA', float_format='%.2f')
|
||||
|
||||
# this layout may need to change
|
||||
'''
|
||||
kpi.csv : specific file that is used for the database, dashboard and blog post
|
||||
A blank entry is a valid entry in some cases.
|
||||
|
||||
Date: date of run
|
||||
test-rig : testbed that the tests are run on for example ct_us_001
|
||||
test-tag : test specific information to differenciate the test, LANforge radios used, security modes (wpa2 , open)
|
||||
dut-hw-version : hardware version of the device under test
|
||||
dut-sw-version : software version of the device under test
|
||||
dut-model-num : model number / name of the device under test
|
||||
test-priority : test-priority is arbitrary number, choosing under 95 means it goes down at bottom of blog report, and higher priority goes at top.
|
||||
test-id : script or test name , AP Auto, wifi capacity, data plane, dfs
|
||||
short-description : short description of the test
|
||||
pass/fail : set blank for performance tests
|
||||
numeric-score : this is the value for the y-axis (x-axis is a timestamp), numeric value of what was measured
|
||||
test-details : what was measured in the numeric-score, e.g. bits per second, bytes per second, upload speed, minimum cx time (ms)
|
||||
Units : units used for the numeric-scort
|
||||
Graph-Group - For the dashboard the graph / panel to put the resutls in . Currently the dashboard is Grafana
|
||||
|
||||
'''
|
||||
class lf_kpi_csv:
|
||||
def __init__(self,
|
||||
_kpi_headers = ['Date','test-rig','test-tag','dut-hw-version','dut-sw-version','dut-model-num',
|
||||
'test-priority','test-id','short-description','pass/fail','numberic-score'
|
||||
'test details','Units','Graph-Group','Subtest-Pass','Subtest-Fail'],
|
||||
_kpi_file='kpi.csv' #Currently this is the only file name accepted
|
||||
):
|
||||
self.kpi_headers = _kpi_headers
|
||||
self.kpi_rows = ""
|
||||
self.kpi_filename = _kpi_file
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
test = lf_csv()
|
||||
test.generate_csv()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -9,7 +9,7 @@ Note: To Run this script gui should be opened with
|
||||
This script is used to automate running Dataplane tests. You
|
||||
may need to view a Dataplane test configured through the GUI to understand
|
||||
the options and how best to input data.
|
||||
|
||||
|
||||
./lf_dataplane_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name dataplane-instance --config_name test_con --upstream 1.1.eth2 \
|
||||
--dut linksys-8450 --duration 15s --station 1.1.sta01500 \
|
||||
@@ -39,7 +39,7 @@ port_sorting: 0
|
||||
kpi_id: Dataplane Pkt-Size
|
||||
notes0: ec5211 in bridge mode, wpa2 auth.
|
||||
bg: 0xE0ECF8
|
||||
test_rig:
|
||||
test_rig:
|
||||
show_scan: 1
|
||||
auto_helper: 0
|
||||
skip_2: 0
|
||||
@@ -87,7 +87,7 @@ show_1m: 1
|
||||
pause_iter: 0
|
||||
outer_loop_atten: 0
|
||||
show_realtime: 1
|
||||
operator:
|
||||
operator:
|
||||
mconn: 1
|
||||
mpkt: 1000
|
||||
tos: 0
|
||||
@@ -105,7 +105,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
@@ -132,17 +131,24 @@ class DataplaneTest(cv_test):
|
||||
duration="15s",
|
||||
station="1.1.sta01500",
|
||||
dut="NA",
|
||||
enables=[],
|
||||
disables=[],
|
||||
raw_lines=[],
|
||||
enables=None,
|
||||
disables=None,
|
||||
raw_lines=None,
|
||||
raw_lines_file="",
|
||||
sets=[],
|
||||
sets=None,
|
||||
graph_groups=None,
|
||||
report_dir="",
|
||||
test_rig=""
|
||||
):
|
||||
super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
|
||||
|
||||
if enables is None:
|
||||
enables = []
|
||||
if disables is None:
|
||||
disables = []
|
||||
if raw_lines is None:
|
||||
raw_lines = []
|
||||
if sets is None:
|
||||
sets = []
|
||||
self.lf_host = lf_host
|
||||
self.lf_port = lf_port
|
||||
self.lf_user = lf_user
|
||||
@@ -164,7 +170,6 @@ class DataplaneTest(cv_test):
|
||||
self.raw_lines_file = raw_lines_file
|
||||
self.sets = sets
|
||||
self.graph_groups = graph_groups
|
||||
self.report_dir = report_dir
|
||||
self.ssh_port = ssh_port
|
||||
self.local_lf_report_dir = local_lf_report_dir
|
||||
self.test_rig = test_rig
|
||||
@@ -180,14 +185,16 @@ class DataplaneTest(cv_test):
|
||||
|
||||
blob_test = "dataplane-test-latest-"
|
||||
|
||||
self.rm_text_blob(self.config_name, blob_test) # To delete old config with same name
|
||||
# To delete old config with same name
|
||||
self.rm_text_blob(self.config_name, blob_test)
|
||||
self.show_text_blob(None, None, False)
|
||||
|
||||
# Test related settings
|
||||
cfg_options = []
|
||||
|
||||
### HERE###
|
||||
self.apply_cfg_options(cfg_options, self.enables, self.disables, self.raw_lines, self.raw_lines_file)
|
||||
self.apply_cfg_options(cfg_options, self.enables,
|
||||
self.disables, self.raw_lines, self.raw_lines_file)
|
||||
|
||||
# cmd line args take precedence and so come last in the cfg array.
|
||||
if self.upstream != "":
|
||||
@@ -215,7 +222,8 @@ class DataplaneTest(cv_test):
|
||||
self.pull_report, self.lf_host, self.lf_user, self.lf_password,
|
||||
cv_cmds, ssh_port=self.ssh_port, local_lf_report_dir=self.local_lf_report_dir,
|
||||
graph_groups_file=self.graph_groups)
|
||||
self.rm_text_blob(self.config_name, blob_test) # To delete old config with same name
|
||||
# To delete old config with same name
|
||||
self.rm_text_blob(self.config_name, blob_test)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -226,7 +234,7 @@ def main():
|
||||
|
||||
IMPORTANT: Start lanforge with socket 3990 : ./lfclient.bash -cli-socket 3990
|
||||
lfclient.bash is located in the LANforgeGUI_X.X.X directory
|
||||
|
||||
|
||||
On local or remote system: ./lfclient.bash -cli-socket 3990 -s LF_MGR
|
||||
On local system the -s LF_MGR will be local_host if not provided
|
||||
|
||||
@@ -246,7 +254,7 @@ def main():
|
||||
--influx_bucket ben \
|
||||
--influx_tag testbed Ferndale-01
|
||||
|
||||
|
||||
|
||||
Example 2:
|
||||
./lf_dataplane_test.py --json <name>.json
|
||||
|
||||
@@ -254,46 +262,47 @@ def main():
|
||||
|
||||
Sample <name>.json between using eth1 and eth2
|
||||
{
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.eth2",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.eth2",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
}
|
||||
|
||||
|
||||
Sample <name>.json between using eth1 and station 1.1.sta0002
|
||||
{
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.sta0002",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
}
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.sta0002",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
}
|
||||
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
cv_add_base_parser(parser) # see cv_test_manager.py
|
||||
|
||||
parser.add_argument('--json', help="--json <config.json> json input file", default="")
|
||||
parser.add_argument('--influx_json', help="--influx_json <influx_config.json> influx config json input file",
|
||||
default="")
|
||||
parser.add_argument(
|
||||
'--json', help="--json <config.json> json input file", default="")
|
||||
parser.add_argument(
|
||||
'--influx_json', help="--influx_json <influx_config.json> influx config json input file", default="")
|
||||
parser.add_argument("-u", "--upstream", type=str, default="",
|
||||
help="Upstream port for wifi capacity test ex. 1.1.eth2")
|
||||
parser.add_argument("--station", type=str, default="",
|
||||
@@ -307,8 +316,8 @@ def main():
|
||||
help="Specify requested upload speed. Percentage of theoretical is also supported. Default: 0")
|
||||
parser.add_argument("--duration", default="",
|
||||
help="Specify duration of each traffic run")
|
||||
parser.add_argument("--graph_groups", help="File to save graph_groups to", default=None)
|
||||
parser.add_argument("--report_dir", default="")
|
||||
parser.add_argument(
|
||||
"--graph_groups", help="File to save graph_groups to", default=None)
|
||||
parser.add_argument("--local_lf_report_dir",
|
||||
help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from",
|
||||
default="")
|
||||
@@ -316,12 +325,12 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
# use json config file
|
||||
if args.json != "":
|
||||
try:
|
||||
if args.json:
|
||||
if os.path.exists(args.json):
|
||||
with open(args.json, 'r') as json_config:
|
||||
json_data = json.load(json_config)
|
||||
except:
|
||||
print("Error reading {}".format(args.json))
|
||||
else:
|
||||
return FileNotFoundError("Error reading {}".format(args.json))
|
||||
# json configuation takes presidence to command line
|
||||
if "mgr" in json_data:
|
||||
args.mgr = json_data["mgr"]
|
||||
@@ -356,12 +365,12 @@ def main():
|
||||
args.raw_line = json_data_tmp
|
||||
|
||||
# use influx json config file
|
||||
if args.influx_json != "":
|
||||
try:
|
||||
with open(args.influx_json, 'r') as influx_json_config:
|
||||
influx_json_data = json.load(influx_json_config)
|
||||
except:
|
||||
print("Error reading {}".format(args.influx_json))
|
||||
if args.influx_json:
|
||||
if os.path.exists(args.influx_json):
|
||||
with open(args.influx_json, 'r') as json_config:
|
||||
influx_json_data = json.load(json_config)
|
||||
else:
|
||||
return FileNotFoundError("Error reading {}".format(args.influx_json))
|
||||
# json configuation takes presidence to command line
|
||||
# influx DB configuration
|
||||
if "influx_host" in influx_json_data:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
"""
|
||||
This Script has two classes :
|
||||
1. LoadScenario : It will load the existing saved scenario to the Lanforge (Here used for Loading Bridged VAP)
|
||||
2. CreateSTA_CX : It will create stations and L3 Cross connects and start them
|
||||
@@ -7,11 +7,11 @@
|
||||
In this example, Another Lanforge is used as DUT
|
||||
It also have a function : GenerateReport that generates the report in xlsx format as well as it plots the Graph of throughput over time with temperature
|
||||
It also have Plot function that generates a html page that contains the plot
|
||||
|
||||
|
||||
Prerequisite
|
||||
|
||||
|
||||
Prerequisite
|
||||
Start the Lanforge Manager both Sides
|
||||
|
||||
|
||||
Installation
|
||||
pip install paramiko
|
||||
pip install bokeh
|
||||
@@ -21,13 +21,12 @@
|
||||
.\Lexus_Final.py --lf_host 192.168.200.15 --dut_host 192.168.200.18 --dut_radio wiphy1 --lf_radio wiphy1 --num_sta 1 --sta_id 1 --lf_ssid lanforge_ap --dut_ssid lexusap --security open --dut_upstream eth2 --lf_upstream eth1 --protocol lf_udp --min_bps 1000 --max_bps 10000 --time 1
|
||||
This Script is intended to automate the testing of DUT that has stations as well as AP.
|
||||
To automate the simultaenous testing and check the DUT Temperature
|
||||
'''
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
import logging
|
||||
import paramiko as pm
|
||||
from paramiko.ssh_exception import NoValidConnectionsError as exception
|
||||
import xlsxwriter
|
||||
@@ -39,7 +38,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -53,58 +51,60 @@ Realm = realm.Realm
|
||||
class Login_DUT:
|
||||
|
||||
def __init__(self, threadID, name, HOST):
|
||||
self.threadID = threadID
|
||||
self.name = name
|
||||
self.host=HOST
|
||||
self.USERNAME = "lanforge"
|
||||
self.PASSWORD = "lanforge"
|
||||
self.CLIENT= pm.SSHClient()
|
||||
self.LF1= self.Connect()
|
||||
self.data_core1=[]
|
||||
self.data_core2=[]
|
||||
if self.CLIENT == 0:
|
||||
exit()
|
||||
print("Connected to " +HOST+" DUT to Measure the Core Temperature")
|
||||
self.threadID = threadID
|
||||
self.name = name
|
||||
self.host = HOST
|
||||
self.USERNAME = "lanforge"
|
||||
self.PASSWORD = "lanforge"
|
||||
self.CLIENT = pm.SSHClient()
|
||||
self.LF1 = self.Connect()
|
||||
self.data_core1 = []
|
||||
self.data_core2 = []
|
||||
if self.CLIENT == 0:
|
||||
exit()
|
||||
print("Connected to " + HOST + " DUT to Measure the Core Temperature")
|
||||
|
||||
def run(self):
|
||||
stdin, stdout, stderr= self.CLIENT.exec_command("sensors")
|
||||
stdin, stdout, stderr = self.CLIENT.exec_command("sensors")
|
||||
out_lines = stdout.readlines()
|
||||
err_lines = stderr.readlines()
|
||||
print(out_lines[len(out_lines)-3], out_lines[len(out_lines)-2])
|
||||
self.data_core1.append(out_lines[len(out_lines)-3])
|
||||
self.data_core2.append(out_lines[len(out_lines)-2])
|
||||
|
||||
print(out_lines[len(out_lines) - 3], out_lines[len(out_lines) - 2])
|
||||
self.data_core1.append(out_lines[len(out_lines) - 3])
|
||||
self.data_core2.append(out_lines[len(out_lines) - 2])
|
||||
|
||||
def Connect(self):
|
||||
self.CLIENT.load_system_host_keys()
|
||||
self.CLIENT.set_missing_host_key_policy(pm.AutoAddPolicy())
|
||||
try:
|
||||
self.CLIENT.connect(self.host, username=self.USERNAME, password=self.PASSWORD,timeout=10)
|
||||
return None
|
||||
self.CLIENT.connect(self.host, username=self.USERNAME, password=self.PASSWORD, timeout=10)
|
||||
return None
|
||||
except exception as error:
|
||||
self.CLIENT = 0;
|
||||
self.CLIENT = 0
|
||||
return None
|
||||
|
||||
|
||||
# Class to Load a Scenario that has been Created in Chamber View saved under DB/[Database_Name]
|
||||
class LoadScenario(LFCliBase):
|
||||
def __init__(self, host, port, db_name, security_debug_on=False, _exit_on_error=False,_exit_on_fail=False):
|
||||
def __init__(self, host, port, db_name, security_debug_on=False, _exit_on_error=False, _exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=security_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.json_post("/cli-json/load", { "name": db_name, "action": 'overwrite' })
|
||||
print(host+ " : Scenario Loaded...")
|
||||
self.json_post("/cli-json/load", {"name": db_name, "action": 'overwrite'})
|
||||
print(host + " : Scenario Loaded...")
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
# Class to create stations and run L3 Cross connects and run them for given time. It also stores the endpoint names for measuring throughput
|
||||
class CreateSTA_CX(LFCliBase):
|
||||
|
||||
def __init__(self, host, port, radio, num_sta, sta_id, ssid, security, password, upstream, protocol, min_bps, max_bps, security_debug_on=True, _exit_on_error=True, _exit_on_fail=True):
|
||||
|
||||
def __init__(self, host, port, radio, num_sta, sta_id, ssid, security, password, upstream, protocol, min_bps,
|
||||
max_bps, security_debug_on=True, _exit_on_error=True, _exit_on_fail=True):
|
||||
super().__init__(host, port, _debug=security_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
|
||||
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.radio = radio
|
||||
|
||||
|
||||
self.num_sta = num_sta
|
||||
self.sta_id = sta_id
|
||||
|
||||
@@ -116,25 +116,25 @@ class CreateSTA_CX(LFCliBase):
|
||||
self.upstream = upstream
|
||||
self.protocol = protocol
|
||||
|
||||
self.min_bps =min_bps
|
||||
self.max_bps =max_bps
|
||||
self.min_bps = min_bps
|
||||
self.max_bps = max_bps
|
||||
|
||||
#Creating a Realm Object
|
||||
# Creating a Realm Object
|
||||
self.local_realm = Realm(lfclient_host=host, lfclient_port=port)
|
||||
|
||||
#Creating Profile Objects
|
||||
# Creating Profile Objects
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.cx_profile = self.local_realm.new_l3_cx_profile()
|
||||
|
||||
#Setting CX Name
|
||||
self.cx_profile.name_prefix_="Connection"
|
||||
# Setting CX Name
|
||||
self.cx_profile.name_prefix_ = "Connection"
|
||||
self.cx_names = []
|
||||
self.sta_list = []
|
||||
self.endp=[]
|
||||
for i in range(sta_id,sta_id+num_sta):
|
||||
self.endp = []
|
||||
for i in range(sta_id, sta_id + num_sta):
|
||||
self.sta_list.append("sta00")
|
||||
|
||||
#portDhcpUpRequest
|
||||
|
||||
# portDhcpUpRequest
|
||||
'''
|
||||
upstream_dhcp = LFRequest.LFRequest("http://"+str(host)+":"+str(port)+"/"+"/cli-form/set_port")
|
||||
upstream_dhcp.addPostData( LFUtils.portSetDhcpDownRequest(1, upstream))
|
||||
@@ -147,42 +147,42 @@ class CreateSTA_CX(LFCliBase):
|
||||
|
||||
def build(self):
|
||||
|
||||
#Creating Stations of Given Profile Settings
|
||||
# Creating Stations of Given Profile Settings
|
||||
self.station_profile.use_security(self.security, self.ssid, passwd=self.password)
|
||||
self.station_profile.create(self.radio, num_stations=self.num_sta, sta_names_=self.sta_list)
|
||||
self.station_profile.admin_up()
|
||||
#Wait for a while
|
||||
# Wait for a while
|
||||
time.sleep(15)
|
||||
|
||||
#Setting up the Parameters for CX
|
||||
|
||||
# Setting up the Parameters for CX
|
||||
self.cx_profile.side_a_min_bps = self.min_bps
|
||||
self.cx_profile.side_b_min_bps = self.min_bps
|
||||
self.cx_profile.side_a_max_bps = self.max_bps
|
||||
self.cx_profile.side_b_max_bps = self.max_bps
|
||||
|
||||
|
||||
self.cx_profile.side_a_min_pdu = 'Auto'
|
||||
self.cx_profile.side_b_min_pdu = 'Auto'
|
||||
self.cx_profile.report_timer = 1000
|
||||
self.cx_profile.side_a_min_pkt='Same'
|
||||
self.cx_profile.side_a_max_pkt='Same'
|
||||
|
||||
#Create Connections of Given Parameters
|
||||
self.cx_profile.create(self.protocol, side_a="1.1."+self.upstream, side_b=list(self.local_realm.find_ports_like("sta0+")))
|
||||
self.cx_profile.side_a_min_pkt = 'Same'
|
||||
self.cx_profile.side_a_max_pkt = 'Same'
|
||||
|
||||
# Create Connections of Given Parameters
|
||||
self.cx_profile.create(self.protocol, side_a="1.1." + self.upstream,
|
||||
side_b=list(self.local_realm.find_ports_like("sta0+")))
|
||||
time.sleep(15)
|
||||
|
||||
|
||||
# Getting all the Endpoint Names for measuring Throughput Later
|
||||
for i in self.cx_profile.get_cx_names():
|
||||
self.cx_names.append(i)
|
||||
self.cx_names.append(i)
|
||||
for j in self.cx_names:
|
||||
x=self.local_realm.json_get("/cx/"+j)
|
||||
x = self.local_realm.json_get("/cx/" + j)
|
||||
self.endp.append(x.get(j).get('endpoints')[1])
|
||||
#print(self.endp)
|
||||
# print(self.endp)
|
||||
return 0
|
||||
|
||||
|
||||
def start(self):
|
||||
#self.station_profile.admin_up()
|
||||
|
||||
# self.station_profile.admin_up()
|
||||
|
||||
self.cx_profile.start_cx()
|
||||
time.sleep(5)
|
||||
return 0
|
||||
@@ -197,75 +197,71 @@ class CreateSTA_CX(LFCliBase):
|
||||
def cleanup(self):
|
||||
# Removing Connections
|
||||
self.local_realm.cleanup_cxe_prefix(self.cx_profile.name_prefix)
|
||||
|
||||
|
||||
vap = self.local_realm.find_ports_like("vap+")
|
||||
bridges = self.local_realm.find_ports_like("br+")
|
||||
station_map = self.local_realm.find_ports_like("sta+")
|
||||
#Removing Bridges
|
||||
for eid,record in bridges.items():
|
||||
# Removing Bridges
|
||||
for eid, record in bridges.items():
|
||||
self.local_realm.remove_vlan_by_eid(eid)
|
||||
time.sleep(0.03)
|
||||
#Removing VAP
|
||||
for eid,record in vap.items():
|
||||
# Removing VAP
|
||||
for eid, record in vap.items():
|
||||
self.local_realm.remove_vlan_by_eid(eid)
|
||||
time.sleep(0.03)
|
||||
|
||||
#Removing stations
|
||||
for eid,record in station_map.items():
|
||||
|
||||
# Removing stations
|
||||
for eid, record in station_map.items():
|
||||
self.local_realm.remove_vlan_by_eid(eid)
|
||||
time.sleep(0.03)
|
||||
del_sta_names = []
|
||||
try:
|
||||
for eid,value in station_map.items():
|
||||
for eid, value in station_map.items():
|
||||
tname = eid[eid.rfind('.'):]
|
||||
del_sta_names.append(tname)
|
||||
except Exception as x:
|
||||
self.local_realm.error(x)
|
||||
try:
|
||||
LFUtils.waitUntilPortsDisappear(base_url=self.local_realm.lfclient_url, port_list=del_sta_names, debug=True)
|
||||
print("Ports Successfully Cleaned up")
|
||||
return 0
|
||||
except:
|
||||
print("Ports Successfully Cleaned up")
|
||||
LFUtils.waitUntilPortsDisappear(base_url=self.local_realm.lfclient_url, port_list=del_sta_names, debug=True)
|
||||
print("Ports Successfully Cleaned up")
|
||||
time.sleep(5)
|
||||
return 0
|
||||
|
||||
|
||||
# Generates XLSX Report
|
||||
def GenerateReport(throughput_sta, throughput_vap, core1_temp, core2_temp, duration,name):
|
||||
def GenerateReport(throughput_sta, throughput_vap, core1_temp, core2_temp, duration, name):
|
||||
workbook = xlsxwriter.Workbook(name)
|
||||
worksheet = workbook.add_worksheet()
|
||||
worksheet.write('A1', 'THROUGHPUT OVER TIME STA CX ')
|
||||
worksheet.write('B1', 'THROUGHPUT OVER TIME VAP ')
|
||||
worksheet.write('C1', 'CORE 0 TEMP')
|
||||
worksheet.write('D1', 'CORE 1 TEMP')
|
||||
core1=[]
|
||||
core2=[]
|
||||
sta_throu=[]
|
||||
vap_throu=[]
|
||||
j=2
|
||||
core1 = []
|
||||
core2 = []
|
||||
sta_throu = []
|
||||
vap_throu = []
|
||||
j = 2
|
||||
for i in throughput_sta:
|
||||
sta_throu.append(i/1000000)
|
||||
worksheet.write('A'+str(j), str(i/1000000)+" Mbps")
|
||||
j=j+1
|
||||
j=2
|
||||
sta_throu.append(i / 1000000)
|
||||
worksheet.write('A' + str(j), str(i / 1000000) + " Mbps")
|
||||
j = j + 1
|
||||
j = 2
|
||||
for i in throughput_vap:
|
||||
vap_throu.append(i/1000000)
|
||||
worksheet.write('B'+str(j), str(i/1000000)+" Mbps")
|
||||
j=j+1
|
||||
j=2
|
||||
vap_throu.append(i / 1000000)
|
||||
worksheet.write('B' + str(j), str(i / 1000000) + " Mbps")
|
||||
j = j + 1
|
||||
j = 2
|
||||
for i in core1_temp:
|
||||
core1.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('C'+str(j),str(i).split(':')[1].split('(')[0] )
|
||||
j=j+1
|
||||
j=2
|
||||
worksheet.write('C' + str(j), str(i).split(':')[1].split('(')[0])
|
||||
j = j + 1
|
||||
j = 2
|
||||
for i in core2_temp:
|
||||
core2.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('D'+str(j), str(i).split(':')[1].split('(')[0])
|
||||
j=j+1
|
||||
worksheet.write('D' + str(j), str(i).split(':')[1].split('(')[0])
|
||||
j = j + 1
|
||||
|
||||
Time =[]
|
||||
for i in range(0,int(duration)*5):
|
||||
Time = []
|
||||
for i in range(0, int(duration) * 5):
|
||||
Time.append(i)
|
||||
plot(sta_throu, vap_throu, core1, core2, Time)
|
||||
workbook.close()
|
||||
@@ -273,169 +269,94 @@ def GenerateReport(throughput_sta, throughput_vap, core1_temp, core2_temp, durat
|
||||
|
||||
# Plotting Function for Parameters
|
||||
def plot(throughput_sta, throughput_vap, core1_temp, core2_temp, Time):
|
||||
|
||||
|
||||
s1 = figure()
|
||||
s1.title.text = "WIFI Throughput vs Temperature Plot"
|
||||
s1.xaxis.axis_label = "Time in Seconds"
|
||||
s1.yaxis.axis_label = "Throughput in Mbps"
|
||||
|
||||
s1.line( Time, throughput_sta, color='black')
|
||||
#s1.circle(Time, throughput_sta, color='red')
|
||||
s1.line(Time, throughput_sta, color='black')
|
||||
# s1.circle(Time, throughput_sta, color='red')
|
||||
|
||||
s1.line(Time, throughput_vap, color='blue')
|
||||
# s1.circle(Time, throughput_vap, color='blue')
|
||||
|
||||
s1.line( Time, throughput_vap, color='blue')
|
||||
#s1.circle(Time, throughput_vap, color='blue')
|
||||
|
||||
s1.extra_y_ranges = {"Temperature": Range1d(start=0, end=150)}
|
||||
s1.add_layout(LinearAxis(y_range_name="Temperature", axis_label="Temperature in Degree Celsius"), 'right')
|
||||
|
||||
|
||||
s1.line(Time, core1_temp, y_range_name='Temperature', color='red')
|
||||
#s1.circle(Time, core1_temp, y_range_name='Temperature', color='red')
|
||||
# s1.circle(Time, core1_temp, y_range_name='Temperature', color='red')
|
||||
|
||||
s1.line(Time, core2_temp, y_range_name='Temperature', color='green')
|
||||
#s1.circle(Time, core2_temp, y_range_name='Temperature', color='blue')
|
||||
# s1.circle(Time, core2_temp, y_range_name='Temperature', color='blue')
|
||||
|
||||
show(s1)
|
||||
|
||||
|
||||
|
||||
# Creates the Instance for LFCliBase
|
||||
class VAP_Measure(LFCliBase):
|
||||
def __init__(self, lfclient_host, lfclient_port):
|
||||
super().__init__(lfclient_host, lfclient_port)
|
||||
|
||||
|
||||
|
||||
# main method
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_dut_sta_vap_test.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
|
||||
parser.add_argument("-m", "--manager", type=str, help="Enter the address of Lanforge Manager (By default localhost)")
|
||||
parser.add_argument("-sc", "--scenario", type=str, help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
|
||||
parser.add_argument("-m", "--manager", type=str,
|
||||
help="Enter the address of Lanforge Manager (By default localhost)", default="localhost")
|
||||
parser.add_argument("-sc", "--scenario", type=str,
|
||||
help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
parser.add_argument("-r", "--radio", type=str, help="Enter the radio on which you want to create a station/s on ")
|
||||
parser.add_argument("-n", "--num_sta", type=int, help="Enter the Number of Stations You want to create")
|
||||
parser.add_argument("-i", "--sta_id", type=int, help="Enter Station id [for sta001, enter 1]")
|
||||
parser.add_argument("-ss", "--ssid", type=str, help="Enter the ssid, with which you want to associate your stations (Enter the SSID of DUT AP)")
|
||||
parser.add_argument("-up", "--upstream", type=str, help="Enter the upstream ethernet port")
|
||||
parser.add_argument("-sec", "--security", type=str, help="Enter the security type [open, wep, wpa, wpa2]")
|
||||
parser.add_argument("-p", "--password", type=str, help="Enter the password if security is not open")
|
||||
parser.add_argument("-pr", "--protocol", type=str, help="Enter the protocol on which you want to run your connections [lf_udp, lf_tcp]")
|
||||
parser.add_argument("-mn", "--min_mbps", type=str, help="Enter the Minimum Rate")
|
||||
parser.add_argument("-mx", "--max_mbps", type=str, help="Enter the Maximum Rate")
|
||||
parser.add_argument("-t", "--duration", type=int, help="Enter the Time for which you want to run test (In Minutes)")
|
||||
parser.add_argument("-o", "--report_name", type=str, help="Enter the Name of the Output file ('Report.xlsx')")
|
||||
args = None
|
||||
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
# Lanforge Manager IP Address
|
||||
if (args.manager is None):
|
||||
manager = "localhost"
|
||||
if (args.manager is not None):
|
||||
manager = args.manager
|
||||
|
||||
# Scenario Name
|
||||
if (args.scenario is not None):
|
||||
scenario = args.scenario
|
||||
# Radio Name
|
||||
if (args.radio is not None):
|
||||
radio = args.radio
|
||||
|
||||
# Number of Stations
|
||||
if (args.num_sta is None):
|
||||
num_sta = 0
|
||||
if (args.num_sta is not None):
|
||||
num_sta = args.num_sta
|
||||
|
||||
# Station ID
|
||||
if (args.sta_id is None):
|
||||
sta_id = '0'
|
||||
if (args.sta_id is not None):
|
||||
sta_id = args.sta_id
|
||||
|
||||
# SSID
|
||||
if (args.ssid is not None):
|
||||
ssid = args.ssid
|
||||
if (args.ssid is not None):
|
||||
ssid = args.ssid
|
||||
parser.add_argument("-n", "--num_sta", type=int, help="Enter the Number of Stations You want to create", default=0)
|
||||
parser.add_argument("-i", "--sta_id", type=int, help="Enter Station id [for sta001, enter 1]", default=0)
|
||||
parser.add_argument("-ss", "--ssid", type=str,
|
||||
help="Enter the ssid, with which you want to associate your stations (Enter the SSID of DUT AP)")
|
||||
parser.add_argument("-up", "--upstream", type=str, help="Enter the upstream ethernet port", default='br0000')
|
||||
parser.add_argument("-sec", "--security", type=str, help="Enter the security type [open, wep, wpa, wpa2]",
|
||||
default='open')
|
||||
parser.add_argument("-p", "--password", type=str, help="Enter the password if security is not open",
|
||||
default='[Blank]')
|
||||
parser.add_argument("-pr", "--protocol", type=str,
|
||||
help="Enter the protocol on which you want to run your connections [lf_udp, lf_tcp]",
|
||||
default='lf_udp')
|
||||
parser.add_argument("-mn", "--min_mbps", type=int, help="Enter the Minimum Rate", default=1000)
|
||||
parser.add_argument("-mx", "--max_mbps", type=int, help="Enter the Maximum Rate")
|
||||
parser.add_argument("-t", "--duration", type=int, help="Enter the Time for which you want to run test (In Minutes)",
|
||||
default=15)
|
||||
parser.add_argument("-o", "--report_name", type=str, help="Enter the Name of the Output file ('Report.xlsx')",
|
||||
default='report.xlsx')
|
||||
|
||||
# Security (Open by Default)
|
||||
if (args.security is None):
|
||||
security = 'open'
|
||||
if (args.security is not None):
|
||||
security = args.security
|
||||
args = parser.parse_args()
|
||||
|
||||
# Password (if Security is not Open)
|
||||
if (args.password is not None):
|
||||
password = args.password
|
||||
if (args.password == 'open'):
|
||||
password = "[Blank]"
|
||||
if (args.password is None):
|
||||
password = "[Blank]"
|
||||
|
||||
# Upstream Port (By default br0000)
|
||||
if (args.upstream is None):
|
||||
upstream = 'br0000'
|
||||
if (args.upstream is not None):
|
||||
upstream = args.upstream
|
||||
|
||||
# Protocol (By Default lf_udp)
|
||||
if (args.protocol is not None):
|
||||
protocol = args.protocol
|
||||
if (args.protocol is None):
|
||||
protocol = 'lf_udp'
|
||||
|
||||
#Min BPS
|
||||
if (args.min_mbps is not None):
|
||||
min_bps = int(args.min_mbps)*1000000
|
||||
if (args.min_mbps is None):
|
||||
min_bps = int(1000)*1000000
|
||||
if (args.max_mbps is None ):
|
||||
max_bps = int(1000)*1000000
|
||||
min_bps = args.min_mbps * 1000000
|
||||
|
||||
if (args.min_mbps is not None):
|
||||
min_bps = int(args.min_mbps)*1000000
|
||||
if (args.max_mbps is not None and args.max_mbps != "same"):
|
||||
max_bps = int(args.max_mbps)*1000000
|
||||
if (args.max_mbps is not None and args.max_mbps == "same"):
|
||||
max_bps = args.min_mbps
|
||||
if (args.duration is not None):
|
||||
duration = (args.duration * 60)/5
|
||||
if (args.report_name is not None):
|
||||
report_name = args.report_name
|
||||
if (args.duration is None):
|
||||
duration = (1 * 60)/5
|
||||
if (args.report_name is None):
|
||||
report_name = "report.xlsx"
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
||||
exit(2)
|
||||
|
||||
if args.max_mbps and args.max_mbps != "same":
|
||||
max_bps = int(args.max_mbps) * 1000000
|
||||
if args.max_mbps and args.max_mbps == "same":
|
||||
max_bps = args.min_mbps
|
||||
|
||||
|
||||
# Start DUT
|
||||
|
||||
|
||||
#Loading the Scenario on Lanforge_1 (Here Considered as DUT) [Created VAP With SSID 'lexusap' on wiphy0 with eth1 as backhaul]
|
||||
# Loading the Scenario on Lanforge_1 (Here Considered as DUT) [Created VAP With SSID 'lexusap' on wiphy0 with eth1 as backhaul]
|
||||
Scenario_1 = LoadScenario("192.168.200.18", 8080, "Lexus_DUT")
|
||||
|
||||
dut_traffic_profile = CreateSTA_CX("192.168.200.18", 8080, "wiphy1", 1, 0, 'lanforge_ap', 'open', password, 'br0000', 'lf_udp', min_bps, max_bps)
|
||||
|
||||
dut_traffic_profile = CreateSTA_CX("192.168.200.18", 8080, "wiphy1", 1, 0, 'lanforge_ap', 'open', args.password,
|
||||
'br0000', 'lf_udp', min_bps, max_bps)
|
||||
dut_traffic_profile.build()
|
||||
|
||||
print("DUT All Set... Lets setup Lanforge")
|
||||
|
||||
|
||||
#Loading the Scenario on Lanforge_2 (Here Considered as LANFORGE Test) [Created VAP With SSID 'lanforge_ap' on wiphy0 with eth2 as backhaul]
|
||||
|
||||
# Loading the Scenario on Lanforge_2 (Here Considered as LANFORGE Test) [Created VAP With SSID 'lanforge_ap' on wiphy0 with eth2 as backhaul]
|
||||
|
||||
DB_Lanforge_2 = "LANforge_TEST"
|
||||
Scenario_2 = LoadScenario(manager, 8080, scenario)
|
||||
|
||||
Scenario_2 = LoadScenario(args.manager, 8080, args.scenario)
|
||||
|
||||
lf_traffic_profile = CreateSTA_CX(manager, 8080, radio, num_sta, sta_id, ssid, security, password, upstream, protocol, min_bps, max_bps)
|
||||
lf_traffic_profile = CreateSTA_CX(args.manager, 8080, args.radio, args.num_sta, args.sta_id, args.ssid,
|
||||
args.security, args.password, args.upstream, args.protocol, min_bps,
|
||||
max_bps)
|
||||
lf_traffic_profile.build()
|
||||
|
||||
print("Lanforge System is All set... Lets start and Measure")
|
||||
@@ -448,21 +369,21 @@ def main():
|
||||
print("Collecting Throughput Values...")
|
||||
|
||||
# Object to Measure Throughput at VAP Side
|
||||
vap_measure_obj = VAP_Measure(manager, 8080)
|
||||
vap_measure_obj = VAP_Measure(args.manager, 8080)
|
||||
|
||||
#
|
||||
dut_temp_obj = Login_DUT(1, "Thread-1", "192.168.200.18")
|
||||
|
||||
#List for Storing the Total Throughput
|
||||
throughput_sta =[]
|
||||
throughput_vap =[]
|
||||
|
||||
# List for Storing the Total Throughput
|
||||
throughput_sta = []
|
||||
throughput_vap = []
|
||||
|
||||
# This loop will get the Data from All the endpoints and sum up to give total Throughput over time
|
||||
for i in range(0,int(duration)):
|
||||
temp=0
|
||||
for i in range(0, int(args.duration)):
|
||||
temp = 0
|
||||
for j in lf_traffic_profile.endp:
|
||||
y=lf_traffic_profile.local_realm.json_get("/endp/"+j).get('endpoint').get('rx rate')
|
||||
temp=temp+y
|
||||
y = lf_traffic_profile.local_realm.json_get("/endp/" + j).get('endpoint').get('rx rate')
|
||||
temp = temp + y
|
||||
throughput_sta.append(temp)
|
||||
throughput_vap.append(vap_measure_obj.json_get("/port/1/1/vap0000/").get('interface').get('bps rx'))
|
||||
dut_temp_obj.run()
|
||||
@@ -472,10 +393,9 @@ def main():
|
||||
print(throughput_sta)
|
||||
dut_traffic_profile.cleanup()
|
||||
lf_traffic_profile.cleanup()
|
||||
GenerateReport(throughput_sta, throughput_vap, dut_temp_obj.data_core1, dut_temp_obj.data_core2, duration, report_name)
|
||||
|
||||
GenerateReport(throughput_sta, throughput_vap, dut_temp_obj.data_core1, dut_temp_obj.data_core2, args.duration,
|
||||
args.report_name)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
""" lf_ftp.py will verify that N clients connected on specified band and can simultaneously download/upload some amount of file from FTP server and measuring the time taken by client to download/upload the file.
|
||||
cli- python3 lf_ftp.py --mgr localhost --mgr_port 8080 --upstream_port eth1 --ssid FTP --security open --passwd BLANK --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_
|
||||
cli- ./lf_ftp.py --ssid <SSID> --passwd <PASSWORD> --file_sizes 2MB --fiveg_duration 4 --mgr 192.168.1.101 --traffic_duration 2 --security wpa2 --bands 5G --fiveg_radio wiphy1 --directions Download Upload
|
||||
Copyright 2021 Candela Technologies Inc
|
||||
License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
"""
|
||||
@@ -11,12 +12,13 @@ from datetime import datetime
|
||||
import time
|
||||
import os
|
||||
import matplotlib.patches as mpatches
|
||||
import pandas as pd
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -26,13 +28,14 @@ realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
lf_report = importlib.import_module("py-scripts.lf_report")
|
||||
lf_graph = importlib.import_module("py-scripts.lf_graph")
|
||||
lf_kpi_csv = importlib.import_module("py-scripts.lf_kpi_csv")
|
||||
|
||||
|
||||
class FtpTest(LFCliBase):
|
||||
def __init__(self, lfclient_host="localhost", lfclient_port=8080, sta_prefix="sta", start_id=0, num_sta=None,
|
||||
dut_ssid=None, dut_security=None, dut_passwd=None, file_size=None, band=None, twog_radio=None,
|
||||
fiveg_radio=None, upstream="eth1", _debug_on=False, _exit_on_error=False, _exit_on_fail=False,
|
||||
direction=None, duration=None, traffic_duration=None, ssh_port=None):
|
||||
direction=None, duration=None, traffic_duration=None, ssh_port=None, kpi_csv=None):
|
||||
super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
print("Test is about to start")
|
||||
self.host = lfclient_host
|
||||
@@ -47,6 +50,7 @@ class FtpTest(LFCliBase):
|
||||
self.password = dut_passwd
|
||||
self.requests_per_ten = 1
|
||||
self.band = band
|
||||
self.kpi_csv = kpi_csv
|
||||
self.file_size = file_size
|
||||
self.direction = direction
|
||||
self.twog_radio = twog_radio
|
||||
@@ -301,7 +305,7 @@ class FtpTest(LFCliBase):
|
||||
for i in range(self.num_sta):
|
||||
list_of_time.append(0)
|
||||
#running layer 4 traffic upto user given time
|
||||
while str(datetime.datetime.now() - time1) <= self.traffic_duration:
|
||||
while str(datetime.now() - time1) <= self.traffic_duration:
|
||||
if list_of_time.count(0) == 0:
|
||||
break
|
||||
|
||||
@@ -309,11 +313,11 @@ class FtpTest(LFCliBase):
|
||||
|
||||
# run script upto given time
|
||||
if counter == 0:
|
||||
if str(datetime.datetime.now() - time1) >= self.duration:
|
||||
if str(datetime.now() - time1) >= self.duration:
|
||||
counter = counter + 1
|
||||
break
|
||||
else:
|
||||
if str(datetime.datetime.now() - time1) >= self.traffic_duration:
|
||||
if str(datetime.now() - time1) >= self.traffic_duration:
|
||||
break
|
||||
|
||||
for i in range(self.num_sta):
|
||||
@@ -321,9 +325,9 @@ class FtpTest(LFCliBase):
|
||||
|
||||
# reading uc-avg data in json format
|
||||
uc_avg = self.json_get("layer4/list?fields=uc-avg")
|
||||
if data['endpoint'][i][data2[i]]['bytes-rd'] <= self.file_size_bytes:
|
||||
if int(data['endpoint'][i][data2[i]]['bytes-rd']) <= self.file_size_bytes:
|
||||
data = self.json_get("layer4/list?fields=bytes-rd")
|
||||
if data['endpoint'][i][data2[i]]['bytes-rd'] >= self.file_size_bytes:
|
||||
if int(data['endpoint'][i][data2[i]]['bytes-rd']) >= self.file_size_bytes:
|
||||
list1.append(i)
|
||||
if list1.count(i) == 1:
|
||||
list2.append(i)
|
||||
@@ -614,7 +618,7 @@ class FtpTest(LFCliBase):
|
||||
def bar_graph(self, x_axis, image_name, dataset, color, labels, x_axis_name, y_axis_name,handles, ncol, box, fontsize):
|
||||
'''This Method will plot bar graph'''
|
||||
|
||||
graph = lf_bar_graph(_data_set=dataset,
|
||||
graph = lf_graph.lf_bar_graph(_data_set=dataset,
|
||||
_xaxis_name=x_axis_name,
|
||||
_yaxis_name=y_axis_name,
|
||||
_xaxis_categories=x_axis,
|
||||
@@ -660,7 +664,7 @@ class FtpTest(LFCliBase):
|
||||
def generate_report(self, ftp_data, date,test_setup_info, input_setup_info):
|
||||
'''Method for generate the report'''
|
||||
|
||||
self.report = lf_report(_results_dir_name="ftp_test", _output_html="ftp_test.html", _output_pdf="ftp_test.pdf")
|
||||
self.report = lf_report.lf_report(_results_dir_name="ftp_test", _output_html="ftp_test.html", _output_pdf="ftp_test.pdf")
|
||||
self.report.set_title("FTP Test")
|
||||
self.report.set_date(date)
|
||||
self.report.build_banner()
|
||||
@@ -703,7 +707,14 @@ def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_ftp.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="FTP Test Script")
|
||||
description='''\
|
||||
---------------------------
|
||||
FTP Test Script - lf_ftp.py
|
||||
---------------------------
|
||||
CLI Example:
|
||||
./lf_ftp.py --ssid <SSID> --passwd <PASSWORD> --file_sizes 2MB --fiveg_duration 4 --mgr 192.168.1.101 --traffic_duration 2 --security wpa2 --bands 5G --fiveg_radio wiphy1 --directions Download Upload
|
||||
---------------------------
|
||||
''')
|
||||
parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||
parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||
parser.add_argument('--upstream_port', help='non-station port that generates traffic: eg: eth1', default='eth1')
|
||||
@@ -716,7 +727,7 @@ def main():
|
||||
parser.add_argument('--fiveg_radio', type=str, help='specify radio for 5G client', default='wiphy0')
|
||||
parser.add_argument('--twog_duration', nargs="+", help='Pass and Fail duration for 2.4G band in minutes')
|
||||
parser.add_argument('--fiveg_duration', nargs="+", help='Pass and Fail duration for 5G band in minutes')
|
||||
parser.add_argument('--Both_duration', nargs="+", help='Pass and Fail duration for Both band in minutes')
|
||||
parser.add_argument('--both_duration', nargs="+", help='Pass and Fail duration for Both band in minutes')
|
||||
parser.add_argument('--traffic_duration', type=int, help='duration for layer 4 traffic running')
|
||||
parser.add_argument('--ssh_port', type=int, help="specify the shh port eg 22", default=22)
|
||||
|
||||
@@ -732,10 +743,10 @@ def main():
|
||||
args = parser.parse_args()
|
||||
|
||||
# 1st time stamp for test duration
|
||||
time_stamp1 = datetime.datetime.now()
|
||||
time_stamp1 = datetime.now()
|
||||
|
||||
# use for creating ftp_test dictionary
|
||||
iteraration_num = 0
|
||||
interation_num = 0
|
||||
|
||||
# empty dictionary for whole test data
|
||||
ftp_data = {}
|
||||
@@ -759,12 +770,12 @@ def main():
|
||||
index = list(args.file_sizes).index(size)
|
||||
duration = args.fiveg_duration[index]
|
||||
else:
|
||||
if len(args.file_sizes) is not len(args.Both_duration):
|
||||
if len(args.file_sizes) is not len(args.both_duration):
|
||||
raise Exception("Give proper Pass or Fail duration for 5G band")
|
||||
for size in args.file_sizes:
|
||||
if size == file_size:
|
||||
index = list(args.file_sizes).index(size)
|
||||
duration = args.Both_duration[index]
|
||||
duration = args.both_duration[index]
|
||||
if duration.isdigit():
|
||||
duration = int(duration)
|
||||
else:
|
||||
@@ -794,7 +805,7 @@ def main():
|
||||
ssh_port=args.ssh_port
|
||||
)
|
||||
|
||||
iteraration_num = iteraration_num + 1
|
||||
interation_num = interation_num + 1
|
||||
obj.file_create()
|
||||
obj.set_values()
|
||||
obj.precleanup()
|
||||
@@ -804,7 +815,7 @@ def main():
|
||||
exit(1)
|
||||
|
||||
# First time stamp
|
||||
time1 = datetime.datetime.now()
|
||||
time1 = datetime.now()
|
||||
|
||||
obj.start(False, False)
|
||||
|
||||
@@ -815,19 +826,19 @@ def main():
|
||||
pass_fail = obj.pass_fail_check(time_list)
|
||||
|
||||
# dictionary of whole data
|
||||
ftp_data[iteraration_num] = obj.ftp_test_data(time_list, pass_fail, args.bands, args.file_sizes,
|
||||
ftp_data[interation_num] = obj.ftp_test_data(time_list, pass_fail, args.bands, args.file_sizes,
|
||||
args.directions, args.num_stations)
|
||||
|
||||
obj.stop()
|
||||
obj.postcleanup()
|
||||
|
||||
# 2nd time stamp for test duration
|
||||
time_stamp2 = datetime.datetime.now()
|
||||
time_stamp2 = datetime.now()
|
||||
|
||||
# total time for test duration
|
||||
test_duration = str(time_stamp2 - time_stamp1)[:-7]
|
||||
|
||||
date = str(datetime.datetime.now()).split(",")[0].replace(" ", "-").split(".")[0]
|
||||
date = str(datetime.now()).split(",")[0].replace(" ", "-").split(".")[0]
|
||||
|
||||
#print(ftp_data)
|
||||
|
||||
|
||||
@@ -24,39 +24,42 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import pdfkit
|
||||
from matplotlib.colors import ListedColormap
|
||||
import argparse
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lf_csv = importlib.import_module("py-scripts.lf_csv")
|
||||
lf_csv = lf_csv.lf_csv
|
||||
|
||||
# internal candela references included during intial phases, to be deleted at future date
|
||||
# internal candela references included during intial phases, to be deleted
|
||||
# at future date
|
||||
|
||||
# graph reporting classes
|
||||
class lf_bar_graph():
|
||||
def __init__(self, _data_set=[[30.4, 55.3, 69.2, 37.1], [45.1, 67.2, 34.3, 22.4], [22.5, 45.6, 12.7, 34.8]],
|
||||
|
||||
|
||||
class lf_bar_graph:
|
||||
def __init__(self, _data_set=None,
|
||||
_xaxis_name="x-axis",
|
||||
_yaxis_name="y-axis",
|
||||
_xaxis_categories=[1, 2, 3, 4],
|
||||
_xaxis_label=["a", "b", "c", "d"],
|
||||
_xaxis_categories=None,
|
||||
_xaxis_label=None,
|
||||
_graph_title="",
|
||||
_title_size=16,
|
||||
_graph_image_name="image_name",
|
||||
_label=["bi-downlink", "bi-uplink", 'uplink'],
|
||||
_label=None,
|
||||
_color=None,
|
||||
_bar_width=0.25,
|
||||
_color_edge='grey',
|
||||
_font_weight='bold',
|
||||
_color_name=['lightcoral', 'darkgrey', 'r', 'g', 'b', 'y'],
|
||||
_color_name=None,
|
||||
_figsize=(10, 5),
|
||||
_show_bar_value=False,
|
||||
_xaxis_step=1,
|
||||
_xticks_font = None,
|
||||
_xaxis_value_location = 0,
|
||||
_xticks_font=None,
|
||||
_xaxis_value_location=0,
|
||||
_text_font=None,
|
||||
_text_rotation=None,
|
||||
_grp_title = "",
|
||||
_grp_title="",
|
||||
_legend_handles=None,
|
||||
_legend_loc="best",
|
||||
_legend_box=None,
|
||||
@@ -65,6 +68,16 @@ class lf_bar_graph():
|
||||
_dpi=96,
|
||||
_enable_csv=False):
|
||||
|
||||
if _data_set is None:
|
||||
_data_set = [[30.4, 55.3, 69.2, 37.1], [45.1, 67.2, 34.3, 22.4], [22.5, 45.6, 12.7, 34.8]]
|
||||
if _xaxis_categories is None:
|
||||
_xaxis_categories = [1, 2, 3, 4]
|
||||
if _xaxis_label is None:
|
||||
_xaxis_label = ["a", "b", "c", "d"]
|
||||
if _label is None:
|
||||
_label = ["bi-downlink", "bi-uplink", 'uplink']
|
||||
if _color_name is None:
|
||||
_color_name = ['lightcoral', 'darkgrey', 'r', 'g', 'b', 'y']
|
||||
self.data_set = _data_set
|
||||
self.xaxis_name = _xaxis_name
|
||||
self.yaxis_name = _yaxis_name
|
||||
@@ -99,20 +112,20 @@ class lf_bar_graph():
|
||||
if self.color is None:
|
||||
i = 0
|
||||
self.color = []
|
||||
for col in self.data_set:
|
||||
for _ in self.data_set:
|
||||
self.color.append(self.color_name[i])
|
||||
i = i + 1
|
||||
|
||||
fig = plt.subplots(figsize=self.figsize)
|
||||
plt.subplots(figsize=self.figsize)
|
||||
i = 0
|
||||
|
||||
def show_value(rects):
|
||||
for rect in rects:
|
||||
def show_value(rectangles):
|
||||
for rect in rectangles:
|
||||
h = rect.get_height()
|
||||
plt.text(rect.get_x() + rect.get_width() / 2., h, h,
|
||||
ha='center', va='bottom', rotation=self.text_rotation, fontsize=self.text_font)
|
||||
|
||||
for data in self.data_set:
|
||||
for _ in self.data_set:
|
||||
if i > 0:
|
||||
br = br1
|
||||
br2 = [x + self.bar_width for x in br]
|
||||
@@ -132,14 +145,22 @@ class lf_bar_graph():
|
||||
plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15)
|
||||
if self.xaxis_categories[0] == 0:
|
||||
plt.xticks(np.arange(0, len(self.xaxis_categories), step=self.xaxis_step),fontsize = self.xticks_font)
|
||||
plt.xticks(np.arange(0,
|
||||
len(self.xaxis_categories),
|
||||
step=self.xaxis_step),
|
||||
fontsize=self.xticks_font)
|
||||
else:
|
||||
plt.xticks([i + self._xaxis_value_location for i in np.arange(0, len(self.data_set[0]), step=self.xaxis_step)],
|
||||
self.xaxis_categories, fontsize=self.xticks_font)
|
||||
plt.legend(handles=self.legend_handles, loc=self.legend_loc, bbox_to_anchor=self.legend_box, ncol=self.legend_ncol, fontsize=self.legend_fontsize)
|
||||
self.xaxis_categories, fontsize=self.xticks_font)
|
||||
plt.legend(
|
||||
handles=self.legend_handles,
|
||||
loc=self.legend_loc,
|
||||
bbox_to_anchor=self.legend_box,
|
||||
ncol=self.legend_ncol,
|
||||
fontsize=self.legend_fontsize)
|
||||
plt.suptitle(self.title, fontsize=self.title_size)
|
||||
plt.title(self.grp_title)
|
||||
fig = plt.gcf()
|
||||
plt.gcf()
|
||||
plt.savefig("%s.png" % self.graph_image_name, dpi=96)
|
||||
plt.close()
|
||||
print("{}.png".format(self.graph_image_name))
|
||||
@@ -155,25 +176,32 @@ class lf_bar_graph():
|
||||
self.lf_csv.filename = f"{self.graph_image_name}.csv"
|
||||
self.lf_csv.generate_csv()
|
||||
else:
|
||||
raise ValueError("Length and x-axis values and y-axis values should be same.")
|
||||
raise ValueError(
|
||||
"Length and x-axis values and y-axis values should be same.")
|
||||
else:
|
||||
print("No Dataset Found")
|
||||
print("{}.csv".format(self.graph_image_name))
|
||||
return "%s.png" % self.graph_image_name
|
||||
|
||||
|
||||
class lf_scatter_graph():
|
||||
class lf_scatter_graph:
|
||||
def __init__(self,
|
||||
_x_data_set=["sta0 ", "sta1", "sta2", "sta3"],
|
||||
_y_data_set=[[30, 55, 69, 37]],
|
||||
_x_data_set=None,
|
||||
_y_data_set=None,
|
||||
_values=None,
|
||||
_xaxis_name="x-axis",
|
||||
_yaxis_name="y-axis",
|
||||
_label=["num1", "num2"],
|
||||
_label=None,
|
||||
_graph_image_name="image_name1",
|
||||
_color=["r", "y"],
|
||||
_color=None,
|
||||
_figsize=(9, 4),
|
||||
_enable_csv=True):
|
||||
if _x_data_set is None:
|
||||
_x_data_set = ["sta0 ", "sta1", "sta2", "sta3"]
|
||||
if _y_data_set is None:
|
||||
_y_data_set = [[30, 55, 69, 37]]
|
||||
if _label is None:
|
||||
_label = ["num1", "num2"]
|
||||
self.x_data_set = _x_data_set
|
||||
self.y_data_set = _y_data_set
|
||||
self.xaxis_name = _xaxis_name
|
||||
@@ -188,20 +216,38 @@ class lf_scatter_graph():
|
||||
|
||||
def build_scatter_graph(self):
|
||||
if self.color is None:
|
||||
self.color = ["orchid", "lime", "aquamarine", "royalblue", "darkgray", "maroon"]
|
||||
fig = plt.subplots(figsize=self.figsize)
|
||||
self.color = [
|
||||
"orchid",
|
||||
"lime",
|
||||
"aquamarine",
|
||||
"royalblue",
|
||||
"darkgray",
|
||||
"maroon"]
|
||||
plt.subplots(figsize=self.figsize)
|
||||
if self.values is None:
|
||||
plt.scatter(self.x_data_set, self.y_data_set[0], color=self.color[0], label=self.label[0])
|
||||
plt.scatter(
|
||||
self.x_data_set,
|
||||
self.y_data_set[0],
|
||||
color=self.color[0],
|
||||
label=self.label[0])
|
||||
if len(self.y_data_set) > 1:
|
||||
for i in range(1, len(self.y_data_set)):
|
||||
plt.scatter(self.x_data_set, self.y_data_set[i], color=self.color[i], label=self.label[i])
|
||||
plt.scatter(
|
||||
self.x_data_set,
|
||||
self.y_data_set[i],
|
||||
color=self.color[i],
|
||||
label=self.label[i])
|
||||
plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.gcf().autofmt_xdate()
|
||||
plt.legend()
|
||||
else:
|
||||
colours = ListedColormap(self.color)
|
||||
scatter = plt.scatter(self.x_data_set, self.y_data_set, c=self.values, cmap=colours)
|
||||
scatter = plt.scatter(
|
||||
self.x_data_set,
|
||||
self.y_data_set,
|
||||
c=self.values,
|
||||
cmap=colours)
|
||||
plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.gcf().autofmt_xdate()
|
||||
@@ -218,16 +264,20 @@ class lf_scatter_graph():
|
||||
return "%s.png" % self.graph_image_name
|
||||
|
||||
|
||||
class lf_stacked_graph():
|
||||
class lf_stacked_graph:
|
||||
def __init__(self,
|
||||
_data_set=[[1, 2, 3, 4], [1, 1, 1, 1], [1, 1, 1, 1]],
|
||||
_data_set=None,
|
||||
_xaxis_name="Stations",
|
||||
_yaxis_name="Numbers",
|
||||
_label=['Success', 'Fail'],
|
||||
_label=None,
|
||||
_graph_image_name="image_name2",
|
||||
_color=["b", "g"],
|
||||
_color=None,
|
||||
_figsize=(9, 4),
|
||||
_enable_csv=True):
|
||||
if _data_set is None:
|
||||
_data_set = [[1, 2, 3, 4], [1, 1, 1, 1], [1, 1, 1, 1]]
|
||||
if _label is None:
|
||||
_label = ['Success', 'Fail']
|
||||
self.data_set = _data_set # [x_axis,y1_axis,y2_axis]
|
||||
self.xaxis_name = _xaxis_name
|
||||
self.yaxis_name = _yaxis_name
|
||||
@@ -239,11 +289,21 @@ class lf_stacked_graph():
|
||||
self.lf_csv = lf_csv()
|
||||
|
||||
def build_stacked_graph(self):
|
||||
fig = plt.subplots(figsize=self.figsize)
|
||||
plt.subplots(figsize=self.figsize)
|
||||
if self.color is None:
|
||||
self.color = ["darkred", "tomato", "springgreen", "skyblue", "indigo", "plum"]
|
||||
self.color = [
|
||||
"darkred",
|
||||
"tomato",
|
||||
"springgreen",
|
||||
"skyblue",
|
||||
"indigo",
|
||||
"plum"]
|
||||
plt.bar(self.data_set[0], self.data_set[1], color=self.color[0])
|
||||
plt.bar(self.data_set[0], self.data_set[2], bottom=self.data_set[1], color=self.color[1])
|
||||
plt.bar(
|
||||
self.data_set[0],
|
||||
self.data_set[2],
|
||||
bottom=self.data_set[1],
|
||||
color=self.color[1])
|
||||
if len(self.data_set) > 3:
|
||||
for i in range(3, len(self.data_set)):
|
||||
plt.bar(self.data_set[0], self.data_set[i],
|
||||
@@ -251,7 +311,7 @@ class lf_stacked_graph():
|
||||
plt.xlabel(self.xaxis_name)
|
||||
plt.ylabel(self.yaxis_name)
|
||||
plt.legend(self.label)
|
||||
plt.savefig("%s.png" % (self.graph_image_name), dpi=96)
|
||||
plt.savefig("%s.png" % self.graph_image_name, dpi=96)
|
||||
plt.close()
|
||||
print("{}.png".format(self.graph_image_name))
|
||||
if self.enable_csv:
|
||||
@@ -259,23 +319,31 @@ class lf_stacked_graph():
|
||||
self.lf_csv.rows = self.data_set
|
||||
self.lf_csv.filename = f"{self.graph_image_name}.csv"
|
||||
self.lf_csv.generate_csv()
|
||||
return "%s.png" % (self.graph_image_name)
|
||||
return "%s.png" % self.graph_image_name
|
||||
|
||||
|
||||
class lf_horizontal_stacked_graph():
|
||||
class lf_horizontal_stacked_graph:
|
||||
def __init__(self,
|
||||
_seg=2,
|
||||
_yaxis_set=('A', 'B'),
|
||||
_xaxis_set1=[12, 0, 0, 16, 15],
|
||||
_xaxis_set2=[23, 34, 23, 0],
|
||||
_xaxis_set1=None,
|
||||
_xaxis_set2=None,
|
||||
_unit="%",
|
||||
_xaxis_name="Stations",
|
||||
_label=['Success', 'Fail'],
|
||||
_label=None,
|
||||
_graph_image_name="image_name3",
|
||||
_color=["success", "Fail"],
|
||||
_color=None,
|
||||
_figsize=(9, 4),
|
||||
_disable_xaxis=False,
|
||||
_enable_csv=True):
|
||||
if _xaxis_set1 is None:
|
||||
_xaxis_set1 = [12, 0, 0, 16, 15]
|
||||
if _xaxis_set2 is None:
|
||||
_xaxis_set2 = [23, 34, 23, 0]
|
||||
if _label is None:
|
||||
_label = ['Success', 'Fail']
|
||||
if _color is None:
|
||||
_color = ["success", "Fail"]
|
||||
self.unit = _unit
|
||||
self.seg = _seg
|
||||
self.xaxis_set1 = _xaxis_set1
|
||||
@@ -303,8 +371,19 @@ class lf_horizontal_stacked_graph():
|
||||
ind = np.arange(n) + .15
|
||||
width = 0.3
|
||||
|
||||
rects1 = plt.barh(ind, values1, width, color=self.color[0], label=self.label[0])
|
||||
rects2 = plt.barh(ind, values2, width, left=sumzip(values1), color=self.color[1], label=self.label[1])
|
||||
plt.barh(
|
||||
ind,
|
||||
values1,
|
||||
width,
|
||||
color=self.color[0],
|
||||
label=self.label[0])
|
||||
plt.barh(
|
||||
ind,
|
||||
values2,
|
||||
width,
|
||||
left=sumzip(values1),
|
||||
color=self.color[1],
|
||||
label=self.label[1])
|
||||
|
||||
extra_space = 0.15
|
||||
ax.set_yticks(ind + width - extra_space)
|
||||
@@ -326,7 +405,12 @@ class lf_horizontal_stacked_graph():
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.legend(loc='upper right')
|
||||
if self.disable_xaxis:
|
||||
plt.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) # disable x-axis
|
||||
plt.tick_params(
|
||||
axis='x',
|
||||
which='both',
|
||||
bottom=False,
|
||||
top=False,
|
||||
labelbottom=False) # disable x-axis
|
||||
plt.savefig("%s.png" % self.graph_image_name, dpi=96)
|
||||
plt.close()
|
||||
print("{}.png".format(self.graph_image_name))
|
||||
@@ -338,21 +422,21 @@ class lf_horizontal_stacked_graph():
|
||||
return "%s.png" % self.graph_image_name
|
||||
|
||||
|
||||
class lf_line_graph():
|
||||
def __init__(self,_data_set=[[30.4, 55.3, 69.2, 37.1], [45.1, 67.2, 34.3, 22.4], [22.5, 45.6, 12.7, 34.8]],
|
||||
class lf_line_graph:
|
||||
def __init__(self, _data_set=None,
|
||||
_xaxis_name="x-axis",
|
||||
_yaxis_name="y-axis",
|
||||
_xaxis_categories=[1, 2, 3, 4, 5],
|
||||
_xaxis_label=["a", "b", "c", "d", "e"],
|
||||
_xaxis_categories=None,
|
||||
_xaxis_label=None,
|
||||
_graph_title="",
|
||||
_title_size=16,
|
||||
_graph_image_name="image_name",
|
||||
_label=["bi-downlink", "bi-uplink", 'uplink'],
|
||||
_label=None,
|
||||
_font_weight='bold',
|
||||
_color=['forestgreen', 'c', 'r', 'g', 'b', 'p'],
|
||||
_color=None,
|
||||
_figsize=(10, 5),
|
||||
_xaxis_step = 5,
|
||||
_xticks_font = None,
|
||||
_xaxis_step=5,
|
||||
_xticks_font=None,
|
||||
_text_font=None,
|
||||
_legend_handles=None,
|
||||
_legend_loc="best",
|
||||
@@ -362,6 +446,16 @@ class lf_line_graph():
|
||||
_marker=None,
|
||||
_dpi=96,
|
||||
_enable_csv=False):
|
||||
if _data_set is None:
|
||||
_data_set = [[30.4, 55.3, 69.2, 37.1], [45.1, 67.2, 34.3, 22.4], [22.5, 45.6, 12.7, 34.8]]
|
||||
if _xaxis_categories is None:
|
||||
_xaxis_categories = [1, 2, 3, 4, 5]
|
||||
if _xaxis_label is None:
|
||||
_xaxis_label = ["a", "b", "c", "d", "e"]
|
||||
if _label is None:
|
||||
_label = ["bi-downlink", "bi-uplink", 'uplink']
|
||||
if _color is None:
|
||||
_color = ['forestgreen', 'c', 'r', 'g', 'b', 'p']
|
||||
self.data_set = _data_set
|
||||
self.xaxis_name = _xaxis_name
|
||||
self.yaxis_name = _yaxis_name
|
||||
@@ -387,17 +481,27 @@ class lf_line_graph():
|
||||
self.legend_fontsize = _legend_fontsize
|
||||
|
||||
def build_line_graph(self):
|
||||
fig = plt.subplots(figsize=self.figsize)
|
||||
plt.subplots(figsize=self.figsize)
|
||||
i = 0
|
||||
for data in self.data_set:
|
||||
plt.plot(self.xaxis_categories, data, color=self.color[i], label=self.label[i], marker = self.marker)
|
||||
plt.plot(
|
||||
self.xaxis_categories,
|
||||
data,
|
||||
color=self.color[i],
|
||||
label=self.label[i],
|
||||
marker=self.marker)
|
||||
i += 1
|
||||
|
||||
plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15)
|
||||
plt.legend(handles=self.legend_handles, loc=self.legend_loc, bbox_to_anchor=self.legend_box, ncol=self.legend_ncol, fontsize=self.legend_fontsize)
|
||||
plt.legend(
|
||||
handles=self.legend_handles,
|
||||
loc=self.legend_loc,
|
||||
bbox_to_anchor=self.legend_box,
|
||||
ncol=self.legend_ncol,
|
||||
fontsize=self.legend_fontsize)
|
||||
plt.suptitle(self.grp_title, fontsize=self.title_size)
|
||||
fig = plt.gcf()
|
||||
plt.gcf()
|
||||
plt.savefig("%s.png" % self.graph_image_name, dpi=96)
|
||||
plt.close()
|
||||
print("{}.png".format(self.graph_image_name))
|
||||
@@ -412,8 +516,46 @@ class lf_line_graph():
|
||||
print("{}.csv".format(self.graph_image_name))
|
||||
return "%s.png" % self.graph_image_name
|
||||
|
||||
# Unit Test
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
# arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_graph.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
lf_graph.py : unit test in lf_graph.py for exersizing the lf_graph.py library
|
||||
''',
|
||||
description='''\
|
||||
-----------------
|
||||
NAME: lf_graph.py
|
||||
|
||||
PURPOSE:
|
||||
Common Library for generating graphs for LANforge output
|
||||
|
||||
SETUP:
|
||||
/lanforge/html-reports directory needs to be present or output generated in local file
|
||||
|
||||
EXAMPLE:
|
||||
see: /py-scritps/lf_report_test.py for example
|
||||
|
||||
COPYWRITE
|
||||
Copyright 2021 Candela Technologies Inc
|
||||
License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
|
||||
INCLUDE_IN_README
|
||||
---------------------
|
||||
''')
|
||||
parser.add_argument(
|
||||
'--mgr',
|
||||
'--lfmgr',
|
||||
dest='lfmgr',
|
||||
help='sample argument: where LANforge GUI is running',
|
||||
default='localhost')
|
||||
# the args parser is not really used , this is so the report is not generated when testing
|
||||
# the imports with --help
|
||||
args = parser.parse_args()
|
||||
print("LANforge manager {lfmgr}".format(lfmgr=args.lfmgr))
|
||||
|
||||
output_html_1 = "graph_1.html"
|
||||
output_pdf_1 = "graph_1.pdf"
|
||||
|
||||
@@ -432,7 +574,8 @@ if __name__ == "__main__":
|
||||
# write logic to generate pdf here
|
||||
# wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
|
||||
# sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
|
||||
options = {"enable-local-file-access": None} # prevent eerror Blocked access to file
|
||||
# prevent eerror Blocked access to file
|
||||
options = {"enable-local-file-access": None}
|
||||
pdfkit.from_file(output_html_1, output_pdf_1, options=options)
|
||||
|
||||
# test build_bar_graph setting values
|
||||
@@ -465,5 +608,11 @@ if __name__ == "__main__":
|
||||
# write logic to generate pdf here
|
||||
# wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
|
||||
# sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
|
||||
options = {"enable-local-file-access": None} # prevent eerror Blocked access to file
|
||||
# prevent eerror Blocked access to file
|
||||
options = {"enable-local-file-access": None}
|
||||
pdfkit.from_file(output_html_2, output_pdf_2, options=options)
|
||||
|
||||
|
||||
# Unit Test
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
8
py-scripts/lf_help_check.bash
Executable file
8
py-scripts/lf_help_check.bash
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILES=`ls *.py`
|
||||
for FILE in $FILES
|
||||
do
|
||||
echo $FILE
|
||||
(timeout 10 python3 ./${FILE} --help > /dev/null && echo PASSED) || echo "FAILED ${FILE}"
|
||||
done
|
||||
239
py-scripts/lf_kpi_csv.py
Normal file
239
py-scripts/lf_kpi_csv.py
Normal file
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
NAME: lf_kpi_csv.py
|
||||
|
||||
PURPOSE:
|
||||
Common Library for generating kpi csv for LANforge output
|
||||
KPI - Key Performance Indicators
|
||||
|
||||
SETUP:
|
||||
None
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
|
||||
COPYWRITE
|
||||
Copyright 2021 Candela Technologies Inc
|
||||
License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
|
||||
INCLUDE_IN_README
|
||||
"""
|
||||
# may need pandas if a data frame is passed in
|
||||
# import pandas as pd
|
||||
import csv
|
||||
import time
|
||||
import argparse
|
||||
|
||||
'''
|
||||
Note teh delimiter for the kpi.csv is a tab
|
||||
|
||||
kpi.csv : specific file that is used for the database, dashboard and blog post
|
||||
A blank entry is a valid entry in some cases.
|
||||
|
||||
Date: date of run
|
||||
test-rig : testbed that the tests are run on for example ct_us_001
|
||||
test-tag : test specific information to differenciate the test, LANforge radios used, security modes (wpa2 , open)
|
||||
dut-hw-version : hardware version of the device under test
|
||||
dut-sw-version : software version of the device under test
|
||||
dut-model-num : model number / name of the device under test
|
||||
dut-serial-num : serial number / serial number of the device under test
|
||||
test-priority : test-priority is arbitrary number, choosing under 95 means it goes down at bottom of blog report, and higher priority goes at top.
|
||||
test-id : script or test name , AP Auto, wifi capacity, data plane, dfs
|
||||
short-description : short description of the test
|
||||
pass/fail : set blank for performance tests
|
||||
numeric-score : this is the value for the y-axis (x-axis is a timestamp), numeric value of what was measured
|
||||
test-details : what was measured in the numeric-score, e.g. bits per second, bytes per second, upload speed, minimum cx time (ms)
|
||||
Units : units used for the numeric-scort
|
||||
Graph-Group - Items graphed together used by dashboard, For the lf_qa.py dashboard
|
||||
|
||||
'''
|
||||
|
||||
|
||||
class lf_kpi_csv:
|
||||
def __init__(self,
|
||||
_kpi_headers=None,
|
||||
_kpi_filename='kpi.csv', # Currently this is the only file name accepted
|
||||
_kpi_path="",
|
||||
_kpi_test_rig="TEST_RIG",
|
||||
_kpi_test_tag="TEST_TAG",
|
||||
_kpi_dut_hw_version="HW_VERSION",
|
||||
_kpi_dut_sw_version="SW_VERSION",
|
||||
_kpi_dut_model_num="MODEL_NUM",
|
||||
_kpi_dut_serial_num="SERIAL_NUM",
|
||||
_kpi_test_id="TEST_ID"
|
||||
):
|
||||
if _kpi_headers is None:
|
||||
_kpi_headers = ['Date', 'test-rig', 'test-tag', 'dut-hw-version', 'dut-sw-version', 'dut-model-num',
|
||||
'dut-serial-num',
|
||||
'test-priority', 'test-id', 'short-description', 'pass/fail', 'numeric-score',
|
||||
'test details', 'Units', 'Graph-Group', 'Subtest-Pass', 'Subtest-Fail']
|
||||
self.kpi_headers = _kpi_headers
|
||||
self.kpi_filename = _kpi_filename
|
||||
self.kpi_full_path = ''
|
||||
self.kpi_file = ""
|
||||
self.kpi_path = _kpi_path
|
||||
self.kpi_test_rig = _kpi_test_rig
|
||||
self.kpi_test_tag = _kpi_test_tag
|
||||
self.kpi_dut_hw_version = _kpi_dut_hw_version
|
||||
self.kpi_dut_sw_version = _kpi_dut_sw_version
|
||||
self.kpi_dut_model_num = _kpi_dut_model_num
|
||||
self.kpi_dut_serial_num = _kpi_dut_serial_num
|
||||
self.kpi_test_id = _kpi_test_id
|
||||
self.kpi_rows = ""
|
||||
try:
|
||||
print("self.kpi_path {kpi_path}".format(kpi_path=self.kpi_path))
|
||||
print("self.kpi_filename {kpi_filename}".format(kpi_filename=self.kpi_filename))
|
||||
if self.kpi_path == "":
|
||||
kpifile = self.kpi_filename
|
||||
else:
|
||||
kpifile = self.kpi_path + '/' + self.kpi_filename
|
||||
print("kpifile {kpifile}".format(kpifile=kpifile))
|
||||
self.kpi_file = open(kpifile, 'w')
|
||||
self.kpi_writer = csv.DictWriter(self.kpi_file, delimiter="\t", fieldnames=self.kpi_headers)
|
||||
self.kpi_writer.writeheader()
|
||||
except:
|
||||
print("lf_kpi_csv.py: {} WARNING unable to open".format(self.kpi_file))
|
||||
|
||||
self.kpi_dict = dict()
|
||||
self.kpi_dict['Date'] = '{date}'.format(date=int(time.time()))
|
||||
self.kpi_dict['test-rig'] = '{test_rig}'.format(test_rig=self.kpi_test_rig)
|
||||
self.kpi_dict['test-tag'] = '{test_tag}'.format(test_tag=self.kpi_test_tag)
|
||||
self.kpi_dict['dut-hw-version'] = '{dut_hw_version}'.format(dut_hw_version=self.kpi_dut_hw_version)
|
||||
self.kpi_dict['dut-sw-version'] = '{dut_sw_version}'.format(dut_sw_version=self.kpi_dut_sw_version)
|
||||
self.kpi_dict['dut-model-num'] = '{dut_model_num}'.format(dut_model_num=self.kpi_dut_model_num)
|
||||
self.kpi_dict['dut-serial-num'] = '{dut_serial_num}'.format(dut_serial_num=self.kpi_dut_serial_num)
|
||||
self.kpi_dict['test-priority'] = ''
|
||||
self.kpi_dict['test-id'] = '{test_id}'.format(test_id=self.kpi_test_id)
|
||||
self.kpi_dict['short-description'] = ''
|
||||
self.kpi_dict['pass/fail'] = ''
|
||||
self.kpi_dict['numeric-score'] = ''
|
||||
self.kpi_dict['test details'] = ''
|
||||
self.kpi_dict['Units'] = ''
|
||||
self.kpi_dict['Graph-Group'] = ''
|
||||
self.kpi_dict['Subtest-Pass'] = ''
|
||||
self.kpi_dict['Subtest-Fail'] = ''
|
||||
|
||||
def kpi_csv_get_dict_update_time(self):
|
||||
self.kpi_dict['Date'] = '{date}'.format(date=round(time.time() * 1000))
|
||||
return self.kpi_dict
|
||||
|
||||
def kpi_csv_write_dict(self, kpi_dict):
|
||||
self.kpi_writer.writerow(kpi_dict)
|
||||
self.kpi_file.flush()
|
||||
|
||||
|
||||
def main():
|
||||
# arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_kpi_csv.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
lf_kpi_csv.py : unit test in lf_kpi_csv.py for exersiging lf_kpi_csv.py library
|
||||
''',
|
||||
description='''\
|
||||
lf_kpi_csv.py
|
||||
-----------
|
||||
|
||||
Summary :
|
||||
---------
|
||||
lf_kpi_csv.py library :
|
||||
|
||||
Date: date of run
|
||||
test-rig : testbed that the tests are run on for example ct_us_001
|
||||
test-tag : test specific information to differenciate the test, LANforge radios used, security modes (wpa2 , open)
|
||||
dut-hw-version : hardware version of the device under test
|
||||
dut-sw-version : software version of the device under test
|
||||
dut-model-num : model number / name of the device under test
|
||||
dut-serial-num : serial number / serial number of the device under test
|
||||
test-priority : test-priority is arbitrary number, choosing under 95 means it goes down at bottom of blog report, and higher priority goes at top.
|
||||
test-id : script or test name , AP Auto, wifi capacity, data plane, dfs
|
||||
short-description : short description of the test
|
||||
pass/fail : set blank for performance tests
|
||||
numeric-score : this is the value for the y-axis (x-axis is a timestamp), numeric value of what was measured
|
||||
test-details : what was measured in the numeric-score, e.g. bits per second, bytes per second, upload speed, minimum cx time (ms)
|
||||
Units : units used for the numeric-scort
|
||||
Graph-Group - Items graphed together used by dashboard, For the lf_qa.py dashboard
|
||||
|
||||
Example :
|
||||
|
||||
This module is included to assist in filling out the kpi.csv correctly
|
||||
The Unit test is used for helping to become familiar with the library
|
||||
|
||||
---------
|
||||
''')
|
||||
|
||||
parser.add_argument(
|
||||
'--local_lf_report_dir',
|
||||
help='--local_lf_report_dir override the report path, primary use when running test in test suite',
|
||||
default="")
|
||||
parser.add_argument("--test_rig", default="lanforge",
|
||||
help="test rig for kpi.csv, testbed that the tests are run on")
|
||||
parser.add_argument("--test_tag", default="kpi_generation",
|
||||
help="test tag for kpi.csv, test specific information to differenciate the test")
|
||||
parser.add_argument("--dut_hw_version", default="hw_01",
|
||||
help="dut hw version for kpi.csv, hardware version of the device under test")
|
||||
parser.add_argument("--dut_sw_version", default="sw_01",
|
||||
help="dut sw version for kpi.csv, software version of the device under test")
|
||||
parser.add_argument("--dut_model_num", default="can_ap",
|
||||
help="dut model for kpi.csv, model number / name of the device under test")
|
||||
parser.add_argument("--test_priority", default="95",
|
||||
help="dut model for kpi.csv, test-priority is arbitrary number")
|
||||
parser.add_argument("--test_id", default="kpi_unit_test", help="test-id for kpi.csv, script or test name")
|
||||
'''
|
||||
Other values that are included in the kpi.csv row.
|
||||
short-description : short description of the test
|
||||
pass/fail : set blank for performance tests
|
||||
numeric-score : this is the value for the y-axis (x-axis is a timestamp), numeric value of what was measured
|
||||
test details : what was measured in the numeric-score, e.g. bits per second, bytes per second, upload speed, minimum cx time (ms)
|
||||
Units : units used for the numeric-scort
|
||||
Graph-Group - For the lf_qa.py dashboard
|
||||
'''
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get the report path to create the kpi.csv path
|
||||
# kpi_path = report.get_report_path() in normal use case would get from lf_report.py library
|
||||
kpi_csv = lf_kpi_csv(
|
||||
_kpi_path=args.local_lf_report_dir,
|
||||
_kpi_test_rig=args.test_rig,
|
||||
_kpi_test_tag=args.test_tag,
|
||||
_kpi_dut_hw_version=args.dut_hw_version,
|
||||
_kpi_dut_sw_version=args.dut_sw_version,
|
||||
_kpi_dut_model_num=args.dut_model_num,
|
||||
_kpi_test_id=args.test_id)
|
||||
|
||||
results_dict = kpi_csv.kpi_dict
|
||||
|
||||
results_dict['Graph-Group'] = "graph_group"
|
||||
results_dict['short-description'] = "short_description"
|
||||
results_dict['numeric-score'] = "100"
|
||||
results_dict['Units'] = "Mbps"
|
||||
|
||||
print("results_dict {results_dict}".format(results_dict=results_dict))
|
||||
print("date {date}".format(date=results_dict['Date']))
|
||||
|
||||
kpi_csv.kpi_csv_write_dict(results_dict)
|
||||
|
||||
# reuse the dictionary
|
||||
results_dict['Graph-Group'] = "graph_group_1_5"
|
||||
results_dict['short-description'] = "short_description_1_5"
|
||||
results_dict['numeric-score'] = "99"
|
||||
results_dict['Units'] = "Mbps"
|
||||
|
||||
kpi_csv.kpi_csv_write_dict(results_dict)
|
||||
|
||||
# append to a row to the existing dictionary
|
||||
results_dict_2 = kpi_csv.kpi_dict
|
||||
# modify an entry
|
||||
results_dict_2['test-tag'] = 'kpi_generation_2'
|
||||
results_dict_2['Graph-Group'] = "graph_group"
|
||||
results_dict_2['short-description'] = "short_description"
|
||||
results_dict_2['numeric-score'] = "100"
|
||||
results_dict_2['Units'] = "Mbps"
|
||||
print("results_dict_2 {results_dict_2}".format(results_dict_2=results_dict_2))
|
||||
print("date 2 {date}".format(date=results_dict_2['Date']))
|
||||
kpi_csv.kpi_csv_write_dict(results_dict_2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -146,14 +146,22 @@ class MeshTest(cvtest):
|
||||
upload_speed="56Kbps",
|
||||
download_speed="85%",
|
||||
duration="60s",
|
||||
enables=[],
|
||||
disables=[],
|
||||
raw_lines=[],
|
||||
enables=None,
|
||||
disables=None,
|
||||
raw_lines=None,
|
||||
raw_lines_file="",
|
||||
sets=[],
|
||||
sets=None,
|
||||
):
|
||||
super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
|
||||
|
||||
if enables is None:
|
||||
enables = []
|
||||
if disables is None:
|
||||
disables = []
|
||||
if raw_lines is None:
|
||||
raw_lines = []
|
||||
if sets is None:
|
||||
sets = []
|
||||
self.lf_host = lf_host
|
||||
self.lf_port = lf_port
|
||||
self.lf_user = lf_user
|
||||
@@ -225,14 +233,14 @@ def main():
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
Example:
|
||||
./lf_mesh_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name mesh-instance --config_name test_con --upstream 1.1.eth1 \
|
||||
--raw_line 'selected_dut2: RootAP wactest 08:36:c9:19:47:40 (1)' \
|
||||
--raw_line 'selected_dut5: RootAP wactest 08:36:c9:19:47:50 (2)' \
|
||||
--duration 15s \
|
||||
--download_speed 85% --upload_speed 56Kbps \
|
||||
--raw_line 'velocity: 100' \
|
||||
--raw_lines_file example-configs/mesh-ferndale-cfg.txt \
|
||||
./lf_mesh_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \\
|
||||
--instance_name mesh-instance --config_name test_con --upstream 1.1.eth1 \\
|
||||
--raw_line 'selected_dut2: RootAP wactest 08:36:c9:19:47:40 (1)' \\
|
||||
--raw_line 'selected_dut5: RootAP wactest 08:36:c9:19:47:50 (2)' \\
|
||||
--duration 15s \\
|
||||
--download_speed 85% --upload_speed 56Kbps \\
|
||||
--raw_line 'velocity: 100' \\
|
||||
--raw_lines_file example-configs/mesh-ferndale-cfg.txt \\
|
||||
--test_rig Ferndale-Mesh-01 --pull_report
|
||||
|
||||
NOTE: There is quite a lot of config needed, see example-configs/mesh-ferndale-cfg.txt
|
||||
@@ -246,9 +254,9 @@ def main():
|
||||
|
||||
parser.add_argument("-u", "--upstream", type=str, default="",
|
||||
help="Upstream port for wifi capacity test ex. 1.1.eth2")
|
||||
|
||||
# argparse uses the % formatting so use %%
|
||||
parser.add_argument("--download_speed", default="",
|
||||
help="Specify requested download speed. Percentage of theoretical is also supported. Default: 85%")
|
||||
help="Specify requested download speed. Percentage of theoretical is also supported. Default: 85%%")
|
||||
parser.add_argument("--upload_speed", default="",
|
||||
help="Specify requested upload speed. Percentage of theoretical is also supported. Default: 0")
|
||||
parser.add_argument("--duration", default="",
|
||||
|
||||
@@ -45,7 +45,7 @@ Realm = realm.Realm
|
||||
class MultiPsk(Realm):
|
||||
def __init__(self,
|
||||
host=None,
|
||||
port=None,
|
||||
port=8080,
|
||||
ssid=None,
|
||||
input=None,
|
||||
security=None,
|
||||
@@ -57,8 +57,10 @@ class MultiPsk(Realm):
|
||||
sta_prefix="sta",
|
||||
debug_=False,
|
||||
):
|
||||
self.host = host
|
||||
self.port = port
|
||||
super().__init__(lfclient_host=host,
|
||||
lfclient_port=port),
|
||||
self.lfclient_host = host
|
||||
self.lfclient_port = port
|
||||
self.ssid = ssid
|
||||
self.input = input
|
||||
self.security = security
|
||||
@@ -69,8 +71,7 @@ class MultiPsk(Realm):
|
||||
self.resource = resource
|
||||
self.sta_prefix = sta_prefix
|
||||
self.debug = debug_
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.station_profile = self.new_station_profile()
|
||||
|
||||
def build(self):
|
||||
station_list = []
|
||||
@@ -84,30 +85,30 @@ class MultiPsk(Realm):
|
||||
else:
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=self.start_id,
|
||||
end_id_=input['num_station'] - 1, padding_number_=100,
|
||||
radio=input['radio'])
|
||||
radio=self.radio)
|
||||
# implementation for non vlan pending ****
|
||||
print("creating stations")
|
||||
self.station_profile.use_security(self.security, self.ssid, str(input['password']))
|
||||
self.station_profile.use_security(self.security, self.ssid, self.passwd)
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=input['radio'], sta_names_=station_list, debug=self.local_realm.debug)
|
||||
self.local_realm.wait_until_ports_appear(sta_list=station_list)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=station_list, debug=self.debug)
|
||||
self.wait_until_ports_appear(sta_list=station_list)
|
||||
self.station_profile.admin_up()
|
||||
if self.local_realm.wait_for_ip(station_list, timeout_sec=120):
|
||||
if self.wait_for_ip(station_list, timeout_sec=120):
|
||||
print("All stations got IPs")
|
||||
else:
|
||||
print("Stations failed to get IPs")
|
||||
|
||||
print("create udp endp")
|
||||
self.cx_profile_udp = self.local_realm.new_l3_cx_profile()
|
||||
self.cx_profile_udp = self.new_l3_cx_profile()
|
||||
self.cx_profile_udp.side_a_min_bps = 128000
|
||||
self.cx_profile_udp.side_b_min_bps = 128000
|
||||
self.cx_profile_udp.side_a_min_pdu = 1200
|
||||
self.cx_profile_udp.side_b_min_pdu = 1500
|
||||
self.cx_profile_udp.report_timer = 1000
|
||||
self.cx_profile_udp.name_prefix = "udp"
|
||||
port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix))
|
||||
port_list = list(self.find_ports_like("%s+" % self.sta_prefix))
|
||||
# print("port list", port_list)
|
||||
if (port_list is None) or (len(port_list) < 1):
|
||||
raise ValueError("Unable to find ports named '%s'+" % self.sta_prefix)
|
||||
@@ -118,13 +119,13 @@ class MultiPsk(Realm):
|
||||
|
||||
# Create TCP endpoints
|
||||
print("create tcp endp")
|
||||
self.l3_tcp_profile = self.local_realm.new_l3_cx_profile()
|
||||
self.l3_tcp_profile = self.new_l3_cx_profile()
|
||||
self.l3_tcp_profile.side_a_min_bps = 128000
|
||||
self.l3_tcp_profile.side_b_min_bps = 56000
|
||||
self.l3_tcp_profile.name_prefix = "tcp"
|
||||
self.l3_tcp_profile.report_timer = 1000
|
||||
self.l3_tcp_profile.create(endp_type="lf_tcp",
|
||||
side_a=list(self.local_realm.find_ports_like("%s+" % self.sta_prefix)),
|
||||
side_a=list(self.find_ports_like("%s+" % self.sta_prefix)),
|
||||
side_b="%d.%s" % (self.resource, input['upstream']),
|
||||
suppress_related_commands=True)
|
||||
|
||||
@@ -140,7 +141,7 @@ class MultiPsk(Realm):
|
||||
if "." in i['upstream']:
|
||||
# print(str(i['upstream']) + " is a vlan upstream port")
|
||||
print("checking its ip ..")
|
||||
data = self.local_realm.json_get("ports/list?fields=IP")
|
||||
data = self.json_get("ports/list?fields=IP")
|
||||
for val in data["interfaces"]:
|
||||
for j in val:
|
||||
if "1." + str(self.resource) + "." + str(i['upstream']) == j:
|
||||
@@ -157,7 +158,7 @@ class MultiPsk(Realm):
|
||||
if "." not in i['upstream']:
|
||||
# print(str(i['upstream']) + " is not an vlan upstream port")
|
||||
print("checking its ip ..")
|
||||
data = self.local_realm.json_get("ports/list?fields=IP")
|
||||
data = self.json_get("ports/list?fields=IP")
|
||||
for val in data["interfaces"]:
|
||||
for j in val:
|
||||
if "1." + str(self.resource) + "." + str(i['upstream']) == j:
|
||||
@@ -168,11 +169,8 @@ class MultiPsk(Realm):
|
||||
return non_vlan_ips
|
||||
|
||||
def get_sta_ip(self):
|
||||
# this function gives station ip dict eg{'eth2.100': '172.17.0.100'}
|
||||
# self.input = [{'password': 'lanforge1', 'upstream': 'eth2.100', 'mac': '', 'num_station': 1, 'radio': 'wiphy4'}, {'password': 'lanforge2', 'upstream': 'eth2.200', 'mac': '', 'num_station': 1, 'radio': 'wiphy4'}, {'password': 'lanforge3', 'upstream': 'eth2', 'mac': '', 'num_station': 1, 'radio': 'wiphy0'}]
|
||||
# port_list = ['1.1.sta200', '1.1.sta00', '1.1.sta100']
|
||||
station_ip = {}
|
||||
port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix))
|
||||
port_list = list(self.find_ports_like("%s+" % self.sta_prefix))
|
||||
# print("port list", port_list)
|
||||
# port list ['1.1.sta200', '1.1.sta00', '1.1.sta100']
|
||||
for name, id in zip(port_list, self.input):
|
||||
@@ -182,7 +180,7 @@ class MultiPsk(Realm):
|
||||
# print(x)
|
||||
|
||||
if name == "1." + str(self.resource) + ".sta" + str(x):
|
||||
data = self.local_realm.json_get("ports/list?fields=IP")
|
||||
data = self.json_get("ports/list?fields=IP")
|
||||
for i in data["interfaces"]:
|
||||
# print(i)
|
||||
for j in i:
|
||||
@@ -227,7 +225,7 @@ class MultiPsk(Realm):
|
||||
# print(x)
|
||||
|
||||
if name == "1." + str(self.resource) + ".sta" + str(x):
|
||||
data = self.local_realm.json_get("ports/list?fields=IP")
|
||||
data = self.json_get("ports/list?fields=IP")
|
||||
for i in data["interfaces"]:
|
||||
# print(i)
|
||||
for j in i:
|
||||
@@ -241,7 +239,7 @@ class MultiPsk(Realm):
|
||||
def get_non_vlan_sta_ip(self):
|
||||
station_nonvlan_ip = {}
|
||||
x = ""
|
||||
port_list = list(self.local_realm.find_ports_like("%s+" % self.sta_prefix))
|
||||
port_list = list(self.find_ports_like("%s+" % self.sta_prefix))
|
||||
# print("port list", port_list)
|
||||
for id in self.input:
|
||||
if "." not in id['upstream']:
|
||||
@@ -249,7 +247,7 @@ class MultiPsk(Realm):
|
||||
# print(x)
|
||||
for name in port_list:
|
||||
if name == "1.1.sta00":
|
||||
data = self.local_realm.json_get("ports/list?fields=IP")
|
||||
data = self.json_get("ports/list?fields=IP")
|
||||
for i in data["interfaces"]:
|
||||
# print(i)
|
||||
for j in i:
|
||||
@@ -270,11 +268,10 @@ class MultiPsk(Realm):
|
||||
y = station_ip[j].split('.')
|
||||
if x[0] == y[0] and x[1] == y[1]:
|
||||
print("station got ip from vlan")
|
||||
x = "Pass"
|
||||
return "Pass"
|
||||
else:
|
||||
print("station did not got ip from vlan")
|
||||
x = "Fail"
|
||||
return x
|
||||
return "Fail"
|
||||
|
||||
def compare_nonvlan_ip_nat(self):
|
||||
non_vlan_sta_ip = self.get_non_vlan_sta_ip()
|
||||
@@ -312,27 +309,22 @@ class MultiPsk(Realm):
|
||||
self.cx_profile_udp.cleanup()
|
||||
self.l3_tcp_profile.cleanup()
|
||||
self.station_profile.cleanup()
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.local_realm.lfclient_url, port_list=self.station_profile.station_names,
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_host, port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
print("Test Completed")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog="lf_multipsk.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="lanforge webpage download Test Script")
|
||||
parser.add_argument('--mgr', help='hostname for where LANforge GUI is running', default='localhost')
|
||||
parser.add_argument('--mgr_port', help='port LANforge GUI HTTP service is running on', default=8080)
|
||||
parser.add_argument('--ssid', help='WiFi SSID for client to associate to')
|
||||
parser.add_argument('--security', help='WiFi Security protocol: {open|wep|wpa2|wpa3', default="wpa2")
|
||||
parser.add_argument('--mode', help="specify mode of ap eg BRIDGE or NAT", default="BRIDGE")
|
||||
parser.add_argument('--n_vlan', help="type number of vlan using in test eg 1 or 2", default=1)
|
||||
# parser.add_argument('--input', nargs="+", help="specify list of parameters like passwords,upstream,mac address, number of clients and radio as input, eg password@123,eth2.100,"",1,wiphy0 lanforge@123,eth2.100,"",1,wiphy1")
|
||||
parser.add_argument('--mode', help="Mode for lf_multipsk", default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
input_data = [{
|
||||
"password": "lanforge1",
|
||||
"password": args.passwd,
|
||||
"upstream": "eth2.100",
|
||||
"mac": "",
|
||||
"num_station": 1,
|
||||
@@ -364,8 +356,11 @@ def main():
|
||||
multi_obj = MultiPsk(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
ssid=args.ssid,
|
||||
passwd=args.passwd,
|
||||
input=input_data,
|
||||
security=args.security)
|
||||
security=args.security,
|
||||
debug_=args.debug,
|
||||
radio=args.radio)
|
||||
|
||||
multi_obj.build()
|
||||
multi_obj.start()
|
||||
|
||||
76
py-scripts/lf_port_probe.py
Executable file
76
py-scripts/lf_port_probe.py
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||
|
||||
from time import sleep
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
|
||||
|
||||
# see https://stackoverflow.com/questions/9295439/python-json-loads-fails-with-valueerror-invalid-control-character-at-line-1-c/16544933#16544933
|
||||
# re-load and reexport JSON with strict=False?
|
||||
|
||||
class ProbePort2(LFCliBase):
|
||||
def __init__(self,
|
||||
lfhost=None,
|
||||
lfport=None,
|
||||
debug=False,
|
||||
eid_str=None):
|
||||
super().__init__(_lfjson_host=lfhost,
|
||||
_lfjson_port=lfport,
|
||||
_debug=debug)
|
||||
hunks = eid_str.split(".")
|
||||
self.probepath = "/probe/1/%s/%s" % (hunks[-2], hunks[-1])
|
||||
# self.decoder = json.JSONDecoder()
|
||||
|
||||
def run(self):
|
||||
self.json_post(self.probepath, {})
|
||||
sleep(0.2)
|
||||
response = self.json_get(self.probepath)
|
||||
if not response:
|
||||
print("problem probing port %s" % self.probepath)
|
||||
exit(1)
|
||||
# pprint.pprint(response)
|
||||
if "probe-results" not in response:
|
||||
print("problem probing port %s" % self.probepath)
|
||||
exit(1)
|
||||
|
||||
probe_res = response["probe-results"][0]
|
||||
#pprint.pprint(probe_res)
|
||||
for (key, value) in probe_res.items():
|
||||
# probe_results = [key]
|
||||
print("port "+key)
|
||||
# pprint.pprint(value['probe results'])
|
||||
xlated_results = str(value['probe results']).replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t")
|
||||
print(xlated_results)
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog=__name__,
|
||||
description='''\
|
||||
Example:
|
||||
./port_probe.py --port 1.1.eth0
|
||||
''')
|
||||
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--port_eid', help='EID of station to be used', default="1.1.eth0")
|
||||
|
||||
args = parser.parse_args()
|
||||
probe = ProbePort2(lfhost=args.mgr,
|
||||
lfport=args.mgr_port,
|
||||
debug=args.debug,
|
||||
eid_str=args.port_eid)
|
||||
probe.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,20 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
'''
|
||||
"""
|
||||
NAME: lf_report.py
|
||||
|
||||
PURPOSE:
|
||||
PURPOSE:
|
||||
|
||||
This program is a helper class for reporting results for a lanforge python script.
|
||||
The class will generate an output directory based on date and time in the /home/lanforge/html-reports/ .
|
||||
The class will generate an output directory based on date and time in the /home/lanforge/html-reports/ .
|
||||
If the reports-data is not present then the date and time directory will be created in the current directory.
|
||||
The banner and Candela Technology logo will be copied in the results directory.
|
||||
The results directory may be over written and many of the other paramaters during construction.
|
||||
The banner and Candela Technology logo will be copied in the results directory.
|
||||
The results directory may be over written and many of the other paramaters during construction.
|
||||
Creating the date time directory on construction was a design choice.
|
||||
|
||||
EXAMPLE:
|
||||
EXAMPLE:
|
||||
|
||||
This is a helper class, a unit test is included at the bottom of the file.
|
||||
This is a helper class, a unit test is included at the bottom of the file.
|
||||
To test lf_report.py and lf_graph.py together use the lf_report_test.py file
|
||||
|
||||
LICENSE:
|
||||
@@ -23,7 +23,7 @@ LICENSE:
|
||||
|
||||
|
||||
INCLUDE_IN_README
|
||||
'''
|
||||
"""
|
||||
# CAUTION: adding imports to this file which are not in update_dependencies.py is not advised
|
||||
import os
|
||||
import shutil
|
||||
@@ -31,25 +31,27 @@ import datetime
|
||||
|
||||
import pandas as pd
|
||||
import pdfkit
|
||||
import argparse
|
||||
|
||||
|
||||
# internal candela references included during intial phases, to be deleted at future date
|
||||
# https://candelatech.atlassian.net/wiki/spaces/LANFORGE/pages/372703360/Scripting+Data+Collection+March+2021
|
||||
# base report class
|
||||
class lf_report():
|
||||
|
||||
class lf_report:
|
||||
def __init__(self,
|
||||
# _path the report directory under which the report directories will be created.
|
||||
_path="/home/lanforge/html-reports",
|
||||
_alt_path="",
|
||||
_date="",
|
||||
_title="LANForge Test Run Heading",
|
||||
_title="LANForge Unit Test Run Heading",
|
||||
_table_title="LANForge Table Heading",
|
||||
_graph_title="LANForge Graph Title",
|
||||
_obj="",
|
||||
_obj_title="",
|
||||
_output_html="outfile.html",
|
||||
_output_pdf="outfile.pdf",
|
||||
_results_dir_name="LANforge_Test_Results",
|
||||
_results_dir_name="LANforge_Test_Results_Unit_Test",
|
||||
_output_format='html', # pass in on the write functionality, current not used
|
||||
_dataframe="",
|
||||
_path_date_time="",
|
||||
@@ -76,6 +78,7 @@ class lf_report():
|
||||
self.output_html = _output_html
|
||||
self.path_date_time = _path_date_time
|
||||
self.write_output_html = ""
|
||||
self.write_output_index_html = ""
|
||||
self.output_pdf = _output_pdf
|
||||
self.write_output_pdf = ""
|
||||
self.banner_html = ""
|
||||
@@ -271,6 +274,17 @@ class lf_report():
|
||||
print("write_html failed")
|
||||
return self.write_output_html
|
||||
|
||||
def write_index_html(self):
|
||||
self.write_output_index_html = str(self.path_date_time) + '/' + str("index.html")
|
||||
print("write_output_index_html: {}".format(self.write_output_index_html))
|
||||
try:
|
||||
test_file = open(self.write_output_index_html, "w")
|
||||
test_file.write(self.html)
|
||||
test_file.close()
|
||||
except:
|
||||
print("write_index_html failed")
|
||||
return self.write_output_index_html
|
||||
|
||||
def write_html_with_timestamp(self):
|
||||
self.write_output_html = "{}/{}-{}".format(self.path_date_time, self.date, self.output_html)
|
||||
print("write_output_html: {}".format(self.write_output_html))
|
||||
@@ -456,7 +470,7 @@ class lf_report():
|
||||
setup_information = """
|
||||
<!-- Test Setup Information -->
|
||||
<table width='700px' border='1' cellpadding='2' cellspacing='0' style='border-top-color: gray; border-top-style: solid; border-top-width: 1px; border-right-color: gray; border-right-style: solid; border-right-width: 1px; border-bottom-color: gray; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: gray; border-left-style: solid; border-left-width: 1px'>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>""" + str(value) + """</td>
|
||||
<td>
|
||||
@@ -496,7 +510,7 @@ class lf_report():
|
||||
function fallbackCopyTextToClipboard(text) {
|
||||
var textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
|
||||
|
||||
// Avoid scrolling to bottom
|
||||
textArea.style.top = "0";
|
||||
textArea.style.left = "0";
|
||||
@@ -561,6 +575,16 @@ function copyTextToClipboard(ele) {
|
||||
|
||||
# Unit Test
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_report.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Reporting library Unit Test")
|
||||
parser.add_argument('--lfmgr', help='sample argument: where LANforge GUI is running', default='localhost')
|
||||
# the args parser is not really used , this is so the report is not generated when testing
|
||||
# the imports with --help
|
||||
args = parser.parse_args()
|
||||
print("LANforge manager {lfmgr}".format(lfmgr=args.lfmgr))
|
||||
|
||||
# Testing: generate data frame
|
||||
dataframe = pd.DataFrame({
|
||||
'product': ['CT521a-264-1ac-1n', 'CT521a-1ac-1ax', 'CT522-264-1ac2-1n', 'CT523c-2ac2-db-10g-cu',
|
||||
@@ -573,7 +597,7 @@ if __name__ == "__main__":
|
||||
|
||||
print(dataframe)
|
||||
|
||||
# Testing: generate data frame
|
||||
# Testing: generate data frame
|
||||
dataframe2 = pd.DataFrame({
|
||||
'station': [1, 2, 3, 4, 5, 6, 7],
|
||||
'time_seconds': [23, 78, 22, 19, 45, 22, 25]
|
||||
@@ -605,4 +629,3 @@ if __name__ == "__main__":
|
||||
report.write_pdf()
|
||||
|
||||
print("report path {}".format(report.get_path()))
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
'''
|
||||
NAME: lf_report_test.py
|
||||
|
||||
PURPOSE:
|
||||
PURPOSE:
|
||||
Common file for testing lf_report and lf_graph Library generates html and pdf output
|
||||
|
||||
SETUP:
|
||||
SETUP:
|
||||
/lanforge/html-reports directory needs to be present or output generated in local file
|
||||
|
||||
EXAMPLE:
|
||||
EXAMPLE:
|
||||
./lf_report_test.py : currently script does not accept input
|
||||
|
||||
COPYWRITE
|
||||
@@ -26,8 +26,9 @@ import numpy as np
|
||||
import pandas as pd
|
||||
import pdfkit
|
||||
import random
|
||||
import argparse
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lf_report = importlib.import_module("py-scripts.lf_report")
|
||||
@@ -38,10 +39,45 @@ lf_scatter_graph = lf_graph.lf_scatter_graph
|
||||
lf_stacked_graph = lf_graph.lf_stacked_graph
|
||||
lf_horizontal_stacked_graph = lf_graph.lf_horizontal_stacked_graph
|
||||
|
||||
|
||||
# Unit Test
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
def main():
|
||||
# Testing: generate data frame
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="lf_report_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='''\
|
||||
-----------------
|
||||
NAME: lf_report_test.py
|
||||
|
||||
PURPOSE:
|
||||
Common file for testing lf_report and lf_graph Library generates html and pdf output
|
||||
|
||||
SETUP:
|
||||
/lanforge/html-reports directory needs to be present or output generated in local file
|
||||
|
||||
EXAMPLE:
|
||||
./lf_report_test.py : currently script does not accept input
|
||||
|
||||
COPYWRITE
|
||||
Copyright 2021 Candela Technologies Inc
|
||||
License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
|
||||
INCLUDE_IN_README
|
||||
''')
|
||||
|
||||
parser.add_argument(
|
||||
'--mgr',
|
||||
'--lfmgr',
|
||||
dest='lfmgr',
|
||||
help='sample argument: where LANforge GUI is running',
|
||||
default='localhost')
|
||||
# the args parser is not really used , this is so the report is not generated when testing
|
||||
# the imports with --help
|
||||
args = parser.parse_args()
|
||||
print("LANforge manager {lfmgr}".format(lfmgr=args.lfmgr))
|
||||
|
||||
dataframe = pd.DataFrame({
|
||||
'product': ['CT521a-264-1ac-1n', 'CT521a-1ac-1ax', 'CT522-264-1ac2-1n', 'CT523c-2ac2-db-10g-cu',
|
||||
'CT523c-3ac2-db-10g-cu', 'CT523c-8ax-ac10g-cu', 'CT523c-192-2ac2-1ac-10g'],
|
||||
@@ -53,7 +89,7 @@ if __name__ == "__main__":
|
||||
|
||||
print(dataframe)
|
||||
|
||||
# Testing: generate data frame
|
||||
# Testing: generate data frame
|
||||
dataframe2 = pd.DataFrame({
|
||||
'station': [1, 2, 3, 4, 5, 6, 7],
|
||||
'time_seconds': [23, 78, 22, 19, 45, 22, 25]
|
||||
@@ -108,7 +144,7 @@ if __name__ == "__main__":
|
||||
_xaxis_categories=x_axis_values,
|
||||
_graph_image_name="Bi-single_radio_2.4GHz",
|
||||
_label=["bi-downlink", "bi-uplink", 'uplink'],
|
||||
_color=['darkorange', 'forestgreen','blueviolet'],
|
||||
_color=['darkorange', 'forestgreen', 'blueviolet'],
|
||||
_color_edge='red',
|
||||
_grp_title="Throughput for each clients",
|
||||
_xaxis_step=5,
|
||||
@@ -117,7 +153,7 @@ if __name__ == "__main__":
|
||||
_text_rotation=45,
|
||||
_xticks_font=7,
|
||||
_legend_loc="best",
|
||||
_legend_box=(1,1),
|
||||
_legend_box=(1, 1),
|
||||
_legend_ncol=1,
|
||||
_legend_fontsize=None,
|
||||
_enable_csv=True)
|
||||
@@ -127,7 +163,7 @@ if __name__ == "__main__":
|
||||
print("graph name {}".format(graph_png))
|
||||
|
||||
report.set_graph_image(graph_png)
|
||||
# need to move the graph image to the results
|
||||
# need to move the graph image to the results
|
||||
report.move_graph_image()
|
||||
if graph.enable_csv:
|
||||
report.set_csv_filename(graph_png)
|
||||
@@ -140,7 +176,7 @@ if __name__ == "__main__":
|
||||
_graph_image_name="image_name1",
|
||||
_color=None,
|
||||
_label=["s1", "s2", "s3"],
|
||||
_enable_csv = False)
|
||||
_enable_csv=False)
|
||||
graph_png = graph2.build_scatter_graph()
|
||||
|
||||
print("graph name {}".format(graph_png))
|
||||
@@ -149,14 +185,15 @@ if __name__ == "__main__":
|
||||
report.move_graph_image()
|
||||
|
||||
report.build_graph()
|
||||
# this will generate graph which is independent,we can customize the value with different colors
|
||||
# this will generate graph which is independent,we can customize the value
|
||||
# with different colors
|
||||
graph2 = lf_scatter_graph(_x_data_set=set1, _y_data_set=[45, 67, 45, 34], _values=[0, 0, 0, 1],
|
||||
_xaxis_name="x-axis",
|
||||
_yaxis_name="y-axis",
|
||||
_graph_image_name="image_name_map",
|
||||
_color=None,
|
||||
_label=["s1", "s2"],
|
||||
_enable_csv = False)
|
||||
_enable_csv=False)
|
||||
graph_png = graph2.build_scatter_graph()
|
||||
|
||||
print("graph name {}".format(graph_png))
|
||||
@@ -165,14 +202,15 @@ if __name__ == "__main__":
|
||||
report.move_graph_image()
|
||||
|
||||
report.build_graph()
|
||||
dataset = [["1", "2", "3", "4"], [12, 45, 67, 34], [23, 67, 23, 12], [25, 45, 34, 23]]
|
||||
dataset = [["1", "2", "3", "4"], [12, 45, 67, 34],
|
||||
[23, 67, 23, 12], [25, 45, 34, 23]]
|
||||
graph = lf_stacked_graph(_data_set=dataset,
|
||||
_xaxis_name="Stations",
|
||||
_yaxis_name="Login PASS/FAIL",
|
||||
_label=['Success', 'Fail', 'both'],
|
||||
_graph_image_name="login_pass_fail1",
|
||||
_color=None,
|
||||
_enable_csv = False)
|
||||
_enable_csv=False)
|
||||
|
||||
graph_png = graph.build_stacked_graph()
|
||||
|
||||
@@ -192,7 +230,7 @@ if __name__ == "__main__":
|
||||
_graph_image_name="image_name_pass_fail",
|
||||
_color=["r", "g"],
|
||||
_figsize=(9, 4),
|
||||
_enable_csv = False)
|
||||
_enable_csv=False)
|
||||
|
||||
graph_png = graph.build_horizontal_stacked_graph()
|
||||
|
||||
@@ -215,3 +253,5 @@ if __name__ == "__main__":
|
||||
# report.write_pdf(_page_size = 'Legal', _orientation='Portrait')
|
||||
|
||||
# report.generate_report()
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -124,7 +124,7 @@ class RvrTest(cvtest):
|
||||
lf_host="localhost",
|
||||
lf_port=8080,
|
||||
ssh_port=22,
|
||||
local_path="",
|
||||
local_lf_report_dir="",
|
||||
graph_groups=None,
|
||||
lf_user="lanforge",
|
||||
lf_password="lanforge",
|
||||
@@ -167,8 +167,8 @@ class RvrTest(cvtest):
|
||||
self.raw_lines_file = raw_lines_file
|
||||
self.sets = sets
|
||||
self.ssh_port = ssh_port
|
||||
self.local_path = local_path
|
||||
self.graph_groups = graph_groups
|
||||
self.local_lf_report_dir = local_lf_report_dir
|
||||
|
||||
def setup(self):
|
||||
# Nothing to do at this time.
|
||||
@@ -212,7 +212,7 @@ class RvrTest(cvtest):
|
||||
self.create_and_run_test(self.load_old_cfg, self.test_name, self.instance_name,
|
||||
self.config_name, self.sets,
|
||||
self.pull_report, self.lf_host, self.lf_user, self.lf_password,
|
||||
cv_cmds, ssh_port=self.ssh_port, local_lf_report_dir=self.local_path,
|
||||
cv_cmds, ssh_port=self.ssh_port, local_lf_report_dir=self.local_lf_report_dir,
|
||||
graph_groups_file=self.graph_groups)
|
||||
self.rm_text_blob(self.config_name, blob_test) # To delete old config with same name
|
||||
|
||||
@@ -226,6 +226,39 @@ def main():
|
||||
|
||||
Example:
|
||||
|
||||
./lf_rvr_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \\
|
||||
--instance_name rvr-instance --config_name test_con --upstream 1.1.eth1 \\
|
||||
--dut RootAP --duration 15s --station 1.1.wlan0 \\
|
||||
--download_speed 85% --upload_speed 56Kbps \\
|
||||
--raw_line 'pkts: MTU' \\
|
||||
--raw_line 'directions: DUT Transmit' \\
|
||||
--raw_line 'traffic_types: TCP' \\
|
||||
--test_rig Ferndale-Mesh-01 --pull_report \\
|
||||
--raw_line 'attenuator: 1.1.1040' \\
|
||||
--raw_line 'attenuations: 0..+50..950' \\
|
||||
--raw_line 'attenuator_mod: 3' \\
|
||||
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \\
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \\
|
||||
--influx_bucket ben \\
|
||||
--influx_tag testbed Ferndale-Mesh
|
||||
|
||||
./lf_rvr_test.py --mgr localhost --port 8080 --lf_user lanforge --lf_password lanforge \\
|
||||
--instance_name rvr-instance --config_name test_con --upstream 1.1.eth1 \\
|
||||
--dut RootAP --duration 15s --station 1.1.wlan0 \\
|
||||
--download_speed 85% --upload_speed 56Kbps \\
|
||||
--raw_line 'pkts: MTU' \\
|
||||
--raw_line 'directions: DUT Transmit' \\
|
||||
--raw_line 'traffic_types: TCP' \\
|
||||
--test_rig Ferndale-Mesh-01 --pull_report \\
|
||||
--raw_line 'attenuator: 1.1.1040' \\
|
||||
--raw_line 'attenuations: 0..+50..950' \\
|
||||
--raw_line 'attenuator_mod: 3' \\
|
||||
--pull_report \\
|
||||
--local_lf_report_dir /tmp/rvr-report \\
|
||||
--raw_line 'notes0: my rvr notes' \\
|
||||
--raw_line 'notes1: are here.' \\
|
||||
--raw_line 'rvr_bringup_wait: 30000' \\
|
||||
--raw_line 'first_byte_wait: 30000'
|
||||
|
||||
"""
|
||||
)
|
||||
@@ -240,13 +273,14 @@ def main():
|
||||
parser.add_argument("--dut", default="",
|
||||
help="Specify DUT used by this test, example: linksys-8450")
|
||||
parser.add_argument("--download_speed", default="",
|
||||
help="Specify requested download speed. Percentage of theoretical is also supported. Default: 85%")
|
||||
help="Specify requested download speed. Percentage of theoretical is also supported. Default: 85")
|
||||
parser.add_argument("--upload_speed", default="",
|
||||
help="Specify requested upload speed. Percentage of theoretical is also supported. Default: 0")
|
||||
parser.add_argument("--duration", default="",
|
||||
help="Specify duration of each traffic run")
|
||||
parser.add_argument("--graph_groups", help="File to save graph_groups to", default=None)
|
||||
parser.add_argument("--report_dir", default="")
|
||||
parser.add_argument("--local_lf_report_dir", help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from",default="")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -260,6 +294,7 @@ def main():
|
||||
config_name=args.config_name,
|
||||
upstream=args.upstream,
|
||||
pull_report=args.pull_report,
|
||||
local_lf_report_dir = args.local_lf_report_dir,
|
||||
load_old_cfg=args.load_old_cfg,
|
||||
download_speed=args.download_speed,
|
||||
upload_speed=args.upload_speed,
|
||||
|
||||
0
py-scripts/lf_rx_sensitivity_test.py
Normal file → Executable file
0
py-scripts/lf_rx_sensitivity_test.py
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -266,7 +266,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
cv_test_manager = importlib.import_module("py-json.cv_test_manager")
|
||||
@@ -291,17 +290,25 @@ class TR398v2Test(cvtest):
|
||||
raw_lines_file="",
|
||||
dut5="",
|
||||
dut2="",
|
||||
enables=[],
|
||||
disables=[],
|
||||
raw_lines=[],
|
||||
sets=[],
|
||||
enables=None,
|
||||
disables=None,
|
||||
raw_lines=None,
|
||||
sets=None,
|
||||
):
|
||||
super().__init__(lfclient_host=lf_host, lfclient_port=lf_port)
|
||||
|
||||
if enables is None:
|
||||
enables = []
|
||||
if disables is None:
|
||||
disables = []
|
||||
if raw_lines is None:
|
||||
raw_lines = []
|
||||
if sets is None:
|
||||
sets = []
|
||||
self.lf_host = lf_host
|
||||
self.lf_port = lf_port
|
||||
self.lf_user = lf_user
|
||||
self.lf_password =lf_password
|
||||
self.lf_password = lf_password
|
||||
self.instance_name = instance_name
|
||||
self.config_name = config_name
|
||||
self.dut5 = dut5
|
||||
@@ -322,13 +329,12 @@ class TR398v2Test(cvtest):
|
||||
# Nothing to do at this time.
|
||||
return
|
||||
|
||||
|
||||
def run(self):
|
||||
self.sync_cv()
|
||||
time.sleep(2)
|
||||
self.sync_cv()
|
||||
|
||||
blob_test = "TR398v2-";
|
||||
blob_test = "TR398v2-"
|
||||
|
||||
self.rm_text_blob(self.config_name, blob_test) # To delete old config with same name
|
||||
self.show_text_blob(None, None, False)
|
||||
@@ -362,7 +368,6 @@ class TR398v2Test(cvtest):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser("""
|
||||
Open this file in an editor and read the top notes for more details.
|
||||
|
||||
@@ -419,25 +424,25 @@ def main():
|
||||
|
||||
cv_base_adjust_parser(args)
|
||||
|
||||
CV_Test = TR398v2Test(lf_host = args.mgr,
|
||||
lf_port = args.port,
|
||||
lf_user = args.lf_user,
|
||||
lf_password = args.lf_password,
|
||||
instance_name = args.instance_name,
|
||||
config_name = args.config_name,
|
||||
upstream = args.upstream,
|
||||
pull_report = args.pull_report,
|
||||
local_lf_report_dir = args.local_lf_report_dir,
|
||||
load_old_cfg = args.load_old_cfg,
|
||||
dut2 = args.dut2,
|
||||
dut5 = args.dut5,
|
||||
raw_lines_file = args.raw_lines_file,
|
||||
enables = args.enable,
|
||||
disables = args.disable,
|
||||
raw_lines = args.raw_line,
|
||||
sets = args.set,
|
||||
CV_Test = TR398v2Test(lf_host=args.mgr,
|
||||
lf_port=args.port,
|
||||
lf_user=args.lf_user,
|
||||
lf_password=args.lf_password,
|
||||
instance_name=args.instance_name,
|
||||
config_name=args.config_name,
|
||||
upstream=args.upstream,
|
||||
pull_report=args.pull_report,
|
||||
local_lf_report_dir=args.local_lf_report_dir,
|
||||
load_old_cfg=args.load_old_cfg,
|
||||
dut2=args.dut2,
|
||||
dut5=args.dut5,
|
||||
raw_lines_file=args.raw_lines_file,
|
||||
enables=args.enable,
|
||||
disables=args.disable,
|
||||
raw_lines=args.raw_line,
|
||||
sets=args.set,
|
||||
test_rig=args.test_rig
|
||||
)
|
||||
)
|
||||
CV_Test.setup()
|
||||
CV_Test.run()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script will create 40 clients on 5Ghz , 2.4Ghz and Both and generate layer4 traffic on LANforge ,The Webpage Download Test is designed to test the performance of the Access Point.The goal is to check whether the
|
||||
webpage loading time meets the expectation when clients connected on single radio as well as dual radio.
|
||||
@@ -13,8 +14,10 @@ import importlib
|
||||
import time
|
||||
import argparse
|
||||
import paramiko
|
||||
from datetime import datetime
|
||||
import pandas as pd
|
||||
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -23,6 +26,7 @@ Realm = realm.Realm
|
||||
PortUtils = realm.PortUtils
|
||||
lf_report = importlib.import_module("py-scripts.lf_report")
|
||||
lf_graph = importlib.import_module("py-scripts.lf_graph")
|
||||
lf_kpi_csv = importlib.import_module("py-scripts.lf_kpi_csv")
|
||||
|
||||
|
||||
class HttpDownload(Realm):
|
||||
@@ -62,7 +66,7 @@ class HttpDownload(Realm):
|
||||
self.radio = [self.twog_radio]
|
||||
elif self.bands == "Both":
|
||||
self.radio = [self.fiveg_radio, self.twog_radio]
|
||||
print( self.radio)
|
||||
print(self.radio)
|
||||
self.num_sta = self.num_sta // 2
|
||||
|
||||
def precleanup(self):
|
||||
@@ -116,7 +120,7 @@ class HttpDownload(Realm):
|
||||
self.station_profile.create(radio=rad, sta_names_=self.station_list, debug=self.local_realm.debug)
|
||||
self.local_realm.wait_until_ports_appear(sta_list=self.station_list)
|
||||
self.station_profile.admin_up()
|
||||
if self.local_realm.wait_for_ip(self.station_list,timeout_sec=60):
|
||||
if self.local_realm.wait_for_ip(self.station_list, timeout_sec=60):
|
||||
self.local_realm._pass("All stations got IPs")
|
||||
else:
|
||||
self.local_realm._fail("Stations failed to get IPs")
|
||||
@@ -153,44 +157,22 @@ class HttpDownload(Realm):
|
||||
def stop(self):
|
||||
self.http_profile.stop_cx()
|
||||
|
||||
def my_monitor(self):
|
||||
def my_monitor(self, data_mon):
|
||||
# data in json format
|
||||
data = self.local_realm.json_get("layer4/list?fields=uc-avg")
|
||||
data = self.local_realm.json_get("layer4/%s/list?fields=%s" %
|
||||
(','.join(self.http_profile.created_cx.keys()), data_mon.replace(' ', '+')))
|
||||
# print(data)
|
||||
data1 = []
|
||||
for i in range(len(data['endpoint'])):
|
||||
data1.append(str(list(data['endpoint'][i]))[2:-2])
|
||||
data2 = []
|
||||
for i in range(self.num_sta):
|
||||
data = self.local_realm.json_get("layer4/list?fields=uc-avg")
|
||||
# print(type(data['endpoint'][i][data1[i]]['uc-avg']))
|
||||
data2.append((data['endpoint'][i][data1[i]]['uc-avg']))
|
||||
return data2
|
||||
|
||||
def monitor_bytes(self):
|
||||
# data in json format
|
||||
data = self.local_realm.json_get("layer4/list?fields=bytes-rd")
|
||||
data1 = []
|
||||
for i in range(len(data['endpoint'])):
|
||||
data1.append(str(list(data['endpoint'][i]))[2:-2])
|
||||
data2 = []
|
||||
for i in range(self.num_sta):
|
||||
data = self.local_realm.json_get("layer4/list?fields=bytes-rd")
|
||||
# print(type(data['endpoint'][i][data1[i]]['uc-avg']))
|
||||
data2.append((data['endpoint'][i][data1[i]]['bytes-rd']))
|
||||
return data2
|
||||
|
||||
def monitor_rx(self):
|
||||
# data in json format
|
||||
data = self.local_realm.json_get("layer4/list?fields=rx rate")
|
||||
data1 = []
|
||||
for i in range(len(data['endpoint'])):
|
||||
data1.append(str(list(data['endpoint'][i]))[2:-2])
|
||||
data2 = []
|
||||
for i in range(self.num_sta):
|
||||
data = self.local_realm.json_get("layer4/list?fields=rx rate")
|
||||
# print(type(data['endpoint'][i][data1[i]]['uc-avg']))
|
||||
data2.append((data['endpoint'][i][data1[i]]['rx rate']))
|
||||
return data2
|
||||
data = data['endpoint']
|
||||
if self.num_sta == 1:
|
||||
data1.append(data[data_mon])
|
||||
else:
|
||||
for cx in self.http_profile.created_cx.keys():
|
||||
for info in data:
|
||||
if cx in info:
|
||||
data1.append(info[cx][data_mon])
|
||||
# print(data_mon, data1)
|
||||
return data1
|
||||
|
||||
def postcleanup(self):
|
||||
self.http_profile.cleanup()
|
||||
@@ -198,7 +180,7 @@ class HttpDownload(Realm):
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.local_realm.lfclient_url, port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
|
||||
def file_create(self,ssh_port):
|
||||
def file_create(self, ssh_port):
|
||||
ip = self.host
|
||||
user = "root"
|
||||
pswd = "lanforge"
|
||||
@@ -228,13 +210,13 @@ class HttpDownload(Realm):
|
||||
time.sleep(1)
|
||||
return output
|
||||
|
||||
def download_time_in_sec(self,result_data):
|
||||
def download_time_in_sec(self, result_data):
|
||||
self.resullt_data = result_data
|
||||
download_time = dict.fromkeys(result_data.keys())
|
||||
for i in download_time:
|
||||
try:
|
||||
download_time[i] = result_data[i]['dl_time']
|
||||
except:
|
||||
except BaseException:
|
||||
download_time[i] = []
|
||||
print(download_time)
|
||||
lst = []
|
||||
@@ -270,13 +252,13 @@ class HttpDownload(Realm):
|
||||
dataset.append(dwnld_time["Both"])
|
||||
return dataset
|
||||
|
||||
def speed_in_Mbps(self,result_data):
|
||||
def speed_in_Mbps(self, result_data):
|
||||
self.resullt_data = result_data
|
||||
speed = dict.fromkeys(result_data.keys())
|
||||
for i in speed:
|
||||
try:
|
||||
speed[i] = result_data[i]['speed']
|
||||
except:
|
||||
except BaseException:
|
||||
speed[i] = []
|
||||
print(speed)
|
||||
lst = []
|
||||
@@ -358,7 +340,7 @@ class HttpDownload(Realm):
|
||||
pass_fail_list.append("PASS")
|
||||
sumry2.append("PASS")
|
||||
# BOTH
|
||||
if float(z11[2]) == 0.0 or float(z11[2]) > float(threshold_both) :
|
||||
if float(z11[2]) == 0.0 or float(z11[2]) > float(threshold_both):
|
||||
var = "FAIL"
|
||||
pass_fail_list.append(var)
|
||||
sumryB.append("FAIL")
|
||||
@@ -462,88 +444,95 @@ class HttpDownload(Realm):
|
||||
pass
|
||||
|
||||
def generate_graph(self, dataset, lis, bands):
|
||||
graph = lf_bar_graph(_data_set=dataset, _xaxis_name="Stations", _yaxis_name="Time in Seconds",
|
||||
_xaxis_categories=lis, _label=bands, _xticks_font=8,
|
||||
_graph_image_name="webpage download time graph",
|
||||
_color=['forestgreen', 'darkorange', 'blueviolet'], _color_edge='black', _figsize=(14, 5),
|
||||
_grp_title="Download time taken by each client", _xaxis_step=1, _show_bar_value=True,
|
||||
_text_font=6, _text_rotation=60,
|
||||
_legend_loc="upper right",
|
||||
_legend_box=(1, 1.15),
|
||||
_enable_csv=True
|
||||
)
|
||||
graph = lf_graph.lf_bar_graph(_data_set=dataset, _xaxis_name="Stations", _yaxis_name="Time in Seconds",
|
||||
_xaxis_categories=lis, _label=bands, _xticks_font=8,
|
||||
_graph_image_name="webpage download time graph",
|
||||
_color=['forestgreen', 'darkorange', 'blueviolet'], _color_edge='black', _figsize=(14, 5),
|
||||
_grp_title="Download time taken by each client", _xaxis_step=1, _show_bar_value=True,
|
||||
_text_font=6, _text_rotation=60,
|
||||
_legend_loc="upper right",
|
||||
_legend_box=(1, 1.15),
|
||||
_enable_csv=True
|
||||
)
|
||||
graph_png = graph.build_bar_graph()
|
||||
print("graph name {}".format(graph_png))
|
||||
return graph_png
|
||||
|
||||
def graph_2(self,dataset2, lis, bands):
|
||||
graph_2 = lf_bar_graph(_data_set=dataset2, _xaxis_name="Stations", _yaxis_name="Download Rate in Mbps",
|
||||
_xaxis_categories=lis, _label=bands, _xticks_font=8,
|
||||
_graph_image_name="webpage_speed_graph",
|
||||
_color=['forestgreen', 'darkorange', 'blueviolet'], _color_edge='black',
|
||||
_figsize=(14, 5),
|
||||
_grp_title="Download rate for each client (Mbps)", _xaxis_step=1, _show_bar_value=True,
|
||||
_text_font=6, _text_rotation=60,
|
||||
_legend_loc="upper right",
|
||||
_legend_box=(1, 1.15),
|
||||
_enable_csv=True
|
||||
)
|
||||
def graph_2(self, dataset2, lis, bands):
|
||||
graph_2 = lf_graph.lf_bar_graph(_data_set=dataset2, _xaxis_name="Stations", _yaxis_name="Download Rate in Mbps",
|
||||
_xaxis_categories=lis, _label=bands, _xticks_font=8,
|
||||
_graph_image_name="webpage_speed_graph",
|
||||
_color=['forestgreen', 'darkorange', 'blueviolet'], _color_edge='black',
|
||||
_figsize=(14, 5),
|
||||
_grp_title="Download rate for each client (Mbps)", _xaxis_step=1, _show_bar_value=True,
|
||||
_text_font=6, _text_rotation=60,
|
||||
_legend_loc="upper right",
|
||||
_legend_box=(1, 1.15),
|
||||
_enable_csv=True
|
||||
)
|
||||
graph_png = graph_2.build_bar_graph()
|
||||
return graph_png
|
||||
|
||||
def generate_report(self,date, num_stations,duration, test_setup_info,dataset,lis,bands,threshold_2g,threshold_5g,threshold_both,dataset2,summary_table_value,result_data,test_input_infor):
|
||||
report = lf_report(_results_dir_name="webpage_test", _output_html="Webpage.html", _output_pdf="Webpage.pdf")
|
||||
report.set_title("WEBPAGE DOWNLOAD TEST")
|
||||
report.set_date(date)
|
||||
report.build_banner()
|
||||
report.set_table_title("Test Setup Information")
|
||||
report.build_table_title()
|
||||
def generate_report(self, date, num_stations, duration, test_setup_info, dataset, lis, bands, threshold_2g,
|
||||
threshold_5g, threshold_both, dataset2, summary_table_value, result_data, test_rig,
|
||||
test_tag, dut_hw_version, dut_sw_version, dut_model_num, dut_serial_num, test_id,
|
||||
test_input_infor, csv_outfile):
|
||||
report = lf_report.lf_report(_results_dir_name="webpage_test", _output_html="Webpage.html", _output_pdf="Webpage.pdf")
|
||||
|
||||
report.test_setup_table(value="Device under test", test_setup_data=test_setup_info)
|
||||
|
||||
report.set_obj_html("Objective",
|
||||
"The Webpage Download Test is designed to test the performance of the Access Point.The goal is to check whether the webpage loading time of all the " + str(
|
||||
num_stations) + " clients which are downloading at the same time meets the expectation when clients connected on single radio as well as dual radio")
|
||||
report.build_objective()
|
||||
report.set_obj_html("Download Time Graph",
|
||||
"The below graph provides information about the download time taken by each client to download webpage for test duration of " + str(
|
||||
duration) + " min")
|
||||
report.build_objective()
|
||||
graph = self.generate_graph(dataset=dataset, lis=lis, bands=bands)
|
||||
report.set_graph_image(graph)
|
||||
report.set_csv_filename(graph)
|
||||
report.move_csv_file()
|
||||
report.move_graph_image()
|
||||
report.build_graph()
|
||||
report.set_obj_html("Download Rate Graph",
|
||||
"The below graph provides information about the download rate in Mbps of each client to download the webpage for test duration of " + str(
|
||||
duration) + " min")
|
||||
report.build_objective()
|
||||
graph2 = self.graph_2(dataset2, lis=lis, bands=bands)
|
||||
print("graph name {}".format(graph2))
|
||||
report.set_graph_image(graph2)
|
||||
report.set_csv_filename(graph2)
|
||||
report.move_csv_file()
|
||||
report.move_graph_image()
|
||||
report.build_graph()
|
||||
report.set_obj_html("Summary Table Description",
|
||||
"This Table shows you the summary result of Webpage Download Test as PASS or FAIL criteria. If the average time taken by " + str(
|
||||
num_stations) + " clients to access the webpage is less than " + str(
|
||||
threshold_2g) + "s it's a PASS criteria for 2.4 ghz clients, If the average time taken by " + "" + str(
|
||||
num_stations) + " clients to access the webpage is less than " + str(
|
||||
threshold_5g) + "s it's a PASS criteria for 5 ghz clients and If the average time taken by " + str(
|
||||
num_stations) + " clients to access the webpage is less than " + str(
|
||||
threshold_both) + "s it's a PASS criteria for 2.4 ghz and 5ghz clients")
|
||||
|
||||
report.build_objective()
|
||||
test_setup1 = pd.DataFrame(summary_table_value)
|
||||
report.set_table_dataframe(test_setup1)
|
||||
report.build_table()
|
||||
|
||||
report.set_obj_html("Download Time Table Description",
|
||||
"This Table will provide you information of the minimum, maximum and the average time taken by clients to download a webpage in seconds")
|
||||
|
||||
report.build_objective()
|
||||
# Section commented because graphing breaks two band report generation
|
||||
# TODO: Fix graphing bug with multiple bands being recorded
|
||||
#
|
||||
# report.set_title("WEBPAGE DOWNLOAD TEST")
|
||||
# report.set_date(date)
|
||||
# report.build_banner()
|
||||
# report.set_table_title("Test Setup Information")
|
||||
# report.build_table_title()
|
||||
#
|
||||
# report.test_setup_table(value="Device under test", test_setup_data=test_setup_info)
|
||||
#
|
||||
# report.set_obj_html("Objective",
|
||||
# "The Webpage Download Test is designed to test the performance of the Access Point.The goal is to check whether the webpage loading time of all the " + str(
|
||||
# num_stations) + " clients which are downloading at the same time meets the expectation when clients connected on single radio as well as dual radio")
|
||||
# report.build_objective()
|
||||
# report.set_obj_html("Download Time Graph",
|
||||
# "The below graph provides information about the download time taken by each client to download webpage for test duration of " + str(
|
||||
# duration) + " min")
|
||||
# report.build_objective()
|
||||
# graph = self.generate_graph(dataset=dataset, lis=lis, bands=bands)
|
||||
# report.set_graph_image(graph)
|
||||
# report.set_csv_filename(graph)
|
||||
# report.move_csv_file()
|
||||
# report.move_graph_image()
|
||||
# report.build_graph()
|
||||
# report.set_obj_html("Download Rate Graph",
|
||||
# "The below graph provides information about the download rate in Mbps of each client to download the webpage for test duration of " + str(
|
||||
# duration) + " min")
|
||||
# report.build_objective()
|
||||
# graph2 = self.graph_2(dataset2, lis=lis, bands=bands)
|
||||
# print("graph name {}".format(graph2))
|
||||
# report.set_graph_image(graph2)
|
||||
# report.set_csv_filename(graph2)
|
||||
# report.move_csv_file()
|
||||
# report.move_graph_image()
|
||||
# report.build_graph()
|
||||
# report.set_obj_html("Summary Table Description",
|
||||
# "This Table shows you the summary result of Webpage Download Test as PASS or FAIL criteria. If the average time taken by " + str(
|
||||
# num_stations) + " clients to access the webpage is less than " + str(
|
||||
# threshold_2g) + "s it's a PASS criteria for 2.4 ghz clients, If the average time taken by " + "" + str(
|
||||
# num_stations) + " clients to access the webpage is less than " + str(
|
||||
# threshold_5g) + "s it's a PASS criteria for 5 ghz clients and If the average time taken by " + str(
|
||||
# num_stations) + " clients to access the webpage is less than " + str(
|
||||
# threshold_both) + "s it's a PASS criteria for 2.4 ghz and 5ghz clients")
|
||||
#
|
||||
# report.build_objective()
|
||||
# test_setup1 = pd.DataFrame(summary_table_value)
|
||||
# report.set_table_dataframe(test_setup1)
|
||||
# report.build_table()
|
||||
#
|
||||
# report.set_obj_html("Download Time Table Description",
|
||||
# "This Table will provide you information of the minimum, maximum and the average time taken by clients to download a webpage in seconds")
|
||||
#
|
||||
# report.build_objective()
|
||||
x = []
|
||||
for fcc in list(result_data.keys()):
|
||||
fcc_type = result_data[fcc]["min"]
|
||||
@@ -595,12 +584,52 @@ class HttpDownload(Realm):
|
||||
z2.append(i)
|
||||
|
||||
download_table_value = {
|
||||
"": bands,
|
||||
"Band": bands,
|
||||
"Minimum": z,
|
||||
"Maximum": z1,
|
||||
"Average": z2
|
||||
|
||||
}
|
||||
|
||||
# Get the report path to create the kpi.csv path
|
||||
kpi_path = report.get_report_path()
|
||||
print("kpi_path :{kpi_path}".format(kpi_path=kpi_path))
|
||||
|
||||
kpi_csv = lf_kpi_csv.lf_kpi_csv(
|
||||
_kpi_path=kpi_path,
|
||||
_kpi_test_rig=test_rig,
|
||||
_kpi_test_tag=test_tag,
|
||||
_kpi_dut_hw_version=dut_hw_version,
|
||||
_kpi_dut_sw_version=dut_sw_version,
|
||||
_kpi_dut_model_num=dut_model_num,
|
||||
_kpi_dut_serial_num=dut_serial_num,
|
||||
_kpi_test_id=test_id)
|
||||
kpi_csv.kpi_dict['Units'] = "Mbps"
|
||||
for band in range(len(download_table_value["Band"])):
|
||||
kpi_csv.kpi_csv_get_dict_update_time()
|
||||
kpi_csv.kpi_dict['Graph-Group'] = "Webpage Download {band}".format(
|
||||
band=download_table_value['Band'][band])
|
||||
kpi_csv.kpi_dict['short-description'] = "Webpage download {band} Minimum".format(
|
||||
band=download_table_value['Band'][band])
|
||||
kpi_csv.kpi_dict['numeric-score'] = "{min}".format(min=download_table_value['Minimum'][band])
|
||||
kpi_csv.kpi_csv_write_dict(kpi_csv.kpi_dict)
|
||||
kpi_csv.kpi_dict['short-description'] = "Webpage download {band} Maximum".format(
|
||||
band=download_table_value['Band'][band])
|
||||
kpi_csv.kpi_dict['numeric-score'] = "{max}".format(max=download_table_value['Maximum'][band])
|
||||
kpi_csv.kpi_csv_write_dict(kpi_csv.kpi_dict)
|
||||
kpi_csv.kpi_dict['short-description'] = "Webpage download {band} Average".format(
|
||||
band=download_table_value['Band'][band])
|
||||
kpi_csv.kpi_dict['numeric-score'] = "{avg}".format(avg=download_table_value['Average'][band])
|
||||
kpi_csv.kpi_csv_write_dict(kpi_csv.kpi_dict)
|
||||
|
||||
if csv_outfile is not None:
|
||||
current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
|
||||
csv_outfile = "{}_{}-test_l3_longevity.csv".format(
|
||||
csv_outfile, current_time)
|
||||
csv_outfile = report.file_add_path(csv_outfile)
|
||||
print("csv output file : {}".format(csv_outfile))
|
||||
|
||||
exit()
|
||||
|
||||
test_setup = pd.DataFrame(download_table_value)
|
||||
report.set_table_dataframe(test_setup)
|
||||
report.build_table()
|
||||
@@ -611,7 +640,8 @@ class HttpDownload(Realm):
|
||||
html_file = report.write_html()
|
||||
print("returned file {}".format(html_file))
|
||||
print(html_file)
|
||||
report.write_pdf()
|
||||
report.write_pdf_with_timestamp(_page_size='A4', _orientation='Landscape')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -629,16 +659,32 @@ def main():
|
||||
parser.add_argument('--passwd', help='WiFi passphrase/password/key')
|
||||
parser.add_argument('--target_per_ten', help='number of request per 10 minutes', default=100)
|
||||
parser.add_argument('--file_size', type=str, help='specify the size of file you want to download', default='5MB')
|
||||
parser.add_argument('--bands', nargs="+", help='specify which band testing you want to run eg 5G OR 2.4G OR 5G 2.4G', default=["5G", "2.4G", "Both"])
|
||||
parser.add_argument('--bands', nargs="+", help='specify which band testing you want to run eg 5G OR 2.4G OR Both',
|
||||
default=["5G", "2.4G", "Both"])
|
||||
parser.add_argument('--duration', type=int, help='time to run traffic')
|
||||
parser.add_argument('--threshold_5g',help="Enter the threshold value for 5G Pass/Fail criteria", default="60")
|
||||
parser.add_argument('--threshold_2g',help="Enter the threshold value for 2.4G Pass/Fail criteria",default="90")
|
||||
parser.add_argument('--threshold_both',help="Enter the threshold value for Both Pass/Fail criteria" , default="50")
|
||||
parser.add_argument('--threshold_5g', help="Enter the threshold value for 5G Pass/Fail criteria", default="60")
|
||||
parser.add_argument('--threshold_2g', help="Enter the threshold value for 2.4G Pass/Fail criteria", default="90")
|
||||
parser.add_argument('--threshold_both', help="Enter the threshold value for Both Pass/Fail criteria", default="50")
|
||||
parser.add_argument('--ap_name', help="specify the ap model ", default="TestAP")
|
||||
parser.add_argument('--ssh_port', type=int, help="specify the shh port eg 22",default=22)
|
||||
parser.add_argument('--ssh_port', type=int, help="specify the ssh port eg 22", default=22)
|
||||
parser.add_argument("--test_rig", default="", help="test rig for kpi.csv, testbed that the tests are run on")
|
||||
parser.add_argument("--test_tag", default="",
|
||||
help="test tag for kpi.csv, test specific information to differentiate the test")
|
||||
parser.add_argument("--dut_hw_version", default="",
|
||||
help="dut hw version for kpi.csv, hardware version of the device under test")
|
||||
parser.add_argument("--dut_sw_version", default="",
|
||||
help="dut sw version for kpi.csv, software version of the device under test")
|
||||
parser.add_argument("--dut_model_num", default="",
|
||||
help="dut model for kpi.csv, model number / name of the device under test")
|
||||
parser.add_argument("--dut_serial_num", default="",
|
||||
help="dut serial for kpi.csv, serial number / serial number of the device under test")
|
||||
parser.add_argument("--test_priority", default="", help="dut model for kpi.csv, test-priority is arbitrary number")
|
||||
parser.add_argument("--test_id", default="lf_webpage", help="test-id for kpi.csv, script or test name")
|
||||
parser.add_argument('--csv_outfile', help="--csv_outfile <Output file for csv data>", default="")
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
test_time = datetime.datetime.now()
|
||||
test_time = datetime.now()
|
||||
test_time = test_time.strftime("%b %d %H:%M:%S")
|
||||
print("Test started at ", test_time)
|
||||
list5G = []
|
||||
@@ -648,14 +694,14 @@ def main():
|
||||
list2G_bytes = []
|
||||
list2G_speed = []
|
||||
Both = []
|
||||
Both_bytes =[]
|
||||
Both_speed =[]
|
||||
Both_bytes = []
|
||||
Both_speed = []
|
||||
dict_keys = []
|
||||
dict_keys.extend(args.bands)
|
||||
# print(dict_keys)
|
||||
final_dict = dict.fromkeys(dict_keys)
|
||||
# print(final_dict)
|
||||
dict1_keys = ['dl_time', 'min', 'max', 'avg','bytes_rd', 'speed']
|
||||
dict1_keys = ['dl_time', 'min', 'max', 'avg', 'bytes_rd', 'speed']
|
||||
for i in final_dict:
|
||||
final_dict[i] = dict.fromkeys(dict1_keys)
|
||||
print(final_dict)
|
||||
@@ -689,21 +735,20 @@ def main():
|
||||
print("time in seconds ", duration)
|
||||
time.sleep(duration)
|
||||
http.stop()
|
||||
value = http.my_monitor()
|
||||
value2 = http.monitor_bytes()
|
||||
value3 = http.monitor_rx()
|
||||
uc_avg_val = http.my_monitor('uc-avg')
|
||||
rx_bytes_val = http.my_monitor('bytes-rd')
|
||||
rx_rate_val = http.my_monitor('rx rate')
|
||||
http.postcleanup()
|
||||
|
||||
if bands == "5G":
|
||||
print("yes")
|
||||
list5G.extend(value)
|
||||
list5G_bytes.extend(value2)
|
||||
list5G_speed.extend(value3)
|
||||
list5G.extend(uc_avg_val)
|
||||
list5G_bytes.extend(rx_bytes_val)
|
||||
list5G_speed.extend(rx_rate_val)
|
||||
print(list5G)
|
||||
print(list5G_bytes)
|
||||
print(list5G_speed)
|
||||
final_dict['5G']['dl_time'] = list5G
|
||||
|
||||
min5.append(min(list5G))
|
||||
final_dict['5G']['min'] = min5
|
||||
max5.append(max(list5G))
|
||||
@@ -714,9 +759,9 @@ def main():
|
||||
final_dict['5G']['speed'] = list5G_speed
|
||||
elif bands == "2.4G":
|
||||
print("no")
|
||||
list2G.extend(value)
|
||||
list2G_bytes.extend(value2)
|
||||
list2G_speed.extend(value3)
|
||||
list2G.extend(uc_avg_val)
|
||||
list2G_bytes.extend(rx_bytes_val)
|
||||
list2G_speed.extend(rx_rate_val)
|
||||
print(list2G)
|
||||
print(list2G_bytes)
|
||||
print(list2G_speed)
|
||||
@@ -730,15 +775,15 @@ def main():
|
||||
final_dict['2.4G']['bytes_rd'] = list2G_bytes
|
||||
final_dict['2.4G']['speed'] = list2G_speed
|
||||
elif bands == "Both":
|
||||
Both.extend(value)
|
||||
Both_bytes.extend(value2)
|
||||
Both_speed.extend(value3)
|
||||
Both.extend(uc_avg_val)
|
||||
Both_bytes.extend(rx_bytes_val)
|
||||
Both_speed.extend(rx_rate_val)
|
||||
final_dict['Both']['dl_time'] = Both
|
||||
min_both.append(min(Both))
|
||||
final_dict['Both']['min'] = min_both
|
||||
max_both.append(max(Both))
|
||||
final_dict['Both']['max'] = max_both
|
||||
avg_both.append((sum(Both) /args.num_stations))
|
||||
avg_both.append((sum(Both) / args.num_stations))
|
||||
final_dict['Both']['avg'] = avg_both
|
||||
final_dict['Both']['bytes_rd'] = Both_bytes
|
||||
final_dict['Both']['speed'] = Both_speed
|
||||
@@ -746,47 +791,52 @@ def main():
|
||||
result_data = final_dict
|
||||
print("result", result_data)
|
||||
print("Test Finished")
|
||||
test_end = datetime.datetime.now()
|
||||
test_end = datetime.now()
|
||||
test_end = test_end.strftime("%b %d %H:%M:%S")
|
||||
print("Test ended at ", test_end)
|
||||
s1 = test_time
|
||||
s2 = test_end # for example
|
||||
FMT = '%b %d %H:%M:%S'
|
||||
test_duration = datetime.datetime.strptime(s2, FMT) - datetime.datetime.strptime(s1, FMT)
|
||||
test_duration = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
|
||||
|
||||
print("total test duration ", test_duration)
|
||||
date = str(datetime.datetime.now()).split(",")[0].replace(" ", "-").split(".")[0]
|
||||
date = str(datetime.now()).split(",")[0].replace(" ", "-").split(".")[0]
|
||||
test_setup_info = {
|
||||
"DUT Name": args.ap_name,
|
||||
"SSID": args.ssid,
|
||||
"Test Duration": test_duration,
|
||||
"DUT Name": args.ap_name,
|
||||
"SSID": args.ssid,
|
||||
"Test Duration": test_duration,
|
||||
}
|
||||
test_input_infor={
|
||||
"LANforge ip":args.mgr,
|
||||
"File Size" : args.file_size,
|
||||
"Bands" : args.bands,
|
||||
test_input_infor = {
|
||||
"LANforge ip": args.mgr,
|
||||
"File Size": args.file_size,
|
||||
"Bands": args.bands,
|
||||
"Upstream": args.upstream_port,
|
||||
"Stations": args.num_stations,
|
||||
"SSID" :args.ssid,
|
||||
"SSID": args.ssid,
|
||||
"Security": args.security,
|
||||
"Duration" : args.duration,
|
||||
"Duration": args.duration,
|
||||
"Contact": "support@candelatech.com"
|
||||
}
|
||||
http1 = HttpDownload(lfclient_host=args.mgr, lfclient_port=args.mgr_port,
|
||||
upstream=args.upstream_port, num_sta=args.num_stations,
|
||||
security=args.security,
|
||||
ssid=args.ssid, password=args.passwd,
|
||||
target_per_ten=args.target_per_ten,
|
||||
file_size=args.file_size, bands=args.bands,
|
||||
twog_radio=args.twog_radio,
|
||||
fiveg_radio=args.fiveg_radio)
|
||||
upstream=args.upstream_port, num_sta=args.num_stations,
|
||||
security=args.security,
|
||||
ssid=args.ssid, password=args.passwd,
|
||||
target_per_ten=args.target_per_ten,
|
||||
file_size=args.file_size, bands=args.bands,
|
||||
twog_radio=args.twog_radio,
|
||||
fiveg_radio=args.fiveg_radio)
|
||||
dataset = http1.download_time_in_sec(result_data=result_data)
|
||||
lis = []
|
||||
for i in range(1, args.num_stations + 1):
|
||||
lis.append(i)
|
||||
|
||||
dataset2= http1.speed_in_Mbps(result_data=result_data)
|
||||
data = http1.summary_calculation(result_data=result_data, bands=args.bands, threshold_5g=args.threshold_5g , threshold_2g= args.threshold_2g, threshold_both=args.threshold_both)
|
||||
dataset2 = http1.speed_in_Mbps(result_data=result_data)
|
||||
data = http1.summary_calculation(
|
||||
result_data=result_data,
|
||||
bands=args.bands,
|
||||
threshold_5g=args.threshold_5g,
|
||||
threshold_2g=args.threshold_2g,
|
||||
threshold_both=args.threshold_both)
|
||||
|
||||
summary_table_value = {
|
||||
"": args.bands,
|
||||
@@ -796,7 +846,13 @@ def main():
|
||||
duration=args.duration, test_setup_info=test_setup_info, dataset=dataset, lis=lis,
|
||||
bands=args.bands, threshold_2g=args.threshold_2g, threshold_5g=args.threshold_5g,
|
||||
threshold_both=args.threshold_both, dataset2=dataset2,
|
||||
summary_table_value=summary_table_value, result_data=result_data, test_input_infor=test_input_infor)
|
||||
summary_table_value=summary_table_value, result_data=result_data,
|
||||
test_rig=args.test_rig, test_tag=args.test_tag, dut_hw_version=args.dut_hw_version,
|
||||
dut_sw_version=args.dut_sw_version, dut_model_num=args.dut_model_num,
|
||||
dut_serial_num=args.dut_serial_num, test_id=args.test_id,
|
||||
test_input_infor=test_input_infor, csv_outfile=args.csv_outfile)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -347,11 +347,11 @@ class WiFiCapacityTest(cv_test):
|
||||
security="open",
|
||||
paswd="[BLANK]",
|
||||
ssid="",
|
||||
enables=[],
|
||||
disables=[],
|
||||
raw_lines=[],
|
||||
enables=None,
|
||||
disables=None,
|
||||
raw_lines=None,
|
||||
raw_lines_file="",
|
||||
sets=[],
|
||||
sets=None,
|
||||
influx_host="localhost",
|
||||
influx_port=8086,
|
||||
report_dir="",
|
||||
@@ -362,6 +362,14 @@ class WiFiCapacityTest(cv_test):
|
||||
):
|
||||
super().__init__(lfclient_host=lfclient_host, lfclient_port=lf_port)
|
||||
|
||||
if enables is None:
|
||||
enables = []
|
||||
if disables is None:
|
||||
disables = []
|
||||
if raw_lines is None:
|
||||
raw_lines = []
|
||||
if sets is None:
|
||||
sets = []
|
||||
self.lfclient_host = lfclient_host
|
||||
self.lf_port = lf_port
|
||||
self.lf_user = lf_user
|
||||
@@ -534,7 +542,7 @@ def main():
|
||||
parser.add_argument("--report_dir", default="")
|
||||
parser.add_argument("--scenario", default="")
|
||||
parser.add_argument("--graph_groups", help="File to save graph groups to", default=None)
|
||||
parser.add_argument("--local_lf_report_dir", help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from",default="")
|
||||
parser.add_argument("--local_lf_report_dir", help="--local_lf_report_dir <where to pull reports to> default '' put where dataplane script run from", default="")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -34,7 +33,7 @@ class MeasureTimeUp(Realm):
|
||||
_port=None,
|
||||
_num_sta=None,
|
||||
_number_template="00000",
|
||||
_radio=["wiphy0", "wiphy1"],
|
||||
_radio=None,
|
||||
_proxy_str=None,
|
||||
_debug_on=False,
|
||||
_up=True,
|
||||
@@ -49,6 +48,8 @@ class MeasureTimeUp(Realm):
|
||||
_clean_dut="no"):
|
||||
super().__init__(_host,
|
||||
_port)
|
||||
if _radio is None:
|
||||
_radio = ["wiphy0", "wiphy1"]
|
||||
self.host = _host
|
||||
self.port = _port
|
||||
self.ssid = _ssid
|
||||
@@ -103,7 +104,7 @@ class MeasureTimeUp(Realm):
|
||||
self._pass("PASS: Station build finished")
|
||||
|
||||
def scenario(self):
|
||||
if self.load is not None:
|
||||
if self.load:
|
||||
data = {
|
||||
"name": self.load,
|
||||
"action": self.action,
|
||||
@@ -117,13 +118,13 @@ class MeasureTimeUp(Realm):
|
||||
print("Loading database %s" % self.load)
|
||||
self.json_post("/cli-json/load", data)
|
||||
|
||||
elif self.start is not None:
|
||||
elif self.start:
|
||||
print("Starting test group %s..." % self.start)
|
||||
self.json_post("/cli-json/start_group", {"name": self.start})
|
||||
elif self.stop is not None:
|
||||
elif self.stop:
|
||||
print("Stopping test group %s..." % self.stop)
|
||||
self.json_post("/cli-json/stop_group", {"name": self.stop})
|
||||
elif self.quiesce is not None:
|
||||
elif self.quiesce:
|
||||
print("Quiescing test group %s..." % self.quiesce)
|
||||
self.json_post("/cli-json/quiesce_group", {"name": self.quiesce})
|
||||
|
||||
@@ -151,35 +152,37 @@ Command example:
|
||||
''')
|
||||
required = parser.add_argument_group('required arguments')
|
||||
required.add_argument('--report_file', help='where you want to store results', required=True)
|
||||
parser.add_argument('--database', help='Which database to load', default='FACTORY_DFLT')
|
||||
parser.add_argument('--radio2', help='second radio to create stations on', default='wiphy7')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.report_file.split('.')[-1] not in ['pkl', 'csv', 'xlsx']:
|
||||
raise NameError('Please make sure your file name ends with either pkl, csv, or xlsx')
|
||||
|
||||
dictionary = dict()
|
||||
for num_sta in list(filter(lambda x: (x % 2 == 0), [*range(0, 200)])):
|
||||
for num_sta in list(filter(lambda x: (x % 2 == 0), [*range(0, args.num_stations)])):
|
||||
print(num_sta)
|
||||
try:
|
||||
create_station = MeasureTimeUp(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_num_sta=num_sta,
|
||||
_radio=["wiphy0", "wiphy1"],
|
||||
_proxy_str=args.proxy,
|
||||
_debug_on=args.debug,
|
||||
_load='FACTORY_DFLT')
|
||||
create_station.scenario()
|
||||
time.sleep(5.0 + num_sta / 10)
|
||||
start = datetime.datetime.now()
|
||||
create_station.build()
|
||||
built = datetime.datetime.now()
|
||||
create_station.station_up()
|
||||
stationsup = datetime.datetime.now()
|
||||
dictionary[num_sta] = [start, built, stationsup]
|
||||
create_station.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=station_list)
|
||||
time.sleep(5.0 + num_sta / 20)
|
||||
except:
|
||||
pass
|
||||
create_station = MeasureTimeUp(_host=args.mgr,
|
||||
_port=args.mgr_port,
|
||||
_ssid=args.ssid,
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_num_sta=num_sta,
|
||||
_radio=[args.radio, args.radio2],
|
||||
_proxy_str=args.proxy,
|
||||
_debug_on=args.debug,
|
||||
_load=args.database)
|
||||
create_station.scenario()
|
||||
time.sleep(5.0 + num_sta / 10)
|
||||
start = datetime.datetime.now()
|
||||
create_station.build()
|
||||
built = datetime.datetime.now()
|
||||
create_station.station_up()
|
||||
stationsup = datetime.datetime.now()
|
||||
dictionary[num_sta] = [start, built, stationsup]
|
||||
create_station.wait_until_ports_disappear()
|
||||
time.sleep(5.0 + num_sta / 20)
|
||||
df = pd.DataFrame.from_dict(dictionary).transpose()
|
||||
df.columns = ['Start', 'Built', 'Stations Up']
|
||||
df['built duration'] = df['Built'] - df['Start']
|
||||
@@ -187,7 +190,12 @@ Command example:
|
||||
df['duration'] = df['Stations Up'] - df['Start']
|
||||
for variable in ['built duration', 'duration']:
|
||||
df[variable] = [x.total_seconds() for x in df[variable]]
|
||||
df.to_pickle(args.report_file)
|
||||
if 'pkl' in args.report_file:
|
||||
df.to_pickle(args.report_file)
|
||||
if 'csv' in args.report_file:
|
||||
df.to_csv(args.report_file)
|
||||
if 'xlsx' in args.report_file:
|
||||
df.to_excel(args.report_file)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
NAME: port_probe.py
|
||||
|
||||
PURPOSE:
|
||||
Probes a port for information. If a station is used, an ssid, radio, and security type must be specified
|
||||
|
||||
Use './port_probe.py --help' to see command line usage and options
|
||||
Copyright 2021 Candela Technologies Inc
|
||||
License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||
|
||||
if 'py-dashboard' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
|
||||
|
||||
import argparse
|
||||
from LANforge import LFUtils
|
||||
from realm import Realm
|
||||
import datetime
|
||||
import time
|
||||
import pprint
|
||||
|
||||
|
||||
class PortProbe(Realm):
|
||||
def __init__(self,
|
||||
ssid=None,
|
||||
security=None,
|
||||
password=None,
|
||||
port_name=None,
|
||||
upstream=None,
|
||||
radio=None,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
mode=0,
|
||||
number_template="00000",
|
||||
use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(lfclient_host=host,
|
||||
lfclient_port=port),
|
||||
self.upstream = upstream
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.ssid = ssid
|
||||
self.port_name = port_name
|
||||
self.security = security
|
||||
self.password = password
|
||||
self.radio = radio
|
||||
self.mode = mode
|
||||
self.debug = _debug_on
|
||||
if 'sta' in self.port_name:
|
||||
self.number_template = number_template
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_profile.ssid = self.ssid
|
||||
self.station_profile.ssid_pass = self.password
|
||||
self.station_profile.security = self.security
|
||||
self.station_profile.number_template_ = self.number_template
|
||||
self.station_profile.debug = self.debug
|
||||
|
||||
self.station_profile.use_ht160 = use_ht160
|
||||
if self.station_profile.use_ht160:
|
||||
self.station_profile.mode = 9
|
||||
self.station_profile.mode = mode
|
||||
|
||||
def start(self):
|
||||
if 'sta' in self.port_name:
|
||||
self.station_profile.admin_up()
|
||||
print("Probing %s" % self.port_name)
|
||||
port_info = self.name_to_eid(self.port_name)
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": self.port_name,
|
||||
"key": "probe_port.quiet.%d.%d.%s" % (port_info[0], port_info[1], port_info[2])
|
||||
}
|
||||
self.json_post("/cli-json/probe_port", data)
|
||||
time.sleep(10)
|
||||
probe_results = self.json_get("probe/1/1/%s" % self.port_name)
|
||||
|
||||
print(probe_results)
|
||||
|
||||
def cleanup(self):
|
||||
if 'sta' in self.port_name:
|
||||
self.station_profile.cleanup()
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
|
||||
def build(self):
|
||||
if 'sta' in self.port_name:
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=[self.port_name], num_stations=1, debug=self.debug)
|
||||
LFUtils.wait_until_ports_appear(self.port_name)
|
||||
self._pass("PASS: Station build finished")
|
||||
|
||||
|
||||
def main():
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog='port_probe_test.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Used to probe ports for information
|
||||
''',
|
||||
description='''\
|
||||
Probes a port for information. If a station is used, an ssid, radio, and security type must be specified
|
||||
|
||||
Example:
|
||||
./port_probe.py --ssid test_name --security open --radio wiphy0
|
||||
''')
|
||||
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--port_name', help='Name of station to be used', default="sta0000")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
port_probe = PortProbe(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
number_template="0000",
|
||||
port_name=args.port_name,
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
security=args.security,
|
||||
use_ht160=False,
|
||||
mode=args.mode,
|
||||
_debug_on=args.debug)
|
||||
|
||||
port_probe.build()
|
||||
# exit()
|
||||
if not port_probe.passes():
|
||||
print(port_probe.get_fail_message())
|
||||
port_probe.exit_fail()
|
||||
|
||||
port_probe.start()
|
||||
port_probe.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -72,7 +72,7 @@ def main():
|
||||
tags=tags)
|
||||
|
||||
else:
|
||||
from influx import RecordInflux
|
||||
from influx_utils import RecordInflux
|
||||
grapher = RecordInflux(_influx_host=args.mgr,
|
||||
_influx_port=args.mgr_port,
|
||||
_influx_db=args.influx_db,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
##########################
|
||||
Help()
|
||||
{
|
||||
echo "This bash script aims to automate the test process of all Candela Technologies's test_* scripts in the lanforge-scripts directory. The script can be run 2 ways and may include (via user input) the \"start_num\" and \"stop_num\" variables to select which tests should be run."
|
||||
echo "This bash script aims to automate the test process of all Candela Technologies test_* scripts in the lanforge-scripts directory to detect software regressions. The script can be run 2 ways and may include (via user input) the \"start_num\" and \"stop_num\" variables to select which tests should be run."
|
||||
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:"
|
||||
@@ -14,10 +14,14 @@ Help()
|
||||
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 "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 "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:S:p:w:m:A:r:F:B:U:D:H:M:C:" option; do
|
||||
case "${option}" in
|
||||
h) # display Help
|
||||
Help
|
||||
@@ -26,6 +30,9 @@ while getopts ":h:s:p:w:m:A:r:F:B:U:" option; do
|
||||
s)
|
||||
SSID_USED=${OPTARG}
|
||||
;;
|
||||
S)
|
||||
SHORT="yes"
|
||||
;;
|
||||
p)
|
||||
PASSWD_USED=${OPTARG}
|
||||
;;
|
||||
@@ -48,7 +55,20 @@ while getopts ":h:s:p:w:m:A:r:F:B:U:" option; do
|
||||
BSSID=${OPTARG}
|
||||
;;
|
||||
U)
|
||||
UPSTREAM=$OPTARG
|
||||
UPSTREAM=${OPTARG}
|
||||
;;
|
||||
D)
|
||||
DUT5=${OPTARG}
|
||||
DUT2=${OPTARG}
|
||||
;;
|
||||
H)
|
||||
./lf_help_check.bash
|
||||
;;
|
||||
M)
|
||||
RADIO2=${OPTARG}
|
||||
;;
|
||||
C)
|
||||
RESOURCE=${OPTARG}
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -56,6 +76,36 @@ while getopts ":h:s:p:w:m:A:r:F:B:U:" option; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ${#MGR} -eq 0 ]]; then # Allow the user to change the radio they test against
|
||||
MGR="localhost"
|
||||
fi
|
||||
|
||||
PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version)')
|
||||
|
||||
BuildVersion=$(wget $MGR:8080 -q -O - | jq '.VersionInfo.BuildVersion')
|
||||
BuildDate=$(wget $MGR:8080 -q -O - | jq '.VersionInfo.BuildDate')
|
||||
OS_Version=$(cat /etc/os-release | grep 'VERSION=')
|
||||
HOSTNAME=$(cat /etc/hostname)
|
||||
IP_ADDRESS=$(ip a sho eth0 | grep 'inet ' | cut -d "/" -f1 | cut -d "t" -f2)
|
||||
PYTHON_ENVIRONMENT=$(which python3)
|
||||
|
||||
#SCENARIO_CHECK="$(python3 -c "import requests; print(requests.get('http://${MGR}:8080/events/').status_code)")"
|
||||
#if [[ ${SCENARIO_CHECK} -eq 200 ]]; then
|
||||
# :
|
||||
#else
|
||||
# echo "${SCENARIO_CHECK}"
|
||||
# echo "Your LANforge Manager is out of date. Regression test requires LANforge version 5.4.4 or higher in order to run"
|
||||
# echo "Please upgrade your LANforge using instructions found at https://www.candelatech.com/downloads.php#releases"
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
if [ -d "/home/lanforge/lanforge_env" ]
|
||||
then
|
||||
pip3 install --upgrade lanforge-scripts
|
||||
else
|
||||
pip3 install --user -r ../requirements.txt --upgrade
|
||||
fi
|
||||
|
||||
if [[ ${#SSID_USED} -eq 0 ]]; then #Network credentials
|
||||
SSID_USED="jedway-wpa2-x2048-5-3"
|
||||
PASSWD_USED="jedway-wpa2-x2048-5-3"
|
||||
@@ -63,17 +113,24 @@ if [[ ${#SSID_USED} -eq 0 ]]; then #Network credentials
|
||||
fi
|
||||
|
||||
if [[ ${#RADIO_USED} -eq 0 ]]; then # Allow the user to change the radio they test against
|
||||
RADIO_USED="wiphy1"
|
||||
RADIO_USED="1.1.wiphy1"
|
||||
fi
|
||||
|
||||
if [[ ${#RADIO2} -eq 0 ]]; then # Allow the user to change the radio they test against
|
||||
RADIO2="1.1.wiphy0"
|
||||
fi
|
||||
if [[ ${#UPSTREAM} -eq 0 ]]; then
|
||||
UPSTREAM="eth1"
|
||||
UPSTREAM="1.1.eth1"
|
||||
fi
|
||||
|
||||
if [[ ${#BSSID} -eq 0 ]]; then
|
||||
BSSID="04:f0:21:2c:41:84"
|
||||
fi
|
||||
|
||||
if [[ $RESOURCE -eq 0 ]]; then
|
||||
RESOURCE="1.1"
|
||||
fi
|
||||
|
||||
FILE="/tmp/gui-update.lock"
|
||||
if test -f "$FILE"; then
|
||||
echo "Finish updating your GUI"
|
||||
@@ -98,6 +155,10 @@ TEST_HTTP_IP=${TEST_HTTP_IP:-10.40.0.1}
|
||||
MGRLEN=${#MGR}
|
||||
COL_NAMES="name,tx_bytes,rx_bytes,dropped"
|
||||
|
||||
if [[ ${#DUT2} -eq 0 ]]; then
|
||||
DUT5="linksys-8450 j-wpa2-153 c4:41:1e:f5:3f:25 (1)"
|
||||
DUT2="linksys-8450 j-wpa2-153 c4:41:1e:f5:3f:25 (1)"
|
||||
fi
|
||||
#CURR_TEST_NUM=0
|
||||
CURR_TEST_NAME="BLANK"
|
||||
|
||||
@@ -114,7 +175,7 @@ fi
|
||||
TEST_DIR="${REPORT_DATA}/${NOW}"
|
||||
|
||||
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 --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" --lfmgr "$MGR"
|
||||
}
|
||||
function testgroup_list_groups() {
|
||||
./scenario.py --load test_l3_scenario_throughput
|
||||
@@ -129,202 +190,213 @@ function testgroup_delete_group() {
|
||||
./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"
|
||||
}
|
||||
if [[ $MGRLEN -gt 0 ]]; then
|
||||
function create_bridge_and_station() {
|
||||
./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR
|
||||
./create_bridge.py --radio $RADIO_USED --upstream_port $UPSTREAM --target_device $RESOURCE.sta0000 --debug --mgr $MGR
|
||||
}
|
||||
function create_station_and_dataplane() {
|
||||
./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR
|
||||
./lf_dataplane_test.py --mgr $MGR --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name dataplane-instance --config_name test_con --upstream $UPSTREAM \
|
||||
--dut linksys-8450 --duration 15s --station $RESOURCE.sta0001 \
|
||||
--download_speed 85% --upload_speed 0 \
|
||||
--test_rig Testbed-01 --pull_report \
|
||||
#--influx_host 192.168.100.153 --influx_port 8086 --influx_org Candela \
|
||||
#--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
#--influx_bucket ben \
|
||||
#--influx_tag testbed Ferndale-01
|
||||
}
|
||||
function create_dut_and_chamberview() {
|
||||
./create_chamberview.py -m $MGR -cs 'regression_test' --delete_scenario \
|
||||
--line "Resource=$RESOURCE Profile=STA-AC Amount=1 Uses-1=$RADIO_USED Freq=-1 DUT=regression_dut DUT_RADIO=$RADIO_USED Traffic=http" \
|
||||
--line "Resource=$RESOURCE Profile=upstream Amount=1 Uses-1=$UPSTREAM Uses-2=AUTO Freq=-1 DUT=regression_dut 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"
|
||||
}
|
||||
|
||||
function create_station_and_sensitivity {
|
||||
./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR
|
||||
./lf_rx_sensitivity_test.py --mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name rx-sensitivity-instance --config_name test_con --upstream $UPSTREAM \
|
||||
--dut linksys-8450 --duration 15s --station $RESOURCE.sta0001 \
|
||||
--download_speed 85% --upload_speed 0 \
|
||||
--raw_line 'txo_preamble\: VHT' \
|
||||
--raw_line 'txo_mcs\: 4 OFDM, HT, VHT;5 OFDM, HT, VHT;6 OFDM, HT, VHT;7 OFDM, HT, VHT' \
|
||||
--raw_line 'spatial_streams\: 3' \
|
||||
--raw_line 'bandw_options\: 80' \
|
||||
--raw_line 'txo_sgi\: ON' \
|
||||
--raw_line 'txo_retries\: No Retry' \
|
||||
--raw_line 'txo_txpower\: 17' \
|
||||
--test_rig Testbed-01 --pull_report \
|
||||
#--influx_host 192.168.100.153 --influx_port 8086 --influx_org Candela \
|
||||
#--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
#--influx_bucket ben \
|
||||
#--influx_tag testbed Ferndale-01
|
||||
}
|
||||
if [[ ${#SHORT} -gt 0 ]]; then
|
||||
testCommands=(
|
||||
#"./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_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_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_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_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
"./lf_ap_auto_test.py \
|
||||
--mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name ap-auto-instance --config_name test_con --upstream $UPSTREAM \
|
||||
--dut5_0 '$DUT5' \
|
||||
--dut2_0 '$DUT2' \
|
||||
--radio2 $RADIO_USED \
|
||||
--radio2 $RADIO2 \
|
||||
--radio2 $RADIO2 \
|
||||
--set 'Basic Client Connectivity' 1 \
|
||||
--set 'Multi Band Performance' 1 \
|
||||
--set 'Skip 2.4Ghz Tests' 1 \
|
||||
--set 'Skip 5Ghz Tests' 1 \
|
||||
--set 'Throughput vs Pkt Size' 0 \
|
||||
--set 'Capacity' 0 \
|
||||
--set 'Stability' 0 \
|
||||
--set 'Band-Steering' 0 \
|
||||
--set 'Multi-Station Throughput vs Pkt Size' 0 \
|
||||
--set 'Long-Term' 0 \
|
||||
--pull_report \
|
||||
--local_lf_report_dir /home/matthew/html-reports/"
|
||||
|
||||
|
||||
)
|
||||
else
|
||||
testCommands=(
|
||||
"./create_bond.py --network_dev_list $RESOURCE.eth0,$UPSTREAM --debug --mgr $MGR"
|
||||
create_bridge_and_station
|
||||
create_dut_and_chamberview
|
||||
"./create_l3.py --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug --mgr $MGR --endp_a wiphy0 --endp_b wiphy1"
|
||||
"./create_l3_stations.py --mgr $MGR --radio $RADIO_USED --ssid $SSID_USED --password $PASSWD_USED --security $SECURITY --debug"
|
||||
"./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 $UPSTREAM --debug --mgr $MGR"
|
||||
"./create_qvlan.py --first_qvlan_ip 192.168.1.50 --mgr $MGR --qvlan_parent $UPSTREAM"
|
||||
"./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
"./create_vap.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
"./create_vr.py --vr_name 2.vr0 --ports 2.br0,2.vap2 --services 1.br0=dhcp,nat --services 1.vr0=radvd"
|
||||
#./create_wanlink
|
||||
#"./create_vr.py --mgr $MGR --vr_name 2.vr0 --ports 2.br0,2.vap2 --services 1.br0=dhcp,nat --services 1.vr0=radvd --debug"
|
||||
#./csv_convert
|
||||
#./csv_processor
|
||||
#./csv_to_grafana
|
||||
#./csv_to_influx
|
||||
"./cv_manager.py --mgr $MGR --scenario FACTORY_DFLT"
|
||||
#"./cv_manager.py --mgr $MGR --scenario FACTORY_DFLT"
|
||||
#"./cv_to_grafana --mgr $MGR "
|
||||
#"./docstrings.py --mgr $MGR"
|
||||
#"./event_breaker --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"
|
||||
#"./scripts_deprecated/event_break_flood.py --mgr $MGR"
|
||||
"./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED \
|
||||
--passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug --mgr $MGR"
|
||||
#./ftp_html.py
|
||||
#./ghost_profile
|
||||
#./grafana_profile
|
||||
#./html_template
|
||||
#./influx
|
||||
#./layer3_test.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY
|
||||
#./layer4_test --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY
|
||||
"./lf_ap_auto_test.py --mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name ap-auto-instance --config_name test_con --upstream 1.1.eth2 \
|
||||
--dut5_0 \"linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)\" \
|
||||
--dut2_0 \"linksys-8450 Default-SSID-2g c4:41:1e:f5:3f:24 (1)\" \
|
||||
--max_stations_2 100 --max_stations_5 100 --max_stations_dual 200 \
|
||||
--radio2 1.1.wiphy0 --radio2 1.1.wiphy1 \
|
||||
--set \"Basic Client Connectivity\" 1 --set \"Multi Band Performance\" 1 \
|
||||
--set \"Skip 2.4Ghz Tests\" 1 --set \"Skip 5Ghz Tests\" 1 \
|
||||
--set \"Throughput vs Pkt Size\" 0 --set 'Capacity' 0 --set 'Stability' 0 --set 'Band-Steering' 0 \
|
||||
--set \"Multi-Station Throughput vs Pkt Size\" 0 --set \"Long-Term\" 0 \
|
||||
--pull_report \
|
||||
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
--influx_bucket ben \
|
||||
--influx_tag testbed Ferndale-01"
|
||||
#./lf_atten_mod_test
|
||||
"./lf_ap_auto_test.py \
|
||||
--mgr $MGR --port 8080 --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name ap-auto-instance --config_name test_con --upstream $UPSTREAM \
|
||||
--dut5_0 '$DUT5' \
|
||||
--dut2_0 '$DUT2' \
|
||||
--max_stations_2 64 \
|
||||
--max_stations_5 64 \
|
||||
--max_stations_dual 64 \
|
||||
--radio2 $RADIO_USED \
|
||||
--radio2 $RADIO2 \
|
||||
--set 'Basic Client Connectivity' 1 \
|
||||
--set 'Multi Band Performance' 1 \
|
||||
--set 'Skip 2.4Ghz Tests' 1 \
|
||||
--set 'Skip 5Ghz Tests' 1 \
|
||||
--set 'Throughput vs Pkt Size' 0 \
|
||||
--set 'Capacity' 0 \
|
||||
--set 'Stability' 0 \
|
||||
--set 'Band-Steering' 0 \
|
||||
--set 'Multi-Station Throughput vs Pkt Size' 0 \
|
||||
--set 'Long-Term' 0 \
|
||||
--pull_report"
|
||||
#"./lf_atten_mod_test.py --host $MGR --debug"
|
||||
#./lf_csv
|
||||
#./lf_dataplane_config
|
||||
"./lf_dataplane_test.py --mgr $MGR --lf_user lanforge --lf_password lanforge \
|
||||
--instance_name dataplane-instance --config_name test_con --upstream 1.1.$UPSTREAM \
|
||||
--dut linksys-8450 --duration 15s --station 1.1.sta01500 \
|
||||
--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 \
|
||||
--influx_host c7-graphana --influx_port 8086 --influx_org Candela \
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
--influx_bucket ben \
|
||||
--influx_tag testbed Ferndale-01"
|
||||
#./lf_dfs_test
|
||||
#./lf_dut_sta_vap_test
|
||||
#"./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_"
|
||||
"./lf_ftp_test.py --mgr $MGR --ssid $SSID --passwd $PASSWD_USED --security $SECURITY --bands 5G --direction Download \
|
||||
--file_size 2MB --num_stations 2"
|
||||
create_station_and_dataplane
|
||||
#"./lf_dut_sta_vap_test.py --manager $MGR --radio $RADIO_USED \
|
||||
# --num_sta 1 --sta_id 1 --ssid $SSID_USED --security $SECURITY --upstream $UPSTREAM \
|
||||
# --protocol lf_udp --min_mbps 1000 --max_mbps 10000 --duration 1"
|
||||
"./lf_graph.py --mgr $MGR"
|
||||
#"./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID'"
|
||||
#./lf_multipsk
|
||||
#./lf_report
|
||||
#./lf_report_test
|
||||
#./lf_rvr_test
|
||||
#./lf_rx_sensitivity_test.py
|
||||
#./lf_sniff_radio
|
||||
#./lf_snp_test
|
||||
"./lf_tr398_test.py --mgr $MGR"
|
||||
"./lf_mesh_test.py --mgr $MGR --upstream $UPSTREAM --raw_line 'selected_dut2 RootAP wactest $BSSID'"
|
||||
"./lf_multipsk.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --debug"
|
||||
"./lf_report.py"
|
||||
"./lf_report_test.py"
|
||||
# "./lf_rvr_test.py"
|
||||
create_station_and_sensitivity
|
||||
"./lf_sniff_radio.py \
|
||||
--mgr $MGR \
|
||||
--mgr_port 8080 \
|
||||
--outfile /home/lanforge/test_sniff.pcap \
|
||||
--duration 20 \
|
||||
--channel 52 \
|
||||
--radio_mode AUTO"
|
||||
"./lf_snp_test.py --help"
|
||||
"./lf_tr398_test.py --mgr $MGR --upstream $UPSTREAM"
|
||||
#./lf_webpage
|
||||
"./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 \
|
||||
--protocol UDP-IPv4 --duration 6000 --pull_report \
|
||||
--test_rig Testbed-01"
|
||||
#--influx_host c7-graphana --influx_port 8086 --influx_org Candela \
|
||||
#--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
#--influx_bucket ben \
|
||||
#measure_station_time_up.py
|
||||
#modify_station.py
|
||||
#modify_vap.py
|
||||
--instance_name this_inst --config_name test_con --upstream $UPSTREAM --batch_size 1,5,25,50,100 --loop_iter 1 \
|
||||
--protocol UDP-IPv4 --duration 6000 --pull_report --ssid $SSID_USED --paswd $PASSWD_USED --security $SECURITY\
|
||||
--test_rig Testbed-01 --create_stations --stations $RESOURCE.sta0000,$RESOURCE.sta0001"
|
||||
"./measure_station_time_up.py --radio $RADIO_USED --num_stations 3 --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED \
|
||||
--debug --report_file measure_station_time_up.pkl --radio2 wiphy1"
|
||||
"./create_station.py --mgr $MGR --radio $RADIO_USED --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED && ./modify_station.py \
|
||||
--mgr $MGR \
|
||||
--radio $RADIO_USED \
|
||||
--station $RESOURCE.sta0000 \
|
||||
--security $SECURITY \
|
||||
--ssid $SSID_USED \
|
||||
--passwd $PASSWD_USED \
|
||||
--enable_flag osen_enable \
|
||||
--disable_flag ht160_enable \
|
||||
--debug"
|
||||
#recordinflux.py
|
||||
#run_cv_scenario.py
|
||||
#rvr_scenario.py
|
||||
"./rvr_scenario.py --lfmgr $MGR --lanforge_db 'handsets' --cv_test Dataplane --test_profile http --cv_scenario ct-us-001"
|
||||
#scenario.py
|
||||
#sta_connect2.py
|
||||
#sta_connect_bssid_mac.py
|
||||
#sta_connect_example.py
|
||||
#sta_connect_multi_example.py
|
||||
#sta_connect.py
|
||||
#sta_scan_test.py
|
||||
#./sta_connect_bssid_mac.py
|
||||
"./sta_connect_example.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --upstream_port $UPSTREAM --test_duration 15s"
|
||||
"./sta_connect.py --mgr $MGR --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --upstream_port $UPSTREAM --test_duration 15s"
|
||||
"./sta_scan_test.py --ssid $SSID_USED --security $SECURITY --passwd $PASSWD_USED --radio $RADIO_USED"
|
||||
#station_layer3.py
|
||||
#stations_connected.py
|
||||
#test_1k_clients_jedtest.py
|
||||
#"./test_1k_clients_jedtest.py
|
||||
# --mgr $MGR
|
||||
# --mgr_port 8080
|
||||
# --sta_per_radio 300
|
||||
# --test_duration 3m
|
||||
# --a_min 1000
|
||||
# --b_min 1000
|
||||
# --a_max 0
|
||||
# --b_max 0
|
||||
# --debug"
|
||||
#test_client_admission.py
|
||||
"./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 --test_duration 30s --mgr $MGR" # Better tested on Kelly, where VRF is turned off
|
||||
"./test_fileio.py --macvlan_parent $UPSTREAM --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --test_duration 30s --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 $TEST_HTTP_IP --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"
|
||||
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfcurl --dest $TEST_HTTP_IP --file_output ${HOMEPATH}/Documents/lfcurl_output.txt --debug --mgr $MGR"
|
||||
"./testgroup.py --group_name group1 --add_group --list_groups --debug --mgr $MGR"
|
||||
#testgroup_list_groups
|
||||
#testgroup_list_connections
|
||||
#testgroup_delete_group
|
||||
#"./testgroup2.py --num_stations 4 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --group_name group0 --add_group --mgr $MGR"
|
||||
"./testgroup2.py --num_stations 4 --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --radio $RADIO_USED --group_name group0 --add_group --mgr $MGR"
|
||||
"./test_ip_connection.py --radio $RADIO_USED --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
#"./test_ip_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 --traffic_type lf_udp"
|
||||
#"./test_ip_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 --traffic_type lf_udp"
|
||||
"./test_ip_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 --traffic_type lf_udp"
|
||||
"./test_ip_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 --traffic_type lf_udp"
|
||||
"./test_ip_connection.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR --ipv6"
|
||||
#"./test_ip_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --debug --mgr $MGR --ipv6 --traffic_type lf_udp"
|
||||
#./test_ipv4_ps
|
||||
#./test_ipv4_ttls
|
||||
"./test_l3_longevity.py --mgr $MGR --endp_type 'lf_udp lf_tcp' --upstream_port 1.1.$UPSTREAM \
|
||||
--radio \"radio==1.1.wiphy0 stations==10 ssid==ASUS_70 ssid_pw==[BLANK] security==open\" \
|
||||
--radio \"radio==1.1.wiphy1 stations==1 ssid==ASUS_70 ssid_pw==[BLANK] security==open\" \
|
||||
--test_duration 5s --influx_host c7-graphana --influx_port 8086 --influx_org Candela \
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
--influx_bucket ben --rates_are_totals --side_a_min_bps=20000 --side_b_min_bps=300000000 \
|
||||
--influx_tag testbed regression_test --influx_tag DUT ROG -o longevity.csv"
|
||||
"./test_ip_variable_time.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --test_duration 15s --debug --mgr $MGR --ipv6 --traffic_type lf_udp"
|
||||
"./test_ipv4_ps.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR --radio2 $RADIO2"
|
||||
"./test_ipv4_ttls.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
"./test_l3_longevity.py --mgr $MGR --endp_type 'lf_tcp' --upstream_port $UPSTREAM --radio \
|
||||
'radio==$RADIO_USED stations==10 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY' --radio \
|
||||
'radio==$RADIO2 stations==1 ssid==$SSID_USED ssid_pw==$PASSWD_USED security==$SECURITY' --test_duration 5s --rates_are_totals --side_a_min_bps=20000 --side_b_min_bps=300000000 -o longevity.csv"
|
||||
"./test_l3_powersave_traffic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR"
|
||||
"./test_l3_scenario_throughput.py -t 15s -sc test_l3_scenario_throughput -m $MGR"
|
||||
#"./test_l3_scenario_throughput.py -t 15s -sc test_l3_scenario_throughput -m $MGR"
|
||||
#./test_l3_unicast_traffic_gen
|
||||
#./test_l3_unicast_traffic_gen
|
||||
#./test_l3_WAN_LAN
|
||||
#./test_l4
|
||||
"./test_l4.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --mgr $MGR --test_duration 15s"
|
||||
"./test_status_msg.py --debug --mgr $MGR" #this is all which is needed to run
|
||||
#"./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
|
||||
#./tip_station_powersave
|
||||
#./vap_stations_example
|
||||
#./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 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 11ac -t Voice -d 9 -spa 3 -ch 20 -gu 800 -high 1 -e TKIP -q Yes -ip 3 -mc 0 -b 6 12 24 54 -m 1518 -co Greenfield -cw 15 -rc Yes -m $MGR"
|
||||
#"./ws_generic_monitor_test.py --mgr $MGR"
|
||||
)
|
||||
elif [[ $MGR == "short" ]]; then
|
||||
testCommands=(
|
||||
run_l3_longevity
|
||||
"./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"
|
||||
)
|
||||
else
|
||||
testCommands=(
|
||||
#"../cpu_stats.py --duration 15"
|
||||
"./example_security_connection.py --num_stations $NUM_STA --ssid jedway-wpa-1 --passwd jedway-wpa-1 --radio $RADIO_USED --security wpa --debug"
|
||||
"./example_security_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --radio $RADIO_USED --security wpa2 --debug"
|
||||
"./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"
|
||||
"./sta_connect_example.py"
|
||||
# want if [[ $DO_FILEIO = 1 ]]
|
||||
"./test_fileio.py --macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --test_duration 30s --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 $TEST_HTTP_IP --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"
|
||||
"./test_generic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --num_stations $NUM_STA --type lfcurl --dest $TEST_HTTP_IP --file_output ${HOMEPATH}/Documents/lfcurl_output.txt --debug"
|
||||
"./testgroup.py --group_name group1 --add_group --list_groups --debug"
|
||||
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"
|
||||
"./test_ipv4_connection.py --radio $RADIO_USED --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
"./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"
|
||||
"./test_ipv4_l4_wifi.py --radio $RADIO_USED --num_stations $NUM_STA --security $SECURITY --ssid $SSID_USED --passwd $PASSWD_USED --test_duration 15s --debug"
|
||||
"./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 --traffic_type lf_udp --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 --traffic_type lf_udp --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_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
|
||||
"./test_l3_powersave_traffic.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
#"./test_l3_scenario_throughput.py -t 15s -sc test_l3_scenario_throughput" #always hangs the regression
|
||||
"./test_status_msg.py --action run_test " #this is all which is needed to run
|
||||
"./test_wanlink.py --debug"
|
||||
#"./ws_generic_monitor_test.py"
|
||||
#"../py-json/ws-sta-monitor.py --debug"
|
||||
"./create_bridge.py --radio $RADIO_USED --upstream_port eth1 --target_device sta0000 --debug"
|
||||
"./create_l3.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
"./create_l4.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
"./create_macvlan.py --radio $RADIO_USED --macvlan_parent eth1 --debug"
|
||||
"./create_station.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
"./create_vap.py --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug"
|
||||
"./create_vr.py --vr_name 2.vr0 --ports 2.br0,2.vap2 --services"
|
||||
"./create_qvlan.py --radio $RADIO_USED --qvlan_parent eth1"
|
||||
"./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"
|
||||
"./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"
|
||||
"./wlan_capacity_calculator.py -sta 11ac -t Voice -d 9 -spa 3 -ch 20 -gu 800 -high 1 -e TKIP -q Yes -ip 3 -mc 0 -b 6 12 24 54 -m 1518 -co Greenfield -cw 15 -rc Yes"
|
||||
#"./ws_generic_monitor_test.py --mgr $MGR"
|
||||
"python3 -c 'import lanforge_scripts'"
|
||||
)
|
||||
fi
|
||||
#declare -A name_to_num
|
||||
@@ -362,7 +434,6 @@ name_to_num=(
|
||||
["lf_csv"]=30
|
||||
["lf_dataplane_config"]=31
|
||||
["lf_dataplane_test"]=32
|
||||
["lf_dfs_test"]=33
|
||||
["lf_dut_sta_vap_test"]=34
|
||||
["lf_ft"]=35
|
||||
["lf_ftp_test"]=36
|
||||
@@ -449,37 +520,69 @@ function echo_print() {
|
||||
|
||||
function test() {
|
||||
if [[ $MGRLEN -gt 0 ]]; then
|
||||
./scenario.py --load FACTORY_DFLT --mgr "${MGR}"
|
||||
./scenario.py --load BLANK --mgr "${MGR}"
|
||||
else
|
||||
./scenario.py --load FACTORY_DFLT
|
||||
./scenario.py --load BLANK
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Test $CURR_TEST_NAME"
|
||||
|
||||
echo_print
|
||||
echo "$i"
|
||||
$i > "${TEST_DIR}/${NAME}.txt" 2> "${TEST_DIR}/${NAME}_stderr.txt"
|
||||
chmod 664 "${TEST_DIR}/${NAME}.txt"
|
||||
FILESIZE=$(stat -c%s "${TEST_DIR}/${NAME}_stderr.txt") || 0
|
||||
if (( FILESIZE > 0)); then
|
||||
results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td>
|
||||
<td class='failure'>Failure</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>")
|
||||
echo "$testcommand"
|
||||
start=$(date +%s)
|
||||
# this command saves stdout and stderr to the stdout file, and has a special file for stderr text.
|
||||
# Modified from https://unix.stackexchange.com/a/364176/327076
|
||||
FILENAME="${TEST_DIR}/${NAME}"
|
||||
{ eval "$testcommand" 2>&1 >&3 3>&- | tee "${FILENAME}_stderr.txt" 3>&-; } > "${FILENAME}.txt" 3>&1
|
||||
chmod 664 "${FILENAME}.txt"
|
||||
FILESIZE=$(stat -c%s "${FILENAME}_stderr.txt") || 0
|
||||
# Check to see if the error is due to LANforge
|
||||
ERROR_DATA=$(cat "${FILENAME}_stderr.txt")
|
||||
if [[ $ERROR_DATA =~ "LANforge Error Messages" ]]
|
||||
then
|
||||
LANforgeError="Lanforge Error"
|
||||
echo "LANforge Error"
|
||||
else
|
||||
results+=("<tr><td>${CURR_TEST_NAME}</td><td class='scriptdetails'>${i}</td>
|
||||
<td class='success'>Success</td>
|
||||
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>
|
||||
<td></td></tr>")
|
||||
LANforgeError=""
|
||||
fi
|
||||
end=$(date +%s)
|
||||
execution="$((end-start))"
|
||||
TEXT=$(cat "${FILENAME}".txt)
|
||||
STDERR=""
|
||||
if [[ $TEXT =~ "tests failed" ]]
|
||||
then
|
||||
TEXTCLASS="partial_failure"
|
||||
TDTEXT="Partial Failure"
|
||||
else
|
||||
TEXTCLASS="success"
|
||||
TDTEXT="Success"
|
||||
fi
|
||||
|
||||
if (( FILESIZE > 0))
|
||||
then
|
||||
echo "Errors detected"
|
||||
TEXTCLASS="failure"
|
||||
TDTEXT="Failure"
|
||||
STDERR="<a href=\"${URL2}/${NAME}_stderr.txt\" target=\"_blank\">STDERR</a>"
|
||||
else
|
||||
echo "No errors detected"
|
||||
fi
|
||||
results+=("<tr><td>${CURR_TEST_NAME}</td>
|
||||
<td class='scriptdetails'>${testcommand}</td>
|
||||
<td class='${TEXTCLASS}'>$TDTEXT</td>
|
||||
<td>${execution}</td>
|
||||
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>
|
||||
<td>${STDERR}</td>
|
||||
<td>${LANforgeError}</td>
|
||||
</tr>")
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
function start_tests() {
|
||||
if [[ ${#A} -gt 0 ]]; then
|
||||
for i in "${testCommands[@]}"; do
|
||||
for testcommand in "${testCommands[@]}"; do
|
||||
NAME=$(cat < /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
CURR_TEST_NAME=${i%%.py*}
|
||||
CURR_TEST_NAME=${testcommand%%.py*}
|
||||
CURR_TEST_NAME=${CURR_TEST_NAME#./*}
|
||||
#CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}"
|
||||
if [[ $A == "$CURR_TEST_NAME" ]]; then
|
||||
@@ -487,9 +590,9 @@ function run_test() {
|
||||
fi
|
||||
done
|
||||
else
|
||||
for i in "${testCommands[@]}"; do
|
||||
for testcommand in "${testCommands[@]}"; do
|
||||
NAME=$(cat < /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
CURR_TEST_NAME=${i%%.py*}
|
||||
CURR_TEST_NAME=${testcommand%%.py*}
|
||||
CURR_TEST_NAME=${CURR_TEST_NAME#./*}
|
||||
#CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}"
|
||||
test
|
||||
@@ -498,61 +601,109 @@ function run_test() {
|
||||
}
|
||||
|
||||
function html_generator() {
|
||||
LAST_COMMIT=$(git log --pretty=oneline | tail -n 1)
|
||||
header="<html>
|
||||
<head>
|
||||
<title>Regression Test Results $NOW</title>
|
||||
<style>
|
||||
.success {
|
||||
background-color:green;
|
||||
}
|
||||
.failure {
|
||||
background-color:red;
|
||||
}
|
||||
table {
|
||||
border: 1px solid gray;
|
||||
}
|
||||
td {
|
||||
margin: 0;
|
||||
padding: 2px;
|
||||
font-family: 'Courier New',courier,sans-serif;
|
||||
}
|
||||
h1, h2, h3, h4 {
|
||||
font-family: 'Century Gothic',Arial,sans,sans-serif;
|
||||
}
|
||||
.scriptdetails {
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
<script src=\"sortabletable.js\"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Regression Results</h1>
|
||||
<h4>$NOW</h4>
|
||||
<h4>$LAST_COMMIT</h4>
|
||||
<table border ='1' id='myTable2'>
|
||||
<tr>
|
||||
<th onclick=\"sortTable(0)\">Command Name</th>
|
||||
<th onclick=\"sortTable(1)\">Command</th>
|
||||
<th onclick=\"sortTable(2)\">Status</th>
|
||||
<th onclick=\"sortTable(3)\">STDOUT</th>
|
||||
<th onclick=\"sortTable(4)\">STDERR</th>
|
||||
</tr>"
|
||||
tail="</body>
|
||||
</html>"
|
||||
LAST_COMMIT=$(git log --pretty=oneline | head -n 1)
|
||||
header="<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>${HOSTNAME} Regression Test Results $NOW</title>
|
||||
<link rel='stylesheet' href='report.css' />
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Century Gothic';
|
||||
}
|
||||
.success {
|
||||
background-color:green;
|
||||
}
|
||||
.failure {
|
||||
background-color:red;
|
||||
}
|
||||
.partial_failure {
|
||||
background-color:yellow;
|
||||
}
|
||||
table {
|
||||
border: 0 none;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
td {
|
||||
margin: 0;
|
||||
padding: 2px;
|
||||
font-family: 'Century Gothic',Arial,Verdana,Tahoma,'Trebuchet MS',Impact,sans-serif;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
h1, h2, h3, h4 {
|
||||
font-family: 'Century Gothic',Arial,Verdana,Tahoma,'Trebuchet MS',Impact,sans-serif;
|
||||
}
|
||||
.scriptdetails {
|
||||
font-size: 10px;
|
||||
font-family:'Lucida Typewriter','Andale Mono','Courier New',Courier,FreeMono,monospace;
|
||||
}
|
||||
td.testname {
|
||||
font-size:14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<script src=\"sortabletable.js\"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Regression Results</h1>
|
||||
<h4 id=\"timestamp\">$NOW</h4>
|
||||
<h4 id=\"Git Commit\">$LAST_COMMIT</h4>
|
||||
<h4>Test results</h4>
|
||||
<table border ='1' id='myTable2' id='SuiteResults'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th onclick=\"sortTable('myTable2', 0)\">Command Name</th>
|
||||
<th onclick=\"sortTable('myTable2', 1)\">Command</th>
|
||||
<th onclick=\"sortTable('myTable2', 2)\">Status</th>
|
||||
<th onclick=\"sortTable('myTable2', 3)\">Execution time</th>
|
||||
<th onclick=\"sortTable('myTable2', 4)\">STDOUT</th>
|
||||
<th onclick=\"sortTable('myTable2', 5)\">STDERR</th>
|
||||
<th onclick=\"sortTable('myTable2', 6)\">LANforge Error</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>"
|
||||
tail="</body></html>"
|
||||
|
||||
fname="${HOMEPATH}/html-reports/regression_file-${NOW}.html"
|
||||
echo "$header" >> "$fname"
|
||||
echo "${results[@]}" >> "$fname"
|
||||
echo "</table>" >> "$fname"
|
||||
echo "</table>
|
||||
</table>
|
||||
<br />
|
||||
<h3>System information</h3>
|
||||
<table id=\"SystemInformation\" border ='1'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Python version</th>
|
||||
<th>LANforge version</th>
|
||||
<th>LANforge build date</th>
|
||||
<th>OS Version</th>
|
||||
<th>Hostname</th>
|
||||
<th>IP Address</th>
|
||||
<th>Python Environment</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td id='PythonVersion'>${PYTHON_VERSION}</td>
|
||||
<td id='LANforgeVersion'>${BuildVersion}</td>
|
||||
<td id='LANforgeBuildDate'>${BuildDate}</td>
|
||||
<td id='OS_Version'>${OS_Version}</td>
|
||||
<td id='Hostname'>${HOSTNAME}</td>
|
||||
<td id='ip_address'>${IP_ADDRESS}</td>
|
||||
<td id='python_environment'>${PYTHON_ENVIRONMENT}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>" >> "$fname"
|
||||
echo "$tail" >> "$fname"
|
||||
if [ -f "${HOMEPATH}/html-reports/latest.html" ]; then
|
||||
rm -f "${HOMEPATH}/html-reports/latest.html"
|
||||
fi
|
||||
ln -s "${fname}" "${HOMEPATH}/html-reports/latest.html"
|
||||
HOSTNAME=$(ip -4 addr show enp3s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
||||
content="View the latest regression report at ${HOSTNAME}/html-reports/latest.html"
|
||||
echo "${content}"
|
||||
echo "Saving HTML file to disk"
|
||||
#HOSTNAME=$(ip -4 addr show enp3s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
||||
#content="View the latest regression report at /html-reports/latest.html"
|
||||
#echo "${content}"
|
||||
#mail -s "Regression Results" scripters@candelatech.com <<<$content
|
||||
}
|
||||
|
||||
@@ -560,9 +711,9 @@ results=()
|
||||
NOW=$(date +"%Y-%m-%d-%H-%M")
|
||||
NOW="${NOW/:/-}"
|
||||
TEST_DIR="${REPORT_DATA}/${NOW}"
|
||||
URL2="${HOMEPATH}/report-data/${NOW}"
|
||||
URL2="/report-data/${NOW}"
|
||||
mkdir "${TEST_DIR}"
|
||||
echo "Recording data to $TEST_DIR"
|
||||
|
||||
run_test
|
||||
start_tests
|
||||
html_generator
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
# This script will set the LANforge to a BLANK database then it will load the specified database
|
||||
# and start a graphical report
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
from time import sleep
|
||||
import importlib
|
||||
import os
|
||||
import pprint
|
||||
import sys
|
||||
import time
|
||||
from time import sleep
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -29,15 +29,19 @@ Realm = realm.Realm
|
||||
cvScenario.test_scenario = args.test_scenario
|
||||
"""
|
||||
|
||||
|
||||
class RunCvScenario(LFCliBase):
|
||||
def __init__(self, lfhost="localhost", lfport=8080, debug_=False, lanforge_db_=None, cv_scenario_=None, cv_test_=None, test_scenario_=None):
|
||||
super().__init__( _lfjson_host=lfhost, _lfjson_port=lfport, _debug=debug_, _exit_on_error=True, _exit_on_fail=True)
|
||||
def __init__(self, lfhost="localhost", lfport=8080, debug_=False, lanforge_db_=None, cv_scenario_=None,
|
||||
cv_test_=None, test_scenario_=None):
|
||||
super().__init__(_lfjson_host=lfhost, _lfjson_port=lfport, _debug=debug_, _exit_on_error=True,
|
||||
_exit_on_fail=True)
|
||||
self.lanforge_db = lanforge_db_
|
||||
self.cv_scenario = cv_scenario_
|
||||
self.cv_test = cv_test_
|
||||
self.test_profile = test_scenario_
|
||||
self.localrealm = Realm(lfclient_host=lfhost, lfclient_port=lfport, debug_=debug_)
|
||||
self.report_name = None
|
||||
self.load_timeout_sec = 2 * 60
|
||||
|
||||
def get_report_file_name(self):
|
||||
return self.report_name
|
||||
@@ -45,14 +49,16 @@ class RunCvScenario(LFCliBase):
|
||||
def build(self):
|
||||
data = {
|
||||
"name": "BLANK",
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"action": "overwrite",
|
||||
"clean_dut": "yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
sleep(1)
|
||||
port_counter = 0;
|
||||
self.wait_for_db_load_and_sync()
|
||||
|
||||
port_counter = 0
|
||||
attempts = 6
|
||||
alias_map = None
|
||||
while (attempts > 0) and (port_counter > 0):
|
||||
sleep(1)
|
||||
attempts -= 1
|
||||
@@ -69,47 +75,131 @@ class RunCvScenario(LFCliBase):
|
||||
|
||||
if (port_counter != 0) and (attempts == 0):
|
||||
print("There appears to be a vAP in this database, quitting.")
|
||||
pprint(alias_map);
|
||||
pprint.pprint(alias_map)
|
||||
exit(1)
|
||||
|
||||
data = {
|
||||
"name": self.lanforge_db,
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"action": "overwrite",
|
||||
"clean_dut": "yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
sleep(1)
|
||||
self.wait_for_db_load_and_sync()
|
||||
self._pass("Loaded scenario %s" % self.lanforge_db, True)
|
||||
return True
|
||||
|
||||
def wait_for_db_load_and_sync(self):
|
||||
events_response = self.json_get("/events/last")
|
||||
if "event" not in events_response:
|
||||
raise ValueError("Unable to find last event")
|
||||
if "id" not in events_response["event"]:
|
||||
pprint.pprint(events_response["event"])
|
||||
raise ValueError("bad event format")
|
||||
previous_event_id = events_response["event"]["id"]
|
||||
|
||||
# check for scenario (db) load message
|
||||
begin_time: int = round(time.time() * 1000)
|
||||
load_completed = False
|
||||
while not load_completed:
|
||||
if time.time() > (begin_time + self.load_timeout_sec):
|
||||
print("Unable to load database within %d sec" % self.load_timeout_sec)
|
||||
exit(1)
|
||||
events_response = self.json_get("/events/since/%s" % previous_event_id)
|
||||
pronoun = None
|
||||
if "events" in events_response:
|
||||
pronoun = "events"
|
||||
elif "event" in events_response:
|
||||
pronoun = "event"
|
||||
if not pronoun:
|
||||
pprint.pprint(("events response", events_response))
|
||||
raise ValueError("incorrect events response")
|
||||
for event_o in events_response[pronoun]:
|
||||
if load_completed:
|
||||
break
|
||||
for (key, record) in event_o.items():
|
||||
if "event description" not in record:
|
||||
continue
|
||||
if not record["event description"]:
|
||||
continue
|
||||
if record["event description"].startswith("LOAD COMPLETED at "):
|
||||
print("load completed: %s " % record["event description"])
|
||||
load_completed = True
|
||||
break
|
||||
if not load_completed:
|
||||
sleep(1)
|
||||
|
||||
blobs_last_updated = begin_time
|
||||
status_response = self.json_get("/")
|
||||
if "text_records_last_updated_ms" in status_response:
|
||||
blobs_last_updated = int(status_response["text_records_last_updated_ms"])
|
||||
# print("*** blobs updated at %d" % blobs_last_updated)
|
||||
else:
|
||||
begin_time = round(time.time() * 1000)
|
||||
print("no text_records_last_updated_ms, using %d " % begin_time)
|
||||
# next we will want to sync our text blobs up
|
||||
self.json_post("/cli-json/show_text_blob", {
|
||||
"type": "ALL",
|
||||
"name": "ALL"
|
||||
})
|
||||
|
||||
load_completed = False
|
||||
while not load_completed:
|
||||
sleep(1)
|
||||
if time.time() > (begin_time + (6 * 1000)):
|
||||
print("waited %d sec for text blobs to update" % self.load_timeout_sec)
|
||||
break
|
||||
status_response = self.json_get("/")
|
||||
if "text_records_last_updated_ms" in status_response:
|
||||
updated = int(status_response["text_records_last_updated_ms"])
|
||||
print(", , , , , , , , , updated at %d" % updated)
|
||||
if updated > blobs_last_updated:
|
||||
break
|
||||
else:
|
||||
pprint.pprint(status_response)
|
||||
self.json_post("/cli-json/show_text_blob", {
|
||||
"type": "ALL",
|
||||
"name": "ALL"
|
||||
})
|
||||
delta: float = (time.time() * 1000) - begin_time
|
||||
print("blobs loaded in %d ms" % delta)
|
||||
|
||||
# next show duts
|
||||
self.json_post("/cli-json/show_dut", {"name": "ALL"})
|
||||
self.json_post("/cli-json/show_profile", {"name": "ALL"})
|
||||
self.json_post("/cli-json/show_traffic_profile", {"name": "ALL"})
|
||||
sleep(5)
|
||||
|
||||
def start(self, debug_=False):
|
||||
# /gui_cli takes commands keyed on 'cmd', so we create an array of commands
|
||||
commands = [
|
||||
"cv sync",
|
||||
"sleep 4",
|
||||
"cv apply '%s'" % self.cv_scenario,
|
||||
"sleep 4",
|
||||
"cv build",
|
||||
"sleep 4",
|
||||
"cv is_built",
|
||||
"cv sync",
|
||||
"sleep 2",
|
||||
"sleep 4",
|
||||
"cv list_instances",
|
||||
"cv create '%s' 'test_ref' 'true'" % self.cv_test,
|
||||
"sleep 2",
|
||||
"cv load test_ref '%s'" % self.test_profile,
|
||||
"sleep 1",
|
||||
"cv click test_ref 'Auto Save Report'",
|
||||
"sleep 5",
|
||||
"cv load test_ref '%s'" % self.test_profile,
|
||||
"sleep 5",
|
||||
"cv click test_ref 'Auto Save Report'",
|
||||
"sleep 1",
|
||||
"cv click test_ref Start",
|
||||
"sleep 60",
|
||||
"cv get test_ref 'Report Location:'",
|
||||
"sleep 5",
|
||||
#"cv click test_ref 'Save HTML'",
|
||||
# "cv click test_ref 'Save HTML'",
|
||||
"cv click test_ref 'Close'",
|
||||
"sleep 1",
|
||||
"cv click test_ref Cancel",
|
||||
"sleep 1",
|
||||
"exit"
|
||||
]
|
||||
response_json = []
|
||||
for command in commands:
|
||||
data = {
|
||||
"cmd": command
|
||||
@@ -117,7 +207,7 @@ class RunCvScenario(LFCliBase):
|
||||
try:
|
||||
debug_par = ""
|
||||
if debug_:
|
||||
debug_par="?_debug=1"
|
||||
debug_par = "?_debug=1"
|
||||
if command.endswith("is_built"):
|
||||
print("Waiting for scenario to build...", end='')
|
||||
self.localrealm.wait_while_building(debug_=False)
|
||||
@@ -127,21 +217,28 @@ class RunCvScenario(LFCliBase):
|
||||
print("sleeping %d..." % nap)
|
||||
sleep(nap)
|
||||
print("...proceeding")
|
||||
elif command == "cv list_instances":
|
||||
response_json = []
|
||||
print("running %s..." % command, end='')
|
||||
response = self.json_post("/gui-json/cmd%s" % debug_par,
|
||||
data,
|
||||
debug_=debug_,
|
||||
response_json_list_=response_json)
|
||||
if debug_:
|
||||
LFUtils.debug_printer.pprint(response)
|
||||
else:
|
||||
response_json = []
|
||||
print("running %s..." % command, end='')
|
||||
response = self.json_post("/gui-json/cmd%s" % debug_par, data, debug_=False, response_json_list_=response_json)
|
||||
self.json_post("/gui-json/cmd%s" % debug_par, data, debug_=False,
|
||||
response_json_list_=response_json)
|
||||
if debug_:
|
||||
LFUtils.debug_printer.pprint(response_json)
|
||||
print("...proceeding")
|
||||
|
||||
|
||||
except Exception as x:
|
||||
print(x)
|
||||
|
||||
self._pass("report finished", print_=True)
|
||||
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
@@ -156,13 +253,14 @@ def main():
|
||||
prog="run_cv_scenario.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Reporting Script: Load a scenario and run a RvR report
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --scenario_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
""")
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test 'WiFi Capacity' --test_profile 'test-20'
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str, help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int, help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-d", "--lanforge_db", type=str, help="Name of test scenario database (see Status Tab)")
|
||||
parser.add_argument("-c", "--cv_scenario", type=str, help="Name of Chamber View test scenario (see CV Manage Scenarios)")
|
||||
parser.add_argument("-c", "--cv_scenario", type=str,
|
||||
help="Name of Chamber View test scenario (see CV Manage Scenarios)")
|
||||
parser.add_argument("-n", "--cv_test", type=str, help="Chamber View test")
|
||||
parser.add_argument("-s", "--test_profile", type=str, help="Name of the saved CV test profile")
|
||||
parser.add_argument("--debug", help='Enable debugging', default=False, action="store_true")
|
||||
@@ -210,7 +308,9 @@ def main():
|
||||
exit(1)
|
||||
|
||||
report_file = run_cv_scenario.get_report_file_name()
|
||||
print("Report file saved to "+report_file)
|
||||
print("Report file saved to " + report_file)
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -29,9 +28,12 @@ Realm = realm.Realm
|
||||
cvScenario.test_scenario = args.test_scenario
|
||||
"""
|
||||
|
||||
|
||||
class RunCvScenario(LFCliBase):
|
||||
def __init__(self, lfhost="localhost", lfport=8080, debug_=False, lanforge_db_=None, cv_scenario_=None, cv_test_=None, test_scenario_=None):
|
||||
super().__init__( _lfjson_host=lfhost, _lfjson_port=lfport, _debug=debug_, _exit_on_error=True, _exit_on_fail=True)
|
||||
def __init__(self, lfhost="localhost", lfport=8080, debug_=False, lanforge_db_=None, cv_scenario_=None,
|
||||
cv_test_=None, test_scenario_=None):
|
||||
super().__init__(_lfjson_host=lfhost, _lfjson_port=lfport, _debug=debug_, _exit_on_error=True,
|
||||
_exit_on_fail=True)
|
||||
self.lanforge_db = lanforge_db_
|
||||
self.cv_scenario = cv_scenario_
|
||||
self.cv_test = cv_test_
|
||||
@@ -45,13 +47,13 @@ class RunCvScenario(LFCliBase):
|
||||
def build(self):
|
||||
data = {
|
||||
"name": "BLANK",
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"action": "overwrite",
|
||||
"clean_dut": "yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
sleep(1)
|
||||
port_counter = 0;
|
||||
port_counter = 0
|
||||
attempts = 6
|
||||
while (attempts > 0) and (port_counter > 0):
|
||||
sleep(1)
|
||||
@@ -74,8 +76,8 @@ class RunCvScenario(LFCliBase):
|
||||
|
||||
data = {
|
||||
"name": self.lanforge_db,
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"action": "overwrite",
|
||||
"clean_dut": "yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
@@ -86,7 +88,7 @@ class RunCvScenario(LFCliBase):
|
||||
def start(self, debug_=False):
|
||||
# /gui_cli takes commands keyed on 'cmd', so we create an array of commands
|
||||
commands = [
|
||||
#"cv apply '%s'" % self.cv_scenario,
|
||||
# "cv apply '%s'" % self.cv_scenario,
|
||||
"sleep 5",
|
||||
"cv build",
|
||||
"sleep 5",
|
||||
@@ -103,9 +105,10 @@ class RunCvScenario(LFCliBase):
|
||||
"cv click test_ref Start",
|
||||
"sleep 2",
|
||||
"cv click test_ref 'Another Iteration'",
|
||||
"sleep 240", #sleep for (test duration for 1 time test takes x num iterations requested) - this example is 2 iterations
|
||||
"cv click test_ref 'Another Iteration'", #unselect Another Iteration before test ends
|
||||
"sleep 50" #finish test
|
||||
"sleep 240",
|
||||
# sleep for (test duration for 1 time test takes x num iterations requested) - this example is 2 iterations
|
||||
"cv click test_ref 'Another Iteration'", # unselect Another Iteration before test ends
|
||||
"sleep 50" # finish test
|
||||
"cv get test_ref 'Report Location:'",
|
||||
"sleep 5",
|
||||
"cv click test_ref 'Save HTML'",
|
||||
@@ -115,7 +118,6 @@ class RunCvScenario(LFCliBase):
|
||||
"sleep 1",
|
||||
"exit"
|
||||
]
|
||||
response_json = []
|
||||
for command in commands:
|
||||
data = {
|
||||
"cmd": command
|
||||
@@ -123,7 +125,7 @@ class RunCvScenario(LFCliBase):
|
||||
try:
|
||||
debug_par = ""
|
||||
if debug_:
|
||||
debug_par="?_debug=1"
|
||||
debug_par = "?_debug=1"
|
||||
if command.endswith("is_built"):
|
||||
print("Waiting for scenario to build...", end='')
|
||||
self.localrealm.wait_while_building(debug_=False)
|
||||
@@ -136,18 +138,16 @@ class RunCvScenario(LFCliBase):
|
||||
else:
|
||||
response_json = []
|
||||
print("running %s..." % command, end='')
|
||||
response = self.json_post("/gui-json/cmd%s" % debug_par, data, debug_=False, response_json_list_=response_json)
|
||||
self.json_post("/gui-json/cmd%s" % debug_par, data, debug_=False, response_json_list_=response_json)
|
||||
if debug_:
|
||||
LFUtils.debug_printer.pprint(response_json)
|
||||
print("...proceeding")
|
||||
|
||||
|
||||
except Exception as x:
|
||||
print(x)
|
||||
|
||||
self._pass("report finished", print_=True)
|
||||
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
@@ -163,17 +163,17 @@ def main():
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Reporting Script: Load a scenario and run a RvR report
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
./rvr_scenario.py --lfmgr 127.0.0.1 --lanforge_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str,
|
||||
parser.add_argument("-m", "--lfmgr", type=str,
|
||||
help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int,
|
||||
parser.add_argument("-o", "--port", type=int,
|
||||
help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("--lanforge_db", "--db", "--lanforge_scenario", type=str,
|
||||
help="Name of test scenario database (see Status Tab)")
|
||||
parser.add_argument("-c", "--cv_scenario", type=str, required=True,
|
||||
parser.add_argument("-c", "--cv_scenario", type=str, required=True,
|
||||
help="Name of Chamber View test scenario (see CV Manage Scenarios)")
|
||||
parser.add_argument("-n", "--cv_test", type=str, required = True,
|
||||
parser.add_argument("-n", "--cv_test", type=str, required=True,
|
||||
help="Chamber View test")
|
||||
parser.add_argument("-s", "--test_profile", "--test_settings", type=str, required=True,
|
||||
help="Name of the saved CV test settings")
|
||||
@@ -220,7 +220,9 @@ Example:
|
||||
exit(1)
|
||||
|
||||
report_file = run_cv_scenario.get_report_file_name()
|
||||
print("Report file saved to "+report_file)
|
||||
print("Report file saved to " + report_file)
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
|
||||
198
py-scripts/sandbox/attenuator_mon.py
Executable file
198
py-scripts/sandbox/attenuator_mon.py
Executable file
@@ -0,0 +1,198 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
NAME: attenuator_mon.py
|
||||
|
||||
PURPOSE: example of a monitoring loop that notices when attenator values change
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
"""
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
|
||||
sys.path.insert(1, "../../py-json")
|
||||
import argparse
|
||||
import importlib
|
||||
import os
|
||||
from os.path import exists
|
||||
import pprint
|
||||
from time import sleep
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||
lfcli_base = importlib.import_module('py-json.LANforge.lfcli_base')
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
LFUtils = importlib.import_module('py-json.LANforge.LFUtils')
|
||||
realm = importlib.import_module('py-json.realm')
|
||||
Realm = realm.Realm
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
|
||||
|
||||
class AttenuatorMonitor(Realm):
|
||||
def __init__(self,
|
||||
host=None,
|
||||
port=None,
|
||||
action=None,
|
||||
action_every_channel=False,
|
||||
attenuator=None,
|
||||
interval_sec: float = 1.0,
|
||||
stop_file=None,
|
||||
_deep_clean=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host,
|
||||
port,
|
||||
debug_=_debug_on,
|
||||
_exit_on_fail=_exit_on_fail)
|
||||
self.action = action
|
||||
self.action_every_channel = action_every_channel
|
||||
self.attenuator = attenuator
|
||||
self.interval_sec = interval_sec
|
||||
self.stop_file = stop_file
|
||||
|
||||
self.prev_values = {
|
||||
"module 1": 0.0,
|
||||
"module 2": 0.0,
|
||||
"module 3": 0.0,
|
||||
"module 4": 0.0,
|
||||
"module 5": 0.0,
|
||||
"module 6": 0.0,
|
||||
"module 7": 0.0,
|
||||
"module 8": 0.0,
|
||||
}
|
||||
# check for attenuator
|
||||
|
||||
response = self.json_get("/atten/list")
|
||||
if "attenuator" not in response:
|
||||
if "attenuators" not in response:
|
||||
print("Unable to retrieve list of attenuators. Is a LANforge GUI at %s:%s ?"
|
||||
% (host, port))
|
||||
exit(1)
|
||||
|
||||
found = False
|
||||
if "attenuator" in response:
|
||||
if response["attenuator"]["entity id"] != self.attenuator:
|
||||
print("Unable to find attenuator %s" % self.attenuator)
|
||||
pprint.pprint(("reponse", response))
|
||||
exit(1)
|
||||
else:
|
||||
found = True
|
||||
elif "attenuators" in response:
|
||||
atten_list = response["attenuators"]
|
||||
for atten_o in atten_list:
|
||||
for key_1 in atten_o.keys():
|
||||
if atten_o[key_1]["entity id"] == self.attenuator:
|
||||
found = True
|
||||
else:
|
||||
print("No attenators on system.")
|
||||
exit(1)
|
||||
if not found:
|
||||
print("No matching attenuators found.")
|
||||
exit(1)
|
||||
|
||||
self.attenuator_url = "/atten/" + self.attenuator
|
||||
|
||||
def run(self):
|
||||
if self.stop_file is not None:
|
||||
if exists(self.stop_file):
|
||||
print("Stop File [%s] already exists. Remove file before starting script." % self.stop_file)
|
||||
exit(0)
|
||||
else:
|
||||
print("No stop file provided. Stop this script with ctrl-c or kill")
|
||||
|
||||
counter = 0;
|
||||
while(True):
|
||||
sleep(self.interval_sec)
|
||||
if exists(self.stop_file):
|
||||
return
|
||||
num_changes = 0
|
||||
changes = {}
|
||||
attenuator_values = self.json_get(self.attenuator_url)
|
||||
z_old: float
|
||||
z_new: float
|
||||
|
||||
for key in self.prev_values.keys():
|
||||
|
||||
if key not in attenuator_values["attenuator"]:
|
||||
pprint.pprint(attenuator_values["attenuator"])
|
||||
raise ValueError("Unexpected lack of keys for attenuator record:")
|
||||
if self.debug:
|
||||
print("I see: %s -> %s" % (self.prev_values[key], attenuator_values["attenuator"][key]))
|
||||
|
||||
if "" == attenuator_values["attenuator"][key]:
|
||||
continue
|
||||
|
||||
z_old = float(self.prev_values[key])
|
||||
z_new = float(attenuator_values["attenuator"][key])
|
||||
|
||||
changes[key] = 0
|
||||
if z_old != z_new:
|
||||
if (counter > 0) and self.action_every_channel:
|
||||
self.do_cmd(channel=key, value=z_new)
|
||||
else:
|
||||
changes[key] = str(z_new)
|
||||
num_changes += 1
|
||||
self.prev_values[key] = z_new
|
||||
|
||||
if (counter > 0) and (num_changes > 0) and (not self.action_every_channel):
|
||||
self.do_cmd(channel="all",
|
||||
value=",".join(changes.values()))
|
||||
if exists(self.stop_file):
|
||||
return
|
||||
counter += 1
|
||||
|
||||
def do_cmd(self,
|
||||
channel=None,
|
||||
value=None):
|
||||
if not channel:
|
||||
raise ValueError("do_cmd not given channel")
|
||||
if not value:
|
||||
raise ValueError("do_cmd not given value")
|
||||
if not self.action:
|
||||
raise ValueError("do_cmd lost self.action")
|
||||
|
||||
pprint.pprint([("channel", channel),
|
||||
("values", value)])
|
||||
os.system(self.action)
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog=__file__,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""
|
||||
""")
|
||||
parser.add_argument('--action', help="command to execute when attenuator changes levels")
|
||||
parser.add_argument('--action_every_channel', help="When True, do an action for every channel that changes")
|
||||
parser.add_argument('--attenuator', help="attenuator entity id to watch; E.G.: 1.1.323")
|
||||
parser.add_argument('--interval_sec', type=float, help="wait between checking")
|
||||
parser.add_argument('--stop_file', help="when this file appears, exit; E.G.: /tmp/stop-monitoring")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if (not args.action) or ("" == args.action):
|
||||
print("--action is required; how about 'echo hi' ?")
|
||||
exit(1)
|
||||
attenuator_mon = AttenuatorMonitor(args.mgr,
|
||||
args.mgr_port,
|
||||
attenuator=args.attenuator,
|
||||
action=args.action,
|
||||
action_every_channel=args.action_every_channel,
|
||||
interval_sec=args.interval_sec,
|
||||
stop_file=args.stop_file,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False)
|
||||
attenuator_mon.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
36
py-scripts/sandbox/example-connection-removal.py
Executable file
36
py-scripts/sandbox/example-connection-removal.py
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
from pprint import pprint #, pformat
|
||||
|
||||
|
||||
path_hunks = os.path.abspath(__file__).split('/')
|
||||
while( path_hunks[-1] != 'lanforge-scripts'):
|
||||
path_hunks.pop()
|
||||
sys.path.append(os.path.join("/".join(path_hunks)))
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
class eggsample(Realm):
|
||||
def __init__(self):
|
||||
super().__init__("ct521a-lion", 8080);
|
||||
|
||||
def run(self):
|
||||
layer3_result = self.cx_list() # this is realm::cx_list()
|
||||
pprint(("layer3 result records:", layer3_result))
|
||||
layer3_names = [ item["name"] for item in layer3_result.values() if "_links" in item]
|
||||
pprint(("layer3 names:", layer3_names))
|
||||
#LFUtils.remove_cx(self.url, layer3_names)
|
||||
|
||||
|
||||
def main():
|
||||
egg = eggsample()
|
||||
egg.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
#
|
||||
|
||||
133
py-scripts/sandbox/jbr_create_wanlink.py
Executable file
133
py-scripts/sandbox/jbr_create_wanlink.py
Executable file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
NAME: jbr_create_wanlink.py
|
||||
|
||||
PURPOSE: create a wanlink
|
||||
|
||||
EXAMPLE:
|
||||
$ ./jbr_create_wanlink.py --host ct521a-jana --wl_name snail
|
||||
|
||||
To enable using lf_json_autogen in other parts of the codebase, set LF_USE_AUTOGEN=1:
|
||||
$ LF_USE_AUTOGEN=1 ./jbr_jag_test.py --test set_port --host ct521a-lion
|
||||
|
||||
NOTES:
|
||||
|
||||
|
||||
TO DO NOTES:
|
||||
|
||||
"""
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
|
||||
import importlib
|
||||
import argparse
|
||||
import pprint
|
||||
sys.path.insert(1, "../../")
|
||||
lanforge_api = importlib.import_module("lanforge_client.lanforge_api")
|
||||
from lanforge_client.lanforge_api import LFSession
|
||||
from lanforge_client.lanforge_api import LFJsonCommand
|
||||
from lanforge_client.lanforge_api import LFJsonQuery
|
||||
|
||||
|
||||
# import LANforge.lfcli_base
|
||||
# from LANforge.lfcli_base import LFCliBase
|
||||
|
||||
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- #
|
||||
|
||||
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- #
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=__file__,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description='tests creating wanlink')
|
||||
parser.add_argument("--host", "--mgr", help='specify the GUI to connect to, assumes port 8080')
|
||||
parser.add_argument("--wl_name", help='name of the wanlink to create')
|
||||
parser.add_argument("--resource", help='LANforge resource')
|
||||
parser.add_argument("--debug", help='turn on debugging', action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
if not args.wl_name:
|
||||
print("No wanlink name provided")
|
||||
exit(1)
|
||||
|
||||
session = LFSession(lfclient_url="http://%s:8080" % args.host,
|
||||
debug=args.debug,
|
||||
connection_timeout_sec=2.0,
|
||||
stream_errors=True,
|
||||
stream_warnings=True,
|
||||
require_session=True,
|
||||
exit_on_error=True)
|
||||
command: LFJsonCommand
|
||||
command = session.get_command()
|
||||
query: LFJsonQuery
|
||||
query = session.get_query()
|
||||
|
||||
command.post_add_rdd(resource=args.resource,
|
||||
port="rd0a",
|
||||
peer_ifname="rd0b",
|
||||
report_timer=1000,
|
||||
shelf=1,
|
||||
debug=args.debug)
|
||||
|
||||
command.post_add_rdd(resource=args.resource,
|
||||
port="rd1a",
|
||||
peer_ifname="rd1b",
|
||||
report_timer=1000,
|
||||
shelf=1,
|
||||
debug=args.debug)
|
||||
|
||||
endp_a = args.wl_name + "-A"
|
||||
endp_b = args.wl_name + "-B"
|
||||
# Comment out some parameters like 'max_jitter', 'drop_freq' and 'wanlink'
|
||||
# in order to view the X-Errors headers
|
||||
command.post_add_wl_endp(alias=endp_a,
|
||||
shelf=1,
|
||||
resource=args.resource,
|
||||
wanlink=args.wl_name,
|
||||
speed=56000,
|
||||
port="rd0a",
|
||||
drop_freq="0",
|
||||
max_jitter="10",
|
||||
latency="10ms",
|
||||
min_reorder_amt="1",
|
||||
max_reorder_amt="10",
|
||||
min_drop_amt="1",
|
||||
debug=args.debug)
|
||||
command.post_add_wl_endp(alias=endp_b,
|
||||
shelf=1,
|
||||
resource=args.resource,
|
||||
port="rd1a",
|
||||
wanlink=args.wl_name,
|
||||
speed=56000,
|
||||
drop_freq="0",
|
||||
max_jitter="10",
|
||||
latency="10ms",
|
||||
min_reorder_amt="1",
|
||||
max_reorder_amt="10",
|
||||
min_drop_amt="1",
|
||||
debug=args.debug)
|
||||
command.post_add_cx(alias=args.wl_name,
|
||||
rx_endp=endp_a,
|
||||
tx_endp=endp_b,
|
||||
test_mgr="default_tm",
|
||||
debug=args.debug)
|
||||
ewarn_list = []
|
||||
result = query.get_wl(eid_list=[args.wl_name],
|
||||
wait_sec=0.2,
|
||||
timeout_sec=2.0,
|
||||
errors_warnings=ewarn_list,
|
||||
debug=args.debug)
|
||||
pprint.pprint(result)
|
||||
result = query.get_wl_endp(eid_list=[args.wl_name+"-A", args.wl_name+"-B"],
|
||||
wait_sec=0.2,
|
||||
timeout_sec=15.0,
|
||||
debug=args.debug)
|
||||
pprint.pprint(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
#
|
||||
353
py-scripts/sandbox/jbr_monitor_bssids.py
Executable file
353
py-scripts/sandbox/jbr_monitor_bssids.py
Executable file
@@ -0,0 +1,353 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
NAME: jbr_monitor_bssids.py
|
||||
|
||||
PURPOSE: Creates a series of stations and L3 connections
|
||||
Uses lanforge_api.
|
||||
|
||||
EXAMPLE:
|
||||
$ ./jbr_monitor_bssids.py --host ct521a-manx \
|
||||
--radio 1.1.wiphy0 \
|
||||
--traffic_dur_sec 60 \
|
||||
--test_duration_min 120 \
|
||||
--security wpa2 \
|
||||
--ssid cyrus \
|
||||
--passwd HelloRudy \
|
||||
--bssid cc:32:e5:4b:ef:b3 \
|
||||
--bssid cc:32:e5:4b:ef:b4 \
|
||||
--bssid 70:4f:57:1e:15:af \
|
||||
--bssid 70:4f:57:1e:15:ae \
|
||||
--bssid d8:0d:17:be:ab:36 \
|
||||
--bssid d8:0d:17:be:ab:37 \
|
||||
--bssid 54:83:3a:9c:38:7f \
|
||||
|
||||
Notes:
|
||||
# cyrus1 161- 3x3 MCS 0-9 AC WPA2 cc:32:e5:4b:ef:b3 -31.0 5805 100 5.76 m
|
||||
cyrus1 11 3x3 MIMO WPA2 cc:32:e5:4b:ef:b4 -32.0 2462 100 5.76 m
|
||||
cyrus 1 3x3 MIMO WPA2 70:4f:57:1e:15:af -48.0 2412 100 5.76 m
|
||||
cyrus 149+ 4x4 MCS 0-9 AC WPA2 70:4f:57:1e:15:ae -53.0 5745 100 5.76 m
|
||||
cyrus 157+ 3x3 MCS 0-9 AC WPA2 d8:0d:17:be:ab:36 -64.0 5785 100 5.76 m
|
||||
cyrus 11 3x3 MIMO WPA2 d8:0d:17:be:ab:37 -65.0 2462 100 5.76 m
|
||||
cyrus 11 3x3 MIMO WPA WPA2 54:83:3a:9c:38:7f -72.0 2462 100 5.76 m
|
||||
|
||||
|
||||
|
||||
TO DO NOTES:
|
||||
|
||||
"""
|
||||
import logging
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
from http.client import HTTPResponse
|
||||
from typing import Optional
|
||||
from pprint import pprint
|
||||
|
||||
path_hunks = os.path.abspath(__file__).split('/')
|
||||
while (path_hunks[-1] != 'lanforge-scripts'):
|
||||
path_hunks.pop()
|
||||
sys.path.append(os.path.join("/".join(path_hunks)))
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
lanforge_api = importlib.import_module("lanforge_client.lanforge_api")
|
||||
Logg = lanforge_api.Logg
|
||||
LFSession = lanforge_api.LFSession
|
||||
LFJsonCommand = lanforge_api.LFJsonCommand
|
||||
LFJsonQuery = lanforge_api.LFJsonQuery
|
||||
|
||||
|
||||
# from scenario import LoadScenario
|
||||
|
||||
|
||||
# print(pprint.pformat(("ospath", sys.path)))
|
||||
|
||||
class BssidMonitor(Realm):
|
||||
def __init__(self,
|
||||
host: str = "localhost",
|
||||
port: int = 8080,
|
||||
debug: bool = False,
|
||||
args: argparse = None,
|
||||
radio: str = None,
|
||||
ssid: str = None,
|
||||
security: str = None,
|
||||
password: str = None,
|
||||
upstream: str = None,
|
||||
mode: int = 0,
|
||||
side_a_min_rate: int = 256000,
|
||||
side_b_min_rate: int = 256000,
|
||||
test_duration_min: str = "5m",
|
||||
report_file: str = None,
|
||||
output_format: str = None,
|
||||
layer3_cols: list = None, # p3.9 list[str]
|
||||
port_mgr_cols=None,
|
||||
monitor_interval_sec: int = 10,
|
||||
bssid_list: list = None): # p3.9 list[str]
|
||||
"""
|
||||
lfclient_host="localhost",
|
||||
lfclient_port=8080,
|
||||
debug_=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False,
|
||||
_proxy_str=None,
|
||||
_capture_signal_list=[]
|
||||
:param host:
|
||||
:param port:
|
||||
:param radio:
|
||||
:param ssid:
|
||||
:param security:
|
||||
:param password:
|
||||
:param upstream:
|
||||
:param mode:
|
||||
:param side_a_min_rate:
|
||||
:param side_b_min_rate:
|
||||
:param test_duration_min:
|
||||
:param report_file:
|
||||
:param output_format:
|
||||
:param layer3_cols:
|
||||
:param port_mgr_cols:
|
||||
:param monitor_interval_sec:
|
||||
:param bssid_list:
|
||||
"""
|
||||
super().__init__(lfclient_host=host,
|
||||
lfclient_port=port,
|
||||
debug_=debug,
|
||||
_exit_on_error=True,
|
||||
_exit_on_fail=False)
|
||||
self.radio: str = radio
|
||||
self.ssid: str = ssid
|
||||
self.security: str = security
|
||||
self.password: str = password
|
||||
self.upstream: str = upstream
|
||||
self.mode: int = mode
|
||||
self.side_a_min_rate: int = side_a_min_rate
|
||||
self.side_b_min_rate: int = side_b_min_rate
|
||||
self.test_duration = test_duration_min
|
||||
self.report_file: str = report_file
|
||||
self.output_format: str = output_format
|
||||
self.port_mgr_cols: list = port_mgr_cols # p3.9 list[str]
|
||||
self.layer3_cols = layer3_cols # py 3.9.x tuple[Optional[list[str]]]
|
||||
# self.layer3_cols: tuple = layer3_cols # py 3.7.7
|
||||
self.monitor_interval_sec: int = monitor_interval_sec
|
||||
|
||||
if not bssid_list:
|
||||
raise ValueError("bssid list necessary to continue")
|
||||
self.bssid_list: list = bssid_list # p 3.9: list[str]
|
||||
self.bssid_sta_profiles: dict = {} #p3.9: dict[str,str]
|
||||
|
||||
'''
|
||||
session = LFSession(lfclient_url="http://localhost:8080",
|
||||
connect_timeout_sec=20,
|
||||
proxy_map={
|
||||
'http':'http://192.168.1.250:3128'
|
||||
},
|
||||
debug=True,
|
||||
die_on_error=False);'''
|
||||
|
||||
self.lf_session: LFSession = \
|
||||
lanforge_api.LFSession(lfclient_url="http://{host}:{port}/".format(host=host, port=port),
|
||||
debug=debug,
|
||||
connection_timeout_sec=2,
|
||||
stream_errors=True,
|
||||
stream_warnings=True,
|
||||
require_session=True,
|
||||
exit_on_error=True)
|
||||
if args and args.debugging:
|
||||
pprint(args.debugging)
|
||||
# we could have a nested list here?
|
||||
for item in args.debugging:
|
||||
if (type(item) is list):
|
||||
item = item[0]
|
||||
if item.startswith("tag:"):
|
||||
Logg.register_tag(item[item.rindex(":"):])
|
||||
if item.startswith("method:"):
|
||||
Logg.register_method_name(item[item.rindex(":"):])
|
||||
|
||||
self.lf_command: LFJsonCommand = self.lf_session.get_command()
|
||||
self.lf_query: LFJsonQuery = self.lf_session.get_query()
|
||||
|
||||
def build(self):
|
||||
# get last event id
|
||||
last_event_id = self.before_load_action()
|
||||
|
||||
# load a database
|
||||
response: HTTPResponse = self.lf_command.post_load(name="BLANK",
|
||||
action="overwrite",
|
||||
clean_dut="NA",
|
||||
clean_chambers="NA",
|
||||
debug=self.debug)
|
||||
|
||||
if not self.wait_for_load_to_finish(since_id=last_event_id):
|
||||
exit(1)
|
||||
|
||||
if not response:
|
||||
raise ConnectionError("lf_command::post_load returned no response")
|
||||
|
||||
# create a series of stations
|
||||
for bssid in self.bssid_list:
|
||||
print("build: bssid: %s" % bssid)
|
||||
|
||||
def before_load_action(self):
|
||||
"""
|
||||
Use this
|
||||
:return: last event ID in event list
|
||||
"""
|
||||
err_warn_list = []
|
||||
self.lf_command.post_show_events(p_type='all',
|
||||
shelf=1,
|
||||
card='all',
|
||||
port='all',
|
||||
endp='all')
|
||||
time.sleep(0.2)
|
||||
|
||||
event_response = self.lf_query.events_last_events(event_count=1,
|
||||
debug=self.debug,
|
||||
wait_sec=1,
|
||||
max_timeout_sec=120,
|
||||
errors_warnings=err_warn_list)
|
||||
if not event_response:
|
||||
Logg.logg(level=logging.ERROR, msg="No event_response, we should have retried that")
|
||||
return
|
||||
# pprint(("event_response:", event_response))
|
||||
if "id" not in event_response:
|
||||
pprint(("event_response:", event_response))
|
||||
return
|
||||
return event_response["id"]
|
||||
|
||||
def wait_for_load_to_finish(self, since_id: int = None):
|
||||
"""
|
||||
TODO: make this a standard method outside this module
|
||||
:param since_id:
|
||||
:return:
|
||||
"""
|
||||
completed = False
|
||||
timer = 0
|
||||
timeout = 60
|
||||
while not completed:
|
||||
new_events = self.lf_query.events_since(event_id=since_id)
|
||||
if new_events:
|
||||
for event_tup in new_events:
|
||||
for event_id in event_tup.keys():
|
||||
event_record = event_tup[event_id]
|
||||
if self.debug:
|
||||
pprint("\n wait_for_load_to_finish: {since} -> {id}: {descr}\n".format(
|
||||
since=since_id,
|
||||
id=event_id,
|
||||
descr=event_record['event description']
|
||||
))
|
||||
if event_record['event description'].startswith('LOAD COMPLETED'):
|
||||
completed = True
|
||||
self.lf_query.logger.warning('Scenario loaded after %s seconds' % timer)
|
||||
break
|
||||
if completed:
|
||||
break
|
||||
else:
|
||||
if (timer % 5) == 0:
|
||||
self.lf_command.post_show_events(p_type='all',
|
||||
shelf=1,
|
||||
card='all',
|
||||
port='all',
|
||||
endp='all')
|
||||
timer += 1
|
||||
time.sleep(1)
|
||||
if timer > timeout:
|
||||
completed = True
|
||||
print('Scenario failed to load after %s seconds' % timeout)
|
||||
break
|
||||
else:
|
||||
print('Waiting %s out of %s seconds to load scenario' % (timer, timeout))
|
||||
return completed
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = Realm.create_basic_argparse(
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
prog=__file__,
|
||||
epilog="",
|
||||
description="Monitor traffic to different APs and report connection stability")
|
||||
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--bssid',
|
||||
action='append', # action='extend' appears in py 3.9
|
||||
type=str,
|
||||
nargs="+",
|
||||
help='Add an AP to the list of APs to test connections to')
|
||||
#parser.add_argument('--debugging',
|
||||
# action='extend',
|
||||
# type=str,
|
||||
# nargs="+",
|
||||
# help='Debugging for specific areas: "tag:keyword" or "method:methodname" ')
|
||||
parser.add_argument('--output_format',
|
||||
type=str,
|
||||
help='choose either csv or xlsx')
|
||||
parser.add_argument('--report_file',
|
||||
default=None,
|
||||
type=str,
|
||||
help='where you want to store results')
|
||||
parser.add_argument('--a_min',
|
||||
default=256000,
|
||||
type=int,
|
||||
help='bps rate minimum for side_a')
|
||||
parser.add_argument('--b_min',
|
||||
default=256000,
|
||||
type=int,
|
||||
help='bps rate minimum for side_b')
|
||||
parser.add_argument('--test_duration_min',
|
||||
default="2",
|
||||
type=int,
|
||||
help='duration of the test in minutes')
|
||||
parser.add_argument('--layer3_cols',
|
||||
type=list, # py3.9 list[str]
|
||||
help='titles of columns to report')
|
||||
parser.add_argument('--port_mgr_cols',
|
||||
type=list, # py3.9 list[str]
|
||||
help='titles of columns to report')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# pprint.pprint(("args.members:", dir(args)))
|
||||
|
||||
bssid_monitor = BssidMonitor(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
debug=args.debug,
|
||||
args=args,
|
||||
radio=args.radio,
|
||||
ssid=args.ssid,
|
||||
security=args.security,
|
||||
password=args.passwd,
|
||||
upstream=args.upstream_port,
|
||||
mode=args.mode,
|
||||
side_a_min_rate=args.a_min,
|
||||
side_b_min_rate=args.b_min,
|
||||
test_duration_min=args.test_duration_min,
|
||||
report_file=args.report_file,
|
||||
output_format=args.output_format,
|
||||
layer3_cols=args.layer3_cols,
|
||||
port_mgr_cols=args.port_mgr_cols,
|
||||
monitor_interval_sec=10,
|
||||
bssid_list=args.bssid)
|
||||
|
||||
bssid_monitor.build()
|
||||
bssid_monitor.start()
|
||||
bssid_monitor.stop()
|
||||
bssid_monitor.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
#
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# script moved to sandbox 11/11/2021 - needs updates
|
||||
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
@@ -14,18 +17,20 @@ if sys.version_info[0] != 3:
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
class Layer3Test(LFCliBase):
|
||||
class Layer3Test(Realm):
|
||||
|
||||
def __init__(self, lfclient_host="localhost", lfclient_port=8080, radio="wiphy1", sta_prefix="sta", start_id=0, num_sta=2,
|
||||
dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="eth1", name_prefix="L3Test",
|
||||
traffic_type="lf_udp",side_a_speed="0M", side_b_speed="10M", session_id="Layer3Test", duration="1m",_debug_on=False, _exit_on_error=False, _exit_on_fail=False):
|
||||
super().__init__(lfclient_host, lfclient_port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
dut_ssid="lexusdut", dut_security="open", dut_passwd="[BLANK]", upstream="1.1.eth1", name_prefix="L3Test",
|
||||
traffic_type="lf_udp",
|
||||
side_a_min_rate=256000, side_a_max_rate=0,
|
||||
side_b_min_rate=256000, side_b_max_rate=0,
|
||||
session_id="Layer3Test", duration="1m",
|
||||
_debug_on=False, _exit_on_error=False, _exit_on_fail=False):
|
||||
super().__init__(lfclient_host=lfclient_host, lfclient_port=lfclient_port, debug_=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
print("Test is about to start")
|
||||
self.host = lfclient_host
|
||||
self.port = lfclient_port
|
||||
@@ -42,29 +47,27 @@ class Layer3Test(LFCliBase):
|
||||
self.password = dut_passwd
|
||||
self.session_id = session_id
|
||||
self.traffic_type = traffic_type
|
||||
self.side_a_speed = side_a_speed
|
||||
self.side_b_speed = side_b_speed
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.cx_profile = self.local_realm.new_l3_cx_profile()
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.cx_profile = self.new_l3_cx_profile()
|
||||
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
self.cx_profile.name_prefix = self.name_prefix
|
||||
self.cx_profile.side_a_min_bps = self.local_realm.parse_speed(self.side_a_speed)
|
||||
self.cx_profile.side_a_max_bps = self.local_realm.parse_speed(self.side_a_speed)
|
||||
self.cx_profile.side_b_min_bps = self.local_realm.parse_speed(self.side_b_speed)
|
||||
self.cx_profile.side_b_max_bps = self.local_realm.parse_speed(self.side_b_speed)
|
||||
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_b_min_bps = side_b_min_rate
|
||||
self.cx_profile.side_b_max_bps = side_b_max_rate
|
||||
|
||||
print("Test is Initialized")
|
||||
|
||||
|
||||
def precleanup(self):
|
||||
print("precleanup started")
|
||||
self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id, end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio)
|
||||
self.station_list = LFUtils.portNameSeries(prefix_=self.sta_prefix, start_id_=self.sta_start_id,
|
||||
end_id_=self.num_sta - 1, padding_number_=10000, radio=self.radio)
|
||||
self.cx_profile.cleanup_prefix()
|
||||
for sta in self.station_list:
|
||||
self.local_realm.rm_port(sta, check_exists=True)
|
||||
self.rm_port(sta, check_exists=True)
|
||||
time.sleep(1)
|
||||
self.cx_profile.cleanup()
|
||||
|
||||
@@ -81,8 +84,9 @@ class Layer3Test(LFCliBase):
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.station_list, debug=self.debug)
|
||||
self.local_realm.wait_until_ports_appear(sta_list=self.station_list)
|
||||
self.cx_profile.create(endp_type=self.traffic_type, side_a=self.station_profile.station_names, side_b=self.upstream, sleep_time=0)
|
||||
self.wait_until_ports_appear(sta_list=self.station_list)
|
||||
self.cx_profile.create(endp_type=self.traffic_type, side_a=self.station_profile.station_names,
|
||||
side_b=self.upstream, sleep_time=0)
|
||||
print("Test Build done")
|
||||
pass
|
||||
|
||||
@@ -92,7 +96,7 @@ class Layer3Test(LFCliBase):
|
||||
self.station_profile.admin_up()
|
||||
temp_stas = self.station_profile.station_names.copy()
|
||||
temp_stas.append(self.upstream)
|
||||
if (self.local_realm.wait_for_ip(temp_stas)):
|
||||
if self.wait_for_ip(temp_stas):
|
||||
self._pass("All stations got IPs", print_pass)
|
||||
else:
|
||||
self._fail("Stations failed to get IPs", print_fail)
|
||||
@@ -101,13 +105,13 @@ class Layer3Test(LFCliBase):
|
||||
try:
|
||||
for i in self.cx_profile.get_cx_names():
|
||||
self.cx_names.append(i)
|
||||
while self.local_realm.json_get("/cx/" + i).get(i).get('state') != 'Run':
|
||||
while self.json_get("/cx/" + i).get(i).get('state') != 'Run':
|
||||
continue
|
||||
except Exception as e:
|
||||
pass
|
||||
print("Test Started")
|
||||
self.cur_time = datetime.datetime.now()
|
||||
self.end_time = self.local_realm.parse_time(self.test_duration) + self.cur_time
|
||||
self.end_time = self.parse_time(self.test_duration) + self.cur_time
|
||||
print(self.end_time-self.cur_time)
|
||||
self.start_monitor()
|
||||
pass
|
||||
@@ -136,8 +140,12 @@ class Layer3Test(LFCliBase):
|
||||
pass
|
||||
|
||||
def main():
|
||||
# This has --mgr, --mgr_port and --debug
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
# Realm.create_basic_argparse defined in
|
||||
# /py-json/LANforge/lfcli_base.py
|
||||
# args --mgr --mgr_port --upstream_port --num_stations --test_id
|
||||
# --debug --proxy --debugging --debug_log
|
||||
# --radio --security --ssid --passwd
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog="layer3_test.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog="About This Script")
|
||||
@@ -156,7 +164,9 @@ def main():
|
||||
obj = Layer3Test(lfclient_host=args.mgr, lfclient_port=args.mgr_port,
|
||||
duration=args.test_duration, session_id=args.session_id,
|
||||
traffic_type=args.traffic_type,
|
||||
dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, num_sta=args.num_client, side_a_speed=args.side_a_min_speed, side_b_speed=args.side_b_min_speed, radio=args.radio)
|
||||
upstream=args.upstream_port,
|
||||
dut_ssid=args.ssid, dut_passwd=args.passwd, dut_security=args.security, num_sta=args.num_client,
|
||||
side_a_min_rate=args.side_a_min_speed, side_b_min_rate=args.side_b_min_speed, radio=args.radio,_debug_on=args.debug)
|
||||
obj.precleanup()
|
||||
obj.build()
|
||||
obj.start()
|
||||
@@ -5,7 +5,11 @@ Candela Technologies Inc.
|
||||
Info : Standard Script for Layer 4 Testing
|
||||
Date :
|
||||
Author : Shivam Thakur
|
||||
|
||||
|
||||
"""
|
||||
|
||||
# script moved to sandbox 11/11/2021 needs work
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
607
py-scripts/sandbox/lf_qa_dash.py
Executable file
607
py-scripts/sandbox/lf_qa_dash.py
Executable file
@@ -0,0 +1,607 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
File: read kpi.csv place in sql database, create png of historical kpi and present graph on dashboard
|
||||
Usage: kpi_csv_sq.py --store --png --show --path <path to directories to traverse> --database <name of database>
|
||||
Example: kpi_csv_sq.py --show (show dashboard generated from database)
|
||||
Example: kpi_csv_sq.py --store --png --show --path <path to read kpi.csv> (read kpi.csv store to database, write png, show dashboard )
|
||||
'''
|
||||
# visit http://127.0.0.1:8050/ in your web browser.
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import dash
|
||||
import dash_core_components as dcc
|
||||
import dash_html_components as html
|
||||
import plotly.express as px
|
||||
import pandas as pd
|
||||
import sqlite3
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||
|
||||
lf_report = importlib.import_module("py-scripts.lf_report")
|
||||
lf_report = lf_report.lf_report
|
||||
|
||||
# Any style components can be used
|
||||
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
|
||||
class csv_sqlite_dash():
|
||||
def __init__(self,
|
||||
_path = '.',
|
||||
_file = 'kpi.csv',
|
||||
_database = 'qa_db',
|
||||
_table = 'qa_table',
|
||||
_server = 'http://192.168.95.6/',
|
||||
_cut = '/home/lanforge/',
|
||||
_png = False):
|
||||
self.path = _path
|
||||
self.file = _file
|
||||
self.database = _database
|
||||
self.table = _table
|
||||
self.server = _server
|
||||
self.cut = _cut
|
||||
self.png = _png
|
||||
self.png_generated = False
|
||||
self.kpi_list = []
|
||||
self.html_list = []
|
||||
self.conn = None
|
||||
self.df = pd.DataFrame()
|
||||
self.plot_figure = []
|
||||
self.children_div = []
|
||||
self.html_results =""
|
||||
self.test_rig_list = []
|
||||
self.server_html_reports = self.server + 'html-reports/' #TODO : hard coded - is this needed? have server
|
||||
self.server_started = False
|
||||
self.dut_model_num_list = "NA"
|
||||
self.dut_model_num = "NA"
|
||||
self.dut_sw_version_list = "NA"
|
||||
self.dut_sw_version = "NA"
|
||||
self.dut_hw_version_list = "NA"
|
||||
self.dut_hw_version = "NA"
|
||||
self.dut_serial_num_list = "NA"
|
||||
self.dut_serial_num = "NA"
|
||||
|
||||
self.app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
|
||||
# https://community.plotly.com/t/putting-a-dash-instance-inside-a-class/6097/3
|
||||
#https://dash.plotly.com/dash-html-components/button
|
||||
#self.app.callback(dash.dependencies.Output('container-button-basic', 'children'),
|
||||
# [dash.dependencies.Input(component_id ='submit-val', component_property ='n_clicks')])(self.show)
|
||||
|
||||
# Helper methods
|
||||
def get_test_rig_list(self):
|
||||
return self.test_rig_list
|
||||
|
||||
def get_html_results(self):
|
||||
return self.html_results
|
||||
|
||||
def get_dut_info(self):
|
||||
#try:
|
||||
print("get_dut_info DUT: {DUT} SW:{SW} HW:{HW} SN:{SN}"
|
||||
.format(DUT=self.dut_model_num,SW=self.dut_sw_version,HW=self.dut_hw_version,SN=self.dut_serial_num))
|
||||
|
||||
dut_dict = {
|
||||
'DUT':[self.dut_model_num],
|
||||
'SW version': [self.dut_sw_version],
|
||||
'HW version':[self.dut_hw_version],
|
||||
'SN':[self.dut_serial_num]
|
||||
}
|
||||
print('DUT dict: {dict}'.format(dict=dut_dict))
|
||||
dut_info_df = pd.DataFrame(dut_dict)
|
||||
print("DUT df from dict: {df}".format(df=dut_info_df))
|
||||
|
||||
return dut_info_df
|
||||
|
||||
def get_parent_path(self,_path):
|
||||
parent_path = os.path.dirname(_path)
|
||||
return parent_path
|
||||
|
||||
def get_test_id_test_tag(self,_kpi_path):
|
||||
test_id = "NA"
|
||||
test_tag = "NA"
|
||||
use_meta_test_tag = False
|
||||
try:
|
||||
kpi_df = pd.read_csv(_kpi_path, sep='\t')
|
||||
test_id_list = list(kpi_df['test-id'])
|
||||
test_id = list(set(test_id_list))
|
||||
test_id = test_id[-1] # done to get element of list
|
||||
except:
|
||||
print("exception reading test_id in csv _kpi_path {kpi_path}".format(kpi_path=_kpi_path))
|
||||
try:
|
||||
test_tag_list = list(kpi_df['test-tag'])
|
||||
test_tag = list(set(test_tag_list))
|
||||
test_tag = test_tag[-1] # done to get element of list
|
||||
except:
|
||||
print("exception reading test-tag in csv _kpi_path {kpi_path}, try meta.txt".format(kpi_path=_kpi_path))
|
||||
|
||||
#if test_tag still NA then try meta file
|
||||
try:
|
||||
if test_tag == "NA":
|
||||
_kpi_path = _kpi_path.replace('kpi.csv','')
|
||||
use_meta_test_tag, test_tag = self.get_test_tag_from_meta(_kpi_path)
|
||||
except:
|
||||
print("exception reading meta.txt _kpi_path: {kpi_path}".format(kpi_path=_kpi_path))
|
||||
if use_meta_test_tag:
|
||||
print("test_tag from meta.txt _kpi_path: {kpi_path}".format(kpi_path=_kpi_path))
|
||||
return test_id , test_tag
|
||||
|
||||
# could enter on the command line, except there may be other exceptions
|
||||
# may need an exception file
|
||||
def get_test_tag_from_meta(self,_kpi_path):
|
||||
test_tag = "NA"
|
||||
use_meta_test_tag = False
|
||||
gui_version_5_4_3 = False
|
||||
print("read meta path {_kpi_path}".format(_kpi_path=_kpi_path))
|
||||
try:
|
||||
meta_data_path = _kpi_path + '/' + '/meta.txt'
|
||||
meta_data_fd = open(meta_data_path, 'r')
|
||||
for line in meta_data_fd:
|
||||
if "gui_version:" in line:
|
||||
gui_version = line.replace("gui_version:","")
|
||||
gui_version = gui_version.strip()
|
||||
if gui_version =='5.4.3':
|
||||
gui_version_5_4_3 = True
|
||||
use_meta_test_tag = True
|
||||
print("meta_data_path: {meta_data_path} gui_version: {gui_version} 5.4.3: {gui_version_5_4_3}".format(
|
||||
meta_data_path=meta_data_path,gui_version=gui_version,gui_version_5_4_3=gui_version_5_4_3))
|
||||
meta_data_fd.close()
|
||||
if gui_version_5_4_3:
|
||||
meta_data_fd = open(meta_data_path, 'r')
|
||||
test_tag = 'NA'
|
||||
for line in meta_data_fd:
|
||||
if "test_tag" in line:
|
||||
test_tag = line.replace("test_tag","")
|
||||
test_tag = test_tag.strip()
|
||||
print("meta_data_path {meta_data_path} test_tag {test_tag}".format(meta_data_path=meta_data_path,test_tag=test_tag))
|
||||
meta_data_fd.close()
|
||||
except:
|
||||
print("exception reading test_tag from {_kpi_path}".format(_kpi_path=_kpi_path))
|
||||
|
||||
return use_meta_test_tag, test_tag
|
||||
|
||||
#TODO pass in list to lf_report
|
||||
# <table border="1" class="dataframe">
|
||||
def get_suite_html(self):
|
||||
suite_html_results = """
|
||||
<table class="dataframe" border="1">
|
||||
<thead>
|
||||
<tr style="text-align: center;">
|
||||
<th>Test</th>
|
||||
<th>Test_Tag</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
"""
|
||||
|
||||
path = Path(self.path)
|
||||
pdf_info_list= list(path.glob('**/*.pdf')) # Hard code for now
|
||||
print("pdf_info_list {}".format(pdf_info_list))
|
||||
for pdf_info in pdf_info_list:
|
||||
if "lf_qa" in str(pdf_info):
|
||||
pass
|
||||
else:
|
||||
pdf_base_name = os.path.basename(pdf_info)
|
||||
if "check" in str(pdf_base_name):
|
||||
pass
|
||||
else:
|
||||
parent_path = os.path.dirname(pdf_info)
|
||||
pdf_path = os.path.join(parent_path,pdf_base_name)
|
||||
pdf_path = self.server + pdf_path.replace(self.cut,'')
|
||||
html_path = os.path.join(parent_path,"index.html")
|
||||
html_path = self.server + html_path.replace(self.cut,'')
|
||||
kpi_path = os.path.join(parent_path,"kpi.csv")
|
||||
test_id, test_tag = self.get_test_id_test_tag(kpi_path)
|
||||
suite_html_results += """
|
||||
<tr style="text-align: center; margin-bottom: 0; margin-top: 0;">
|
||||
<td>{test_id}</td><td>{test_tag}</td><td><a href="{html_path}" target="_blank">html</a> / <a href="{pdf_path}" target="_blank">pdf</a></td></tr>
|
||||
""".format(test_id=test_id,test_tag=test_tag,html_path=html_path,pdf_path=pdf_path)
|
||||
suite_html_results += """
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
"""
|
||||
|
||||
return suite_html_results
|
||||
|
||||
def get_kpi_chart_html(self):
|
||||
kpi_chart_html = """
|
||||
<table border="0">
|
||||
<tbody>
|
||||
"""
|
||||
path = Path(self.path)
|
||||
kpi_chart_list= list(path.glob('**/kpi-chart*.png')) # Hard code for now
|
||||
table_index = 0
|
||||
for kpi_chart in kpi_chart_list:
|
||||
parent_path = os.path.dirname(kpi_chart)
|
||||
kpi_path = os.path.join(parent_path,"kpi.csv")
|
||||
test_tag , test_id = self.get_test_id_test_tag(kpi_path)
|
||||
kpi_chart = os.path.abspath(kpi_chart) # Path returns a list of objects
|
||||
kpi_chart = self.server + kpi_chart.replace(self.cut,'')
|
||||
if "print" in kpi_chart:
|
||||
pass
|
||||
else:
|
||||
if (table_index %2) == 0:
|
||||
kpi_chart_html += """<tr>"""
|
||||
kpi_chart_html += """
|
||||
<td>
|
||||
{test_tag} {test_id}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{kpi_chart_0}" target="_blank">
|
||||
<img src="{kpi_chart_1}" style="width:400px;max-width:400px" title="{kpi_chart_2}">
|
||||
</a>
|
||||
</td>
|
||||
""".format(test_tag=test_tag,test_id=test_id,kpi_chart_0=kpi_chart,kpi_chart_1=kpi_chart,kpi_chart_2=kpi_chart)
|
||||
table_index += 1
|
||||
if (table_index %2) == 0:
|
||||
kpi_chart_html += """</tr>"""
|
||||
if (table_index %2) != 0:
|
||||
kpi_chart_html += """</tr>"""
|
||||
kpi_chart_html += """</tbody></table>"""
|
||||
return kpi_chart_html
|
||||
|
||||
# information on sqlite database
|
||||
# https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_sql.html
|
||||
def store(self):
|
||||
print("reading kpi and storing in db {}".format(self.database))
|
||||
path = Path(self.path)
|
||||
self.kpi_list = list(path.glob('**/kpi.csv')) # Hard code for now
|
||||
|
||||
if not self.kpi_list:
|
||||
print("WARNING: used --store , no new kpi.csv found, check input path or remove --store from command line")
|
||||
|
||||
for kpi in self.kpi_list: #TODO note empty kpi.csv failed test
|
||||
df_kpi_tmp = pd.read_csv(kpi, sep='\t')
|
||||
_kpi_path = str(kpi).replace('kpi.csv','') # only store the path to the kpi.csv file
|
||||
df_kpi_tmp['kpi_path'] = _kpi_path
|
||||
use_meta_test_tag, test_tag = self.get_test_tag_from_meta(_kpi_path)
|
||||
if use_meta_test_tag:
|
||||
df_kpi_tmp['test-tag'] = test_tag
|
||||
df_kpi_tmp = df_kpi_tmp.append(df_kpi_tmp, ignore_index=True)
|
||||
self.df = self.df.append(df_kpi_tmp, ignore_index=True)
|
||||
|
||||
self.conn = sqlite3.connect(self.database)
|
||||
try:
|
||||
self.df.to_sql(self.table,self.conn,if_exists='append')
|
||||
except:
|
||||
print("attempt to append to database with different column layout, caused an exception, input new name --database <new name>")
|
||||
print("Error attempt to append to database with different column layout, caused an exception, input new name --database <new name>", file=sys.stderr)
|
||||
exit(1)
|
||||
self.conn.close()
|
||||
|
||||
def generate_graph_png(self):
|
||||
print("generate png and html to display, generate time: {}".format(time.time()))
|
||||
|
||||
#https://datacarpentry.org/python-ecology-lesson/09-working-with-sql/index.html-
|
||||
self.conn = sqlite3.connect(self.database)
|
||||
df3 = pd.read_sql_query("SELECT * from {}".format(self.table) ,self.conn) #current connection is sqlite3 /TODO move to SQLAlchemy
|
||||
# sort by date from oldest to newest.
|
||||
try:
|
||||
df3 = df3.sort_values(by='Date')
|
||||
except:
|
||||
print("Database empty: KeyError(key) when sorting by Date, check Database name, path to kpi, typo in path, exiting")
|
||||
exit(1)
|
||||
self.conn.close()
|
||||
|
||||
# graph group and test-tag are used for detemining the graphs, can use any columns
|
||||
# the following list manipulation removes the duplicates
|
||||
graph_group_list = list(df3['Graph-Group'])
|
||||
graph_group_list = list(set(graph_group_list))
|
||||
print("graph_group_list: {}".format(graph_group_list))
|
||||
|
||||
# prior to 5.4.3 there was not test-tag
|
||||
#try:
|
||||
print("dataframe df3 {df3}".format(df3=df3))
|
||||
test_tag_list = list(df3['test-tag'])
|
||||
test_tag_list = list(set(test_tag_list))
|
||||
print("test_tag_list: {}".format(test_tag_list) )
|
||||
#except:
|
||||
#test_tag_list = ['NO_TAG_PRE_5.4.4']
|
||||
#print("exception when creating test_tag_list: {}".format(test_tag_list) )
|
||||
#print("Check database, exception when creating test_tag_list: {}".format(test_tag_list) )
|
||||
|
||||
|
||||
|
||||
test_rig_list = list(df3['test-rig'])
|
||||
test_rig_list = list(set(test_rig_list))
|
||||
self.test_rig_list = test_rig_list
|
||||
print("test_rig_list: {}".format(test_rig_list) )
|
||||
|
||||
self.children_div.append(html.A('html_reports', href=self.server_html_reports, target='_blank'))
|
||||
for test_rig in test_rig_list:
|
||||
for test_tag in test_tag_list:
|
||||
for group in graph_group_list:
|
||||
df_tmp = df3.loc[(df3['test-rig'] == test_rig) & (df3['Graph-Group'] == str(group)) & (df3['test-tag'] == str(test_tag))]
|
||||
if df_tmp.empty == False:
|
||||
|
||||
df_tmp = df_tmp.sort_values(by='Date')
|
||||
test_id_list = list(df_tmp['test-id'])
|
||||
kpi_path_list = list(df_tmp['kpi_path'])
|
||||
# get Device Under Test Information ,
|
||||
# the set reduces the redundency , list puts it back into a list
|
||||
self.dut_model_num_list = list(set(list(df_tmp['dut-model-num'])))
|
||||
print("in png self.dut_model_num_list {dut_model_num_list}".format(dut_model_num_list=self.dut_model_num_list))
|
||||
if self.dut_model_num_list[0] != None:
|
||||
self.dut_model_num = self.dut_model_num_list[0]
|
||||
self.dut_sw_version_list = list(set(list(df_tmp['dut-sw-version'])))
|
||||
if self.dut_sw_version_list[0] != None:
|
||||
self.dut_sw_version = self.dut_sw_version_list[0]
|
||||
self.dut_hw_version_list = list(set(list(df_tmp['dut-hw-version'])))
|
||||
if self.dut_hw_version_list[0] != None:
|
||||
self.dut_hw_version = self.dut_hw_version_list[0]
|
||||
self.dut_serial_num_list = list(set(list(df_tmp['dut-serial-num'])))
|
||||
if self.dut_serial_num_list[0] != None:
|
||||
self.dut_serial_num_ = self.dut_serial_num_list[0]
|
||||
|
||||
print("In png DUT: {DUT} SW:{SW} HW:{HW} SN:{SN}"
|
||||
.format(DUT=self.dut_model_num_list,SW=self.dut_sw_version_list,HW=self.dut_hw_version_list,SN=self.dut_serial_num_list))
|
||||
|
||||
units_list = list(df_tmp['Units'])
|
||||
print("GRAPHING::: test-rig {} test-tag {} Graph-Group {}".format(test_rig,test_tag,group))
|
||||
kpi_fig = (px.scatter(df_tmp, x="Date", y="numeric-score",
|
||||
color="short-description", hover_name="short-description",
|
||||
size_max=60)).update_traces(mode='lines+markers')
|
||||
|
||||
kpi_fig.update_layout(
|
||||
title="{} : {} : {} : {}".format(test_id_list[-1], group, test_tag, test_rig),
|
||||
xaxis_title="Time",
|
||||
yaxis_title="{}".format(units_list[-1]),
|
||||
xaxis = {'type' : 'date'}
|
||||
)
|
||||
# save the figure - figures will be over written png
|
||||
# for testing
|
||||
png_server_img = ''
|
||||
#TODO work out when to generate the png files
|
||||
if self.png:
|
||||
if self.png_generated:
|
||||
pass
|
||||
else:
|
||||
print("generate png and kpi images from kpi kpi_path:{}".format(df_tmp['kpi_path']))
|
||||
# generate png img path
|
||||
png_path = os.path.join(kpi_path_list[-1],"{}_{}_{}_kpi.png".format( group, test_tag, test_rig))
|
||||
png_path = png_path.replace(' ','')
|
||||
# generate html graphics path
|
||||
html_path = os.path.join(kpi_path_list[-1],"{}_{}_{}_kpi.html".format( group, test_tag, test_rig))
|
||||
html_path = html_path.replace(' ','')
|
||||
# NOTE: html links to png do not like spaces
|
||||
png_server_img = self.server + png_path.replace(self.cut,'')
|
||||
# generate png image
|
||||
try:
|
||||
kpi_fig.write_image(png_path,scale=1,width=1200,height=350)
|
||||
except:
|
||||
print("ERROR: {database} Was correct database passed in, moved or duplicates of same name?".format(database=self.database))
|
||||
#https://plotly.com/python/interactive-html-export/
|
||||
# generate html image (interactive)
|
||||
kpi_fig.write_html(html_path)
|
||||
# generate link for dashboard
|
||||
self.children_div.append(html.Img(src=png_server_img))
|
||||
#HERE add clickable link
|
||||
img_kpi_html_path = self.server + html_path
|
||||
img_kpi_html_path = img_kpi_html_path.replace(self.cut,'')
|
||||
|
||||
self.html_results += """
|
||||
<a href={img_kpi_html_path} target="_blank">
|
||||
<img src={png_server_img}>
|
||||
</a>
|
||||
""".format(img_kpi_html_path=img_kpi_html_path,png_server_img=png_server_img)
|
||||
|
||||
# WARNING: DO NOT USE os.path.join will use the path for where the script is RUN which can be container.
|
||||
# Constructed path to server manually.
|
||||
# link to interactive results
|
||||
kpi_html_path = self.server + html_path
|
||||
kpi_html_path = kpi_html_path.replace(self.cut,'')
|
||||
self.children_div.append(html.Br())
|
||||
#self.html_results +="""<br>"""
|
||||
self.children_div.append(html.A('{test_id}_{group}_{test_tag}_{test_rig}_kpi.html'
|
||||
.format(test_id=test_id_list[-1], group=group, test_tag=test_tag, test_rig=test_rig),
|
||||
href=kpi_html_path, target='_blank'))
|
||||
|
||||
# link to full test results
|
||||
report_index_html_path = self.server + kpi_path_list[-1] + "index.html"
|
||||
report_index_html_path = report_index_html_path.replace(self.cut,'')
|
||||
self.children_div.append(html.Br())
|
||||
#self.html_results +="""<br>"""
|
||||
self.children_div.append(html.A('{test_id}_{group}_{test_tag}_{test_rig}_report.html'
|
||||
.format(test_id=test_id_list[-1], group=group, test_tag=test_tag, test_rig=test_rig),
|
||||
href=report_index_html_path, target='_blank'))
|
||||
self.html_results +="""<a href={report_index_html_path} target="_blank">{test_id}_{group}_{test_tag}_{test_rig}_Report </a>
|
||||
""".format(report_index_html_path=report_index_html_path,test_id=test_id_list[-1], group=group, test_tag=test_tag, test_rig=test_rig)
|
||||
self.children_div.append(html.Br())
|
||||
self.children_div.append(html.Br())
|
||||
self.children_div.append(html.Br())
|
||||
self.html_results +="""<br>"""
|
||||
self.html_results +="""<br>"""
|
||||
self.html_results +="""<br>"""
|
||||
self.html_results +="""<br>"""
|
||||
self.html_results +="""<br>"""
|
||||
|
||||
# TODO see if this stops the regenration of the graphs each time
|
||||
self.png_generated = True
|
||||
|
||||
|
||||
# access from server
|
||||
# https://stackoverflow.com/questions/61678129/how-to-access-a-plotly-dash-app-server-via-lan
|
||||
#def show(self,n_clicks):
|
||||
def show(self):
|
||||
# gererate dash display
|
||||
#print("refreshes: {}".format(n_clicks))
|
||||
self.generate_graph_png()
|
||||
if not self.children_div:
|
||||
print("NOTE: test-tag may not be present in the kpi thus no results generated")
|
||||
print("show: {}".format(time.time()))
|
||||
self.app.layout = html.Div([
|
||||
html.Div(id='my-output'),
|
||||
html.H1(children= "LANforge Testing",className="lanforge",
|
||||
style={'color':'green','text-align':'center'}),
|
||||
#For dash refresh # html.Button('Submit Recalculate',id='submit-val', n_clicks=0),
|
||||
#For dash refresh # html.Div(id='container-button-basic', children='to recalculate hit submit'),
|
||||
html.H2(children= "Results",className="ts1",
|
||||
style={'color':'#00361c','text-align':'left'}),
|
||||
# images_div is already a list, children = a list of html components
|
||||
# remove scrolling : html.Div(children= self.children_div, style={"maxHeight": "600px", "overflow": "scroll"} ),
|
||||
html.Div(children= self.children_div ),
|
||||
html.A('www.candelatech.com',href='http://www.candelatech.com', target='_blank',
|
||||
style={'color':'#00361c','text-align':'left'}),
|
||||
])
|
||||
|
||||
# save as standalone files
|
||||
#https://plotly.com/python/static-image-export/
|
||||
|
||||
if self.server_started:
|
||||
print("refresh complete")
|
||||
pass
|
||||
else:
|
||||
self.server_started = True
|
||||
print("self.server_started {}".format(self.server_started))
|
||||
#NOTE: the server_started flag needs to be set prior to run_server (or you get to debug an infinite loop)
|
||||
#NOTE: debug=False will prevent init going though twice, also stops auto reload when editing code
|
||||
self.app.run_server(host= '0.0.0.0', debug=True)
|
||||
# host = '0.0.0.0' allows for remote access, local debug host = '127.0.0.1'
|
||||
# app.run_server(host= '0.0.0.0', debug=True)
|
||||
|
||||
# Feature, Sum up the subtests passed/failed from the kpi files for each run, poke those into the database, and generate a kpi graph for them.
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='lf_qa.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
read kpi.csv into sqlite database , save png of history and preset on dashboard
|
||||
|
||||
''',
|
||||
description='''\
|
||||
File: read kpi.csv place in sql database, create png of historical kpi and present graph on dashboard
|
||||
Usage: kpi_csv_sq.py --store --png --show --path <path to directories to traverse> --database <name of database>
|
||||
Example: kpi_csv_sq.py --show (show dashboard generated from database)
|
||||
Example: kpi_csv_sq.py --store --png --show --path <path to read kpi.csv> (read kpi.csv store to database, write png, show dashboard )
|
||||
|
||||
''')
|
||||
parser.add_argument('--path', help='--path top directory path to kpi if regererating database or png files',default='')
|
||||
parser.add_argument('--file', help='--file kpi.csv default: kpi.csv',default='kpi.csv') #TODO is this needed
|
||||
parser.add_argument('--database', help='--database qa_test_db default: qa_test_db',default='qa_test_db')
|
||||
parser.add_argument('--table', help='--table qa_table default: qa_table',default='qa_table')
|
||||
parser.add_argument('--server', help='--server http://<server ip>/ default: http://192.168.95.6/',default='http://192.168.95.6/')
|
||||
parser.add_argument('--cut', help='--cut /home/lanforge/ used to adjust server path default: /home/lanforge/',default='/home/lanforge/')
|
||||
parser.add_argument('--store', help='--store , store kpi to db, action store_true',action='store_true')
|
||||
parser.add_argument('--png', help='--png, generate png for kpi in path, generate display, action store_true',action='store_true')
|
||||
parser.add_argument('--show', help='--show generate display and show dashboard, action store_true',action='store_true')
|
||||
parser.add_argument('--dir', help="--dir <results directory> default lf_qa", default="lf_qa")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
__path = args.path
|
||||
__file = args.file
|
||||
__database = args.database
|
||||
__table = args.table
|
||||
__server = args.server
|
||||
__png = args.png
|
||||
__dir = args.dir
|
||||
__cut = args.cut
|
||||
|
||||
# needed for refresh button
|
||||
# n_clicks = 0
|
||||
|
||||
print("config: path:{} file:{} database:{} table:{} server:{} store:{} png:{} show:{} "
|
||||
.format(__path,__file,__database,__table,__server,args.store, args.png,args.show))
|
||||
|
||||
if(__path == '' and args.store == True):
|
||||
print("--path <path of kpi.csv> must be entered if --store , exiting")
|
||||
exit(1)
|
||||
|
||||
if(args.png == True and args.store == False):
|
||||
print("if --png set to create png files then --store must also be set, exiting")
|
||||
exit(1)
|
||||
|
||||
if(args.png == True and args.show == True):
|
||||
print("generating png files will effect initial display performance")
|
||||
|
||||
if args.store == False and args.png == False and args.show == False:
|
||||
print("Need to enter an action of --store --png --show ")
|
||||
|
||||
# create report class for reporting
|
||||
report = lf_report(_path = __path,
|
||||
_results_dir_name =__dir,
|
||||
_output_html="lf_qa.html",
|
||||
_output_pdf="lf_qa.pdf" )
|
||||
|
||||
csv_dash = csv_sqlite_dash(
|
||||
_path = __path,
|
||||
_file = __file,
|
||||
_database = __database,
|
||||
_table = __table,
|
||||
_server = __server,
|
||||
_cut = __cut,
|
||||
_png = __png)
|
||||
if args.store:
|
||||
csv_dash.store()
|
||||
if args.png:
|
||||
csv_dash.generate_graph_png()
|
||||
|
||||
# generate output reports
|
||||
report.set_title("LF QA: Verification Test Run")
|
||||
report.build_banner_left()
|
||||
report.start_content_div2()
|
||||
report.set_obj_html("Objective", "QA Verification")
|
||||
report.build_objective()
|
||||
report.set_table_title("Device Under Test")
|
||||
report.build_table_title()
|
||||
dut_info_df = csv_dash.get_dut_info()
|
||||
print("DUT Results: {}".format(dut_info_df))
|
||||
report.set_table_dataframe(dut_info_df)
|
||||
report.build_table()
|
||||
|
||||
test_rig_list = csv_dash.get_test_rig_list()
|
||||
report.set_table_title("Test Rig: {} Links".format(test_rig_list[-1])) # keep the list, currently one test bed results
|
||||
report.build_table_title()
|
||||
|
||||
pdf_link_path = report.get_pdf_path()
|
||||
pdf_link_path = __server + pdf_link_path.replace(__cut,'')
|
||||
report.build_pdf_link("PDF_Report",pdf_link_path)
|
||||
|
||||
report_path = report.get_path()
|
||||
report_path = __server + report_path.replace(__cut,'')
|
||||
report.build_link("Current Test Suite Results Directory",report_path)
|
||||
|
||||
report_parent_path = report.get_parent_path()
|
||||
report_parent_path = __server + report_parent_path.replace(__cut,'')
|
||||
report.build_link("All Test-Rig Test Suites Results Directory",report_parent_path)
|
||||
|
||||
# links table for tests TODO : can this be a table
|
||||
report.set_table_title("Test Suite")
|
||||
report.build_table_title()
|
||||
suite_html = csv_dash.get_suite_html()
|
||||
print("suite_html {}".format(suite_html))
|
||||
report.set_custom_html(suite_html)
|
||||
report.build_custom()
|
||||
|
||||
# png summary of test
|
||||
report.set_table_title("Suite Summary")
|
||||
report.build_table_title()
|
||||
kpi_chart_html = csv_dash.get_kpi_chart_html()
|
||||
report.set_custom_html(kpi_chart_html)
|
||||
report.build_custom()
|
||||
|
||||
|
||||
report.set_table_title("QA Test Results")
|
||||
report.build_table_title()
|
||||
# report.set_text("lanforge-scripts git sha: {}".format(git_sha))
|
||||
# report.build_text()
|
||||
html_results = csv_dash.get_html_results()
|
||||
report.set_custom_html(html_results)
|
||||
report.build_custom()
|
||||
report.build_footer()
|
||||
html_report = report.write_html_with_timestamp()
|
||||
print("html report: {}".format(html_report))
|
||||
try:
|
||||
report.write_pdf_with_timestamp()
|
||||
except:
|
||||
print("exception write_pdf_with_timestamp()")
|
||||
|
||||
if args.show:
|
||||
#csv_dash.show(n_clicks)
|
||||
csv_dash.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
51
py-scripts/sandbox/logger_example.py
Executable file
51
py-scripts/sandbox/logger_example.py
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import logging
|
||||
from random import choice
|
||||
logging.basicConfig()
|
||||
|
||||
|
||||
class ContextFilter(logging.Filter):
|
||||
"""
|
||||
This is a filter which injects contextual information into the log.
|
||||
|
||||
Rather than use actual contextual information, we just use random
|
||||
data in this demo.
|
||||
"""
|
||||
|
||||
USERS = ['jim', 'fred', 'sheila']
|
||||
IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']
|
||||
|
||||
def filter(self, record):
|
||||
|
||||
record.ip = choice(ContextFilter.IPS)
|
||||
record.user = choice(ContextFilter.USERS)
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s')
|
||||
a1 = logging.getLogger('a.b.c')
|
||||
a2 = logging.getLogger('d.e.f')
|
||||
|
||||
logging.basicConfig(filename='example.log', level=logging.DEBUG)
|
||||
logging.warning('this is a tutorial')
|
||||
logging.info('It includes the basic logging functions')
|
||||
|
||||
logging.info("Don't include certain strings")
|
||||
logging.info('define a filter')
|
||||
f = ContextFilter()
|
||||
a1.addFilter(f)
|
||||
a2.addFilter(f)
|
||||
a1.debug('A debug message')
|
||||
a1.info('An info message with %s', 'some parameters')
|
||||
for x in range(10):
|
||||
lvl = choice(levels)
|
||||
lvlname = logging.getLevelName(lvl)
|
||||
a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
26
py-scripts/sandbox/logger_example_1.py
Executable file
26
py-scripts/sandbox/logger_example_1.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--debug',
|
||||
type=int,
|
||||
default=2,
|
||||
help="Set logging level, range 0 through 4. 0 is DEBUG, 4 is CRITICAL")
|
||||
|
||||
args = parser.parse_args()
|
||||
levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]
|
||||
logging.basicConfig(level=levels[args.debug])
|
||||
|
||||
logging.debug('This is debug output, level 0')
|
||||
logging.info('This is info output, level 1')
|
||||
logging.warning('This is warning output, level 2')
|
||||
logging.error('This is error output, level 3')
|
||||
logging.critical('This is error output, level 4')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
244
py-scripts/sandbox/monitor_rvr.py
Executable file
244
py-scripts/sandbox/monitor_rvr.py
Executable file
@@ -0,0 +1,244 @@
|
||||
#!/usr/bin/env python3
|
||||
# This script will set the LANforge to a BLANK database then it will load the specified database
|
||||
# and start a graphical report
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
from time import sleep
|
||||
import pprint
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
"""
|
||||
cvScenario.scenario_db = args.scenario_db
|
||||
if args.cv_test is not None:
|
||||
cvScenario.cv_test = args.cv_test
|
||||
if args.test_scenario is not None:
|
||||
cvScenario.test_scenario = args.test_scenario
|
||||
"""
|
||||
|
||||
class RunCvScenario(LFCliBase):
|
||||
def __init__(self, lfhost="localhost", lfport=8080, debug_=False, lanforge_db_=None, cv_scenario_=None, cv_test_=None, test_scenario_=None):
|
||||
super().__init__( _lfjson_host=lfhost, _lfjson_port=lfport, _debug=debug_, _exit_on_error=True, _exit_on_fail=True)
|
||||
self.lanforge_db = lanforge_db_
|
||||
self.cv_scenario = cv_scenario_
|
||||
self.cv_test = cv_test_
|
||||
self.test_profile = test_scenario_
|
||||
self.localrealm = Realm(lfclient_host=lfhost, lfclient_port=lfport, debug_=debug_)
|
||||
self.report_name = None
|
||||
|
||||
def get_report_file_name(self):
|
||||
return self.report_name
|
||||
|
||||
def build(self):
|
||||
data = {
|
||||
"name": "BLANK",
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
sleep(1)
|
||||
port_counter = 0
|
||||
attempts = 6
|
||||
while (attempts > 0) and (port_counter > 0):
|
||||
sleep(1)
|
||||
attempts -= 1
|
||||
print("looking for ports like vap+")
|
||||
port_list = self.localrealm.find_ports_like("vap+")
|
||||
alias_map = LFUtils.portListToAliasMap(port_list)
|
||||
port_counter = len(alias_map)
|
||||
|
||||
port_list = self.localrealm.find_ports_like("sta+")
|
||||
alias_map = LFUtils.portListToAliasMap(port_list)
|
||||
port_counter += len(alias_map)
|
||||
if port_counter == 0:
|
||||
break
|
||||
|
||||
if (port_counter != 0) and (attempts == 0):
|
||||
print("There appears to be a vAP in this database, quitting.")
|
||||
pprint(alias_map)
|
||||
exit(1)
|
||||
|
||||
data = {
|
||||
"name": self.lanforge_db,
|
||||
"action":"overwrite",
|
||||
"clean_dut":"yes",
|
||||
"clean_chambers": "yes"
|
||||
}
|
||||
self.json_post("/cli-json/load", data)
|
||||
sleep(1)
|
||||
self._pass("Loaded scenario %s" % self.lanforge_db, True)
|
||||
return True
|
||||
|
||||
def start(self, debug_=False):
|
||||
# /gui_cli takes commands keyed on 'cmd', so we create an array of commands
|
||||
commands = [
|
||||
"sleep 4",
|
||||
"cv sync",
|
||||
"sleep 4",
|
||||
"cv apply '%s'" % self.cv_scenario,
|
||||
"sleep 4",
|
||||
"cv build",
|
||||
"sleep 10",
|
||||
"cv is_built",
|
||||
"sleep 1",
|
||||
"cv sync",
|
||||
"sleep 5",
|
||||
"cv create '%s' 'test_ref' 'true'" % self.cv_test,
|
||||
"sleep 5",
|
||||
"cv load test_ref '%s'" % self.test_profile,
|
||||
"sleep 5",
|
||||
"cv click test_ref 'Auto Save Report'",
|
||||
"sleep 1",
|
||||
"cv click test_ref Start",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"sleep 2",
|
||||
"cv get test_ref progress_area",
|
||||
"cv get test_ref 'Report Location:'",
|
||||
"sleep 5",
|
||||
#"cv click test_ref 'Save HTML'",
|
||||
"cv click test_ref 'Close'",
|
||||
"sleep 1",
|
||||
"cv click test_ref Cancel",
|
||||
"sleep 1",
|
||||
"exit"
|
||||
]
|
||||
response_json = []
|
||||
for command in commands:
|
||||
data = {
|
||||
"cmd": command
|
||||
}
|
||||
try:
|
||||
debug_par = ""
|
||||
if debug_:
|
||||
debug_par="?_debug=1"
|
||||
if command.endswith("is_built"):
|
||||
print("Waiting for scenario to build...", end='')
|
||||
self.localrealm.wait_while_building(debug_=False)
|
||||
print("...proceeding")
|
||||
elif command.startswith("sleep "):
|
||||
nap = int(command.split(" ")[1])
|
||||
print("sleeping %d..." % nap)
|
||||
sleep(nap)
|
||||
print("...proceeding")
|
||||
else:
|
||||
response_json = []
|
||||
print("running %s..." % command, end='')
|
||||
response = self.json_post("/gui-json/cmd%s" % debug_par, data, debug_=False, response_json_list_=response_json)
|
||||
if debug_ or command.startswith("cv get "):
|
||||
LFUtils.debug_printer.pprint(response_json)
|
||||
print("...proceeding")
|
||||
|
||||
|
||||
except Exception as x:
|
||||
print(x)
|
||||
|
||||
self._pass("report finished", print_=True)
|
||||
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="run_cv_scenario.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Reporting Script: Load a scenario and run a RvR report
|
||||
Example:
|
||||
./load_ap_scenario.py --lfmgr 127.0.0.1 --scenario_db 'handsets' --cv_test --test_scenario 'test-20'
|
||||
""")
|
||||
parser.add_argument("-m", "--lfmgr", type=str, help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int, help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-d", "--lanforge_db", type=str, help="Name of test scenario database (see Status Tab)")
|
||||
parser.add_argument("-c", "--cv_scenario", type=str, help="Name of Chamber View test scenario (see CV Manage Scenarios)")
|
||||
parser.add_argument("-n", "--cv_test", type=str, help="Chamber View test")
|
||||
parser.add_argument("-s", "--test_profile", type=str, help="Name of the saved CV test profile")
|
||||
parser.add_argument("--debug", help='Enable debugging', default=False, action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.lfmgr is not None:
|
||||
lfjson_host = args.lfmgr
|
||||
if args.port is not None:
|
||||
lfjson_port = args.port
|
||||
debug = False
|
||||
if args.debug is not None:
|
||||
debug = args.debug
|
||||
run_cv_scenario = RunCvScenario(lfjson_host, lfjson_port, debug_=debug)
|
||||
|
||||
if args.lanforge_db is not None:
|
||||
run_cv_scenario.lanforge_db = args.lanforge_db
|
||||
if args.cv_scenario is not None:
|
||||
run_cv_scenario.cv_scenario = args.cv_scenario
|
||||
if args.cv_test is not None:
|
||||
run_cv_scenario.cv_test = args.cv_test
|
||||
if args.test_profile is not None:
|
||||
run_cv_scenario.test_profile = args.test_profile
|
||||
|
||||
if (run_cv_scenario.lanforge_db is None) or (run_cv_scenario.lanforge_db == ""):
|
||||
raise ValueError("Please specificy scenario database name with --scenario_db")
|
||||
|
||||
if not (run_cv_scenario.build() and run_cv_scenario.passes()):
|
||||
print("scenario failed to build.")
|
||||
print(run_cv_scenario.get_fail_message())
|
||||
exit(1)
|
||||
|
||||
if not (run_cv_scenario.start() and run_cv_scenario.passes()):
|
||||
print("scenario failed to start.")
|
||||
print(run_cv_scenario.get_fail_message())
|
||||
exit(1)
|
||||
|
||||
if not (run_cv_scenario.stop() and run_cv_scenario.passes()):
|
||||
print("scenario failed to stop:")
|
||||
print(run_cv_scenario.get_fail_message())
|
||||
exit(1)
|
||||
|
||||
if not (run_cv_scenario.cleanup() and run_cv_scenario.passes()):
|
||||
print("scenario failed to clean up:")
|
||||
print(run_cv_scenario.get_fail_message())
|
||||
exit(1)
|
||||
|
||||
report_file = run_cv_scenario.get_report_file_name()
|
||||
print("Report file saved to "+report_file)
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1899
py-scripts/sandbox/test_l3_longevity_beta.py
Normal file
1899
py-scripts/sandbox/test_l3_longevity_beta.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,12 +3,12 @@ import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -18,63 +18,169 @@ realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog='scenario.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''Load a database file and control test groups\n''',
|
||||
description='''scenario.py
|
||||
--------------------
|
||||
Generic command example:
|
||||
scenario.py --load db1 --action overwrite --clean_dut --clean_chambers
|
||||
def get_events(event_log, value):
|
||||
results = []
|
||||
for event in event_log:
|
||||
if event.values():
|
||||
results.append(list(event.values())[0][value])
|
||||
return results
|
||||
|
||||
scenario.py --start test_group1
|
||||
|
||||
scenario.py --quiesce test_group1
|
||||
def find_new_events(original, new):
|
||||
new_times = list()
|
||||
new_events = list()
|
||||
original_times = get_events(original['events'], 'time-stamp')
|
||||
current_times = get_events(new['events'], 'time-stamp')
|
||||
for x in current_times:
|
||||
if x not in original_times:
|
||||
new_times.append(x)
|
||||
for x in new['events']:
|
||||
if list(x.values())[0]['time-stamp'] in new_times:
|
||||
new_events.append(x)
|
||||
return new_events
|
||||
|
||||
scenario.py --stop test_group1
|
||||
''')
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
class LoadScenario(Realm):
|
||||
def __init__(self,
|
||||
mgr='localhost',
|
||||
mgr_port=8080,
|
||||
scenario=None,
|
||||
action='overwrite',
|
||||
clean_dut=True,
|
||||
clean_chambers=True,
|
||||
start=None,
|
||||
stop=None,
|
||||
quiesce=None,
|
||||
timeout=120,
|
||||
debug=False):
|
||||
super().__init__(lfclient_host=mgr,
|
||||
lfclient_port=mgr_port,
|
||||
debug_=debug)
|
||||
self.mgr = mgr
|
||||
self.scenario = scenario
|
||||
self.action = action
|
||||
self.clean_dut = clean_dut
|
||||
self.clean_chambers = clean_chambers
|
||||
self.start = start
|
||||
self.stop = stop
|
||||
self.quiesce = quiesce
|
||||
self.timeout = timeout
|
||||
self.BuildVersion = self.json_get('/')['VersionInfo']['BuildVersion']
|
||||
self.starting_events = None
|
||||
|
||||
parser.add_argument('--load', help='name of database to load', default=None)
|
||||
def start_test(self):
|
||||
self.starting_events = self.json_get('/events/since=time/1h')
|
||||
|
||||
parser.add_argument('--action', help='action to take with database {overwrite | append}', default="overwrite")
|
||||
def load_scenario(self):
|
||||
if self.scenario is not None:
|
||||
data = {
|
||||
"name": self.scenario,
|
||||
"action": self.action,
|
||||
"clean_dut": "no",
|
||||
"clean_chambers": "no"
|
||||
}
|
||||
if self.clean_dut:
|
||||
data['clean_dut'] = "yes"
|
||||
if self.clean_chambers:
|
||||
data['clean_chambers'] = "yes"
|
||||
print("Loading database %s" % self.scenario)
|
||||
self.json_post("/cli-json/load", data)
|
||||
elif self.start is not None:
|
||||
print("Starting test group %s..." % self.start)
|
||||
self.json_post("/cli-json/start_group", {"name": self.start})
|
||||
elif self.stop is not None:
|
||||
print("Stopping test group %s..." % self.stop)
|
||||
self.json_post("/cli-json/stop_group", {"name": self.stop})
|
||||
elif self.quiesce is not None:
|
||||
print("Quiescing test group %s..." % self.quiesce)
|
||||
self.json_post("/cli-json/quiesce_group", {"name": self.quiesce})
|
||||
|
||||
parser.add_argument('--clean_dut',
|
||||
help='use to cleanup DUT will be when overwrite is selected, otherwise they will be kept',
|
||||
action="store_true")
|
||||
def check_if_complete(self):
|
||||
completed = False
|
||||
timer = 0
|
||||
while not completed:
|
||||
current_events = self.json_get('/events/since=time/1h')
|
||||
new_events = find_new_events(self.starting_events, current_events)
|
||||
target_events = [event for event in get_events(new_events, 'event description') if
|
||||
event.startswith('LOAD COMPLETED')]
|
||||
if 'LOAD-DB: Load attempt has been completed.' in get_events(new_events, 'event description'):
|
||||
completed = True
|
||||
print('Scenario %s fully loaded after %s seconds' % (self.scenario, timer))
|
||||
elif len(target_events) > 0:
|
||||
completed = True
|
||||
print('Scenario %s fully loaded after %s seconds' % (self.scenario, timer))
|
||||
else:
|
||||
timer += 1
|
||||
time.sleep(1)
|
||||
if timer > self.timeout:
|
||||
completed = True
|
||||
print('Scenario failed to load after %s seconds' % self.timeout)
|
||||
else:
|
||||
print(new_events)
|
||||
print('Waiting %s out of %s seconds to load scenario %s' % (timer, self.timeout, self.scenario))
|
||||
|
||||
parser.add_argument('--clean_chambers',
|
||||
help='use to cleanup Chambers will be when overwrite is selected, otherwise they will be kept',
|
||||
action="store_true")
|
||||
|
||||
group.add_argument('--start', help='name of test group to start', default=None)
|
||||
group.add_argument('--quiesce', help='name of test group to quiesce', default=None)
|
||||
group.add_argument('--stop', help='name of test group to stop', default=None)
|
||||
args = parser.parse_args()
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog='scenario.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''Load a database file and control test groups\n''',
|
||||
description='''scenario.py
|
||||
--------------------
|
||||
Generic command example:
|
||||
scenario.py --load db1 --action overwrite --clean_dut --clean_chambers
|
||||
|
||||
scenario.py --start test_group1
|
||||
|
||||
scenario.py --quiesce test_group1
|
||||
|
||||
scenario.py --stop test_group1
|
||||
''')
|
||||
|
||||
local_realm = realm.Realm(lfclient_host=args.mgr, lfclient_port=args.mgr_port, debug_=args.debug)
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
|
||||
if args.load is not None:
|
||||
data = {
|
||||
"name": args.load,
|
||||
"action": args.action,
|
||||
"clean_dut": "no",
|
||||
"clean_chambers": "no"
|
||||
}
|
||||
if args.clean_dut:
|
||||
data['clean_dut'] = "yes"
|
||||
if args.clean_chambers:
|
||||
data['clean_chambers'] = "yes"
|
||||
print("Loading database %s" % args.load)
|
||||
local_realm.json_post("/cli-json/load", data)
|
||||
parser.add_argument('--load', help='name of database to load', default=None)
|
||||
|
||||
elif args.start is not None:
|
||||
print("Starting test group %s..." % args.start)
|
||||
local_realm.json_post("/cli-json/start_group", {"name": args.start})
|
||||
elif args.stop is not None:
|
||||
print("Stopping test group %s..." % args.stop)
|
||||
local_realm.json_post("/cli-json/stop_group", {"name": args.stop})
|
||||
elif args.quiesce is not None:
|
||||
print("Quiescing test group %s..." % args.quiesce)
|
||||
local_realm.json_post("/cli-json/quiesce_group", {"name": args.quiesce})
|
||||
parser.add_argument('--action', help='action to take with database {overwrite | append}', default="overwrite")
|
||||
|
||||
parser.add_argument('--clean_dut',
|
||||
help='use to cleanup DUT will be when overwrite is selected, otherwise they will be kept',
|
||||
action="store_true")
|
||||
|
||||
parser.add_argument('--clean_chambers',
|
||||
help='use to cleanup Chambers will be when overwrite is selected, otherwise they will be kept',
|
||||
action="store_true")
|
||||
|
||||
group.add_argument('--start', help='name of test group to start', default=None)
|
||||
group.add_argument('--quiesce', help='name of test group to quiesce', default=None)
|
||||
group.add_argument('--stop', help='name of test group to stop', default=None)
|
||||
parser.add_argument('--timeout', help='Stop trying to load scenario after this many seconds', default=120)
|
||||
args = parser.parse_args()
|
||||
|
||||
scenario = LoadScenario(mgr=args.mgr,
|
||||
scenario=args.load,
|
||||
action=args.action,
|
||||
clean_dut=args.clean_dut,
|
||||
clean_chambers=args.clean_chambers,
|
||||
start=args.start,
|
||||
stop=args.stop,
|
||||
quiesce=args.quiesce,
|
||||
timeout=args.timeout,
|
||||
debug=args.debug)
|
||||
if scenario.BuildVersion == '5.4.4':
|
||||
scenario.start_test()
|
||||
|
||||
scenario.load_scenario()
|
||||
|
||||
if scenario.BuildVersion != '5.4.4':
|
||||
print('sleeping 30 seconds, please upgrade your LANforge for a better experience, more information at https://www.candelatech.com/downloads.php#releases')
|
||||
time.sleep(30)
|
||||
|
||||
if scenario.BuildVersion == '5.4.4':
|
||||
scenario.check_if_complete()
|
||||
|
||||
# scenario_loader.load_scenario()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -147,7 +147,7 @@ class APIClient:
|
||||
# Update the result in TestRail using send_post function.
|
||||
# Parameters for add_result_for_case is the combination of runid and case id.
|
||||
# status_id is 1 for Passed, 2 For Blocked, 4 for Retest and 5 for Failed
|
||||
#status_id = 1 if result_flag is True else 5
|
||||
#status_id = 1 if result_flag else 5
|
||||
|
||||
print("result status is = ", status_id)
|
||||
print("case id=", case_id)
|
||||
46
py-scripts/scripts_deprecated/event_break_flood.py
Executable file
46
py-scripts/scripts_deprecated/event_break_flood.py
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import threading
|
||||
from event_flood import EventFlood
|
||||
from event_breaker import EventBreaker
|
||||
import importlib
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
|
||||
|
||||
def event_break(args):
|
||||
event_breaker = EventBreaker(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
duration='30s')
|
||||
event_breaker.create()
|
||||
event_breaker.run()
|
||||
event_breaker.cleanup()
|
||||
|
||||
|
||||
def event_flooding(args):
|
||||
event_flood = EventFlood(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
duration='30s',
|
||||
pause_ms=30)
|
||||
event_flood.create()
|
||||
event_flood.run()
|
||||
event_flood.cleanup()
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse()
|
||||
args = parser.parse_args()
|
||||
flood = threading.Thread(target=event_flooding(args))
|
||||
breaker = threading.Thread(target=event_break(args))
|
||||
|
||||
flood.start()
|
||||
breaker.start()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -9,14 +9,12 @@ import os
|
||||
import importlib
|
||||
from datetime import datetime
|
||||
import pprint
|
||||
import argparse
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
@@ -25,15 +23,15 @@ Realm = realm.Realm
|
||||
|
||||
|
||||
class EventBreaker(Realm):
|
||||
def __init__(self, host, port,
|
||||
def __init__(self, host, port,
|
||||
duration=None,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port)
|
||||
self.counter = 0
|
||||
self.test_duration=duration
|
||||
if (self.test_duration is None):
|
||||
self.test_duration = duration
|
||||
if self.test_duration is None:
|
||||
raise ValueError("run wants numeric run_duration_sec")
|
||||
|
||||
def create(self):
|
||||
@@ -42,25 +40,18 @@ class EventBreaker(Realm):
|
||||
def run(self):
|
||||
|
||||
now = datetime.now()
|
||||
now_ms = 0
|
||||
end_time = self.parse_time(self.test_duration) + now
|
||||
client_time_ms = 0
|
||||
prev_client_time_ms = 0
|
||||
start_loop_time_ms = 0
|
||||
loop_time_ms = 0
|
||||
prev_loop_time_ms = 0
|
||||
num_events = 0
|
||||
prev_num_events = 0
|
||||
bad_events = []
|
||||
while datetime.now() < end_time:
|
||||
bad_events = []
|
||||
start_loop_time_ms = int(self.get_milliseconds(datetime.now()))
|
||||
print ('\r♦ ', end='')
|
||||
#prev_loop_time_ms = loop_time_ms
|
||||
# loop_time_ms = self.get_milliseconds(datetime.now())
|
||||
print('\r♦ ', end='')
|
||||
prev_client_time_ms = client_time_ms
|
||||
response = self.json_get("/events/all")
|
||||
#pprint.pprint(response)
|
||||
if self.debug:
|
||||
pprint.pprint(response)
|
||||
|
||||
if "events" not in response:
|
||||
pprint.pprint(response)
|
||||
@@ -69,32 +60,35 @@ class EventBreaker(Realm):
|
||||
prev_num_events = num_events
|
||||
num_events = len(events)
|
||||
if num_events != prev_num_events:
|
||||
print("%s events Δ%s"%(num_events, (num_events - prev_num_events)))
|
||||
print("%s events Δ%s" % (num_events, (num_events - prev_num_events)))
|
||||
if "candela.lanforge.HttpEvents" in response:
|
||||
client_time_ms = float(response["candela.lanforge.HttpEvents"]["duration"])
|
||||
# print(" client_time %d"%client_time_ms)
|
||||
if self.debug:
|
||||
print(" client_time %d" % client_time_ms)
|
||||
|
||||
if abs(prev_client_time_ms - client_time_ms) > 30:
|
||||
print(" client time %d ms Δ%d"%(client_time_ms, (prev_client_time_ms - client_time_ms)),
|
||||
print(" client time %d ms Δ%d" % (client_time_ms, (prev_client_time_ms - client_time_ms)),
|
||||
end='')
|
||||
event_index = 0
|
||||
for record in events:
|
||||
|
||||
for k in record.keys():
|
||||
if record[k] is None:
|
||||
print (' ☠no %s☠'%k, end='')
|
||||
print(' ☠no %s☠' % k, end='')
|
||||
continue
|
||||
# pprint.pprint( record[k])
|
||||
if self.debug:
|
||||
pprint.pprint(record[k])
|
||||
if "NA" == record[k]["event"] \
|
||||
or "NA" == record[k]["name"] \
|
||||
or "NA" == record[k]["type"] \
|
||||
or "NA" == record[k]["priority"]:
|
||||
bad_events.append(int(k))
|
||||
pprint.pprint(record[k])
|
||||
# print( " ☠id[%s]☠"%k, end='')
|
||||
if self.debug:
|
||||
print(" ☠id[%s]☠" % k, end='')
|
||||
if len(bad_events) > 0:
|
||||
pprint.pprint(events[event_index])
|
||||
print( " ☠id[%s]☠"%bad_events, end='')
|
||||
print(" ☠id[%s]☠" % bad_events, end='')
|
||||
exit(1)
|
||||
event_index += 1
|
||||
prev_loop_time_ms = loop_time_ms
|
||||
@@ -102,7 +96,7 @@ class EventBreaker(Realm):
|
||||
loop_time_ms = now_ms - start_loop_time_ms
|
||||
if (prev_loop_time_ms - loop_time_ms) > 15:
|
||||
print(" loop time %d ms Δ%d "
|
||||
%(loop_time_ms, (prev_loop_time_ms - loop_time_ms)),
|
||||
% (loop_time_ms, (prev_loop_time_ms - loop_time_ms)),
|
||||
end='')
|
||||
if (prev_loop_time_ms - loop_time_ms) > 30:
|
||||
print("")
|
||||
@@ -110,13 +104,14 @@ class EventBreaker(Realm):
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog='event_breaker.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
description="""event breaker is meant to be used in conjunction with event flood
|
||||
Please use the event_break_flood.py script""")
|
||||
|
||||
parser.add_argument("--test_duration", help='test duration', default="30s" )
|
||||
# if optional_args is not None:
|
||||
parser.add_argument("--test_duration", help='test duration', default="30s")
|
||||
args = parser.parse_args()
|
||||
|
||||
event_breaker = EventBreaker(host=args.mgr,
|
||||
@@ -129,5 +124,6 @@ def main():
|
||||
event_breaker.run()
|
||||
event_breaker.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -7,16 +7,15 @@ Please concurrently use with event_breaker.py.
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
import pprint
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
@@ -24,8 +23,8 @@ realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
class EventBreaker(Realm):
|
||||
def __init__(self, host, port,
|
||||
class EventFlood(Realm):
|
||||
def __init__(self, host, port,
|
||||
duration=None,
|
||||
pause_ms=None,
|
||||
_debug_on=False,
|
||||
@@ -35,7 +34,7 @@ class EventBreaker(Realm):
|
||||
self.counter = 0
|
||||
self.test_duration = duration
|
||||
self.pause_ms = pause_ms
|
||||
if (self.test_duration is None):
|
||||
if self.test_duration is None:
|
||||
raise ValueError("run wants numeric run_duration_sec")
|
||||
|
||||
def create(self):
|
||||
@@ -44,73 +43,68 @@ class EventBreaker(Realm):
|
||||
def run(self):
|
||||
last_second_ms = 0
|
||||
start_time = datetime.now()
|
||||
now_ms = 0
|
||||
end_time = self.parse_time(self.test_duration) + start_time
|
||||
client_time_ms = 0
|
||||
prev_client_time_ms = 0
|
||||
start_loop_time_ms = 0
|
||||
loop_time_ms = 0
|
||||
prev_loop_time_ms = 0
|
||||
num_events = 0
|
||||
prev_num_events = 0
|
||||
|
||||
while datetime.now() < end_time:
|
||||
sleep( self.pause_ms / 1000 )
|
||||
sleep(self.pause_ms / 1000)
|
||||
start_loop_time_ms = int(self.get_milliseconds(datetime.now()))
|
||||
print ('\r♦ ', end='')
|
||||
#prev_loop_time_ms = loop_time_ms
|
||||
# loop_time_ms = self.get_milliseconds(datetime.now())
|
||||
prev_client_time_ms = client_time_ms
|
||||
print('\r♦ ', end='')
|
||||
response_list = []
|
||||
response = self.json_post("/cli-json/add_event",
|
||||
{
|
||||
"event_id": "new",
|
||||
"details": "event_flood %d"%start_loop_time_ms,
|
||||
"priority": "INFO",
|
||||
"name": "custom"
|
||||
},
|
||||
response_json_list_=response_list)
|
||||
# pprint.pprint(response_list)
|
||||
self.json_post("/cli-json/add_event",
|
||||
{
|
||||
"event_id": "new",
|
||||
"details": "event_flood %d" % start_loop_time_ms,
|
||||
"priority": "INFO",
|
||||
"name": "custom"
|
||||
},
|
||||
response_json_list_=response_list)
|
||||
if self.debug:
|
||||
pprint.pprint(response_list)
|
||||
prev_client_time_ms = client_time_ms
|
||||
prev_loop_time_ms = loop_time_ms
|
||||
now = int(self.get_milliseconds(datetime.now()))
|
||||
loop_time_ms = now - start_loop_time_ms
|
||||
|
||||
client_time_ms = response_list[0]["LAST"]["duration"]
|
||||
if (client_time_ms != prev_client_time_ms):
|
||||
print(" client %d ms %d"%(client_time_ms,
|
||||
(prev_client_time_ms - client_time_ms)),
|
||||
if client_time_ms != prev_client_time_ms:
|
||||
print(" client %d ms %d" % (client_time_ms,
|
||||
(prev_client_time_ms - client_time_ms)),
|
||||
end='')
|
||||
if (loop_time_ms != prev_loop_time_ms):
|
||||
print(" loop %d ms %d "%(loop_time_ms,
|
||||
(prev_loop_time_ms - loop_time_ms)),
|
||||
if loop_time_ms != prev_loop_time_ms:
|
||||
print(" loop %d ms %d " % (loop_time_ms,
|
||||
(prev_loop_time_ms - loop_time_ms)),
|
||||
end='')
|
||||
if (last_second_ms + 1000) < now:
|
||||
last_second_ms = now
|
||||
print("")
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_bare_argparse(
|
||||
prog='event_breaker.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
description="""event flood is meant to be used in conjunction with event breaker
|
||||
Please use the event_break_flood.py script""")
|
||||
|
||||
parser.add_argument("--test_duration", help='test duration', default="30s" )
|
||||
parser.add_argument("--pause_ms", help='interval between submitting events', default="30" )
|
||||
# if optional_args is not None:
|
||||
parser.add_argument("--test_duration", help='test duration', default="30s")
|
||||
parser.add_argument("--pause_ms", help='interval between submitting events', default="30")
|
||||
args = parser.parse_args()
|
||||
|
||||
event_breaker = EventBreaker(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
duration=args.test_duration,
|
||||
pause_ms=int(args.pause_ms),
|
||||
_debug_on=True,
|
||||
_exit_on_error=True,
|
||||
_exit_on_fail=True)
|
||||
event_breaker = EventFlood(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
duration=args.test_duration,
|
||||
pause_ms=int(args.pause_ms),
|
||||
_debug_on=True,
|
||||
_exit_on_error=True,
|
||||
_exit_on_fail=True)
|
||||
event_breaker.create()
|
||||
event_breaker.run()
|
||||
event_breaker.cleanup()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -196,7 +196,7 @@ def main():
|
||||
if args.folder is not None:
|
||||
Ghost.upload_images(args.folder)
|
||||
|
||||
if args.kpi_to_ghost is True:
|
||||
if args.kpi_to_ghost:
|
||||
Ghost.kpi(args.authors,
|
||||
args.folders,
|
||||
args.parent_folder,
|
||||
41
py-scripts/sortabletable.js
Normal file
41
py-scripts/sortabletable.js
Normal file
@@ -0,0 +1,41 @@
|
||||
function sortTable(tableID, n) {
|
||||
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
|
||||
|
||||
table = document.getElementById(tableID);
|
||||
switching = true;
|
||||
dir = "asc";
|
||||
while (switching) {
|
||||
switching = false;
|
||||
rows = table.getElementsByTagName("TR");
|
||||
for (i = 1; i < (rows.length - 1); i++) {
|
||||
shouldSwitch = false;
|
||||
x = rows[i].getElementsByTagName("TD")[n];
|
||||
y = rows[i + 1].getElementsByTagName("TD")[n];
|
||||
var cmpX=isNaN(parseInt(x.innerHTML))?x.innerHTML.toLowerCase():parseInt(x.innerHTML);
|
||||
var cmpY=isNaN(parseInt(y.innerHTML))?y.innerHTML.toLowerCase():parseInt(y.innerHTML);
|
||||
cmpX=(cmpX=='-')?0:cmpX;
|
||||
cmpY=(cmpY=='-')?0:cmpY;
|
||||
if (dir == "asc") {
|
||||
if (cmpX > cmpY) {
|
||||
shouldSwitch= true;
|
||||
break;
|
||||
}
|
||||
} else if (dir == "desc") {
|
||||
if (cmpX < cmpY) {
|
||||
shouldSwitch= true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldSwitch) {
|
||||
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
||||
switching = true;
|
||||
switchcount ++;
|
||||
} else {
|
||||
if (switchcount == 0 && dir == "asc") {
|
||||
dir = "desc";
|
||||
switching = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,11 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
removeCX = LFUtils.removeCX
|
||||
removeEndps = LFUtils.removeEndps
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
@@ -31,16 +28,20 @@ WPA2 = "wpa2"
|
||||
MODE_AUTO = 0
|
||||
|
||||
|
||||
class StaConnect(LFCliBase):
|
||||
class StaConnect(Realm):
|
||||
def __init__(self, host, port, _dut_ssid="MyAP", _dut_passwd="NA", _dut_bssid="",
|
||||
_user="", _passwd="", _sta_mode="0", _radio="wiphy0",
|
||||
_user="lanforge", _passwd="lanforge", _sta_mode="0", _radio="wiphy0",
|
||||
_resource=1, _upstream_resource=1, _upstream_port="eth2",
|
||||
_sta_name=None, _debugOn=False, _dut_security=OPEN, _exit_on_error=False,
|
||||
_cleanup_on_exit=True, _runtime_sec=60, _exit_on_fail=False):
|
||||
# do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn)
|
||||
# that is py2 era syntax and will force self into the host variable, making you
|
||||
# very confused.
|
||||
super().__init__(host, port, _debug=_debugOn, _exit_on_fail=_exit_on_fail)
|
||||
super().__init__(lfclient_host=host, lfclient_port=port, debug_=_debugOn, _exit_on_fail=_exit_on_fail)
|
||||
fields = "_links,port,alias,ip,ap,port+type"
|
||||
self.station_results = self.find_ports_like("sta*", fields, debug_=False)
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.debugOn = _debugOn
|
||||
self.dut_security = ""
|
||||
self.dut_ssid = _dut_ssid
|
||||
@@ -60,15 +61,13 @@ class StaConnect(LFCliBase):
|
||||
self.station_names = []
|
||||
self.cx_names = {}
|
||||
if _sta_name is not None:
|
||||
self.station_names = [ _sta_name ]
|
||||
# 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.station_names = [_sta_name]
|
||||
self.resulting_stations = {}
|
||||
self.resulting_endpoints = {}
|
||||
|
||||
# def get_realm(self) -> Realm: # py > 3.6
|
||||
def get_realm(self):
|
||||
return self.localrealm
|
||||
self.cx_profile = self.new_l3_cx_profile()
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
|
||||
def get_station_url(self, sta_name_=None):
|
||||
if sta_name_ is None:
|
||||
@@ -99,24 +98,22 @@ class StaConnect(LFCliBase):
|
||||
def num_associated(self, bssid):
|
||||
counter = 0
|
||||
# print("there are %d results" % len(self.station_results))
|
||||
fields = "_links,port,alias,ip,ap,port+type"
|
||||
self.station_results = self.localrealm.find_ports_like("sta*", fields, debug_=False)
|
||||
if (self.station_results is None) or (len(self.station_results) < 1):
|
||||
self.get_failed_result_list()
|
||||
for eid,record in self.station_results.items():
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
#pprint(eid)
|
||||
#pprint(record)
|
||||
for eid, record in self.station_results.items():
|
||||
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# pprint(eid)
|
||||
# pprint(record)
|
||||
if record["ap"] == bssid:
|
||||
counter += 1
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# 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()
|
||||
# super(StaConnect, self).clear_test_results().test_results.clear()
|
||||
|
||||
def run(self):
|
||||
if not self.setup():
|
||||
@@ -152,8 +149,7 @@ class StaConnect(LFCliBase):
|
||||
if response is not None:
|
||||
if response["interface"] is not None:
|
||||
print("removing old station")
|
||||
for sta_name in self.station_names:
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url, debug=False)
|
||||
LFUtils.waitUntilPortsDisappear(self.resource, self.lfclient_url, self.station_names)
|
||||
|
||||
# Create stations and turn dhcp on
|
||||
@@ -233,7 +229,7 @@ class StaConnect(LFCliBase):
|
||||
else:
|
||||
connected_stations[sta_name] = sta_url
|
||||
data = {
|
||||
"shelf":1,
|
||||
"shelf": 1,
|
||||
"resource": self.resource,
|
||||
"port": "ALL",
|
||||
"probe_flags": 1
|
||||
@@ -242,10 +238,9 @@ class StaConnect(LFCliBase):
|
||||
|
||||
# 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"]
|
||||
@@ -253,13 +248,14 @@ class StaConnect(LFCliBase):
|
||||
print(" %s +AP %s, " % (sta_name, ap), end="")
|
||||
if self.dut_bssid != "":
|
||||
if self.dut_bssid.lower() == ap.lower():
|
||||
self._pass(sta_name+" connected to BSSID: " + ap)
|
||||
self._pass(sta_name + " connected to BSSID: " + ap)
|
||||
# self.test_results.append("PASSED: )
|
||||
# print("PASSED: Connected to BSSID: "+ap)
|
||||
else:
|
||||
self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
||||
self._fail(
|
||||
"%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
||||
else:
|
||||
self._fail(sta_name+" did not connect to AP")
|
||||
self._fail(sta_name + " did not connect to AP")
|
||||
return False
|
||||
|
||||
if ip == "0.0.0.0":
|
||||
@@ -267,7 +263,7 @@ class StaConnect(LFCliBase):
|
||||
else:
|
||||
self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip))
|
||||
|
||||
if self.passes() == False:
|
||||
if not self.passes():
|
||||
if self.cleanup_on_exit:
|
||||
print("Cleaning up...")
|
||||
self.remove_stations()
|
||||
@@ -275,11 +271,10 @@ class StaConnect(LFCliBase):
|
||||
|
||||
# create endpoints and cxs
|
||||
# Create UDP endpoints
|
||||
self.cx_names = {}
|
||||
|
||||
for sta_name in self.station_names:
|
||||
self.cx_names["testUDP-"+sta_name] = { "a": "testUDP-%s-A" % sta_name,
|
||||
"b": "testUDP-%s-B" % sta_name}
|
||||
self.cx_names["testUDP-" + sta_name] = {"a": "testUDP-%s-A" % sta_name,
|
||||
"b": "testUDP-%s-B" % sta_name}
|
||||
data = {
|
||||
"alias": "testUDP-%s-A" % sta_name,
|
||||
"shelf": 1,
|
||||
@@ -292,9 +287,9 @@ class StaConnect(LFCliBase):
|
||||
self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True)
|
||||
|
||||
data = {
|
||||
"name" : "testUDP-%s-A" % sta_name,
|
||||
"flag" : "UseAutoNAT",
|
||||
"val" : 1
|
||||
"name": "testUDP-%s-A" % sta_name,
|
||||
"flag": "UseAutoNAT",
|
||||
"val": 1
|
||||
}
|
||||
self.json_post("/cli-json/set_endp_flag", data, suppress_related_commands_=True)
|
||||
|
||||
@@ -310,9 +305,9 @@ class StaConnect(LFCliBase):
|
||||
self.json_post("/cli-json/add_endp", data, suppress_related_commands_=True)
|
||||
|
||||
data = {
|
||||
"name" : "testUDP-%s-B" % sta_name,
|
||||
"flag" : "UseAutoNAT",
|
||||
"val" : 1
|
||||
"name": "testUDP-%s-B" % sta_name,
|
||||
"flag": "UseAutoNAT",
|
||||
"val": 1
|
||||
}
|
||||
self.json_post("/cli-json/set_endp_flag", data, suppress_related_commands_=True)
|
||||
|
||||
@@ -333,8 +328,8 @@ class StaConnect(LFCliBase):
|
||||
self.json_post("/cli-json/set_cx_report_timer", data, suppress_related_commands_=True)
|
||||
|
||||
# Create TCP endpoints
|
||||
self.cx_names["testTCP-"+sta_name] = { "a": "testUDP-%s-A" % sta_name,
|
||||
"b": "testUDP-%s-B" % sta_name}
|
||||
self.cx_names["testTCP-" + sta_name] = {"a": "testTCP-%s-A" % sta_name,
|
||||
"b": "testTCP-%s-B" % sta_name}
|
||||
data = {
|
||||
"alias": "testTCP-%s-A" % sta_name,
|
||||
"shelf": 1,
|
||||
@@ -373,6 +368,7 @@ class StaConnect(LFCliBase):
|
||||
}
|
||||
self.json_post("/cli-json/set_cx_report_timer", data, suppress_related_commands_=True)
|
||||
|
||||
self.wait_until_endps_appear(self.cx_names)
|
||||
return True
|
||||
|
||||
def start(self):
|
||||
@@ -396,19 +392,9 @@ class StaConnect(LFCliBase):
|
||||
}
|
||||
self.json_post("/cli-json/show_cxe", data)
|
||||
return True
|
||||
|
||||
|
||||
def stop(self):
|
||||
# stop cx traffic
|
||||
print("Stopping CX Traffic")
|
||||
for cx_name in self.cx_names.keys():
|
||||
data = {
|
||||
"test_mgr": "ALL",
|
||||
"cx_name": cx_name,
|
||||
"cx_state": "STOPPED"
|
||||
}
|
||||
self.json_post("/cli-json/set_cx_state", data)
|
||||
return True
|
||||
self.cx_profile.stop_cx()
|
||||
|
||||
def finish(self):
|
||||
# Refresh stats
|
||||
@@ -436,7 +422,7 @@ class StaConnect(LFCliBase):
|
||||
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" % self.cx_names[cx_name]["b"])
|
||||
# ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % self.cx_names[cx_name]["b"])
|
||||
endp_url = "/endp/%s" % self.cx_names[cx_name]["b"]
|
||||
ptest = self.json_get(endp_url)
|
||||
self.resulting_endpoints[endp_url] = ptest
|
||||
@@ -458,59 +444,46 @@ class StaConnect(LFCliBase):
|
||||
# self.test_results.append("FAILED message will fail")
|
||||
# print("\n")
|
||||
|
||||
|
||||
def cleanup(self):
|
||||
for sta_name in self.station_names:
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url, debug=False)
|
||||
endp_names = []
|
||||
removeCX(self.lfclient_url, self.cx_names.keys())
|
||||
for cx_name in self.cx_names:
|
||||
endp_names.append(self.cx_names[cx_name]["a"])
|
||||
endp_names.append(self.cx_names[cx_name]["b"])
|
||||
removeEndps(self.lfclient_url, endp_names)
|
||||
|
||||
# ~class
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
if self.debug:
|
||||
print("Removing endpoints %s" % self.cx_names.values())
|
||||
removeEndps(self.lfclient_url, endp_names, debug=False)
|
||||
|
||||
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
parser = argparse.ArgumentParser(
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog="sta_connect.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="""LANforge Unit Test: Connect Station to AP
|
||||
Example:
|
||||
./sta_connect.py --dest 192.168.100.209 --dut_ssid OpenWrt-2 --dut_bssid 24:F5:A2:08:21:6C
|
||||
./sta_connect.py --mgr 192.168.100.209 --dut_ssid OpenWrt-2 --dut_bssid 24:F5:A2:08:21:6C
|
||||
""")
|
||||
parser.add_argument("-d", "--dest", type=str, help="address of the LANforge GUI machine (localhost is default)")
|
||||
parser.add_argument("-o", "--port", type=int, help="IP Port the LANforge GUI is listening on (8080 is default)")
|
||||
parser.add_argument("-u", "--user", type=str, help="TBD: credential login/username")
|
||||
parser.add_argument("-p", "--passwd", type=str, help="TBD: credential password")
|
||||
parser.add_argument("--resource", type=str, help="LANforge Station resource ID to use, default is 1")
|
||||
parser.add_argument("--upstream_resource", type=str, help="LANforge Ethernet port resource ID to use, default is 1")
|
||||
parser.add_argument("--upstream_port", type=str, help="LANforge Ethernet port name, default is eth2")
|
||||
parser.add_argument("--radio", type=str, help="LANforge radio to use, default is wiphy0")
|
||||
parser.add_argument("--sta_mode", type=str,
|
||||
help="LANforge station-mode setting (see add_sta LANforge CLI documentation, default is 0 (auto))")
|
||||
parser.add_argument("--dut_ssid", type=str, help="DUT SSID")
|
||||
parser.add_argument("--dut_passwd", type=str, help="DUT PSK password. Do not set for OPEN auth")
|
||||
parser.add_argument("--dut_bssid", type=str, help="DUT BSSID to which we expect to connect.")
|
||||
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.dest is not None:
|
||||
lfjson_host = args.dest
|
||||
monitor_interval = Realm.parse_time(args.test_duration).total_seconds()
|
||||
if args.mgr is not None:
|
||||
lfjson_host = args.mgr
|
||||
if args.port is not None:
|
||||
lfjson_port = args.port
|
||||
|
||||
staConnect = StaConnect(lfjson_host, lfjson_port)
|
||||
staConnect.station_names = [ "sta0000" ]
|
||||
if args.user is not None:
|
||||
staConnect.user = args.user
|
||||
if args.passwd is not None:
|
||||
staConnect.passwd = args.passwd
|
||||
staConnect = StaConnect(lfjson_host, lfjson_port, _runtime_sec=monitor_interval)
|
||||
staConnect.station_names = ["sta0000"]
|
||||
if args.sta_mode is not None:
|
||||
staConnect.sta_mode = args.sta_mode
|
||||
if args.upstream_resource is not None:
|
||||
@@ -521,34 +494,34 @@ Example:
|
||||
staConnect.radio = args.radio
|
||||
if args.resource is not None:
|
||||
staConnect.resource = args.resource
|
||||
if args.dut_passwd is not None:
|
||||
staConnect.dut_passwd = args.dut_passwd
|
||||
if args.passwd is not None:
|
||||
staConnect.dut_passwd = args.passwd
|
||||
if args.dut_bssid is not None:
|
||||
staConnect.dut_bssid = args.dut_bssid
|
||||
if args.dut_ssid is not None:
|
||||
staConnect.dut_ssid = args.dut_ssid
|
||||
if args.ssid is not None:
|
||||
staConnect.dut_ssid = args.ssid
|
||||
if args.security is not None:
|
||||
staConnect.dut_security = args.security
|
||||
|
||||
staConnect.run()
|
||||
|
||||
run_results = staConnect.get_result_list()
|
||||
staConnect.get_result_list()
|
||||
|
||||
|
||||
is_passing = staConnect.passes()
|
||||
if is_passing == False:
|
||||
if not staConnect.passes():
|
||||
print("FAIL: Some tests failed")
|
||||
else:
|
||||
print("PASS: All tests pass")
|
||||
|
||||
print(staConnect.get_all_message())
|
||||
|
||||
is_passing = staConnect.passes()
|
||||
if is_passing == False:
|
||||
if not staConnect.passes():
|
||||
print("FAIL: Some tests failed")
|
||||
else:
|
||||
print("PASS: All tests pass")
|
||||
|
||||
print(staConnect.get_all_message())
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -68,11 +67,11 @@ class StaConnect2(LFCliBase):
|
||||
self.upstream_url = None # defer construction
|
||||
self.station_names = []
|
||||
if _sta_name is not None:
|
||||
self.station_names = [ _sta_name ]
|
||||
self.station_names = [_sta_name]
|
||||
self.sta_prefix = _sta_prefix
|
||||
self.bringup_time_sec = _bringup_time_sec
|
||||
# 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.localrealm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6
|
||||
self.resulting_stations = {}
|
||||
self.resulting_endpoints = {}
|
||||
self.station_profile = None
|
||||
@@ -117,25 +116,27 @@ class StaConnect2(LFCliBase):
|
||||
counter = 0
|
||||
# print("there are %d results" % len(self.station_results))
|
||||
fields = "_links,port,alias,ip,ap,port+type"
|
||||
self.station_results = self.localrealm.find_ports_like("%s*"%self.sta_prefix, fields, debug_=False)
|
||||
self.station_results = self.localrealm.find_ports_like("%s*" % self.sta_prefix, fields, debug_=False)
|
||||
if (self.station_results is None) or (len(self.station_results) < 1):
|
||||
self.get_failed_result_list()
|
||||
for eid,record in self.station_results.items():
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
#pprint(eid)
|
||||
#pprint(record)
|
||||
for eid, record in self.station_results.items():
|
||||
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# pprint(eid)
|
||||
# pprint(record)
|
||||
if record["ap"] == bssid:
|
||||
counter += 1
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# 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()
|
||||
# super(StaConnect, self).clear_test_results().test_results.clear()
|
||||
|
||||
def setup(self, extra_securities=[]):
|
||||
def setup(self, extra_securities=None):
|
||||
if extra_securities is None:
|
||||
extra_securities = []
|
||||
self.clear_test_results()
|
||||
self.check_connect()
|
||||
upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False)
|
||||
@@ -149,6 +150,7 @@ class StaConnect2(LFCliBase):
|
||||
pprint.pprint(upstream_json)
|
||||
self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True)
|
||||
return False
|
||||
|
||||
# remove old stations
|
||||
if self.clean_all_sta:
|
||||
print("Removing all stations on resource.")
|
||||
@@ -159,8 +161,8 @@ class StaConnect2(LFCliBase):
|
||||
sta_url = self.get_station_url(sta_name)
|
||||
response = self.json_get(sta_url)
|
||||
if (response is not None) and (response["interface"] is not None):
|
||||
for sta_name in self.station_names:
|
||||
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
|
||||
for station in self.station_names:
|
||||
LFUtils.removePort(self.resource, station, self.lfclient_url)
|
||||
LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names)
|
||||
|
||||
# Create stations and turn dhcp on
|
||||
@@ -180,7 +182,8 @@ class StaConnect2(LFCliBase):
|
||||
for security in extra_securities:
|
||||
self.station_profile.add_security_extra(security=security)
|
||||
print("Adding new stations ", end="")
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug,
|
||||
suppress_related_commands_=True)
|
||||
LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug)
|
||||
|
||||
# Create UDP endpoints
|
||||
@@ -191,13 +194,13 @@ class StaConnect2(LFCliBase):
|
||||
self.l3_udp_profile.side_b_min_pdu = 1500
|
||||
self.l3_udp_profile.report_timer = 1000
|
||||
self.l3_udp_profile.name_prefix = "udp"
|
||||
port_list = list(self.localrealm.find_ports_like("%s+"%self.sta_prefix))
|
||||
port_list = list(self.localrealm.find_ports_like("%s+" % self.sta_prefix))
|
||||
if (port_list is None) or (len(port_list) < 1):
|
||||
raise ValueError("Unable to find ports named '%s'+"%self.sta_prefix)
|
||||
raise ValueError("Unable to find ports named '%s'+" % self.sta_prefix)
|
||||
self.l3_udp_profile.create(endp_type="lf_udp",
|
||||
side_a=port_list,
|
||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||
suppress_related_commands=True)
|
||||
side_a=port_list,
|
||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||
suppress_related_commands=True)
|
||||
|
||||
# Create TCP endpoints
|
||||
self.l3_tcp_profile = self.localrealm.new_l3_cx_profile()
|
||||
@@ -206,9 +209,9 @@ class StaConnect2(LFCliBase):
|
||||
self.l3_tcp_profile.name_prefix = "tcp"
|
||||
self.l3_tcp_profile.report_timer = 1000
|
||||
self.l3_tcp_profile.create(endp_type="lf_tcp",
|
||||
side_a=list(self.localrealm.find_ports_like("%s+"%self.sta_prefix)),
|
||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||
suppress_related_commands=True)
|
||||
side_a=list(self.localrealm.find_ports_like("%s+" % self.sta_prefix)),
|
||||
side_b="%d.%s" % (self.resource, self.upstream_port),
|
||||
suppress_related_commands=True)
|
||||
|
||||
def start(self):
|
||||
if self.station_profile is None:
|
||||
@@ -216,17 +219,17 @@ class StaConnect2(LFCliBase):
|
||||
pprint.pprint(self.station_profile)
|
||||
if self.station_profile.up is None:
|
||||
self._fail("Incorrect station profile, missing profile.up")
|
||||
if self.station_profile.up == False:
|
||||
if not self.station_profile.up:
|
||||
print("\nBringing ports up...")
|
||||
data = {"shelf": 1,
|
||||
"resource": self.resource,
|
||||
"port": "ALL",
|
||||
"probe_flags": 1}
|
||||
"resource": self.resource,
|
||||
"port": "ALL",
|
||||
"probe_flags": 1}
|
||||
self.json_post("/cli-json/nc_show_ports", data)
|
||||
self.station_profile.admin_up()
|
||||
LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names)
|
||||
|
||||
if self.influx_db is not None:
|
||||
if self.influx_db:
|
||||
grapher = RecordInflux(_influx_host=self.influx_host,
|
||||
_influx_db=self.influx_db,
|
||||
_influx_user=self.influx_user,
|
||||
@@ -268,19 +271,19 @@ class StaConnect2(LFCliBase):
|
||||
else:
|
||||
connected_stations[sta_name] = sta_url
|
||||
data = {
|
||||
"shelf":1,
|
||||
"shelf": 1,
|
||||
"resource": self.resource,
|
||||
"port": "ALL",
|
||||
"probe_flags": 1
|
||||
}
|
||||
self.json_post("/cli-json/nc_show_ports", data)
|
||||
if self.influx_db is not None:
|
||||
if self.influx_db:
|
||||
grapher.getdata()
|
||||
LFUtils.wait_until_ports_appear()
|
||||
|
||||
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")
|
||||
if station_info is None:
|
||||
print("unable to query %s" % sta_url)
|
||||
self.resulting_stations[sta_url] = station_info
|
||||
@@ -294,13 +297,14 @@ class StaConnect2(LFCliBase):
|
||||
print(" %s +AP %s, " % (sta_name, ap), end="")
|
||||
if self.dut_bssid != "":
|
||||
if self.dut_bssid.lower() == ap.lower():
|
||||
self._pass(sta_name+" connected to BSSID: " + ap)
|
||||
self._pass(sta_name + " connected to BSSID: " + ap)
|
||||
# self.test_results.append("PASSED: )
|
||||
# print("PASSED: Connected to BSSID: "+ap)
|
||||
else:
|
||||
self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
||||
self._fail(
|
||||
"%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap))
|
||||
else:
|
||||
self._fail(sta_name+" did not connect to AP")
|
||||
self._fail(sta_name + " did not connect to AP")
|
||||
return False
|
||||
|
||||
if ip == "0.0.0.0":
|
||||
@@ -308,10 +312,10 @@ class StaConnect2(LFCliBase):
|
||||
else:
|
||||
self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip))
|
||||
|
||||
if self.passes() == False:
|
||||
if not self.passes():
|
||||
if self.cleanup_on_exit:
|
||||
print("Cleaning up...")
|
||||
#self.remove_stations()
|
||||
self.remove_stations()
|
||||
return False
|
||||
|
||||
# start cx traffic
|
||||
@@ -325,7 +329,7 @@ class StaConnect2(LFCliBase):
|
||||
|
||||
def collect_endp_stats(self, endp_map):
|
||||
print("Collecting Data")
|
||||
fields="/all"
|
||||
fields = "/all"
|
||||
for (cx_name, endps) in endp_map.items():
|
||||
try:
|
||||
endp_url = "/endp/%s%s" % (endps[0], fields)
|
||||
@@ -334,7 +338,7 @@ class StaConnect2(LFCliBase):
|
||||
ptest_a_tx = endp_json['endpoint']['tx bytes']
|
||||
ptest_a_rx = endp_json['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%s" % (endps[1], fields)
|
||||
endp_json = self.json_get(endp_url)
|
||||
self.resulting_endpoints[endp_url] = endp_json
|
||||
@@ -351,7 +355,6 @@ class StaConnect2(LFCliBase):
|
||||
except Exception as e:
|
||||
self.error(e)
|
||||
|
||||
|
||||
def stop(self):
|
||||
# stop cx traffic
|
||||
print("Stopping CX Traffic")
|
||||
@@ -384,8 +387,9 @@ class StaConnect2(LFCliBase):
|
||||
curr_endp_names.append(endp_names[1])
|
||||
for (cx_name, endp_names) in self.l3_tcp_profile.created_cx.items():
|
||||
curr_endp_names.append(endp_names[0])
|
||||
curr_endp_names.append(endp_names[1])
|
||||
removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug)
|
||||
curr_endp_names.append(endp_names[1])
|
||||
removeEndps(self.lfclient_url, curr_endp_names, debug=self.debug)
|
||||
|
||||
|
||||
# ~class
|
||||
|
||||
@@ -419,11 +423,14 @@ Example:
|
||||
parser.add_argument("--dut_bssid", type=str, help="DUT BSSID to which we expect to connect.")
|
||||
parser.add_argument("--debug", type=str, help="enable debugging")
|
||||
parser.add_argument("--prefix", type=str, help="Station prefix. Default: 'sta'", default='sta')
|
||||
parser.add_argument("--bringup_time", type=int, help="Seconds to wait for stations to associate and aquire IP. Default: 300", default=300)
|
||||
parser.add_argument("--bringup_time", type=int,
|
||||
help="Seconds to wait for stations to associate and aquire IP. Default: 300", default=300)
|
||||
parser.add_argument('--influx_user', help='Username for your Influx database', default=None)
|
||||
parser.add_argument('--influx_passwd', help='Password for your Influx database', default=None)
|
||||
parser.add_argument('--influx_db', help='Name of your Influx database', default=None)
|
||||
parser.add_argument('--influx_host', help='Host of your influx database if different from the system you are running on', default='localhost')
|
||||
parser.add_argument('--influx_host',
|
||||
help='Host of your influx database if different from the system you are running on',
|
||||
default='localhost')
|
||||
parser.add_argument('--monitor_interval', help='How frequently you want to append to your database', default='5s')
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -432,18 +439,12 @@ Example:
|
||||
if args.port is not None:
|
||||
lfjson_port = args.port
|
||||
|
||||
on_flags = [ 1, "1", "on", "yes", "true" ]
|
||||
debug_v = False
|
||||
if args.debug is not None:
|
||||
if args.debug in on_flags:
|
||||
debug_v = True
|
||||
|
||||
staConnect = StaConnect2(lfjson_host, lfjson_port,
|
||||
debug_=True,
|
||||
_influx_db = args.influx_db,
|
||||
_influx_passwd = args.influx_passwd,
|
||||
_influx_user = args.influx_user,
|
||||
_influx_host = args.influx_host,
|
||||
_influx_db=args.influx_db,
|
||||
_influx_passwd=args.influx_passwd,
|
||||
_influx_user=args.influx_user,
|
||||
_influx_host=args.influx_host,
|
||||
_exit_on_fail=True,
|
||||
_exit_on_error=False)
|
||||
|
||||
@@ -471,19 +472,19 @@ Example:
|
||||
staConnect.dut_security = args.dut_security
|
||||
if (args.prefix is not None) or (args.prefix != "sta"):
|
||||
staConnect.sta_prefix = args.prefix
|
||||
staConnect.station_names = [ "%s0000"%args.prefix ]
|
||||
staConnect.station_names = ["%s0000" % args.prefix]
|
||||
staConnect.bringup_time_sec = args.bringup_time
|
||||
|
||||
# staConnect.cleanup()
|
||||
# staConnect.cleanup()
|
||||
staConnect.setup()
|
||||
staConnect.start()
|
||||
print("napping %f sec" % staConnect.runtime_secs)
|
||||
|
||||
time.sleep(staConnect.runtime_secs)
|
||||
staConnect.stop()
|
||||
run_results = staConnect.get_result_list()
|
||||
staConnect.get_result_list()
|
||||
is_passing = staConnect.passes()
|
||||
if is_passing == False:
|
||||
if not is_passing:
|
||||
print("FAIL: Some tests failed")
|
||||
else:
|
||||
print("PASS: All tests pass")
|
||||
@@ -491,6 +492,7 @@ Example:
|
||||
|
||||
staConnect.cleanup()
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -60,23 +59,19 @@ class client_connect(Realm):
|
||||
self.station_profile.desired_add_sta_flags_mask = ["use-bss-transition"]
|
||||
|
||||
for station_name in range(len(station_)):
|
||||
stat_list = []
|
||||
stat_list = [station_[station_name]]
|
||||
|
||||
stat_list.append(station_[station_name])
|
||||
print(station_name)
|
||||
self.station_profile.cleanup(stat_list)
|
||||
|
||||
try:
|
||||
if self.bssid[station_name] is not None or self.bssid[station_name] != "":
|
||||
self.station_profile.set_command_param("add_sta", "ap", bssid_list[station_name])
|
||||
except:
|
||||
if self.bssid[station_name]:
|
||||
self.station_profile.set_command_param("add_sta", "ap", bssid_list[station_name])
|
||||
else:
|
||||
self.station_profile.set_command_param("add_sta", "ap", "DEFAULT")
|
||||
|
||||
try:
|
||||
if self.mac[station_name] is not None or self.mac[station_name] != "":
|
||||
self.station_profile.add_sta_data["mac"] = mac_list[station_name]
|
||||
print(self.mac[station_name])
|
||||
except:
|
||||
if self.mac[station_name]:
|
||||
self.station_profile.add_sta_data["mac"] = mac_list[station_name]
|
||||
else:
|
||||
self.station_profile.add_sta_data["mac"] = "xx:xx:xx:xx:*:*"
|
||||
|
||||
print(stat_list)
|
||||
@@ -91,8 +86,7 @@ class client_connect(Realm):
|
||||
def main():
|
||||
# This has --mgr, --mgr_port and --debug
|
||||
parser = LFCliBase.create_bare_argparse(prog="sta_connect_bssid_mac.py",
|
||||
description=
|
||||
"""
|
||||
description="""
|
||||
--mgr localhost --mgr_port 8080
|
||||
--ssid "TestAP-Jitendra"
|
||||
--radio wiphy0
|
||||
|
||||
@@ -25,19 +25,11 @@ def main():
|
||||
prog='sta_connect_example.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter
|
||||
)
|
||||
required_args=None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args=group
|
||||
break;
|
||||
|
||||
optional_args=None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args=group
|
||||
break;
|
||||
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
monitor_interval = LFCliBase.parse_time(args.test_duration).total_seconds()
|
||||
if args.upstream_port is None:
|
||||
args.upstream_port = "eth2"
|
||||
if args.ssid is None:
|
||||
@@ -48,7 +40,7 @@ def main():
|
||||
args.security = sta_connect.WPA2
|
||||
if args.radio is None:
|
||||
args.radio = "wiphy0"
|
||||
staConnect = StaConnect("localhost", 8080, _debugOn=False)
|
||||
staConnect = StaConnect(args.mgr, args.mgr_port, _debugOn=args.debug, _runtime_sec=monitor_interval)
|
||||
staConnect.sta_mode = 0
|
||||
staConnect.upstream_resource = 1
|
||||
staConnect.upstream_port = args.upstream_port
|
||||
@@ -57,15 +49,15 @@ def main():
|
||||
staConnect.dut_security = args.security
|
||||
staConnect.dut_ssid = args.ssid
|
||||
staConnect.dut_passwd = args.passwd
|
||||
staConnect.station_names = [ "sta000" ]
|
||||
staConnect.station_names = ["sta000"]
|
||||
staConnect.setup()
|
||||
staConnect.start()
|
||||
time.sleep(20)
|
||||
staConnect.stop()
|
||||
#staConnect.finish()
|
||||
# staConnect.finish()
|
||||
staConnect.cleanup()
|
||||
is_passing = staConnect.passes()
|
||||
if is_passing == False:
|
||||
if not is_passing:
|
||||
# run_results = staConnect.get_failed_result_list()
|
||||
fail_message = staConnect.get_fail_message()
|
||||
print("Some tests failed:\n" + fail_message)
|
||||
@@ -78,5 +70,3 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
#
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
# if you lack __init__.py in this directory you will not find sta_connect module
|
||||
@@ -20,11 +20,24 @@ StaConnect = sta_connect.StaConnect
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='sta_connected_multip_example.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
sta_connected_multip_example.py
|
||||
|
||||
''',
|
||||
description='''\
|
||||
Example of how to instantiate StaConnect and run the test
|
||||
''')
|
||||
# args = parser.parse_args() - add this line if adding arguments
|
||||
parser.parse_args()
|
||||
|
||||
# create multiple OPEN stations
|
||||
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)
|
||||
_cleanup_on_exit=False, _runtime_sec=360, _exit_on_fail=True)
|
||||
test.sta_mode = sta_connect.MODE_AUTO
|
||||
test.upstream_resource = 1
|
||||
test.upstream_port = "eth1"
|
||||
@@ -49,7 +62,7 @@ def main():
|
||||
print("** endp: "+endp_name)
|
||||
pprint.pprint(test.resulting_endpoints[endp_name])
|
||||
'''
|
||||
if is_passing == False:
|
||||
if not is_passing:
|
||||
# run_results = staConnect.get_failed_result_list()
|
||||
fail_message = test.get_fail_message()
|
||||
print("Some tests failed:\n" + fail_message)
|
||||
@@ -63,7 +76,7 @@ def main():
|
||||
test.dut_passwd = "jedway-wpa2-x2048-5-1"
|
||||
test.run()
|
||||
is_passing = test.passes()
|
||||
if is_passing == False:
|
||||
if not is_passing:
|
||||
# run_results = staConnect.get_failed_result_list()
|
||||
fail_message = test.get_fail_message()
|
||||
print("Some tests failed:\n" + fail_message)
|
||||
@@ -71,7 +84,7 @@ def main():
|
||||
else:
|
||||
print("Tests pass")
|
||||
|
||||
if test.cleanup_on_exit == True:
|
||||
if test.cleanup_on_exit:
|
||||
test.remove_stations()
|
||||
|
||||
|
||||
|
||||
@@ -14,39 +14,42 @@ License: Free to distribute and modify. LANforge systems must be licensed.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import pandas as pd
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||
|
||||
if 'py-dashboard' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
|
||||
|
||||
import argparse
|
||||
from LANforge import LFUtils
|
||||
from realm import Realm
|
||||
import time
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
|
||||
|
||||
class StaScan(Realm):
|
||||
def __init__(self,
|
||||
ssid=None,
|
||||
security=None,
|
||||
password=None,
|
||||
sta_list=[],
|
||||
sta_list=None,
|
||||
upstream=None,
|
||||
radio=None,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
mode=0,
|
||||
number_template="00000",
|
||||
csv_output=False,
|
||||
use_ht160=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
if sta_list is None:
|
||||
sta_list = []
|
||||
super().__init__(lfclient_host=host,
|
||||
lfclient_port=port),
|
||||
self.upstream = upstream
|
||||
@@ -59,6 +62,7 @@ class StaScan(Realm):
|
||||
self.radio = radio
|
||||
self.mode = mode
|
||||
self.number_template = number_template
|
||||
self.csv_output = csv_output
|
||||
self.debug = _debug_on
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
@@ -76,22 +80,50 @@ class StaScan(Realm):
|
||||
def start(self):
|
||||
self.station_profile.admin_up()
|
||||
print(self.sta_list)
|
||||
print("Sleeping 15s while waiting for scan")
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": self.sta_list
|
||||
}
|
||||
self.json_post("/cli-json/scan_wifi", data)
|
||||
time.sleep(15)
|
||||
scan_results = self.json_get("scanresults/1/1/%s" % ','.join(self.sta_list))
|
||||
|
||||
print("{0:<23}".format("BSS"), "{0:<7}".format("Signal"), "{0:<5}".format("SSID"))
|
||||
for result in scan_results['scan-results']:
|
||||
for name, info in result.items():
|
||||
print("%s\t%s\t%s" % (info['bss'], info['signal'], info['ssid']))
|
||||
|
||||
LFUtils.wait_until_ports_admin_up(base_url=self.lfclient_url, port_list=self.station_profile.station_names,
|
||||
debug_=self.debug)
|
||||
stations = [LFUtils.name_to_eid(x) for x in self.sta_list]
|
||||
stations = pd.DataFrame(stations)
|
||||
resources = stations[1].unique()
|
||||
interfaces = list()
|
||||
for resource in resources:
|
||||
shelf = stations[0][0]
|
||||
resource_station = list(stations[stations[1] == resource][2])
|
||||
url = '/port/%s/%s/%s' % (shelf, resource, ','.join(resource_station))
|
||||
response = self.json_get(url)
|
||||
if 'interface' in response.keys():
|
||||
interface = response['interface']
|
||||
interfaces.append(interface)
|
||||
elif 'interfaces' in response.keys():
|
||||
response_interfaces = response['interfaces']
|
||||
for interface in response_interfaces:
|
||||
for item in interface.values():
|
||||
interfaces.append(item)
|
||||
df = pd.DataFrame(interfaces)
|
||||
stations = df[df['port type'] == 'WIFI-STA']
|
||||
stations = list(stations.drop_duplicates('parent dev')['alias'])
|
||||
stations = [station for station in stations if station in self.sta_list]
|
||||
|
||||
for port in stations:
|
||||
port = LFUtils.name_to_eid(port)
|
||||
data = {
|
||||
"shelf": port[0],
|
||||
"resource": port[1],
|
||||
"port": port[2]
|
||||
}
|
||||
self.json_post("/cli-json/scan_wifi", data)
|
||||
time.sleep(15)
|
||||
scan_results = self.json_get("scanresults/%s/%s/%s" % (port[0], port[1], port[2]))
|
||||
if self.csv_output:
|
||||
results = scan_results['scan-results']
|
||||
df = pd.DataFrame([list(result.values())[0] for result in results])
|
||||
df.to_csv(self.csv_output)
|
||||
print('CSV output saved at %s' % self.csv_output)
|
||||
else:
|
||||
print("{0:<23}".format("BSS"), "{0:<7}".format("Signal"), "{0:<5}".format("SSID"))
|
||||
for result in scan_results['scan-results']:
|
||||
for name, info in result.items():
|
||||
print("%s\t%s\t%s" % (info['bss'], info['signal'], info['ssid']))
|
||||
|
||||
def pre_cleanup(self):
|
||||
for sta in self.sta_list:
|
||||
@@ -130,7 +162,9 @@ def main():
|
||||
''')
|
||||
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--sta_name', help='Name of station to be used', default=["sta0000"])
|
||||
parser.add_argument('--sta_name', help='Optional: User defined station names, can be a comma or space separated list', nargs='+',
|
||||
default=["sta0000"])
|
||||
parser.add_argument('--csv_output', help='create CSV from scan results, otherwise print it in the terminal', default=None)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -145,6 +179,7 @@ def main():
|
||||
radio=args.radio,
|
||||
security=args.security,
|
||||
use_ht160=False,
|
||||
csv_output=args.csv_output,
|
||||
mode=args.mode,
|
||||
_debug_on=args.debug)
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
"""
|
||||
this script creates 1 station on given arguments
|
||||
how to run - [lanforge@LF4-Node2 py-scripts]$ python3 station_banao.py -hst localhost -s TestAP22 -pwd [BLANK] -sec open -rad wiphy0
|
||||
'''
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
import time
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -20,7 +19,8 @@ Realm = realm.Realm
|
||||
|
||||
|
||||
class STATION(LFCliBase):
|
||||
def __init__(self, lfclient_host, lfclient_port, ssid, paswd, security, radio, sta_list=None, name_prefix="L3Test", upstream="eth2"):
|
||||
def __init__(self, lfclient_host, lfclient_port, ssid, paswd, security, radio, sta_list=None, name_prefix="L3Test",
|
||||
upstream="eth2"):
|
||||
super().__init__(lfclient_host, lfclient_port)
|
||||
self.host = lfclient_host
|
||||
self.port = lfclient_port
|
||||
@@ -46,7 +46,6 @@ class STATION(LFCliBase):
|
||||
self.cx_profile.side_b_min_bps = 1000000
|
||||
self.cx_profile.side_b_max_bps = 1000000
|
||||
|
||||
|
||||
def precleanup(self, sta_list):
|
||||
self.cx_profile.cleanup_prefix()
|
||||
for sta in self.sta_list:
|
||||
@@ -62,7 +61,7 @@ class STATION(LFCliBase):
|
||||
self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream,
|
||||
sleep_time=0)
|
||||
|
||||
def start(self, sta_list):
|
||||
def start(self):
|
||||
self.station_profile.admin_up()
|
||||
temp_stas = self.station_profile.station_names.copy()
|
||||
if self.local_realm.wait_for_ip(temp_stas):
|
||||
@@ -72,16 +71,12 @@ class STATION(LFCliBase):
|
||||
self.exit_fail()
|
||||
self.cx_profile.start_cx()
|
||||
|
||||
|
||||
def stop(self):
|
||||
# Bring stations down
|
||||
self.station_profile.admin_down()
|
||||
self.cx_profile.stop_cx()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='station_layer3.py',
|
||||
@@ -92,7 +87,7 @@ def main():
|
||||
parser.add_argument('-pwd', '--passwd', type=str, help='password to connect to ssid')
|
||||
parser.add_argument('-sec', '--security', type=str, help='security')
|
||||
parser.add_argument('-rad', '--radio', type=str, help='radio at which client will be connected')
|
||||
#parser.add_argument()
|
||||
# parser.add_argument()
|
||||
args = parser.parse_args()
|
||||
num_sta = 1
|
||||
station_list = LFUtils.port_name_series(prefix="sta",
|
||||
@@ -100,10 +95,12 @@ def main():
|
||||
end_id=num_sta - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
obj = STATION(lfclient_host= args.host, lfclient_port=8080, ssid=args.ssid , paswd=args.passwd, security=args.security, radio=args.radio, sta_list=station_list)
|
||||
obj = STATION(lfclient_host=args.host, lfclient_port=8080, ssid=args.ssid, paswd=args.passwd,
|
||||
security=args.security, radio=args.radio, sta_list=station_list)
|
||||
obj.precleanup(station_list)
|
||||
obj.build()
|
||||
obj.start(station_list)
|
||||
obj.start()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
import argparse
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -19,16 +19,16 @@ Realm = realm.Realm
|
||||
|
||||
class StationsConnected(LFCliBase):
|
||||
def __init__(self, lfjson_host, lfjson_port):
|
||||
super().__init__(_lfjson_host=lfjson_host, _lfjson_port=lfjson_port, _debug=False)
|
||||
self.localrealm = Realm(lfclient_host=lfjson_host, lfclient_port=lfjson_port, debug=False)
|
||||
super().__init__(_lfjson_host=lfjson_host, _lfjson_port=lfjson_port)
|
||||
self.localrealm = Realm(lfclient_host=lfjson_host, lfclient_port=lfjson_port)
|
||||
self.check_connect()
|
||||
fields = "_links,port,alias,ip,ap,port+type"
|
||||
self.station_results = self.localrealm.find_ports_like("sta*", fields, debug_=False)
|
||||
|
||||
def run(self):
|
||||
self.clear_test_results()
|
||||
fields = "_links,port,alias,ip,ap,port+type"
|
||||
self.station_results = self.localrealm.find_ports_like("sta*", fields, debug_=False)
|
||||
#pprint(self.station_results)
|
||||
if (self.station_results is None) or (len(self.station_results) < 1):
|
||||
# pprint(self.station_results)
|
||||
if not self.station_results or (len(self.station_results) < 1):
|
||||
self.get_failed_result_list()
|
||||
return False
|
||||
return True
|
||||
@@ -36,16 +36,30 @@ class StationsConnected(LFCliBase):
|
||||
def num_associated(self, bssid):
|
||||
counter = 0
|
||||
# print("there are %d results" % len(self.station_results))
|
||||
for eid,record in self.station_results.items():
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
#pprint(eid)
|
||||
#pprint(record)
|
||||
for eid, record in self.station_results.items():
|
||||
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# pprint(eid)
|
||||
# pprint(record)
|
||||
if record["ap"] == bssid:
|
||||
counter += 1
|
||||
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
# print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
|
||||
return counter
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='stations_connected.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
stations_connected.py
|
||||
|
||||
''',
|
||||
description='''\
|
||||
Contains examples of using realm to query stations and get specific information from them
|
||||
''')
|
||||
# if args are added args=parser.parse_args() swap out next line
|
||||
parser.parse_args()
|
||||
|
||||
qstationsx = StationsConnected("localhost", 8080)
|
||||
bssid = "00:0E:8E:7B:DF:9B"
|
||||
if qstationsx.run():
|
||||
@@ -54,5 +68,6 @@ def main():
|
||||
else:
|
||||
print("problem querying for stations for %s" % bssid)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -10,7 +10,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
@@ -22,45 +21,51 @@ Realm = realm.Realm
|
||||
|
||||
class Test1KClients(LFCliBase):
|
||||
def __init__(self,
|
||||
upstream,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
side_a_min_rate= 0,side_a_max_rate= 56000,
|
||||
side_b_min_rate= 0,side_b_max_rate= 56000,
|
||||
num_sta_=200,
|
||||
test_duration="2d",
|
||||
_debug_on=True,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
upstream,
|
||||
host="localhost",
|
||||
port=8080,
|
||||
side_a_min_rate=0, side_a_max_rate=56000,
|
||||
side_b_min_rate=0, side_b_max_rate=56000,
|
||||
num_sta_=200,
|
||||
test_duration="2d",
|
||||
_debug_on=True,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host,
|
||||
port,
|
||||
_debug=_debug_on,
|
||||
_local_realm=Realm(lfclient_host=host, lfclient_port=port),
|
||||
_exit_on_fail=_exit_on_fail)
|
||||
self.ssid_radio_map = {
|
||||
'1.1.wiphy0' : ("wpa2", "jedway-wpa2-x2048-4-4", "jedway-wpa2-x2048-4-4"),
|
||||
'1.1.wiphy1' : ("wpa2", "jedway-wpa2-x2048-5-1", "jedway-wpa2-x2048-5-1"),
|
||||
'1.1.wiphy2' : ("wpa2", "jedway-wpa2-x2048-4-1", "jedway-wpa2-x2048-4-1"),
|
||||
'1.1.wiphy0': ("wpa2", "jedway-wpa2-x2048-4-4", "jedway-wpa2-x2048-4-4"),
|
||||
'1.1.wiphy1': ("wpa2", "jedway-wpa2-x2048-5-1", "jedway-wpa2-x2048-5-1"),
|
||||
'1.1.wiphy2': ("wpa2", "jedway-wpa2-x2048-4-1", "jedway-wpa2-x2048-4-1"),
|
||||
|
||||
'1.2.wiphy0' : ("wpa2", "jedway-wpa2-x2048-5-3", "jedway-wpa2-x2048-5-3"),
|
||||
'1.2.wiphy1' : ("wpa2", "jedway-wpa2-x2048-4-4", "jedway-wpa2-x2048-4-4"),
|
||||
'1.2.wiphy2' : ("wpa2", "jedway-wpa2-x2048-4-1", "jedway-wpa2-x2048-4-1"),
|
||||
'1.2.wiphy0': ("wpa2", "jedway-wpa2-x2048-5-3", "jedway-wpa2-x2048-5-3"),
|
||||
'1.2.wiphy1': ("wpa2", "jedway-wpa2-x2048-4-4", "jedway-wpa2-x2048-4-4"),
|
||||
'1.2.wiphy2': ("wpa2", "jedway-wpa2-x2048-4-1", "jedway-wpa2-x2048-4-1"),
|
||||
}
|
||||
if num_sta_ is None:
|
||||
raise ValueError("need a number of stations per radio")
|
||||
self.num_sta = int(num_sta_)
|
||||
self.station_radio_map = {
|
||||
# port_name_series(prefix=prefix_, start_id=start_id_, end_id=end_id_, padding_number=padding_number_, radio=radio)
|
||||
"1.1.wiphy0" : LFUtils.port_name_series(start_id=0, end_id=self.num_sta-1, padding_number=10000, radio="1.1.wiphy0"),
|
||||
"1.1.wiphy1" : LFUtils.port_name_series(start_id=1000, end_id=1000+self.num_sta-1, padding_number=10000, radio="1.1.wiphy1"),
|
||||
"1.1.wiphy2" : LFUtils.port_name_series(start_id=2000, end_id=2000+self.num_sta-1, padding_number=10000, radio="1.1.wiphy2"),
|
||||
"1.1.wiphy0": LFUtils.port_name_series(start_id=0, end_id=self.num_sta - 1, padding_number=10000,
|
||||
radio="1.1.wiphy0"),
|
||||
"1.1.wiphy1": LFUtils.port_name_series(start_id=1000, end_id=1000 + self.num_sta - 1, padding_number=10000,
|
||||
radio="1.1.wiphy1"),
|
||||
"1.1.wiphy2": LFUtils.port_name_series(start_id=2000, end_id=2000 + self.num_sta - 1, padding_number=10000,
|
||||
radio="1.1.wiphy2"),
|
||||
|
||||
"1.2.wiphy0" : LFUtils.port_name_series(start_id=3000, end_id=3000+self.num_sta-1, padding_number=10000, radio="1.2.wiphy0"),
|
||||
"1.2.wiphy1" : LFUtils.port_name_series(start_id=4000, end_id=4000+self.num_sta-1, padding_number=10000, radio="1.2.wiphy1"),
|
||||
"1.2.wiphy2" : LFUtils.port_name_series(start_id=5000, end_id=5000+self.num_sta-1, padding_number=10000, radio="1.2.wiphy2")
|
||||
"1.2.wiphy0": LFUtils.port_name_series(start_id=3000, end_id=3000 + self.num_sta - 1, padding_number=10000,
|
||||
radio="1.2.wiphy0"),
|
||||
"1.2.wiphy1": LFUtils.port_name_series(start_id=4000, end_id=4000 + self.num_sta - 1, padding_number=10000,
|
||||
radio="1.2.wiphy1"),
|
||||
"1.2.wiphy2": LFUtils.port_name_series(start_id=5000, end_id=5000 + self.num_sta - 1, padding_number=10000,
|
||||
radio="1.2.wiphy2")
|
||||
}
|
||||
self.test_duration=test_duration
|
||||
self.upstream=upstream
|
||||
self.test_duration = test_duration
|
||||
self.upstream = upstream
|
||||
self.name_prefix = "1k"
|
||||
self.cx_profile = self.local_realm.new_l3_cx_profile()
|
||||
self.cx_profile.name_prefix = self.name_prefix
|
||||
@@ -70,28 +75,27 @@ class Test1KClients(LFCliBase):
|
||||
self.cx_profile.side_b_max_bps = side_b_max_rate
|
||||
|
||||
self.station_profile_map = {}
|
||||
#change resource admin_up rate
|
||||
# change resource admin_up rate
|
||||
self.local_realm.json_post("/cli-json/set_resource", {
|
||||
"shelf":1,
|
||||
"resource":all,
|
||||
"shelf": 1,
|
||||
"resource": all,
|
||||
"max_staged_bringup": 30,
|
||||
"max_trying_ifup": 15,
|
||||
"max_station_bringup": 6
|
||||
})
|
||||
|
||||
|
||||
def build(self):
|
||||
for (radio, name_series) in self.station_radio_map.items():
|
||||
print("building stations for %s"%radio)
|
||||
print("building stations for %s" % radio)
|
||||
if (name_series is None) or len(name_series) < 1:
|
||||
print("No name series for %s"%radio)
|
||||
print("No name series for %s" % radio)
|
||||
continue
|
||||
station_profile = self.local_realm.new_station_profile()
|
||||
station_profile.use_security(self.ssid_radio_map[radio][0],
|
||||
self.ssid_radio_map[radio][1],
|
||||
self.ssid_radio_map[radio][2])
|
||||
self.station_profile_map[radio] = station_profile
|
||||
|
||||
|
||||
self._pass("defined %s station profiles" % len(self.station_radio_map))
|
||||
for (radio, station_profile) in self.station_profile_map.items():
|
||||
station_profile.create(radio=radio,
|
||||
@@ -105,7 +109,8 @@ class Test1KClients(LFCliBase):
|
||||
sleep_time=.02)
|
||||
station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.cx_profile.create(endp_type="lf_udp", side_a=station_profile.station_names, side_b=self.upstream, sleep_time=0)
|
||||
self.cx_profile.create(endp_type="lf_udp", side_a=station_profile.station_names, side_b=self.upstream,
|
||||
sleep_time=0)
|
||||
|
||||
self._pass("built stations on %s radios" % len(self.station_radio_map))
|
||||
|
||||
@@ -118,8 +123,8 @@ class Test1KClients(LFCliBase):
|
||||
if cx_name != 'uri' and cx_name != 'handler':
|
||||
for item, value in cx_name.items():
|
||||
for value_name, value_rx in value.items():
|
||||
if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values():
|
||||
cx_rx_map[item] = value_rx
|
||||
if value_name == 'rx bytes' and item in self.cx_profile.created_cx.values():
|
||||
cx_rx_map[item] = value_rx
|
||||
return cx_rx_map
|
||||
|
||||
def __compare_vals(self, old_list, new_list):
|
||||
@@ -135,28 +140,32 @@ class Test1KClients(LFCliBase):
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
return False
|
||||
|
||||
def start(self):
|
||||
print("Bringing stations up...")
|
||||
prev_ip_num=0
|
||||
prev_ip_num = 0
|
||||
for (radio, station_profile) in self.station_profile_map.items():
|
||||
station_profile.admin_up()
|
||||
total_num_sta=6*self.num_sta
|
||||
total_num_sta = 6 * self.num_sta
|
||||
self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=30)
|
||||
curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug)
|
||||
while ((prev_ip_num < curr_ip_num) and (curr_ip_num < total_num_sta)):
|
||||
self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug, timeout_sec=90)
|
||||
curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,
|
||||
station_list=self.station_radio_map[radio],
|
||||
debug=self.debug)
|
||||
while (prev_ip_num < curr_ip_num) and (curr_ip_num < total_num_sta):
|
||||
self.local_realm.wait_for_ip(station_list=self.station_radio_map[radio], debug=self.debug,
|
||||
timeout_sec=90)
|
||||
prev_ip_num = curr_ip_num
|
||||
curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,station_list=self.station_radio_map[radio], debug=self.debug)
|
||||
curr_ip_num = self.local_realm.get_curr_num_ips(num_sta_with_ips=prev_ip_num,
|
||||
station_list=self.station_radio_map[radio],
|
||||
debug=self.debug)
|
||||
if curr_ip_num == total_num_sta:
|
||||
self._pass("stations on radio %s up" % radio)
|
||||
else:
|
||||
else:
|
||||
self._fail("FAIL: Not all stations on radio %s up" % radio)
|
||||
self.exit_fail()
|
||||
|
||||
|
||||
old_cx_rx_values = self.__get_rx_values()
|
||||
|
||||
old_cx_rx_values = self.__get_rx_values()
|
||||
self.cx_profile.start_cx()
|
||||
|
||||
passes = 0
|
||||
@@ -188,34 +197,31 @@ class Test1KClients(LFCliBase):
|
||||
if passes == expected_passes:
|
||||
self._pass("PASS: All tests passed")
|
||||
|
||||
|
||||
def stop(self):
|
||||
self.cx_profile.stop_cx()
|
||||
|
||||
def pre_cleanup(self):
|
||||
self.cx_profile.cleanup_prefix()
|
||||
for (radio, name_series) in self.station_radio_map.items():
|
||||
sta_list= self.station_radio_map[radio]
|
||||
sta_list = self.station_radio_map[radio]
|
||||
for sta in sta_list:
|
||||
self.local_realm.rm_port(sta, check_exists=True)
|
||||
|
||||
def post_cleanup(self):
|
||||
self.cx_profile.cleanup()
|
||||
for (radio, name_series) in self.station_radio_map.items():
|
||||
sta_list= self.station_radio_map[radio]
|
||||
sta_list = self.station_radio_map[radio]
|
||||
for sta in sta_list:
|
||||
self.local_realm.rm_port(sta, check_exists=True)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
parser = LFCliBase.create_bare_argparse(prog=__file__,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
creates lots of stations across multiple radios.
|
||||
''',
|
||||
description='''\
|
||||
description='''\
|
||||
test_1k_clients_jedtest.py:
|
||||
--------------------
|
||||
Generic command layout:
|
||||
@@ -228,31 +234,33 @@ def main():
|
||||
--b_min 1000
|
||||
--a_max 0
|
||||
--b_max 0
|
||||
--debug '''
|
||||
)
|
||||
|
||||
required_args=None
|
||||
--debug '''
|
||||
)
|
||||
|
||||
required_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "required arguments":
|
||||
required_args=group
|
||||
required_args = group
|
||||
break
|
||||
|
||||
if required_args is not None:
|
||||
required_args.add_argument("--sta_per_radio",type=int,help="number of stations per radio")
|
||||
|
||||
optional_args=None
|
||||
required_args.add_argument("--sta_per_radio", type=int, help="number of stations per radio")
|
||||
|
||||
optional_args = None
|
||||
for group in parser._action_groups:
|
||||
if group.title == "optional arguments":
|
||||
optional_args=group
|
||||
optional_args = group
|
||||
break
|
||||
if optional_args is not None:
|
||||
optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=0)
|
||||
optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=0)
|
||||
optional_args.add_argument('--a_max', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
optional_args.add_argument('--b_max', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m")
|
||||
optional_args.add_argument('-u', '--upstream_port',help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',default='1.eth1')
|
||||
|
||||
optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test',
|
||||
default="2m")
|
||||
optional_args.add_argument('-u', '--upstream_port',
|
||||
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
|
||||
default='1.eth1')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -275,10 +283,11 @@ def main():
|
||||
kilo_test.exit_failed()
|
||||
kilo_test.stop()
|
||||
if not kilo_test.passes():
|
||||
kilo_test.exit_failed()
|
||||
kilo_test.exit_failed()
|
||||
time.sleep(60)
|
||||
kilo_test.post_cleanup()
|
||||
kilo_test.exit_success()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -49,7 +49,7 @@ class LoadLayer3(Realm):
|
||||
self.cx_profile.side_b_min_bps = 0
|
||||
self.cx_profile.side_b_max_bps = 0
|
||||
|
||||
def precleanup(self, num_sta):
|
||||
def precleanup(self):
|
||||
num_sta = self.num_sta
|
||||
station_list = LFUtils.port_name_series(prefix="sta",
|
||||
start_id=0,
|
||||
@@ -80,7 +80,7 @@ class LoadLayer3(Realm):
|
||||
self.local_realm._fail("Stations failed to get IPs", print_=True)
|
||||
return 0
|
||||
|
||||
def start(self, num_sta):
|
||||
def start(self):
|
||||
num_sta = self.num_sta
|
||||
station_list = LFUtils.port_name_series(prefix="sta",
|
||||
start_id=0,
|
||||
@@ -118,9 +118,9 @@ def main():
|
||||
|
||||
obj = LoadLayer3(lfclient_host=args.host, lfclient_port=8080, ssid=args.ssid, paswd=args.passwd,
|
||||
security=args.security, radio=args.radio, num_sta=args.num_sta)
|
||||
obj.precleanup(num_sta=args.num_sta)
|
||||
obj.precleanup()
|
||||
|
||||
obj.start(num_sta=args.num_sta)
|
||||
obj.start()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -37,7 +37,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -54,14 +53,14 @@ class FileIOTest(LFCliBase):
|
||||
number_template="00000",
|
||||
radio="wiphy0",
|
||||
fs_type=fe_fstype.EP_FE_NFS4.name,
|
||||
min_rw_size=64*1024,
|
||||
max_rw_size=64*1024,
|
||||
min_file_size=25*1024*1024,
|
||||
max_file_size=25*1024*1024,
|
||||
min_read_rate_bps=1000*1000,
|
||||
max_read_rate_bps=1000*1000,
|
||||
min_rw_size=64 * 1024,
|
||||
max_rw_size=64 * 1024,
|
||||
min_file_size=25 * 1024 * 1024,
|
||||
max_file_size=25 * 1024 * 1024,
|
||||
min_read_rate_bps=1000 * 1000,
|
||||
max_read_rate_bps=1000 * 1000,
|
||||
min_write_rate_bps="1G",
|
||||
max_write_rate_bps=1000*1000,
|
||||
max_write_rate_bps=1000 * 1000,
|
||||
directory="AUTO",
|
||||
test_duration="5m",
|
||||
upstream_port="eth1",
|
||||
@@ -76,15 +75,19 @@ class FileIOTest(LFCliBase):
|
||||
use_test_groups=False,
|
||||
write_only_test_group=None,
|
||||
read_only_test_group=None,
|
||||
port_list=[],
|
||||
port_list=None,
|
||||
ip_list=None,
|
||||
connections_per_port=1,
|
||||
mode="both",
|
||||
update_group_args={"name": None, "action": None, "cxs": None},
|
||||
update_group_args=None,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
if port_list is None:
|
||||
port_list = []
|
||||
if update_group_args is None:
|
||||
update_group_args = {"name": None, "action": None, "cxs": None}
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.radio = radio
|
||||
@@ -128,14 +131,14 @@ class FileIOTest(LFCliBase):
|
||||
raise ValueError("--write_only_test_group and --read_only_test_group "
|
||||
"must be used to set test group names")
|
||||
|
||||
#self.min_rw_size = self.parse_size(min_rw_size)
|
||||
#self.max_rw_size = self.parse_size(max_rw_size)
|
||||
#self.min_file_size = self.parse_size(min_file_size)
|
||||
#self.min_file_size = self.parse_size(min_file_size)
|
||||
#self.min_read_rate_bps = self.parse_size_bps(min_read_rate_bps)
|
||||
# self.min_rw_size = self.parse_size(min_rw_size)
|
||||
# self.max_rw_size = self.parse_size(max_rw_size)
|
||||
# self.min_file_size = self.parse_size(min_file_size)
|
||||
# self.min_file_size = self.parse_size(min_file_size)
|
||||
# self.min_read_rate_bps = self.parse_size_bps(min_read_rate_bps)
|
||||
# self.max_read_rate_bps = self.sisize_bps(max_read_rate_bps)
|
||||
# self.min_write_rate_bps = self.parse_size_bps(min_write_rate_bps)
|
||||
#self.max_write_rate_bps = self.parse_size_bps(max_write_rate_bps)
|
||||
# self.max_write_rate_bps = self.parse_size_bps(max_write_rate_bps)
|
||||
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.wo_profile = self.local_realm.new_fio_endp_profile()
|
||||
@@ -271,14 +274,14 @@ class FileIOTest(LFCliBase):
|
||||
time.sleep(3)
|
||||
if self.mode == "write":
|
||||
cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % (
|
||||
','.join(self.wo_profile.created_cx.keys())), debug_=self.debug)
|
||||
','.join(self.wo_profile.created_cx.keys())), debug_=self.debug)
|
||||
elif self.mode == "read":
|
||||
cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % (
|
||||
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
|
||||
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
|
||||
else:
|
||||
cx_list = self.json_get("fileio/%s,%s?fields=write-bps,read-bps" % (
|
||||
','.join(self.wo_profile.created_cx.keys()),
|
||||
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
|
||||
','.join(self.wo_profile.created_cx.keys()),
|
||||
','.join(self.ro_profile.created_cx.keys())), debug_=self.debug)
|
||||
# print(cx_list)
|
||||
# print("==============\n", cx_list, "\n==============")
|
||||
cx_map = {}
|
||||
@@ -288,7 +291,8 @@ class FileIOTest(LFCliBase):
|
||||
for i in cx_list:
|
||||
for item, value in i.items():
|
||||
# print(item, value)
|
||||
cx_map[self.local_realm.name_to_eid(item)[2]] = {"read-bps": value['read-bps'], "write-bps": value['write-bps']}
|
||||
cx_map[self.local_realm.name_to_eid(item)[2]] = {"read-bps": value['read-bps'],
|
||||
"write-bps": value['write-bps']}
|
||||
# print(cx_map)
|
||||
return cx_map
|
||||
|
||||
@@ -342,7 +346,8 @@ class FileIOTest(LFCliBase):
|
||||
if self.wo_tg_exists:
|
||||
if not self.wo_tg_cx_exists:
|
||||
print("Creating Write Only CXs")
|
||||
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||
self.wo_profile.create(ports=self.created_ports,
|
||||
connections_per_port=self.connections_per_port,
|
||||
sleep_time=.5, debug_=self.debug,
|
||||
suppress_related_commands_=None)
|
||||
time.sleep(1)
|
||||
@@ -364,7 +369,8 @@ class FileIOTest(LFCliBase):
|
||||
if self.ro_tg_exists:
|
||||
if not self.ro_tg_cx_exists:
|
||||
print("Creating Read Only CXs")
|
||||
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||
self.ro_profile.create(ports=self.created_ports,
|
||||
connections_per_port=self.connections_per_port,
|
||||
sleep_time=.5, debug_=self.debug,
|
||||
suppress_related_commands_=None)
|
||||
time.sleep(1)
|
||||
@@ -386,7 +392,8 @@ class FileIOTest(LFCliBase):
|
||||
if self.wo_tg_exists:
|
||||
if not self.wo_tg_cx_exists:
|
||||
print("Creating Write Only CXs")
|
||||
self.wo_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||
self.wo_profile.create(ports=self.created_ports,
|
||||
connections_per_port=self.connections_per_port,
|
||||
sleep_time=.5, debug_=self.debug,
|
||||
suppress_related_commands_=None)
|
||||
time.sleep(1)
|
||||
@@ -407,7 +414,8 @@ class FileIOTest(LFCliBase):
|
||||
if self.ro_tg_exists:
|
||||
if not self.ro_tg_cx_exists:
|
||||
print("Creating Read Only CXs")
|
||||
self.ro_profile.create(ports=self.created_ports, connections_per_port=self.connections_per_port,
|
||||
self.ro_profile.create(ports=self.created_ports,
|
||||
connections_per_port=self.connections_per_port,
|
||||
sleep_time=.5, debug_=self.debug,
|
||||
suppress_related_commands_=None)
|
||||
time.sleep(1)
|
||||
@@ -454,7 +462,7 @@ class FileIOTest(LFCliBase):
|
||||
|
||||
def start(self, print_pass=False, print_fail=False):
|
||||
temp_ports = self.created_ports.copy()
|
||||
#temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2])
|
||||
# temp_stas.append(self.local_realm.name_to_eid(self.upstream_port)[2])
|
||||
if not self.use_macvlans:
|
||||
self.station_profile.admin_up()
|
||||
else:
|
||||
@@ -617,14 +625,14 @@ Generic command layout:
|
||||
parser.add_argument('--passwd', '--password', '--key', help='WiFi passphrase/password/key')
|
||||
parser.add_argument('--security', help='security type to use for ssid { wep | wpa | wpa2 | wpa3 | open }')
|
||||
parser.add_argument('-u', '--upstream_port',
|
||||
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
|
||||
default='1.eth1')
|
||||
help='non-station port that generates traffic: <resource>.<port>, e.g: 1.eth1',
|
||||
default='1.eth1')
|
||||
parser.add_argument('--test_duration', help='sets the duration of the test', default="5m")
|
||||
parser.add_argument('--fs_type', help='endpoint type', default="fe_nfs4")
|
||||
parser.add_argument('--min_rw_size', help='minimum read/write size', default=64*1024)
|
||||
parser.add_argument('--max_rw_size', help='maximum read/write size', default=64*1024)
|
||||
parser.add_argument('--min_file_size', help='minimum file size', default=50*1024*1024)
|
||||
parser.add_argument('--max_file_size', help='maximum file size', default=50*1024*1024)
|
||||
parser.add_argument('--min_rw_size', help='minimum read/write size', default=64 * 1024)
|
||||
parser.add_argument('--max_rw_size', help='maximum read/write size', default=64 * 1024)
|
||||
parser.add_argument('--min_file_size', help='minimum file size', default=50 * 1024 * 1024)
|
||||
parser.add_argument('--max_file_size', help='maximum file size', default=50 * 1024 * 1024)
|
||||
parser.add_argument('--min_read_rate_bps', help='minimum bps read rate', default=10e9)
|
||||
parser.add_argument('--max_read_rate_bps', help='maximum bps read rate', default=10e9)
|
||||
parser.add_argument('--min_write_rate_bps', help='minimum bps write rate', default=10e9)
|
||||
@@ -654,15 +662,14 @@ Generic command layout:
|
||||
tg_group = parser.add_mutually_exclusive_group()
|
||||
tg_group.add_argument('--add_to_group', help='name of test group to add cxs to', default=None)
|
||||
tg_group.add_argument('--del_from_group', help='name of test group to delete cxs from', default=None)
|
||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group'
|
||||
, default=None)
|
||||
parser.add_argument('--cxs', help='list of cxs to add/remove depending on use of --add_to_group or --del_from_group', default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
update_group_args = {
|
||||
"name": None,
|
||||
"action": None,
|
||||
"cxs": None
|
||||
}
|
||||
}
|
||||
if args.add_to_group is not None and args.cxs is not None:
|
||||
update_group_args['name'] = args.add_to_group
|
||||
update_group_args['action'] = "add"
|
||||
@@ -679,17 +686,17 @@ Generic command layout:
|
||||
if (args.num_ports is not None) and (int(args.num_ports) > 0):
|
||||
start_num = int(args.first_port[3:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num+num_ports-1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num + num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
if (args.num_ports is not None) and args.macvlan_parent is not None and (int(args.num_ports) > 0) \
|
||||
and args.macvlan_parent in args.first_port:
|
||||
start_num = int(args.first_port[args.first_port.index('#')+1:])
|
||||
and args.macvlan_parent in args.first_port:
|
||||
start_num = int(args.first_port[args.first_port.index('#') + 1:])
|
||||
num_ports = int(args.num_ports)
|
||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent+"#", start_id=start_num,
|
||||
end_id=start_num+num_ports-1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=start_num,
|
||||
end_id=start_num + num_ports - 1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
raise ValueError("Invalid values for num_ports [%s], macvlan_parent [%s], and/or first_port [%s].\n"
|
||||
"first_port must contain parent port and num_ports must be greater than 0"
|
||||
@@ -699,12 +706,12 @@ Generic command layout:
|
||||
num_ports = int(args.num_ports)
|
||||
if not args.use_macvlans:
|
||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1,
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
padding_number=10000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0,
|
||||
end_id=num_ports - 1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
end_id=num_ports - 1, padding_number=100000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
temp_list = args.use_ports.split(',')
|
||||
for port in temp_list:
|
||||
@@ -763,7 +770,7 @@ Generic command layout:
|
||||
use_test_groups=args.use_test_groups,
|
||||
write_only_test_group=args.write_only_test_group,
|
||||
read_only_test_group=args.read_only_test_group,
|
||||
update_group_args = update_group_args,
|
||||
update_group_args=update_group_args,
|
||||
connections_per_port=args.connections_per_port,
|
||||
mode=args.mode
|
||||
# want a mount options param
|
||||
|
||||
@@ -43,7 +43,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -55,14 +54,14 @@ Realm = realm.Realm
|
||||
|
||||
class GenTest(LFCliBase):
|
||||
def __init__(self, ssid, security, passwd, sta_list, client, name_prefix, upstream, host="localhost", port=8080,
|
||||
number_template="000", test_duration="5m", type="lfping", dest=None, cmd =None,
|
||||
number_template="000", test_duration="5m", test_type="lfping", dest=None, cmd=None,
|
||||
interval=1, radio=None, speedtest_min_up=None, speedtest_min_dl=None, speedtest_max_ping=None,
|
||||
file_output=None,
|
||||
loop_count=None,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port, _local_realm=Realm(host,port), _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
super().__init__(host, port, _local_realm=Realm(host, port), _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.ssid = ssid
|
||||
self.radio = radio
|
||||
self.upstream = upstream
|
||||
@@ -73,7 +72,7 @@ class GenTest(LFCliBase):
|
||||
self.name_prefix = name_prefix
|
||||
self.test_duration = test_duration
|
||||
self.debug = _debug_on
|
||||
if (client is not None):
|
||||
if client:
|
||||
self.client_name = client
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.generic_endps_profile = self.local_realm.new_generic_endp_profile()
|
||||
@@ -86,17 +85,17 @@ class GenTest(LFCliBase):
|
||||
self.station_profile.mode = 0
|
||||
|
||||
self.generic_endps_profile.name = name_prefix
|
||||
self.generic_endps_profile.type = type
|
||||
self.generic_endps_profile.type = test_type
|
||||
self.generic_endps_profile.dest = dest
|
||||
self.generic_endps_profile.cmd = cmd
|
||||
self.generic_endps_profile.interval = interval
|
||||
self.generic_endps_profile.file_output= file_output
|
||||
self.generic_endps_profile.file_output = file_output
|
||||
self.generic_endps_profile.loop_count = loop_count
|
||||
if (speedtest_min_up is not None):
|
||||
if speedtest_min_up is not None:
|
||||
self.generic_endps_profile.speedtest_min_up = float(speedtest_min_up)
|
||||
if (speedtest_min_dl is not None):
|
||||
if speedtest_min_dl is not None:
|
||||
self.generic_endps_profile.speedtest_min_dl = float(speedtest_min_dl)
|
||||
if (speedtest_max_ping is not None):
|
||||
if speedtest_max_ping is not None:
|
||||
self.generic_endps_profile.speedtest_max_ping = float(speedtest_max_ping)
|
||||
|
||||
def check_tab_exists(self):
|
||||
@@ -106,7 +105,7 @@ class GenTest(LFCliBase):
|
||||
else:
|
||||
return True
|
||||
|
||||
def start(self, print_pass=False, print_fail=False):
|
||||
def start(self):
|
||||
self.station_profile.admin_up()
|
||||
temp_stas = []
|
||||
for station in self.sta_list.copy():
|
||||
@@ -202,18 +201,23 @@ python3 ./test_generic.py
|
||||
IPERF3 (under construction):
|
||||
./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy1 --num_stations 3 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --security wpa2 --type iperf3
|
||||
''',
|
||||
more_optional=optional)
|
||||
more_optional=optional)
|
||||
|
||||
parser.add_argument('--type', help='type of command to run: generic, lfping, iperf3-client, iperf3-server, lfcurl', default="lfping")
|
||||
parser.add_argument('--type', help='type of command to run: generic, lfping, iperf3-client, iperf3-server, lfcurl',
|
||||
default="lfping")
|
||||
parser.add_argument('--cmd', help='specifies command to be run by generic type endp', default='')
|
||||
parser.add_argument('--dest', help='destination IP for command', default="10.40.0.1")
|
||||
parser.add_argument('--test_duration', help='duration of the test eg: 30s, 2m, 4h', default="2m")
|
||||
parser.add_argument('--interval', help='interval to use when running lfping (1s, 1m)', default=1)
|
||||
parser.add_argument('--speedtest_min_up', help='sets the minimum upload threshold for the speedtest type', default=None)
|
||||
parser.add_argument('--speedtest_min_dl', help='sets the minimum download threshold for the speedtest type', default=None)
|
||||
parser.add_argument('--speedtest_max_ping', help='sets the minimum ping threshold for the speedtest type', default=None)
|
||||
parser.add_argument('--speedtest_min_up', help='sets the minimum upload threshold for the speedtest type',
|
||||
default=None)
|
||||
parser.add_argument('--speedtest_min_dl', help='sets the minimum download threshold for the speedtest type',
|
||||
default=None)
|
||||
parser.add_argument('--speedtest_max_ping', help='sets the minimum ping threshold for the speedtest type',
|
||||
default=None)
|
||||
parser.add_argument('--client', help='client to the iperf3 server', default=None)
|
||||
parser.add_argument('--file_output', help='location to output results of lf_curl, absolute path preferred', default=None)
|
||||
parser.add_argument('--file_output', help='location to output results of lf_curl, absolute path preferred',
|
||||
default=None)
|
||||
parser.add_argument('--loop_count', help='determines the number of loops to use in lf_curl', default=None)
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -231,10 +235,10 @@ python3 ./test_generic.py
|
||||
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_generic' # create path name
|
||||
try:
|
||||
if os.path.exists('/home/lanforge/report-data/'):
|
||||
path = os.path.join('/home/lanforge/report-data/', new_file_path)
|
||||
os.mkdir(path)
|
||||
except:
|
||||
else:
|
||||
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)
|
||||
@@ -273,7 +277,7 @@ python3 ./test_generic.py
|
||||
station_list = LFUtils.portNameSeries(radio=args.radio,
|
||||
prefix_="sta",
|
||||
start_id_=0,
|
||||
end_id_=num_sta-1,
|
||||
end_id_=num_sta - 1,
|
||||
padding_number_=100)
|
||||
|
||||
generic_test = GenTest(host=args.mgr, port=args.mgr_port,
|
||||
@@ -281,7 +285,7 @@ python3 ./test_generic.py
|
||||
radio=args.radio,
|
||||
sta_list=station_list,
|
||||
name_prefix="GT",
|
||||
type=args.type,
|
||||
test_type=args.type,
|
||||
dest=args.dest,
|
||||
cmd=args.cmd,
|
||||
interval=1,
|
||||
@@ -312,8 +316,10 @@ python3 ./test_generic.py
|
||||
|
||||
try:
|
||||
genconnections = ','.join([[*x.keys()][0] for x in generic_test.json_get('generic')['endpoints']])
|
||||
except:
|
||||
raise ValueError('1. Enable the generic tab in LANforge GUI , if still fails 2. Try setting the upstream port flag if your device does not have an eth1 port')
|
||||
except ValueError as error:
|
||||
raise ValueError(
|
||||
'1. Enable the generic tab in LANforge GUI , if still fails 2. Try setting the upstream port flag if your device does not have an eth1 port \n'
|
||||
'%s' % error)
|
||||
|
||||
if type(args.gen_cols) is not list:
|
||||
generic_cols = list(args.gen_cols.split(","))
|
||||
@@ -335,22 +341,24 @@ python3 ./test_generic.py
|
||||
try:
|
||||
monitor_interval = Realm.parse_time(args.monitor_interval).total_seconds()
|
||||
except ValueError as 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. "))
|
||||
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. \n"
|
||||
"%s" % error))
|
||||
exit(1)
|
||||
generic_test.start(False, False)
|
||||
generic_test.start()
|
||||
generic_test.generic_endps_profile.monitor(generic_cols=generic_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=genconnections,
|
||||
output_format=output,
|
||||
compared_report=compared_rept,
|
||||
script_name='test_generic',
|
||||
arguments=args,
|
||||
debug=args.debug)
|
||||
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=genconnections,
|
||||
output_format=output,
|
||||
compared_report=compared_rept,
|
||||
script_name='test_generic',
|
||||
arguments=args,
|
||||
debug=args.debug)
|
||||
|
||||
generic_test.stop()
|
||||
time.sleep(30)
|
||||
@@ -359,6 +367,5 @@ python3 ./test_generic.py
|
||||
generic_test.exit_success()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -31,17 +31,14 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
|
||||
|
||||
class ConnectTest(LFCliBase):
|
||||
class ConnectTest(Realm):
|
||||
def __init__(self,
|
||||
_ssid=None,
|
||||
_security=None,
|
||||
@@ -49,6 +46,7 @@ class ConnectTest(LFCliBase):
|
||||
_host=None,
|
||||
_port=None,
|
||||
_sta_list=None,
|
||||
_use_existing_sta=False,
|
||||
_number_template="00000",
|
||||
_radio="wiphy0",
|
||||
_proxy_str=None,
|
||||
@@ -60,23 +58,19 @@ class ConnectTest(LFCliBase):
|
||||
_mode=0,
|
||||
_num_stations=0,
|
||||
_timeout=120):
|
||||
super().__init__(_host,
|
||||
_port,
|
||||
super().__init__(lfclient_host=_host,
|
||||
lfclient_port=_port,
|
||||
_exit_on_error=_exit_on_error,
|
||||
_exit_on_fail=_exit_on_fail,
|
||||
_proxy_str=_proxy_str,
|
||||
_local_realm=realm.Realm(lfclient_host=_host,
|
||||
lfclient_port=_port,
|
||||
_exit_on_error=_exit_on_error,
|
||||
_exit_on_fail=_exit_on_fail,
|
||||
_proxy_str=_proxy_str,
|
||||
debug_=_debug_on),
|
||||
_debug=_debug_on,
|
||||
_exit_on_fail=_exit_on_fail)
|
||||
debug_=_debug_on)
|
||||
self.host = _host
|
||||
self.port = _port
|
||||
self.ssid = _ssid
|
||||
self.security = _security
|
||||
self.password = _password
|
||||
self.sta_list = _sta_list
|
||||
self.use_existing_sta = _use_existing_sta
|
||||
self.radio = _radio
|
||||
self.timeout = 120
|
||||
self.number_template = _number_template
|
||||
@@ -86,7 +80,7 @@ class ConnectTest(LFCliBase):
|
||||
self.ipv6 = _ipv6
|
||||
self.num_stations = _num_stations
|
||||
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_profile.ssid = self.ssid
|
||||
self.station_profile.ssid_pass = self.password
|
||||
@@ -98,7 +92,6 @@ class ConnectTest(LFCliBase):
|
||||
pprint.pprint(self.sta_list)
|
||||
print("---- ~Station List ----- ----- ----- ----- ----- ----- \n")
|
||||
|
||||
|
||||
def build(self):
|
||||
# Build stations
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
@@ -118,9 +111,9 @@ class ConnectTest(LFCliBase):
|
||||
print("Starting test...")
|
||||
for sec in range(self.timeout):
|
||||
for sta_name in sta_list:
|
||||
shelf = self.local_realm.name_to_eid(sta_name)[0]
|
||||
resource = self.local_realm.name_to_eid(sta_name)[1]
|
||||
name = self.local_realm.name_to_eid(sta_name)[2]
|
||||
shelf = self.name_to_eid(sta_name)[0]
|
||||
resource = self.name_to_eid(sta_name)[1]
|
||||
name = self.name_to_eid(sta_name)[2]
|
||||
if self.ipv6:
|
||||
url = "port/%s/%s/%s?fields=port,alias,ipv6+address,ap" % (shelf, resource, name)
|
||||
else:
|
||||
@@ -135,7 +128,8 @@ class ConnectTest(LFCliBase):
|
||||
associated_map[sta_name] = 1
|
||||
if self.debug:
|
||||
if self.ipv6:
|
||||
print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ipv6 address'])
|
||||
print("Associated", sta_name, sta_status['interface']['ap'],
|
||||
sta_status['interface']['ipv6 address'])
|
||||
else:
|
||||
print("Associated", sta_name, sta_status['interface']['ap'], sta_status['interface']['ip'])
|
||||
|
||||
@@ -183,9 +177,15 @@ class ConnectTest(LFCliBase):
|
||||
debug=self.debug)
|
||||
time.sleep(1)
|
||||
|
||||
def pre_cleanup(self):
|
||||
# do not clean up station if existed prior to test
|
||||
if not self.use_existing_sta:
|
||||
for sta in self.sta_list:
|
||||
self.rm_port(sta, check_exists=True, debug_=False)
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog='test_ip_connection.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
@@ -222,12 +222,6 @@ Generic ipv4 command example:
|
||||
--passwd BLANK
|
||||
--debug''')
|
||||
|
||||
required = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
# if required is not None:
|
||||
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
@@ -236,14 +230,15 @@ Generic ipv4 command example:
|
||||
if optional is not None:
|
||||
optional.add_argument("--ipv6", help="Use ipv6 connections instead of ipv4", action="store_true", default=False)
|
||||
optional.add_argument("--ap", help="Add BSSID of access point to connect to")
|
||||
optional.add_argument('--mode', help=LFCliBase.Help_Mode)
|
||||
optional.add_argument('--mode', help=Realm.Help_Mode)
|
||||
optional.add_argument('--timeout',
|
||||
help='--timeout sets the length of time to wait until a connection is successful',
|
||||
default=30)
|
||||
parser.add_argument('--use_existing_sta', help='Used an existing stationsto a particular AP', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if (args.radio is None):
|
||||
if args.radio is None:
|
||||
raise ValueError("--radio required")
|
||||
|
||||
num_sta = 2
|
||||
@@ -264,6 +259,7 @@ Generic ipv4 command example:
|
||||
_password=args.passwd,
|
||||
_security=args.security,
|
||||
_sta_list=station_list,
|
||||
_use_existing_sta=args.use_existing_sta,
|
||||
_radio=args.radio,
|
||||
_proxy_str=args.proxy,
|
||||
_debug_on=args.debug,
|
||||
@@ -272,7 +268,7 @@ Generic ipv4 command example:
|
||||
_mode=args.mode,
|
||||
_timeout=args.timeout)
|
||||
|
||||
ip_test.cleanup(station_list)
|
||||
ip_test.pre_cleanup()
|
||||
ip_test.build()
|
||||
if not ip_test.passes():
|
||||
print(ip_test.get_fail_message())
|
||||
@@ -290,5 +286,6 @@ Generic ipv4 command example:
|
||||
ip_test.add_event(name="test_ip_connection.py", message="Full test passed, all stations associated and got IP")
|
||||
ip_test.exit_success()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -33,12 +33,13 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
InfluxRequest = importlib.import_module('py-dashboard.InfluxRequest')
|
||||
RecordInflux = InfluxRequest.RecordInflux
|
||||
|
||||
|
||||
class IPVariableTime(Realm):
|
||||
@@ -46,8 +47,8 @@ class IPVariableTime(Realm):
|
||||
ssid=None,
|
||||
security=None,
|
||||
password=None,
|
||||
sta_list=[],
|
||||
create_sta=True,
|
||||
sta_list=None,
|
||||
use_existing_sta=False,
|
||||
name_prefix=None,
|
||||
upstream=None,
|
||||
radio=None,
|
||||
@@ -56,23 +57,40 @@ class IPVariableTime(Realm):
|
||||
mode=0,
|
||||
ap=None,
|
||||
traffic_type=None,
|
||||
side_a_min_rate=56, side_a_max_rate=0,
|
||||
side_b_min_rate=56, side_b_max_rate=0,
|
||||
side_a_min_rate=256000, side_a_max_rate=0,
|
||||
side_b_min_rate=256000, side_b_max_rate=0,
|
||||
number_template="00000",
|
||||
test_duration="5m",
|
||||
use_ht160=False,
|
||||
report_file=None,
|
||||
output_format=None,
|
||||
layer3_cols=None,
|
||||
port_mgr_cols=None,
|
||||
monitor_interval='10s',
|
||||
influx_host=None,
|
||||
influx_port=None,
|
||||
influx_org=None,
|
||||
influx_token=None,
|
||||
influx_bucket=None,
|
||||
influx_tag=None,
|
||||
compared_report=None,
|
||||
ipv6=False,
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
if sta_list is None:
|
||||
sta_list = []
|
||||
if layer3_cols is None:
|
||||
layer3_cols = ['name', 'tx bytes', 'rx bytes', 'tx rate', 'rx rate']
|
||||
super().__init__(lfclient_host=host,
|
||||
lfclient_port=port),
|
||||
lfclient_port=port,
|
||||
debug_=_debug_on),
|
||||
self.upstream = upstream
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.ssid = ssid
|
||||
self.sta_list = sta_list
|
||||
self.create_sta = create_sta
|
||||
self.use_existing_sta = use_existing_sta
|
||||
self.security = security
|
||||
self.password = password
|
||||
self.radio = radio
|
||||
@@ -88,72 +106,102 @@ class IPVariableTime(Realm):
|
||||
# "max_trying_ifup": 15,
|
||||
# "max_station_bringup": 6
|
||||
# })
|
||||
self.name_prefix = name_prefix
|
||||
self.test_duration = test_duration
|
||||
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.cx_profile = self.new_l3_cx_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_profile.ssid = self.ssid
|
||||
self.station_profile.ssid_pass = self.password
|
||||
self.station_profile.security = self.security
|
||||
self.station_profile.number_template_ = self.number_template
|
||||
self.station_profile.debug = self.debug
|
||||
|
||||
self.station_profile.use_ht160 = use_ht160
|
||||
if self.station_profile.use_ht160:
|
||||
self.station_profile.mode = 9
|
||||
self.station_profile.mode = mode
|
||||
if self.ap is not None:
|
||||
if self.ap:
|
||||
self.station_profile.set_command_param("add_sta", "ap", self.ap)
|
||||
if self.use_existing_sta:
|
||||
self.station_profile.station_names = self.sta_list
|
||||
|
||||
self.name_prefix = name_prefix
|
||||
self.test_duration = test_duration
|
||||
self.cx_profile = self.new_l3_cx_profile()
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
self.ipv6 = ipv6
|
||||
self.report_file = report_file
|
||||
self.output_format = output_format
|
||||
self.layer3_cols = layer3_cols
|
||||
self.port_mgr_cols = port_mgr_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.influx_tag = influx_tag
|
||||
self.compared_report = compared_report
|
||||
self.cx_profile.name_prefix = self.name_prefix
|
||||
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_b_min_bps = side_b_min_rate
|
||||
self.cx_profile.side_b_max_bps = side_b_max_rate
|
||||
|
||||
def start(self, print_pass=False, print_fail=False):
|
||||
if self.create_sta:
|
||||
self.station_profile.admin_up()
|
||||
# to-do- check here if upstream port got IP
|
||||
temp_stas = self.station_profile.station_names.copy()
|
||||
def set_wifi_radio(self, country=0, resource=1, mode="NA", radio="wiphy6", channel=5):
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": resource,
|
||||
"radio": radio,
|
||||
"mode": mode, # "NA", #0 for AUTO or "NA"
|
||||
"channel": channel,
|
||||
"country": 0,
|
||||
"frequency": super().channel_freq(channel_=channel)
|
||||
}
|
||||
super().json_post("/cli-json/set_wifi_radio", _data=data)
|
||||
|
||||
if self.wait_for_ip(temp_stas, ipv4=not self.ipv6, ipv6=self.ipv6):
|
||||
self._pass("All stations got IPs")
|
||||
else:
|
||||
self._fail("Stations failed to get IPs")
|
||||
self.exit_fail()
|
||||
def start(self):
|
||||
# if self.use_existing_station:
|
||||
# to-do- check here if upstream port got IP
|
||||
self.station_profile.admin_up()
|
||||
temp_stas = self.station_profile.station_names.copy()
|
||||
print("temp_stas {temp_stas}".format(temp_stas=temp_stas))
|
||||
if self.wait_for_ip(temp_stas, ipv4=not self.ipv6, ipv6=self.ipv6):
|
||||
self._pass("All stations got IPs")
|
||||
else:
|
||||
self._fail("Stations failed to get IPs")
|
||||
self.exit_fail()
|
||||
self.cx_profile.start_cx()
|
||||
|
||||
def stop(self):
|
||||
self.cx_profile.stop_cx()
|
||||
if self.create_sta:
|
||||
self.station_profile.admin_down()
|
||||
self.station_profile.admin_down()
|
||||
|
||||
def pre_cleanup(self):
|
||||
self.cx_profile.cleanup_prefix()
|
||||
if self.create_sta:
|
||||
# do not clean up station if existed prior to test
|
||||
if not self.use_existing_sta:
|
||||
for sta in self.sta_list:
|
||||
self.rm_port(sta, check_exists=True)
|
||||
self.rm_port(sta, check_exists=True, debug_=False)
|
||||
|
||||
def cleanup(self):
|
||||
self.cx_profile.cleanup()
|
||||
if self.create_sta:
|
||||
if not self.use_existing_sta:
|
||||
self.station_profile.cleanup()
|
||||
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.station_profile.station_names,
|
||||
debug=self.debug)
|
||||
|
||||
def build(self):
|
||||
if self.create_sta:
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
self.station_profile.use_security(self.security, self.ssid, self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
# print("sta_list {}".format(self.sta_list))
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
|
||||
if self.use_existing_sta:
|
||||
print("Use Existing Stations: {sta_list}".format(sta_list=self.sta_list))
|
||||
else:
|
||||
print("Creating stations")
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
self.station_profile.set_command_flag("set_port", "rpt_timer", 1)
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self._pass("PASS: Station build finished")
|
||||
|
||||
@@ -161,8 +209,133 @@ class IPVariableTime(Realm):
|
||||
side_b=self.upstream,
|
||||
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
|
||||
if os.path.exists('/home/lanforge/report-data'):
|
||||
path = os.path.join('/home/lanforge/report-data/', new_file_path)
|
||||
os.mkdir(path)
|
||||
else:
|
||||
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()
|
||||
# CMR What is this code doing
|
||||
if not self.use_existing_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 ValueError:
|
||||
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)
|
||||
|
||||
try:
|
||||
monitor_interval = Realm.parse_time(self.monitor_interval).total_seconds()
|
||||
except ValueError as error:
|
||||
print(error)
|
||||
return ValueError(
|
||||
"The time string provided for monitor_interval argument is invalid. Please see supported time stamp increments and inputs for monitor_interval in --help. ")
|
||||
self.start()
|
||||
|
||||
if self.influx_org is not None:
|
||||
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 self.sta_list]
|
||||
tags = dict()
|
||||
tags['script'] = 'test_ip_variable_time'
|
||||
if self.influx_tag:
|
||||
for k in self.influx_tag:
|
||||
tags[k[0]] = k[1]
|
||||
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':
|
||||
raise ValueError("Cannot process this file type. Please select a different file and re-run script.")
|
||||
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=self.test_duration,
|
||||
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 not self.use_existing_sta:
|
||||
if not self.passes():
|
||||
print(self.get_fail_message())
|
||||
self.exit_fail()
|
||||
|
||||
if self.passes():
|
||||
self.success()
|
||||
self.cleanup()
|
||||
print("IP Variable Time Test Report Data: {}".format(report_f))
|
||||
|
||||
|
||||
def main():
|
||||
# Realm args parser is one directory up then traverse into /py-json/LANforge/lfcli_base.py
|
||||
# search for create_basic_argsparse
|
||||
# --mgr --mgr_port --upstream_port --num_stations --radio --security --ssid --passwd
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog='test_ip_variable_time.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
@@ -173,6 +346,10 @@ def main():
|
||||
description='''\
|
||||
test_ip_variable_time.py:
|
||||
--------------------
|
||||
Report:
|
||||
The report will be in /home/lanforge/report-data/<timestamp>_test_ip_variable_time .
|
||||
if the directory it not present it "should" place it in the local directory from where the script was run.
|
||||
|
||||
Generic command layout:
|
||||
|
||||
python3 ./test_ip_variable_time.py
|
||||
@@ -198,7 +375,7 @@ python3 ./test_ip_variable_time.py
|
||||
--ssid netgear
|
||||
--password admin123
|
||||
--test_duration 2m (default)
|
||||
--monitor_interval_ms
|
||||
--monitor_interval_ms
|
||||
--a_min 3000
|
||||
--b_min 1000
|
||||
--ap "00:0e:8e:78:e1:76"
|
||||
@@ -212,11 +389,17 @@ python3 ./test_ip_variable_time.py
|
||||
|
||||
python3 ./test_ip_variable_time.py
|
||||
--upstream_port eth1 (upstream Port)
|
||||
--traffic_type lf_udp (traffic type, lf_udp | lf_tcp)
|
||||
--traffic_type lf_udp (traffic type, lf_udp | lf_tcp)
|
||||
--test_duration 5m (duration to run traffic 5m --> 5 Minutes)
|
||||
--create_sta False (False, means it will not create stations and use the sta_names specified below)
|
||||
--sta_names sta000,sta001,sta002 (used if --create_sta False, comma separated names of stations)
|
||||
|
||||
Example Command:
|
||||
python3 ./test_ip_variable_time.py --mgr 192.168.100.116 --radio wiphy1
|
||||
--ssid asus11ax-5 --passwd hello123 --security wpa2 --test_duration 60s
|
||||
--output_format excel --traffic_type lf_tcp --a_min 1000000 --b_min 1000000
|
||||
--upstream_port eth2 --mode "5" --layer3_cols 'name','tx rate','rx rate'
|
||||
--port_mgr_cols 'alias','channel','activity','mode'
|
||||
|
||||
===============================================================================
|
||||
** FURTHER INFORMATION **
|
||||
@@ -282,13 +465,123 @@ python3 ./test_ip_variable_time.py
|
||||
Elapsed | 'elapsed'
|
||||
Destination Addr | 'destination addr'
|
||||
Source Addr | 'source addr'
|
||||
|
||||
Using the port_mgr_cols flag:
|
||||
'4way time (us)'
|
||||
'activity'
|
||||
'alias'
|
||||
'anqp time (us)'
|
||||
'ap'
|
||||
'beacon'
|
||||
'bps rx'
|
||||
'bps rx ll'
|
||||
'bps tx'
|
||||
'bps tx ll'
|
||||
'bytes rx ll'
|
||||
'bytes tx ll'
|
||||
'channel'
|
||||
'collisions'
|
||||
'connections'
|
||||
'crypt'
|
||||
'cx ago'
|
||||
'cx time (us)'
|
||||
'device'
|
||||
'dhcp (ms)'
|
||||
'down'
|
||||
'entity id'
|
||||
'gateway ip'
|
||||
'ip'
|
||||
'ipv6 address'
|
||||
'ipv6 gateway'
|
||||
'key/phrase'
|
||||
'login-fail'
|
||||
'login-ok'
|
||||
'logout-fail'
|
||||
'logout-ok'
|
||||
'mac'
|
||||
'mask'
|
||||
'misc'
|
||||
'mode'
|
||||
'mtu'
|
||||
'no cx (us)'
|
||||
'noise'
|
||||
'parent dev'
|
||||
'phantom'
|
||||
'port'
|
||||
'port type'
|
||||
'pps rx'
|
||||
'pps tx'
|
||||
'qlen'
|
||||
'reset'
|
||||
'retry failed'
|
||||
'rx bytes'
|
||||
'rx crc'
|
||||
'rx drop'
|
||||
'rx errors'
|
||||
'rx fifo'
|
||||
'rx frame'
|
||||
'rx length'
|
||||
'rx miss'
|
||||
'rx over'
|
||||
'rx pkts'
|
||||
'rx-rate'
|
||||
'sec'
|
||||
'signal'
|
||||
'ssid'
|
||||
'status'
|
||||
'time-stamp'
|
||||
'tx abort'
|
||||
'tx bytes'
|
||||
'tx crr'
|
||||
'tx errors'
|
||||
'tx fifo'
|
||||
'tx hb'
|
||||
'tx pkts'
|
||||
'tx wind'
|
||||
'tx-failed %'
|
||||
'tx-rate'
|
||||
'wifi retries'
|
||||
|
||||
Can't decide what columns to use? You can just use 'all' to select all available columns from both tables.
|
||||
|
||||
This script uses two args parsers one in the script the second is Realm args parser
|
||||
Realm args parser is one directory up then traverse into /py-json/LANforge/lfcli_base.py
|
||||
search for create_basic_argsparse
|
||||
--mgr --mgr_port --upstream_port --num_stations --radio --security --ssid --passwd
|
||||
|
||||
|
||||
Example command:
|
||||
1. Use Existing station , Note: put the resource.shelf.wifi-sta (below is 1.1.wlan4),
|
||||
The station needs to configured with the ssid, passwd, security and mode in the LANforge GUI
|
||||
./test_ip_variable_time.py --mgr 192.168.0.100 --radio wiphy4 --ssid ssid_5g --passwd pass_5g
|
||||
--security wpa2 --test_duration 60s --output_format csv --traffic_type lf_tcp
|
||||
--a_min 600000000 --b_min 600000000 --upstream_port eth2 --mode '5'
|
||||
--layer3_cols 'name','tx rate','rx rate' --port_mgr_cols 'alias','channel','activity','mode'
|
||||
--use_existing_sta --sta_names 1.1.wlan4
|
||||
|
||||
2. Create a one station (script default is 1 if --num_stations not entered)
|
||||
./test_ip_variable_time.py --mgr 192.168.0.100 --radio wiphy6 --ssid ssid_5g --passwd pass_5g
|
||||
--security wpa2 --test_duration 60s --output_format csv --traffic_type lf_tcp
|
||||
--a_min 600000000 --b_min 600000000 --upstream_port eth2 --mode '5'
|
||||
--layer3_cols 'name','tx rate','rx rate' --port_mgr_cols 'alias','channel','activity','mode'
|
||||
|
||||
3. Create two stations
|
||||
./test_ip_variable_time.py --mgr 192.168.0.100 --radio wiphy1 --ssid ssid_5g --passwd pass_5g
|
||||
--security wpa2 --test_duration 60s --output_format csv --traffic_type lf_tcp
|
||||
--a_min 600000000 --b_min 600000000 --upstream_port eth2 --mode '5'
|
||||
--layer3_cols 'name','tx rate','rx rate' --port_mgr_cols 'alias','channel','activity','mode'
|
||||
--num_stations 2
|
||||
|
||||
''')
|
||||
|
||||
# Realm args parser is one directory up then traverse into /py-json/LANforge/lfcli_base.py
|
||||
# search for create_basic_argsparse
|
||||
# --mgr --mgr_port --upstream_port --num_stations --radio --security --ssid --passwd
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--ap', help='Used to force a connection to a particular AP')
|
||||
parser.add_argument('--traffic_type', help='Select the Traffic Type [lf_udp, lf_tcp, udp, tcp], type will be '
|
||||
'adjusted automatically between ipv4 and ipv6 based on use of --ipv6 flag'
|
||||
, required=True)
|
||||
'adjusted automatically between ipv4 and ipv6 based on use of --ipv6 flag',
|
||||
required=True)
|
||||
parser.add_argument('--output_format', help='choose either csv or xlsx')
|
||||
parser.add_argument('--report_file', help='where you want to store results', default=None)
|
||||
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
@@ -297,11 +590,11 @@ python3 ./test_ip_variable_time.py
|
||||
parser.add_argument('--layer3_cols', help='Columns wished to be monitored from layer 3 endpoint tab',
|
||||
default=['name', 'tx bytes', 'rx bytes', 'tx rate', 'rx rate'])
|
||||
parser.add_argument('--port_mgr_cols', help='Columns wished to be monitored from port manager tab',
|
||||
default=['ap', 'ip', 'parent dev'])
|
||||
default=['alias', 'ap', 'ip', 'parent dev', 'rx-rate'])
|
||||
parser.add_argument('--compared_report', help='report path and file which is wished to be compared with new report',
|
||||
default=None)
|
||||
parser.add_argument('--monitor_interval',
|
||||
help='how frequently do you want your monitor function to take measurements; \, 35s, 2h',
|
||||
help='how frequently do you want your monitor function to take measurements, 35s, 2h',
|
||||
default='10s')
|
||||
parser.add_argument('--ipv6', help='Sets the test to use IPv6 traffic instead of IPv4', action='store_true')
|
||||
parser.add_argument('--influx_host')
|
||||
@@ -314,75 +607,36 @@ python3 ./test_ip_variable_time.py
|
||||
parser.add_argument('--influx_mgr',
|
||||
help='IP address of the server your Influx database is hosted if different from your LANforge Manager',
|
||||
default=None)
|
||||
parser.add_argument('--create_sta', help='Used to force a connection to a particular AP', default=True)
|
||||
parser.add_argument('--use_existing_sta', help='Used an existing stationsto a particular AP', action='store_true')
|
||||
parser.add_argument('--sta_names', help='Used to force a connection to a particular AP', default="sta0000")
|
||||
args = parser.parse_args()
|
||||
create_sta = True
|
||||
if args.create_sta == "False":
|
||||
create_sta = False
|
||||
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
num_sta = 1
|
||||
if args.num_stations:
|
||||
print("one")
|
||||
num_sta = int(args.num_stations)
|
||||
if not args.use_existing_sta:
|
||||
print("two")
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1,
|
||||
padding_number_=10000,
|
||||
radio=args.radio)
|
||||
else:
|
||||
print("three")
|
||||
station_list = args.sta_names.split(",")
|
||||
|
||||
print("args.num_stations: {create}".format(create=args.num_stations))
|
||||
print("args.sta_names: {create}".format(create=args.sta_names))
|
||||
print("args.use_existing_sta: {create} {typeof}".format(create=args.use_existing_sta, typeof=type(args.use_existing_sta)))
|
||||
print("station_list: {sta}".format(sta=station_list))
|
||||
|
||||
# Create directory
|
||||
|
||||
# if file path with output file extension is not given...
|
||||
# check if home/lanforge/report-data exists. if not, save
|
||||
# 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")
|
||||
|
||||
if (args.traffic_type is None) or (args.traffic_type not in CX_TYPES):
|
||||
if not args.traffic_type or (args.traffic_type not in CX_TYPES):
|
||||
print("cx_type needs to be lf_tcp, lf_udp, tcp, or udp, bye")
|
||||
exit(1)
|
||||
|
||||
@@ -401,7 +655,7 @@ python3 ./test_ip_variable_time.py
|
||||
port=args.mgr_port,
|
||||
number_template="0000",
|
||||
sta_list=station_list,
|
||||
create_sta=create_sta,
|
||||
use_existing_sta=args.use_existing_sta,
|
||||
name_prefix="VT",
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
@@ -414,106 +668,24 @@ python3 ./test_ip_variable_time.py
|
||||
side_b_min_rate=args.b_min,
|
||||
mode=args.mode,
|
||||
ap=args.ap,
|
||||
report_file=args.report_file,
|
||||
output_format=args.output_format,
|
||||
layer3_cols=args.layer3_cols,
|
||||
port_mgr_cols=args.port_mgr_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,
|
||||
influx_tag=args.influx_tag,
|
||||
compared_report=args.compared_report,
|
||||
ipv6=args.ipv6,
|
||||
traffic_type=args.traffic_type,
|
||||
_debug_on=args.debug)
|
||||
|
||||
ip_var_test.pre_cleanup()
|
||||
|
||||
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))
|
||||
# work in progress - may delete in the future
|
||||
# ip_var_test.set_wifi_radio(radio=args.radio)
|
||||
ip_var_test.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -10,7 +10,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -22,7 +21,7 @@ Realm = realm.Realm
|
||||
|
||||
class IPV4VariableTime(LFCliBase):
|
||||
def __init__(self, ssid, security, password, sta_list, name_prefix, upstream, radio,
|
||||
host="localhost", port=8080,
|
||||
radio2, host="localhost", port=8080,
|
||||
side_a_min_rate=56, side_a_max_rate=0,
|
||||
side_b_min_rate=56, side_b_max_rate=0,
|
||||
number_template="00000", test_duration="5m", use_ht160=False,
|
||||
@@ -38,6 +37,7 @@ class IPV4VariableTime(LFCliBase):
|
||||
self.security = security
|
||||
self.password = password
|
||||
self.radio = radio
|
||||
self.radio2 = radio2
|
||||
self.number_template = number_template
|
||||
self.debug = _debug_on
|
||||
self.name_prefix = name_prefix
|
||||
@@ -78,7 +78,8 @@ class IPV4VariableTime(LFCliBase):
|
||||
cx_rx_map[item] = value_rx
|
||||
return cx_rx_map
|
||||
|
||||
def __compare_vals(self, old_list, new_list):
|
||||
@staticmethod
|
||||
def __compare_vals(old_list, new_list):
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
if len(old_list) == len(new_list):
|
||||
@@ -107,7 +108,7 @@ class IPV4VariableTime(LFCliBase):
|
||||
self.vap_profile.set_command_flag("add_vap", "use-bss-transition", 1)
|
||||
self.vap_profile.create(resource=1, radio="wiphy1", channel=161, up_=True, debug=False,
|
||||
suppress_related_commands_=True)
|
||||
self.monitor.create(resource_=1, channel=161, radio_="wiphy2", name_="moni0")
|
||||
self.monitor.create(resource_=1, channel=161, radio_=self.radio2, name_="moni0")
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream,
|
||||
sleep_time=0)
|
||||
@@ -172,7 +173,6 @@ class IPV4VariableTime(LFCliBase):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
prog='test_ipv4_variable_time.py',
|
||||
# formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
@@ -194,20 +194,15 @@ Generic command layout:
|
||||
--test_duration 2m
|
||||
--debug
|
||||
''')
|
||||
required = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
#if required is not None:
|
||||
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
optional = agroup
|
||||
if optional is not None:
|
||||
if optional is not None:
|
||||
optional.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
optional.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
optional.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m")
|
||||
optional.add_argument('--radio2', help='radio to create monitor on', default='1.wiphy2')
|
||||
|
||||
args = parser.parse_args()
|
||||
num_sta = 2
|
||||
@@ -215,8 +210,7 @@ Generic command layout:
|
||||
num_stations_converted = int(args.num_stations)
|
||||
num_sta = num_stations_converted
|
||||
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000,
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000,
|
||||
radio=args.radio)
|
||||
|
||||
ip_var_test = IPV4VariableTime(host=args.mgr, port=args.mgr_port,
|
||||
@@ -227,6 +221,7 @@ Generic command layout:
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
radio2=args.radio2,
|
||||
security=args.security, test_duration=args.test_duration, use_ht160=False,
|
||||
side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug)
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ if sys.version_info[0] != 3:
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
LFCliBase = lfcli_base.LFCliBase
|
||||
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
|
||||
realm = importlib.import_module("py-json.realm")
|
||||
Realm = realm.Realm
|
||||
@@ -22,7 +20,7 @@ test_ip_variable_time = importlib.import_module("py-scripts.test_ip_variable_tim
|
||||
IPVariableTime = test_ip_variable_time.IPVariableTime
|
||||
|
||||
|
||||
class TTLSTest(LFCliBase):
|
||||
class TTLSTest(Realm):
|
||||
def __init__(self, host="localhost", port=8080,
|
||||
ssid="[BLANK]",
|
||||
security="wpa2",
|
||||
@@ -65,7 +63,8 @@ class TTLSTest(LFCliBase):
|
||||
_debug_on=False,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
super().__init__(lfclient_host=host, lfclient_port=port, debug_=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.resulting_endpoints = {}
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.ssid = ssid
|
||||
@@ -111,13 +110,12 @@ class TTLSTest(LFCliBase):
|
||||
self.timeout = 120
|
||||
self.number_template = number_template
|
||||
self.debug = _debug_on
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.station_profile = self.new_station_profile()
|
||||
self.vap = vap
|
||||
self.upstream_port = "eth1"
|
||||
self.upstream_resource = 1
|
||||
if self.vap:
|
||||
self.vap_profile = self.local_realm.new_vap_profile()
|
||||
self.vap_profile = self.new_vap_profile()
|
||||
self.vap_profile.vap_name = "TestNet"
|
||||
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
@@ -127,8 +125,9 @@ class TTLSTest(LFCliBase):
|
||||
self.station_profile.mode = 0
|
||||
|
||||
# Layer3 Traffic
|
||||
self.l3_cx_obj_udp = IPVariableTime(host=self.host, port=self.port,
|
||||
create_sta=False, sta_list=self.sta_list, traffic_type="lf_udp",
|
||||
self.l3_cx_obj_udp = IPVariableTime(host=self.host, port=self.port, radio=self.radio,
|
||||
ssid=self.ssid, password=self.password, security=self.security,
|
||||
use_existing_sta=False, sta_list=self.sta_list, traffic_type="lf_udp",
|
||||
upstream=self.upstream_port)
|
||||
self.l3_cx_obj_udp.cx_profile.name_prefix = "udp-"
|
||||
|
||||
@@ -140,8 +139,9 @@ class TTLSTest(LFCliBase):
|
||||
self.l3_cx_obj_udp.cx_profile.side_b_min_pdu = 1500
|
||||
self.l3_cx_obj_udp.cx_profile.report_timer = 1000
|
||||
|
||||
self.l3_cx_obj_tcp = IPVariableTime(host=self.host, port=self.port,
|
||||
create_sta=False, sta_list=self.sta_list, traffic_type="lf_tcp",
|
||||
self.l3_cx_obj_tcp = IPVariableTime(host=self.host, port=self.port, radio=self.radio,
|
||||
ssid=self.ssid, password=self.password, security=self.security,
|
||||
use_existing_sta=True, sta_list=self.sta_list, traffic_type="lf_tcp",
|
||||
upstream=self.upstream_port)
|
||||
self.l3_cx_obj_tcp.cx_profile.name_prefix = "tcp-"
|
||||
self.l3_cx_obj_tcp.cx_profile.side_a_min_bps = 128000
|
||||
@@ -152,13 +152,14 @@ class TTLSTest(LFCliBase):
|
||||
self.l3_cx_obj_tcp.cx_profile.side_b_min_pdu = 1500
|
||||
self.l3_cx_obj_tcp.cx_profile.report_timer = 1000
|
||||
|
||||
def build(self, extra_securities=[]):
|
||||
def build(self,
|
||||
extra_securities=None):
|
||||
# Build stations
|
||||
keyphrase = "[BLANK]"
|
||||
|
||||
self.station_profile.use_security(self.security, self.ssid, passwd=self.password)
|
||||
for security in extra_securities:
|
||||
self.station_profile.add_security_extra(security=security)
|
||||
if extra_securities is not None:
|
||||
for security in extra_securities:
|
||||
self.station_profile.add_security_extra(security=security)
|
||||
if self.vap:
|
||||
self.vap_profile.use_security(self.security, self.ssid, passwd=self.password)
|
||||
self.station_profile.set_number_template(self.number_template)
|
||||
@@ -202,12 +203,6 @@ class TTLSTest(LFCliBase):
|
||||
suppress_related_commands_=True,
|
||||
use_radius=True,
|
||||
hs20_enable=False)
|
||||
self.station_profile.create(radio=self.radio,
|
||||
sta_names_=self.sta_list,
|
||||
debug=self.debug,
|
||||
use_radius=True,
|
||||
hs20_enable=False)
|
||||
self._pass("Station build finished")
|
||||
self.l3_cx_obj_udp.build()
|
||||
self.l3_cx_obj_tcp.build()
|
||||
if self.debug:
|
||||
@@ -269,8 +264,6 @@ class TTLSTest(LFCliBase):
|
||||
self.collect_endp_stats(self.l3_cx_obj_udp.cx_profile.created_cx, traffic_type="UDP")
|
||||
|
||||
def cleanup(self, sta_list):
|
||||
self.l3_cx_obj_udp.cleanup()
|
||||
self.l3_cx_obj_tcp.cleanup()
|
||||
self.station_profile.cleanup(sta_list)
|
||||
if self.vap:
|
||||
self.vap_profile.cleanup(1)
|
||||
@@ -278,7 +271,6 @@ class TTLSTest(LFCliBase):
|
||||
debug=self.debug)
|
||||
|
||||
def collect_endp_stats(self, endp_map, traffic_type="TCP"):
|
||||
self.resulting_endpoints = {}
|
||||
print("Collecting Data")
|
||||
fields = "?fields=name,tx+bytes,rx+bytes"
|
||||
for (cx_name, endps) in endp_map.items():
|
||||
@@ -303,7 +295,6 @@ class TTLSTest(LFCliBase):
|
||||
self.compare_vals("test" + traffic_type + "-B TX", ptest_b_tx)
|
||||
self.compare_vals("test" + traffic_type + "-B RX", ptest_b_rx)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print("Is this the function having the error?")
|
||||
self.error(e)
|
||||
@@ -317,7 +308,7 @@ class TTLSTest(LFCliBase):
|
||||
|
||||
|
||||
def main():
|
||||
parser = LFCliBase.create_basic_argparse(
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog='test_ipv4_ttls.py',
|
||||
# formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
@@ -338,43 +329,32 @@ test_ipv4_ttls.py:
|
||||
--debug
|
||||
|
||||
''')
|
||||
required = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
# if required is not None:
|
||||
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
optional = agroup
|
||||
|
||||
if optional is not None:
|
||||
optional.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
optional.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
optional.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m")
|
||||
optional.add_argument('--key-mgmt', help="--key-mgt: { %s }" % ", ".join(realm.wpa_ent_list()),
|
||||
default="WPA-EAP")
|
||||
optional.add_argument('--wpa_psk', help='wpa-ent pre shared key', default="[BLANK]")
|
||||
optional.add_argument('--eap', help='--eap eap method to use', default="TTLS")
|
||||
optional.add_argument('--identity', help='--identity eap identity string', default="testuser")
|
||||
optional.add_argument('--ttls_passwd', help='--ttls_passwd eap password string', default="testpasswd")
|
||||
optional.add_argument('--ttls_realm', help='--ttls_realm 802.11u home realm to use',
|
||||
default="localhost.localdomain")
|
||||
optional.add_argument('--domain', help='--domain 802.11 domain to use', default="localhost.localdomain")
|
||||
optional.add_argument('--hessid', help='--hessid 802.11u HESSID (MAC addr format/peer for WDS)',
|
||||
default="00:00:00:00:00:01")
|
||||
optional.add_argument('--ieee80211w', help='--ieee80211w <disabled(0),optional(1),required(2)', default='1')
|
||||
optional.add_argument('--use_hs20', help='use HotSpot 2.0', default=False)
|
||||
optional.add_argument('--enable_pkc', help='enable opportunistic PMKSA WPA2 key caching', default=False)
|
||||
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m")
|
||||
parser.add_argument('--key-mgmt', help="--key-mgt: { %s }" % ", ".join(realm.wpa_ent_list()), default="WPA-EAP")
|
||||
parser.add_argument('--wpa_psk', help='wpa-ent pre shared key', default="[BLANK]")
|
||||
parser.add_argument('--eap', help='--eap eap method to use', default="TTLS")
|
||||
parser.add_argument('--identity', help='--identity eap identity string', default="testuser")
|
||||
parser.add_argument('--ttls_passwd', help='--ttls_passwd eap password string', default="testpasswd")
|
||||
parser.add_argument('--ttls_realm', help='--ttls_realm 802.11u home realm to use', default="localhost.localdomain")
|
||||
parser.add_argument('--domain', help='--domain 802.11 domain to use', default="localhost.localdomain")
|
||||
parser.add_argument('--hessid', help='--hessid 802.11u HESSID (MAC addr format/peer for WDS)',
|
||||
default="00:00:00:00:00:01")
|
||||
parser.add_argument('--ieee80211w', help='--ieee80211w <disabled(0),optional(1),required(2)', default='1')
|
||||
parser.add_argument('--use_hs20', help='use HotSpot 2.0', default=False)
|
||||
parser.add_argument('--enable_pkc', help='enable opportunistic PMKSA WPA2 key caching', default=False)
|
||||
parser.add_argument('--vap', help='Create VAP on host device', default=True)
|
||||
args = parser.parse_args()
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
if args.num_stations:
|
||||
num_stations_converted = int(args.num_stations)
|
||||
num_sta = num_stations_converted
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000)
|
||||
ttls_test = TTLSTest(host=args.mgr, port=args.mgr_port,
|
||||
ttls_test = TTLSTest(host=args.mgr,
|
||||
port=args.mgr_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
security=args.security,
|
||||
@@ -383,7 +363,7 @@ test_ipv4_ttls.py:
|
||||
key_mgmt=args.key_mgmt,
|
||||
wpa_psk=args.wpa_psk,
|
||||
eap=args.eap,
|
||||
vap=True,
|
||||
vap=args.vap,
|
||||
identity=args.identity,
|
||||
ttls_passwd=args.ttls_passwd,
|
||||
ttls_realm=args.ttls_realm,
|
||||
|
||||
@@ -10,7 +10,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -89,7 +88,8 @@ class VRTest(LFCliBase):
|
||||
cx_rx_map[item] = value_rx
|
||||
return cx_rx_map
|
||||
|
||||
def __compare_vals(self, old_list, new_list):
|
||||
@staticmethod
|
||||
def __compare_vals(old_list, new_list):
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
if len(old_list) == len(new_list):
|
||||
@@ -168,10 +168,10 @@ class VRTest(LFCliBase):
|
||||
upstream_temp = self.local_realm.name_to_eid(self.upstream)
|
||||
print("Creating Virtual Router and connections")
|
||||
self.vr_profile.create(resource=upstream_temp[1], upstream_port=upstream_temp[2], debug=self.debug,
|
||||
upstream_subnets=self.upstream_subnets, upstream_nexthop=self.upstream_nexthop,
|
||||
local_subnets=self.local_subnets, local_nexthop=self.local_nexthop,
|
||||
rdd_ip=self.rdd_ip, rdd_gateway=self.rdd_gateway, rdd_netmask=self.rdd_netmask,
|
||||
suppress_related_commands_=True)
|
||||
upstream_subnets=self.upstream_subnets, upstream_nexthop=self.upstream_nexthop,
|
||||
local_subnets=self.local_subnets, local_nexthop=self.local_nexthop,
|
||||
rdd_ip=self.rdd_ip, rdd_gateway=self.rdd_gateway, rdd_netmask=self.rdd_netmask,
|
||||
suppress_related_commands_=True)
|
||||
print("Creating stations")
|
||||
self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug)
|
||||
self.cx_profile.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b=self.upstream,
|
||||
@@ -179,6 +179,7 @@ class VRTest(LFCliBase):
|
||||
self._pass("PASS: Station build finished")
|
||||
exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
lfjson_port = 8080
|
||||
|
||||
@@ -200,36 +201,44 @@ TBD
|
||||
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
|
||||
parser.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000)
|
||||
parser.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="5m")
|
||||
parser.add_argument('--upstream_subnets', help='--upstream_subnets sets the subnets used by the upstream vrcx', default="20.20.20.0/24")
|
||||
parser.add_argument('--upstream_nexthop', help='--upstream_nexthop sets the nexthop used by the upstream vrcx, should be rdd gateway', default="20.20.20.1")
|
||||
parser.add_argument('--local_subnets', help='--local_subnets sets the subnets used by the rdd vrcx', default="10.40.0.0/24")
|
||||
parser.add_argument('--local_nexthop', help='--local_nexthop sets the nexthop used by the upstream vrcx, should be upstream ip', default="10.40.3.198")
|
||||
parser.add_argument('--upstream_subnets', help='--upstream_subnets sets the subnets used by the upstream vrcx',
|
||||
default="20.20.20.0/24")
|
||||
parser.add_argument('--upstream_nexthop',
|
||||
help='--upstream_nexthop sets the nexthop used by the upstream vrcx, should be rdd gateway',
|
||||
default="20.20.20.1")
|
||||
parser.add_argument('--local_subnets', help='--local_subnets sets the subnets used by the rdd vrcx',
|
||||
default="10.40.0.0/24")
|
||||
parser.add_argument('--local_nexthop',
|
||||
help='--local_nexthop sets the nexthop used by the upstream vrcx, should be upstream ip',
|
||||
default="10.40.3.198")
|
||||
parser.add_argument('--rdd_ip', help='--rdd_ip sets the ip to be used by the rdd', default="20.20.20.20")
|
||||
parser.add_argument('--rdd_gateway', help='--rdd_gateway sets the gateway to be used by the rdd', default="20.20.20.1")
|
||||
parser.add_argument('--rdd_netmask', help='--rdd_netmask sets the netmask to be used by the rdd', default="255.255.255.0")
|
||||
parser.add_argument('--rdd_gateway', help='--rdd_gateway sets the gateway to be used by the rdd',
|
||||
default="20.20.20.1")
|
||||
parser.add_argument('--rdd_netmask', help='--rdd_netmask sets the netmask to be used by the rdd',
|
||||
default="255.255.255.0")
|
||||
parser.add_argument('--vr_name', help='--vr_name sets the name to be used by the virtual router', default="vr_test")
|
||||
|
||||
args = parser.parse_args()
|
||||
num_sta=2
|
||||
num_sta = 2
|
||||
if (args.num_stations is not None) and (int(args.num_stations) > 0):
|
||||
num_stations_converted = int(args.num_stations)
|
||||
num_sta = num_stations_converted
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta-1, padding_number_=10000,
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000,
|
||||
radio=args.radio)
|
||||
|
||||
ip_var_test = VRTest(args.mgr, lfjson_port, number_template="00", sta_list=station_list,
|
||||
name_prefix="VRT",
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
security=args.security, test_duration=args.test_duration, use_ht160=False,
|
||||
side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug,
|
||||
upstream_subnets=args.upstream_subnets, upstream_nexthop=args.upstream_nexthop,
|
||||
local_subnets=args.local_subnets, local_nexthop=args.local_nexthop,
|
||||
rdd_ip=args.rdd_ip, rdd_gateway=args.rdd_gateway,
|
||||
rdd_netmask = args.rdd_netmask ,vr_name=args.vr_name)
|
||||
name_prefix="VRT",
|
||||
upstream=args.upstream_port,
|
||||
ssid=args.ssid,
|
||||
password=args.passwd,
|
||||
radio=args.radio,
|
||||
security=args.security, test_duration=args.test_duration, use_ht160=False,
|
||||
side_a_min_rate=args.a_min, side_b_min_rate=args.b_min, _debug_on=args.debug,
|
||||
upstream_subnets=args.upstream_subnets, upstream_nexthop=args.upstream_nexthop,
|
||||
local_subnets=args.local_subnets, local_nexthop=args.local_nexthop,
|
||||
rdd_ip=args.rdd_ip, rdd_gateway=args.rdd_gateway,
|
||||
rdd_netmask=args.rdd_netmask, vr_name=args.vr_name)
|
||||
|
||||
ip_var_test.pre_cleanup()
|
||||
ip_var_test.build()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,12 +4,12 @@ import os
|
||||
import importlib
|
||||
import time
|
||||
import datetime
|
||||
import argparse
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -39,17 +39,17 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=False)
|
||||
# upload
|
||||
self.cx_prof_upload = l3_cxprofile.L3CXProfile(self.host, self.port, self.local_realm,
|
||||
side_a_min_bps=side_a_min_rate, side_b_min_bps=0,
|
||||
side_a_max_bps=side_a_max_rate, side_b_max_bps=0,
|
||||
side_a_min_pdu=pdu_size, side_a_max_pdu=pdu_size,
|
||||
side_b_min_pdu=0, side_b_max_pdu=0, debug_=False)
|
||||
side_a_min_bps=side_a_min_rate, side_b_min_bps=0,
|
||||
side_a_max_bps=side_a_max_rate, side_b_max_bps=0,
|
||||
side_a_min_pdu=pdu_size, side_a_max_pdu=pdu_size,
|
||||
side_b_min_pdu=0, side_b_max_pdu=0, debug_=False)
|
||||
|
||||
# download
|
||||
self.cx_prof_download = l3_cxprofile.L3CXProfile(self.host, self.port, self.local_realm,
|
||||
side_a_min_bps=0, side_b_min_bps=side_b_min_rate,
|
||||
side_a_max_bps=0, side_b_max_bps=side_b_max_rate,
|
||||
side_a_min_pdu=0, side_a_max_pdu=0,
|
||||
side_b_min_pdu=pdu_size, side_b_max_pdu=pdu_size, debug_=False)
|
||||
side_a_min_bps=0, side_b_min_bps=side_b_min_rate,
|
||||
side_a_max_bps=0, side_b_max_bps=side_b_max_rate,
|
||||
side_a_min_pdu=0, side_a_max_pdu=0,
|
||||
side_b_min_pdu=pdu_size, side_b_max_pdu=pdu_size, debug_=False)
|
||||
self.test_duration = test_duration
|
||||
self.station_profile = realm.StationProfile(self.lfclient_url, self.local_realm, ssid=self.ssid,
|
||||
ssid_pass=self.password,
|
||||
@@ -60,7 +60,7 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
self.new_monitor = realm.WifiMonitor(self.lfclient_url, self.local_realm, debug_=_debug_on)
|
||||
|
||||
def build(self):
|
||||
self.station_profile.use_security("open", ssid=self.ssid, passwd=self.password)
|
||||
self.station_profile.use_security(self.security, ssid=self.ssid, passwd=self.password)
|
||||
self.station_profile.set_number_template(self.prefix)
|
||||
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
|
||||
self.station_profile.set_command_param("set_port", "report_timer", 1500)
|
||||
@@ -78,9 +78,11 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
self.cx_prof_upload.name_prefix = "UDP_up"
|
||||
self.cx_prof_download.name_prefix = "UDP_down"
|
||||
print("Creating upload cx profile ")
|
||||
self.cx_prof_upload.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b="1.eth1", sleep_time=.05)
|
||||
self.cx_prof_upload.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b="1.eth1",
|
||||
sleep_time=.05)
|
||||
print("Creating download cx profile")
|
||||
self.cx_prof_download.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b="1.eth1", sleep_time=.05)
|
||||
self.cx_prof_download.create(endp_type="lf_udp", side_a=self.station_profile.station_names, side_b="1.eth1",
|
||||
sleep_time=.05)
|
||||
|
||||
def __get_rx_values(self):
|
||||
cx_list = self.json_get("/endp/list?fields=name,rx+bytes", debug_=False)
|
||||
@@ -94,7 +96,7 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
cx_rx_map[item] = value_rx
|
||||
return cx_rx_map
|
||||
|
||||
def start(self, print_pass=False, print_fail=False):
|
||||
def start(self):
|
||||
# start one test, measure
|
||||
# start second test, measure
|
||||
cur_time = datetime.datetime.now()
|
||||
@@ -111,7 +113,7 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
self.station_profile.admin_up()
|
||||
# self.new_monitor.set_flag()
|
||||
# print(self.station_profile.station_names)
|
||||
if self.local_realm.wait_for_ip(self.station_profile.station_names):
|
||||
if self.local_realm.wait_for_ip(self.station_profile.station_names):
|
||||
self._pass("All stations got IPs")
|
||||
else:
|
||||
self._fail("Stations failed to get IPs")
|
||||
@@ -153,12 +155,23 @@ class L3PowersaveTraffic(LFCliBase):
|
||||
|
||||
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
parser = Realm.create_basic_argparse(
|
||||
prog='test_l3_powersave_traffic.py',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
test_l3_powersave_traffic.py
|
||||
|
||||
''',
|
||||
description='''\
|
||||
Example of creating traffic on an l3 connection
|
||||
''')
|
||||
args = parser.parse_args()
|
||||
|
||||
lfjson_host = args.mgr
|
||||
lfjson_port = 8080
|
||||
# station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000)
|
||||
station_list = ["sta0000", "sta0001"]
|
||||
ip_powersave_test = L3PowersaveTraffic(lfjson_host, lfjson_port, ssid="jedway-open-149", security="open",
|
||||
password="[BLANK]", station_list=station_list, side_a_min_rate=2000,
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=4, padding_number_=10000)
|
||||
ip_powersave_test = L3PowersaveTraffic(lfjson_host, lfjson_port, ssid=args.ssid, security=args.security,
|
||||
password=args.passwd, station_list=station_list, side_a_min_rate=2000,
|
||||
side_b_min_rate=2000, side_a_max_rate=0,
|
||||
side_b_max_rate=0, prefix="00000", test_duration="30s",
|
||||
_debug_on=False, _exit_on_error=True, _exit_on_fail=True)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
"""
|
||||
This Script Loads the Existing Scenario and Run the Simultaenous Throughput over time and Generate Report and Plot the Graph
|
||||
This Script has three classes :
|
||||
1. LoadScenario : It will load the existing saved scenario to the Lanforge (Here used for Loading Bridged VAP)
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
This Script is intended to automate the testing of DUT That has stations as well as AP.
|
||||
To automate the simultaenous testing and check the DUT Temperature
|
||||
'''
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import importlib
|
||||
@@ -31,7 +31,6 @@ import argparse
|
||||
import time
|
||||
import logging
|
||||
import paramiko as pmgo
|
||||
from paramiko.ssh_exception import NoValidConnectionsError as exception
|
||||
import xlsxwriter
|
||||
from bokeh.io import show
|
||||
from bokeh.plotting import figure
|
||||
@@ -43,7 +42,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -57,104 +55,96 @@ Realm = realm.Realm
|
||||
class Login_DUT:
|
||||
|
||||
def __init__(self, threadID, name, HOST):
|
||||
self.threadID = threadID
|
||||
self.name = name
|
||||
self.host=HOST
|
||||
self.USERNAME = "lanforge"
|
||||
self.PASSWORD = "lanforge"
|
||||
self.CLIENT= pmgo.SSHClient()
|
||||
self.LF1= self.Connect()
|
||||
self.data_core1=[]
|
||||
self.data_core2=[]
|
||||
if self.CLIENT == 0:
|
||||
exit()
|
||||
print("Connected to " +HOST+" DUT to Measure the Core Temperature")
|
||||
self.threadID = threadID
|
||||
self.name = name
|
||||
self.host = HOST
|
||||
self.USERNAME = "lanforge"
|
||||
self.PASSWORD = "lanforge"
|
||||
self.CLIENT = pmgo.SSHClient()
|
||||
self.data_core1 = []
|
||||
self.data_core2 = []
|
||||
if self.CLIENT == 0:
|
||||
exit()
|
||||
print("Connected to " + HOST + " DUT to Measure the Core Temperature")
|
||||
self.Connect()
|
||||
|
||||
def run(self):
|
||||
stdin, stdout, stderr= self.CLIENT.exec_command("sensors")
|
||||
stdin, stdout, stderr = self.CLIENT.exec_command("sensors")
|
||||
out_lines = stdout.readlines()
|
||||
err_lines = stderr.readlines()
|
||||
print(out_lines[len(out_lines)-3], out_lines[len(out_lines)-2])
|
||||
self.data_core1.append(out_lines[len(out_lines)-3])
|
||||
self.data_core2.append(out_lines[len(out_lines)-2])
|
||||
|
||||
print(out_lines[len(out_lines) - 3], out_lines[len(out_lines) - 2])
|
||||
self.data_core1.append(out_lines[len(out_lines) - 3])
|
||||
self.data_core2.append(out_lines[len(out_lines) - 2])
|
||||
|
||||
def Connect(self):
|
||||
self.CLIENT.load_system_host_keys()
|
||||
self.CLIENT.set_missing_host_key_policy(pmgo.AutoAddPolicy())
|
||||
try:
|
||||
self.CLIENT.connect(self.host, username=self.USERNAME, password=self.PASSWORD,timeout=10)
|
||||
return None
|
||||
except exception as error:
|
||||
self.CLIENT = 0;
|
||||
return None
|
||||
|
||||
self.CLIENT.connect(self.host, username=self.USERNAME, password=self.PASSWORD, timeout=10)
|
||||
|
||||
|
||||
# Class to Load a Scenario that has been Created in Chamber View saved under DB/[Database_Name]
|
||||
class LoadScenario(LFCliBase):
|
||||
def __init__(self, host, port, db_name, security_debug_on=False, _exit_on_error=False,_exit_on_fail=False):
|
||||
def __init__(self, host, port, db_name, security_debug_on=False, _exit_on_error=False, _exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=security_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.json_post("/cli-json/load", { "name": db_name, "action": 'overwrite' })
|
||||
print(host+ " : Scenario Loaded...")
|
||||
self.json_post("/cli-json/load", {"name": db_name, "action": 'overwrite'})
|
||||
print(host + " : Scenario Loaded...")
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
|
||||
|
||||
# Generates XLSX Report
|
||||
def GenerateReport(scenario, detail, throughput_sta, throughput_vap, absolute_time, relative_time, core1_temp, core2_temp, duration, name):
|
||||
def GenerateReport(scenario, detail, throughput_sta, throughput_vap, absolute_time, relative_time, core1_temp,
|
||||
core2_temp, duration, name):
|
||||
workbook = xlsxwriter.Workbook(name)
|
||||
worksheet = workbook.add_worksheet()
|
||||
worksheet.write('A1',"Scenario Runned: "+scenario+"\n Scenario Details: "+detail)
|
||||
worksheet.write('A1', "Scenario Runned: " + scenario + "\n Scenario Details: " + detail)
|
||||
worksheet.write('A2', 'ABSOLUTE TIME')
|
||||
worksheet.write('B2', 'RELATIVE TIME (ms)')
|
||||
worksheet.write('C2', 'THROUGHPUT STATION SIDE (Mbps)')
|
||||
worksheet.write('D2', 'THROUGHPUT VAP SIDE (Mbps)')
|
||||
worksheet.write('E2', 'CORE 0 TEMP (Degree Celsius)')
|
||||
worksheet.write('F2', 'CORE 1 TEMP (Degree Celsius)')
|
||||
core1=[]
|
||||
core2=[]
|
||||
core1 = []
|
||||
core2 = []
|
||||
|
||||
|
||||
j=3
|
||||
j = 3
|
||||
for i in absolute_time:
|
||||
worksheet.write('A'+str(j),i)
|
||||
j=j+1
|
||||
worksheet.write('A' + str(j), i)
|
||||
j = j + 1
|
||||
|
||||
j=3
|
||||
j = 3
|
||||
for i in relative_time:
|
||||
worksheet.write('B'+str(j),i)
|
||||
j=j+1
|
||||
worksheet.write('B' + str(j), i)
|
||||
j = j + 1
|
||||
|
||||
sta_throu=[]
|
||||
vap_throu=[]
|
||||
j=3
|
||||
sta_throu = []
|
||||
vap_throu = []
|
||||
j = 3
|
||||
for i in throughput_sta:
|
||||
print(i)
|
||||
sta_throu.append(i/1000000)
|
||||
worksheet.write('C'+str(j), str(i/1000000)+" Mbps")
|
||||
j=j+1
|
||||
j=3
|
||||
sta_throu.append(i / 1000000)
|
||||
worksheet.write('C' + str(j), str(i / 1000000) + " Mbps")
|
||||
j = j + 1
|
||||
j = 3
|
||||
for i in throughput_vap:
|
||||
print(i)
|
||||
vap_throu.append(i/1000000)
|
||||
worksheet.write('D'+str(j), str(i/1000000)+" Mbps")
|
||||
j=j+1
|
||||
j=3
|
||||
vap_throu.append(i / 1000000)
|
||||
worksheet.write('D' + str(j), str(i / 1000000) + " Mbps")
|
||||
j = j + 1
|
||||
j = 3
|
||||
for i in core1_temp:
|
||||
core1.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('E'+str(j),str(i).split(':')[1].split('(')[0] )
|
||||
j=j+1
|
||||
j=3
|
||||
worksheet.write('E' + str(j), str(i).split(':')[1].split('(')[0])
|
||||
j = j + 1
|
||||
j = 3
|
||||
for i in core2_temp:
|
||||
core2.append(int(str(i).split(':')[1].split('(')[0].split('.')[0].split('+')[1]))
|
||||
worksheet.write('F'+str(j), str(i).split(':')[1].split('(')[0])
|
||||
j=j+1
|
||||
worksheet.write('F' + str(j), str(i).split(':')[1].split('(')[0])
|
||||
j = j + 1
|
||||
|
||||
Time =[]
|
||||
for i in range(0,int(duration)*5):
|
||||
Time = []
|
||||
for i in range(0, int(duration) * 5):
|
||||
Time.append(i)
|
||||
plot(sta_throu, vap_throu, core1, core2, Time)
|
||||
workbook.close()
|
||||
@@ -162,27 +152,26 @@ def GenerateReport(scenario, detail, throughput_sta, throughput_vap, absolute_ti
|
||||
|
||||
# Plotting Function for Parameters
|
||||
def plot(throughput_sta, throughput_vap, core1_temp, core2_temp, Time):
|
||||
|
||||
print(throughput_vap)
|
||||
s1 = figure(plot_width=1000, plot_height=600)
|
||||
s1.title.text = "WIFI Throughput vs Temperature Plot"
|
||||
s1.xaxis.axis_label = "Time "
|
||||
s1.yaxis.axis_label = "Throughput in Mbps"
|
||||
|
||||
s1.line( Time, throughput_sta, color='black', legend_label ="Throughput Over Station Connections ")
|
||||
#s1.circle(Time, throughput_sta, color='red')
|
||||
s1.line(Time, throughput_sta, color='black', legend_label="Throughput Over Station Connections ")
|
||||
# s1.circle(Time, throughput_sta, color='red')
|
||||
|
||||
s1.line( Time, throughput_vap, color='blue', legend_label ="Throughput Over VAP ")
|
||||
#s1.circle(Time, throughput_vap, color='blue')
|
||||
s1.line(Time, throughput_vap, color='blue', legend_label="Throughput Over VAP ")
|
||||
# s1.circle(Time, throughput_vap, color='blue')
|
||||
|
||||
s1.extra_y_ranges = {"Temperature": Range1d(start=0, end=150)}
|
||||
s1.add_layout(LinearAxis(y_range_name="Temperature", axis_label="Temperature in Degree Celsius"), 'right')
|
||||
|
||||
s1.line(Time, core1_temp, y_range_name='Temperature', color='red', legend_label ="CPU CORE 0 TEMPERATURE ")
|
||||
#s1.circle(Time, core1_temp, y_range_name='Temperature', color='red')
|
||||
s1.line(Time, core1_temp, y_range_name='Temperature', color='red', legend_label="CPU CORE 0 TEMPERATURE ")
|
||||
# s1.circle(Time, core1_temp, y_range_name='Temperature', color='red')
|
||||
|
||||
s1.line(Time, core2_temp, y_range_name='Temperature', color='green', legend_label ="CPU CORE 1 TEMPERATURE ")
|
||||
#s1.circle(Time, core2_temp, y_range_name='Temperature', color='blue')
|
||||
s1.line(Time, core2_temp, y_range_name='Temperature', color='green', legend_label="CPU CORE 1 TEMPERATURE ")
|
||||
# s1.circle(Time, core2_temp, y_range_name='Temperature', color='blue')
|
||||
|
||||
show(s1)
|
||||
|
||||
@@ -193,46 +182,40 @@ class VAP_Measure(LFCliBase):
|
||||
super().__init__(lfclient_host, lfclient_port)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Added Standard Function to Fetch L3 CX and VAP Directly
|
||||
class FindPorts(LFCliBase):
|
||||
def __init__(self, host, port, security_debug_on=False, _exit_on_error=False,_exit_on_fail=False):
|
||||
def __init__(self, host, port, security_debug_on=False, _exit_on_error=False, _exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=security_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
#Creating a Realm Object
|
||||
# Creating a Realm Object
|
||||
self.local_realm = Realm(lfclient_host=host, lfclient_port=port)
|
||||
|
||||
def FindExistingCX(self):
|
||||
return self.local_realm.cx_list()
|
||||
|
||||
def FindExistingCX(self):
|
||||
def FindVAP(self):
|
||||
return self.local_realm.vap_list()
|
||||
|
||||
return self.local_realm.cx_list()
|
||||
|
||||
def FindVAP(self):
|
||||
return self.local_realm.vap_list()
|
||||
|
||||
# Utility to Find the Traffic Running on Existing CX and VAP
|
||||
def PortUtility(host, port, duration, report_name, scenario, detail):
|
||||
|
||||
lf_utils = FindPorts(host, port)
|
||||
|
||||
# cx data will be having all parameters of L3 Connections available in the Realm. It is needed to get the names of all L3 CX, which is stored in cx_names. It is required so as we can extract the real time data running on that CX
|
||||
cx_data = lf_utils.FindExistingCX()
|
||||
#print(cx_data)
|
||||
# print(cx_data)
|
||||
|
||||
# vap_list will have the List of all the vap ports available, This is required to get the VAP names in order to fetch the throughput over that vap
|
||||
vap_list =lf_utils.FindVAP()
|
||||
vap_measure_obj=VAP_Measure(host,port)
|
||||
|
||||
hostname=socket.gethostbyname(socket.gethostname())
|
||||
vap_list = lf_utils.FindVAP()
|
||||
vap_measure_obj = VAP_Measure(host, port)
|
||||
|
||||
hostname = socket.gethostbyname(socket.gethostname())
|
||||
dut_temp_obj = Login_DUT(1, "Thread-1", hostname)
|
||||
|
||||
#print(vap_list)
|
||||
vap_names=[]
|
||||
# print(vap_list)
|
||||
vap_names = []
|
||||
for i in vap_list:
|
||||
vap_names.append(str(i.keys()).split('.')[2].split('\'')[0])
|
||||
print(vap_names[0])
|
||||
@@ -240,95 +223,69 @@ def PortUtility(host, port, duration, report_name, scenario, detail):
|
||||
cx_names = list(cx_data.keys())
|
||||
cx_names.remove('handler')
|
||||
cx_names.remove('uri')
|
||||
absolute_time=[]
|
||||
temp_time =[]
|
||||
absolute_time = []
|
||||
temp_time = []
|
||||
|
||||
Total_Throughput_CX_Side =[]
|
||||
Total_Throughput_VAP_Side =[]
|
||||
print(lf_utils.local_realm.json_get("/cx/"+cx_names[0]).get(cx_names[0]).get('state'))
|
||||
for i in cx_names:
|
||||
while(lf_utils.local_realm.json_get("/cx/"+cx_names[0]).get(cx_names[0]).get('state') != 'Run'):
|
||||
Total_Throughput_CX_Side = []
|
||||
Total_Throughput_VAP_Side = []
|
||||
print(lf_utils.local_realm.json_get("/cx/" + cx_names[0]).get(cx_names[0]).get('state'))
|
||||
for _ in cx_names:
|
||||
while lf_utils.local_realm.json_get("/cx/" + cx_names[0]).get(cx_names[0]).get('state') != 'Run':
|
||||
continue
|
||||
offset=int(round(time.time() * 1000))
|
||||
for i in range(0,int(duration)):
|
||||
temp=0
|
||||
for i in cx_names:
|
||||
temp=temp+int(lf_utils.local_realm.json_get("/cx/"+i).get(i).get('bps rx a'))
|
||||
#temp=temp+lf_utils.local_realm.json_get("/cx/"+i).get(i).get('bps rx b')
|
||||
for i in vap_names:
|
||||
Total_Throughput_VAP_Side.append(int(vap_measure_obj.json_get("/port/1/1/"+str(i)).get('interface').get('bps rx')))
|
||||
offset = int(round(time.time() * 1000))
|
||||
for _ in range(0, int(duration)):
|
||||
temp = 0
|
||||
for cx_name in cx_names:
|
||||
temp = temp + int(lf_utils.local_realm.json_get("/cx/" + cx_name).get(cx_name).get('bps rx a'))
|
||||
# temp=temp+lf_utils.local_realm.json_get("/cx/"+i).get(i).get('bps rx b')
|
||||
for vap_name in vap_names:
|
||||
Total_Throughput_VAP_Side.append(
|
||||
int(vap_measure_obj.json_get("/port/1/1/" + str(vap_name)).get('interface').get('bps rx')))
|
||||
absolute_time.append(datetime.now().strftime("%H:%M:%S"))
|
||||
temp_time.append(int(round(time.time() * 1000)-offset))
|
||||
temp_time.append(int(round(time.time() * 1000) - offset))
|
||||
Total_Throughput_CX_Side.append(temp)
|
||||
dut_temp_obj.run()
|
||||
time.sleep(5)
|
||||
relative_time=[]
|
||||
relative_time.append(0)
|
||||
for i in range (0,len(temp_time)-1):
|
||||
relative_time.append(temp_time[i+1]-temp_time[i])
|
||||
relative_time = [0]
|
||||
for i in range(0, len(temp_time) - 1):
|
||||
relative_time.append(temp_time[i + 1] - temp_time[i])
|
||||
print(Total_Throughput_CX_Side)
|
||||
print(Total_Throughput_VAP_Side)
|
||||
GenerateReport(scenario, detail, Total_Throughput_CX_Side, Total_Throughput_VAP_Side, absolute_time, relative_time, dut_temp_obj.data_core1, dut_temp_obj.data_core2, duration, report_name)
|
||||
GenerateReport(scenario, detail, Total_Throughput_CX_Side, Total_Throughput_VAP_Side, absolute_time, relative_time,
|
||||
dut_temp_obj.data_core1, dut_temp_obj.data_core2, duration, report_name)
|
||||
|
||||
|
||||
# main method
|
||||
def main():
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="test_l3_scenario_throughput.py",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
description="Test Scenario of DUT Temperature measurement along with simultaneous throughput on VAP as well as stations")
|
||||
|
||||
parser.add_argument("-m", "--manager", type=str, help="Enter the address of Lanforge Manager (By default localhost)")
|
||||
parser.add_argument("-sc", "--scenario", type=str, help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
parser.add_argument("-m", "--manager", type=str,
|
||||
help="Enter the address of Lanforge Manager (By default localhost)")
|
||||
parser.add_argument("-sc", "--scenario", type=str,
|
||||
help="Enter the Name of the Scenario you want to load (by Default DFLT)")
|
||||
|
||||
parser.add_argument("-t", "--duration", type=str, help="Enter the Time for which you want to run test")
|
||||
parser.add_argument("-o", "--report_name", type=str, help="Enter the Name of the Output file ('Report.xlsx')")
|
||||
parser.add_argument("-td", "--test_detail", type=str, help="Enter the Test Detail in Quotes ")
|
||||
parser.add_argument("-o", "--report_name", type=str, help="Enter the Name of the Output file ('Report.xlsx')", default='report.xlsx')
|
||||
parser.add_argument("-td", "--test_detail", type=str, help="Enter the Test Detail in Quotes ", default='Blank test')
|
||||
|
||||
args = None
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
# Lanforge Manager IP Address
|
||||
if (args.manager is None):
|
||||
manager = "localhost"
|
||||
if (args.manager is not None):
|
||||
manager = args.manager
|
||||
if (args.scenario is not None):
|
||||
scenario = args.scenario
|
||||
if (args.report_name is not None):
|
||||
report_name = args.report_name
|
||||
if (args.duration is None):
|
||||
duration = (1 * 60)/5
|
||||
if (args.report_name is None):
|
||||
report_name = "report.xlsx"
|
||||
if (args.test_detail is not None):
|
||||
test_detail = args.test_detail
|
||||
if (args.test_detail is None):
|
||||
test_detail = "Blank test"
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
exit(2)
|
||||
|
||||
|
||||
hostname=socket.gethostbyname(socket.gethostname())
|
||||
hostname = socket.gethostbyname(socket.gethostname())
|
||||
# Loading DUT Scenario
|
||||
Scenario_1 = LoadScenario("192.168.200.18", 8080, "Lexus_Dut")
|
||||
|
||||
|
||||
# Loading LF Scenario
|
||||
DB_Lanforge_2 = "LF_Device"
|
||||
Scenario_2 = LoadScenario(manager, 8080, scenario)
|
||||
#Wait for Sometime
|
||||
Scenario_2 = LoadScenario(args.manager, 8080, args.scenario)
|
||||
# Wait for Sometime
|
||||
time.sleep(10)
|
||||
duration_sec=Realm.parse_time(args.duration).total_seconds() * 60
|
||||
duration_sec = Realm.parse_time(args.duration).total_seconds() * 60
|
||||
|
||||
# Port Utility function for reading CX and VAP
|
||||
PortUtility(manager,8080, duration_sec, report_name, scenario, test_detail)
|
||||
|
||||
|
||||
|
||||
PortUtility(args.manager, 8080, duration_sec, args.report_name, args.scenario, args.test_detail)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -10,7 +10,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -36,23 +35,22 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
self.side_b = side_b
|
||||
self.ssid_list = ssid_list
|
||||
self.ssid_password_list = ssid_password_list
|
||||
self.station_lists = station_lists
|
||||
self.station_lists = station_lists
|
||||
self.security = security
|
||||
self.number_template = number_template
|
||||
self.resource = resource
|
||||
self.debug=_debug_on
|
||||
self.debug = _debug_on
|
||||
self.name_prefix = name_prefix
|
||||
self.test_duration = test_duration
|
||||
self.cx_stations_lists = station_lists
|
||||
self.radios = radios # from the command line
|
||||
self.radios = radios # from the command line
|
||||
self.radio_list = radio_name_list
|
||||
self.number_of_stations_per_radio_list = number_of_stations_per_radio_list
|
||||
self.number_of_stations_per_radio_list = number_of_stations_per_radio_list
|
||||
self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
|
||||
self.cx_profile = self.local_realm.new_l3_cx_profile()
|
||||
self.station_profiles = []
|
||||
|
||||
index = 0
|
||||
for radio in radios:
|
||||
|
||||
for index in range(0, len(radios)):
|
||||
self.station_profile = self.local_realm.new_station_profile()
|
||||
self.station_profile.lfclient_url = self.lfclient_url
|
||||
self.station_profile.ssid = ssid_list[index]
|
||||
@@ -61,8 +59,7 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
self.station_profile.number_template = self.number_template
|
||||
self.station_profile.mode = 0
|
||||
self.station_profiles.append(self.station_profile)
|
||||
index += 1
|
||||
|
||||
|
||||
self.cx_profile.host = self.host
|
||||
self.cx_profile.port = self.port
|
||||
self.cx_profile.name_prefix = self.name_prefix
|
||||
@@ -78,11 +75,12 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
if cx_name != 'uri' and cx_name != 'handler':
|
||||
for item, value in cx_name.items():
|
||||
for value_name, value_rx in value.items():
|
||||
if value_name == 'rx bytes':
|
||||
cx_rx_map[item] = value_rx
|
||||
if value_name == 'rx bytes':
|
||||
cx_rx_map[item] = value_rx
|
||||
return cx_rx_map
|
||||
|
||||
def __compare_vals(self, old_list, new_list):
|
||||
@staticmethod
|
||||
def __compare_vals(old_list, new_list):
|
||||
passes = 0
|
||||
expected_passes = 0
|
||||
if len(old_list) == len(new_list):
|
||||
@@ -107,22 +105,19 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
if self.debug:
|
||||
print("Bringing up station {}".format(station_profile))
|
||||
station_profile.admin_up(self.resource)
|
||||
if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=10*len(station_list)):
|
||||
if self.local_realm.wait_for_ip(self.resource, station_list, timeout_sec=10 * len(station_list)):
|
||||
if self.debug:
|
||||
print("ip's aquired {}".format(station_list))
|
||||
else:
|
||||
print("print failed to get IP's: {}".format(station_list))
|
||||
if self.local_realm.wait_for_ip(self.resource, station_list,timeout_sec=120):
|
||||
if self.local_realm.wait_for_ip(self.resource, station_list, timeout_sec=120):
|
||||
print("tried again: print failed to get IP's: {}".format(station_list))
|
||||
exit(1)
|
||||
|
||||
|
||||
|
||||
self.cx_profile.start_cx()
|
||||
|
||||
cur_time = datetime.datetime.now()
|
||||
old_rx_values = self.__get_rx_values()
|
||||
filtered_old_rx_values = []
|
||||
filtered_old_rx_values = old_rx_values
|
||||
|
||||
end_time = self.local_realm.parse_time(self.test_duration) + cur_time
|
||||
@@ -134,9 +129,8 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
while cur_time < interval_time:
|
||||
cur_time = datetime.datetime.now()
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
new_rx_values = self.__get_rx_values()
|
||||
filtered_new_rx_values = []
|
||||
filtered_new_rx_values = new_rx_values
|
||||
|
||||
expected_passes += 1
|
||||
@@ -145,7 +139,6 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
else:
|
||||
self._fail("FAIL: Not all stations increased traffic", print_fail)
|
||||
break
|
||||
old_rx_values = new_rx_values
|
||||
cur_time = datetime.datetime.now()
|
||||
|
||||
if passes == expected_passes:
|
||||
@@ -159,19 +152,18 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
url = "cli-json/set_port"
|
||||
self.json_post(url, data)
|
||||
|
||||
def cleanup(self, resource):
|
||||
resource = 1
|
||||
def cleanup(self,):
|
||||
data = {
|
||||
"name":"BLANK",
|
||||
"action":"overwrite"
|
||||
"name": "BLANK",
|
||||
"action": "overwrite"
|
||||
}
|
||||
url = "cli-json/load"
|
||||
self.json_post(url, data)
|
||||
|
||||
timeout = 20
|
||||
done = False
|
||||
while timeout > 0 and done == False:
|
||||
time.sleep( 1)
|
||||
while timeout > 0 and not done:
|
||||
time.sleep(1)
|
||||
port_r = self.json_get("/port/1/1/list?fields=alias")
|
||||
if self.debug:
|
||||
print("port interfaces {}".format(port_r["interfaces"]))
|
||||
@@ -181,37 +173,37 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
print("interface {}".format(interface))
|
||||
else:
|
||||
done = True
|
||||
break
|
||||
break
|
||||
timeout -= 1
|
||||
|
||||
if timeout <= 0:
|
||||
print("not all station ports removed {}".format(port_r["interfaces"]))
|
||||
|
||||
def build(self):
|
||||
def build(self):
|
||||
# refactor in LFUtils.port_zero_request()
|
||||
resource = 1
|
||||
|
||||
data ={
|
||||
'shelf':1,
|
||||
'resource':1,
|
||||
'port':'eth1',
|
||||
'ip_addr':'0.0.0.0',
|
||||
'netmask':'0.0.0.0',
|
||||
'gateway':'0.0.0.0',
|
||||
'current_flags':0,
|
||||
'interest':402653212
|
||||
}
|
||||
|
||||
data = {
|
||||
'shelf': 1,
|
||||
'resource': 1,
|
||||
'port': 'eth1',
|
||||
'ip_addr': '0.0.0.0',
|
||||
'netmask': '0.0.0.0',
|
||||
'gateway': '0.0.0.0',
|
||||
'current_flags': 0,
|
||||
'interest': 402653212
|
||||
}
|
||||
|
||||
url = "cli-json/set_port"
|
||||
self.json_post(url, data)
|
||||
|
||||
# refactor into LFUtils
|
||||
data ={
|
||||
"shelf":1,
|
||||
"resource": resource,
|
||||
"port":"br0",
|
||||
"network_devs":"eth1",
|
||||
"br_flags":1
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": resource,
|
||||
"port": "br0",
|
||||
"network_devs": "eth1",
|
||||
"br_flags": 1
|
||||
}
|
||||
url = "cli-json/add_br"
|
||||
self.json_post(url, data)
|
||||
@@ -221,39 +213,43 @@ class L3VariableTimeLongevity(LFCliBase):
|
||||
self.json_post("/cli-json/set_port", data)
|
||||
except:
|
||||
print("LFUtils.port_dhcp_up_request didn't complete ")
|
||||
print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(self.side_b))
|
||||
print("or the json_post failed either way {} did not set up dhcp so test may not pass data ".format(
|
||||
self.side_b))
|
||||
|
||||
resource = 1
|
||||
index = 0
|
||||
index = 0
|
||||
temp_station_list = []
|
||||
for station_profile, station_list in zip(self.station_profiles, self.station_lists):
|
||||
station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass)
|
||||
station_profile.set_number_template(station_profile.number_template)
|
||||
if self.debug:
|
||||
print("radio: {} station_profile: {} Creating stations: {} ".format(self.radio_list[index],station_profile, station_list))
|
||||
|
||||
temp_station_list = []
|
||||
print("radio: {} station_profile: {} Creating stations: {} ".format(self.radio_list[index],
|
||||
station_profile, station_list))
|
||||
|
||||
for station in range(len(station_list)):
|
||||
temp_station_list.append(str(self.resource) + "." + station_list[station])
|
||||
station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=False )
|
||||
station_profile.create(radio=self.radio_list[index], sta_names_=station_list, debug=False)
|
||||
index += 1
|
||||
self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.'+self.side_b, sleep_time=.5)
|
||||
self.cx_profile.create(endp_type=self.endp_type, side_a=temp_station_list, side_b='1.' + self.side_b,
|
||||
sleep_time=.5)
|
||||
self._pass("PASS: Stations build finished")
|
||||
|
||||
|
||||
def valid_endp_type(endp_type):
|
||||
valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6']
|
||||
if str(endp_type) in valid_endp_type:
|
||||
valid_endp_types = ['lf_udp', 'lf_udp6', 'lf_tcp', 'lf_tcp6']
|
||||
if str(endp_type) in valid_endp_types:
|
||||
return endp_type
|
||||
else:
|
||||
print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6')
|
||||
print('invalid endp_type. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6')
|
||||
exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='test_l3_longevity.py',
|
||||
#formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
# formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
epilog='''\
|
||||
Useful Information:
|
||||
@@ -264,7 +260,7 @@ Useful Information:
|
||||
4. Security is fixed at WPA2
|
||||
5. Maximum stations per radio is 64
|
||||
''',
|
||||
|
||||
|
||||
description='''\
|
||||
test_l3_longevity.py:
|
||||
--------------------
|
||||
@@ -317,43 +313,39 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type lf_tcp --upstream
|
||||
|
||||
''')
|
||||
|
||||
|
||||
parser.add_argument('-d','--test_duration', help='--test_duration <how long to run> example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m')
|
||||
parser.add_argument('-t', '--endp_type', help='--endp_type <type of traffic> example --endp_type lf_udp, default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6',
|
||||
default='lf_udp',type=valid_endp_type)
|
||||
parser.add_argument('-u', '--upstream_port', help='--upstream_port <upstream_port> example: --upstream_port eth1',default='eth1')
|
||||
parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||
parser.add_argument('-d', '--test_duration',
|
||||
help='--test_duration <how long to run> example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',
|
||||
default='3m')
|
||||
parser.add_argument('-t', '--endp_type',
|
||||
help='--endp_type <type of traffic> example --endp_type lf_udp, default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6',
|
||||
default='lf_udp', type=valid_endp_type)
|
||||
parser.add_argument('-u', '--upstream_port', help='--upstream_port <upstream_port> example: --upstream_port eth1',
|
||||
default='eth1')
|
||||
parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true")
|
||||
|
||||
requiredNamed = parser.add_argument_group('required arguments')
|
||||
requiredNamed.add_argument('-r','--radio', action='append', nargs=4, metavar=('<wiphyX>', '<number last station>','<ssid>','<ssid password>'),
|
||||
help ='--radio <number_of_wiphy> <number of last station> <ssid> <ssid password> ',required=True)
|
||||
requiredNamed.add_argument('-r', '--radio', action='append', nargs=4,
|
||||
metavar=('<wiphyX>', '<number last station>', '<ssid>', '<ssid password>'),
|
||||
help='--radio <number_of_wiphy> <number of last station> <ssid> <ssid password> ',
|
||||
required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.test_duration:
|
||||
test_duration = args.test_duration
|
||||
|
||||
if args.endp_type:
|
||||
endp_type = args.endp_type
|
||||
|
||||
side_b = args.upstream_port
|
||||
|
||||
if args.radio:
|
||||
radios = args.radio
|
||||
|
||||
radio_offset = 0
|
||||
number_of_stations_offset = 1
|
||||
ssid_offset = 2
|
||||
ssid_password_offset = 3
|
||||
|
||||
MAX_NUMBER_OF_STATIONS = 64
|
||||
|
||||
|
||||
radio_name_list = []
|
||||
number_of_stations_per_radio_list = []
|
||||
ssid_list = []
|
||||
ssid_password_list = []
|
||||
|
||||
index = 0
|
||||
for radio in radios:
|
||||
for radio in args.radio:
|
||||
radio_name = radio[radio_offset]
|
||||
radio_name_list.append(radio_name)
|
||||
number_of_stations_per_radio = radio[number_of_stations_offset]
|
||||
@@ -366,43 +358,44 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type lf_tcp --upstream
|
||||
|
||||
index = 0
|
||||
station_lists = []
|
||||
for radio in radios:
|
||||
for _ in args.radio:
|
||||
number_of_stations = int(number_of_stations_per_radio_list[index])
|
||||
if number_of_stations > MAX_NUMBER_OF_STATIONS:
|
||||
print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS))
|
||||
quit(1)
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, padding_number_=10000)
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=1 + index * 1000,
|
||||
end_id_=number_of_stations + index * 1000, padding_number_=10000)
|
||||
station_lists.append(station_list)
|
||||
index += 1
|
||||
ip_var_test = L3VariableTimeLongevity(lfjson_host,
|
||||
lfjson_port,
|
||||
number_template="00",
|
||||
station_lists= station_lists,
|
||||
name_prefix="var_time",
|
||||
endp_type=endp_type,
|
||||
side_b=side_b,
|
||||
radios=radios,
|
||||
radio_name_list=radio_name_list,
|
||||
number_of_stations_per_radio_list=number_of_stations_per_radio_list,
|
||||
ssid_list=ssid_list,
|
||||
ssid_password_list=ssid_password_list,
|
||||
resource=1,
|
||||
security="wpa2", test_duration=test_duration,
|
||||
side_a_min_rate=256000, side_b_min_rate=256000,
|
||||
_debug_on=args.debug)
|
||||
ip_var_test = L3VariableTimeLongevity(lfjson_host,
|
||||
lfjson_port,
|
||||
number_template="00",
|
||||
station_lists=station_lists,
|
||||
name_prefix="var_time",
|
||||
endp_type=args.endp_type,
|
||||
side_b=side_b,
|
||||
radios=args.radio,
|
||||
radio_name_list=radio_name_list,
|
||||
number_of_stations_per_radio_list=number_of_stations_per_radio_list,
|
||||
ssid_list=ssid_list,
|
||||
ssid_password_list=ssid_password_list,
|
||||
resource=1,
|
||||
security="wpa2", test_duration=args.test_duration,
|
||||
side_a_min_rate=256000, side_b_min_rate=256000,
|
||||
_debug_on=args.debug)
|
||||
|
||||
ip_var_test.cleanup(station_list)
|
||||
ip_var_test.cleanup()
|
||||
ip_var_test.build()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
exit(1)
|
||||
exit(1)
|
||||
ip_var_test.start(False, False)
|
||||
ip_var_test.stop()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
exit(1)
|
||||
exit(1)
|
||||
time.sleep(30)
|
||||
ip_var_test.cleanup(station_list)
|
||||
ip_var_test.cleanup()
|
||||
if ip_var_test.passes():
|
||||
print("Full test passed, all connections increased rx bytes")
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -257,43 +256,31 @@ python3 ./test_l4.py
|
||||
--test_duration 2m \\
|
||||
--debug
|
||||
''')
|
||||
required = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "required arguments":
|
||||
required = agroup
|
||||
# if required is not None:
|
||||
|
||||
optional = None
|
||||
for agroup in parser._action_groups:
|
||||
if agroup.title == "optional arguments":
|
||||
optional = agroup
|
||||
|
||||
if optional is not None:
|
||||
optional.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes',
|
||||
default=600)
|
||||
optional.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes',
|
||||
default=1)
|
||||
optional.add_argument('--url', help='--url specifies upload/download, address, and dest',
|
||||
default="dl http://10.40.0.1 /dev/null")
|
||||
optional.add_argument('--test_duration', help='duration of test', default="2m")
|
||||
optional.add_argument('--target_per_ten',
|
||||
help='--target_per_ten target number of request per ten minutes. test will check for 90 percent this value',
|
||||
default=600)
|
||||
optional.add_argument('--mode', help='Used to force mode of stations')
|
||||
optional.add_argument('--ap', help='Used to force a connection to a particular AP')
|
||||
optional.add_argument('--report_file', help='where you want to store results')
|
||||
optional.add_argument('--output_format', help='choose csv or xlsx') # update once other forms are completed
|
||||
optional.add_argument('--ftp', help='Use ftp for the test', action='store_true')
|
||||
optional.add_argument('--test_type', help='Choose type of test to run {urls, bytes-rd, bytes-wr}',
|
||||
default='bytes-rd')
|
||||
optional.add_argument('--ftp_user', help='--ftp_user sets the username to be used for ftp', default=None)
|
||||
optional.add_argument('--ftp_passwd', help='--ftp_user sets the password to be used for ftp', default=None)
|
||||
optional.add_argument('--dest',
|
||||
help='--dest specifies the destination for the file, should be used when downloading',
|
||||
default="/dev/null")
|
||||
optional.add_argument('--source',
|
||||
help='--source specifies the source of the file, should be used when uploading',
|
||||
default="/var/www/html/data_slug_4K.bin")
|
||||
parser.add_argument('--requests_per_ten', help='--requests_per_ten number of request per ten minutes',
|
||||
default=600)
|
||||
parser.add_argument('--num_tests', help='--num_tests number of tests to run. Each test runs 10 minutes',
|
||||
default=1)
|
||||
parser.add_argument('--url', help='--url specifies upload/download, address, and dest',
|
||||
default="dl http://10.40.0.1 /dev/null")
|
||||
parser.add_argument('--test_duration', help='duration of test', default="2m")
|
||||
parser.add_argument('--target_per_ten',
|
||||
help='--target_per_ten target number of request per ten minutes. test will check for 90 percent this value',
|
||||
default=600)
|
||||
parser.add_argument('--mode', help='Used to force mode of stations')
|
||||
parser.add_argument('--ap', help='Used to force a connection to a particular AP')
|
||||
parser.add_argument('--report_file', help='where you want to store results')
|
||||
parser.add_argument('--output_format', help='choose csv or xlsx') # update once other forms are completed
|
||||
parser.add_argument('--ftp', help='Use ftp for the test', action='store_true')
|
||||
parser.add_argument('--test_type', help='Choose type of test to run {urls, bytes-rd, bytes-wr}',
|
||||
default='bytes-rd')
|
||||
parser.add_argument('--ftp_user', help='--ftp_user sets the username to be used for ftp', default=None)
|
||||
parser.add_argument('--ftp_passwd', help='--ftp_user sets the password to be used for ftp', default=None)
|
||||
parser.add_argument('--dest',
|
||||
help='--dest specifies the destination for the file, should be used when downloading',
|
||||
default="/dev/null")
|
||||
parser.add_argument('--source',
|
||||
help='--source specifies the source of the file, should be used when uploading',
|
||||
default="/var/www/html/data_slug_4K.bin")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -305,15 +292,11 @@ python3 ./test_l4.py
|
||||
if args.output_format in ['csv', 'json', 'html', 'hdf', 'stata', 'pickle', 'pdf', 'parquet', 'png', 'df',
|
||||
'xlsx']:
|
||||
output_form = args.output_format.lower()
|
||||
print("Defaulting file output placement to /home/lanforge.")
|
||||
rpt_file = '/home/data.' + output_form
|
||||
else:
|
||||
print("Defaulting data file output type to Excel")
|
||||
rpt_file = '/home/lanforge/data.xlsx'
|
||||
output_form = 'xlsx'
|
||||
|
||||
else:
|
||||
rpt_file = args.report_file
|
||||
if args.output_format is None:
|
||||
output_form = str(args.report_file).split('.')[-1]
|
||||
else:
|
||||
@@ -321,32 +304,21 @@ python3 ./test_l4.py
|
||||
|
||||
# Create directory
|
||||
if args.report_file is None:
|
||||
try:
|
||||
homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':',
|
||||
'-') + 'test_l4'
|
||||
if os.path.isdir('/home/lanforge/report-data'):
|
||||
homedir = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")).replace(':', '-') + 'test_l4'
|
||||
path = os.path.join('/home/lanforge/report-data/', homedir)
|
||||
os.mkdir(path)
|
||||
except:
|
||||
else:
|
||||
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
print('Saving file to local directory')
|
||||
else:
|
||||
pass
|
||||
|
||||
if args.report_file is None:
|
||||
if args.output_format in ['csv', 'json', 'html', 'hdf', 'stata', 'pickle', 'pdf', 'png', 'df', 'parquet',
|
||||
'xlsx']:
|
||||
rpt_file = path + '/data.' + args.output_format
|
||||
output = args.output_format
|
||||
else:
|
||||
print('Defaulting data file output type to Excel')
|
||||
rpt_file = path + '/data.xlsx'
|
||||
output = 'xlsx'
|
||||
else:
|
||||
rpt_file = args.report_file
|
||||
if args.output_format is None:
|
||||
output = str(args.report_file).split('.')[-1]
|
||||
else:
|
||||
output = args.output_format
|
||||
|
||||
station_list = LFUtils.portNameSeries(prefix_="sta", start_id_=0, end_id_=num_sta - 1, padding_number_=10000,
|
||||
radio=args.radio)
|
||||
@@ -376,13 +348,10 @@ python3 ./test_l4.py
|
||||
ip_test.build()
|
||||
ip_test.start()
|
||||
|
||||
try:
|
||||
layer4traffic = ','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']])
|
||||
except:
|
||||
pass
|
||||
layer4traffic = ','.join([[*x.keys()][0] for x in ip_test.local_realm.json_get('layer4')['endpoint']])
|
||||
ip_test.cx_profile.monitor(col_names=['name', 'bytes-rd', 'urls/s', 'bytes-wr'],
|
||||
report_file=rpt_file,
|
||||
duration_sec=ip_test.local_realm.parse_time(args.test_duration).total_seconds(),
|
||||
duration_sec=args.test_duration,
|
||||
created_cx=layer4traffic,
|
||||
output_format=output_form,
|
||||
script_name='test_l4',
|
||||
|
||||
@@ -10,7 +10,6 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python 3")
|
||||
exit(1)
|
||||
|
||||
|
||||
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
|
||||
|
||||
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
|
||||
@@ -24,20 +23,24 @@ class TestStatusMessage(LFCliBase):
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False):
|
||||
super().__init__(host, port, _debug=_debug_on, _exit_on_fail=_exit_on_fail)
|
||||
self.exit_on_error = False
|
||||
self.status_msg_url = "/status-msg"
|
||||
self.session_url = None
|
||||
self.msg_count = 0
|
||||
self.deep_clean = _deep_clean
|
||||
self.check_connect()
|
||||
self.debug = _debug_on
|
||||
|
||||
def build(self):
|
||||
"""create a new session"""
|
||||
new_session = uuid1()
|
||||
self.status_msg_url = "/status-msg"
|
||||
self.session_url = "/status-msg/"+str(new_session)
|
||||
self.session_url = "/status-msg/" + str(new_session)
|
||||
# print("----- ----- ----- ----- ----- PUT ----- ----- ----- ----- ----- ----- ")
|
||||
self.json_put(self.session_url, _data={})
|
||||
|
||||
# we should see list of sessions
|
||||
try:
|
||||
#print("----- ----- ----- ----- ----- GET ----- ----- ----- ----- ----- ----- ")
|
||||
# print("----- ----- ----- ----- ----- GET ----- ----- ----- ----- ----- ----- ")
|
||||
session_response = self.json_get(self.status_msg_url)
|
||||
if self.debug:
|
||||
pprint(session_response)
|
||||
@@ -47,7 +50,7 @@ class TestStatusMessage(LFCliBase):
|
||||
if len(session_response["sessions"]) < 2:
|
||||
self._fail("why do we have less than two sessions?")
|
||||
for session in session_response["sessions"]:
|
||||
#print("----- ----- ----- ----- ----- SESSION ----- ----- ----- ----- ----- ----- ")
|
||||
# print("----- ----- ----- ----- ----- SESSION ----- ----- ----- ----- ----- ----- ")
|
||||
pprint(session)
|
||||
self._pass("session created")
|
||||
except ValueError as ve:
|
||||
@@ -55,37 +58,39 @@ class TestStatusMessage(LFCliBase):
|
||||
self._fail(ve)
|
||||
return
|
||||
|
||||
def start(self, print_pass=False, print_fail=False):
|
||||
def start(self):
|
||||
"""
|
||||
create a series of messages
|
||||
:return: None
|
||||
"""
|
||||
#print("----- ----- ----- ----- ----- START ----- %s ----- ----- ----- ----- ----- " % self.session_url)
|
||||
# print("----- ----- ----- ----- ----- START ----- %s ----- ----- ----- ----- ----- " % self.session_url)
|
||||
message_response = self.json_get(self.session_url)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
if "empty" in message_response:
|
||||
self._pass("empty response, zero messages")
|
||||
elif "messages" in message_response:
|
||||
messages_a = message_response["messages"]
|
||||
if len(messages_a) > 0:
|
||||
self._fail("we should have zero messages")
|
||||
if message_response:
|
||||
if "empty" in message_response:
|
||||
self._pass("empty response, zero messages")
|
||||
elif "messages" in message_response:
|
||||
messages_a = message_response["messages"]
|
||||
if len(messages_a) > 0:
|
||||
self._fail("we should have zero messages")
|
||||
|
||||
for msg_num in ( 1, 2, 3, 4, 5 ):
|
||||
#print("----- ----- ----- ----- ----- ----- %s ----- ----- ----- ----- ----- " % msg_num)
|
||||
#print("session url: "+self.session_url)
|
||||
for msg_num in (1, 2, 3, 4, 5):
|
||||
# print("----- ----- ----- ----- ----- ----- %s ----- ----- ----- ----- ----- " % msg_num)
|
||||
# print("session url: "+self.session_url)
|
||||
self.msg_count = msg_num
|
||||
self.json_post(self.session_url, {
|
||||
"key": "test_status_message.py",
|
||||
"content-type":"application/json",
|
||||
"message":"message %s"%msg_num
|
||||
"content-type": "application/json",
|
||||
"message": "message %s" % msg_num
|
||||
})
|
||||
message_response = self.json_get(self.session_url)
|
||||
if len(message_response["messages"]) != msg_num:
|
||||
pprint(message_response)
|
||||
self._fail("we should have %s messages"%msg_num)
|
||||
if message_response:
|
||||
if len(message_response["messages"]) != msg_num:
|
||||
pprint(message_response)
|
||||
self._fail("we should have %s messages" % msg_num)
|
||||
|
||||
self._pass("created and listed %s messages counted"%msg_num)
|
||||
self._pass("created and listed %s messages counted" % msg_num)
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
@@ -94,86 +99,84 @@ class TestStatusMessage(LFCliBase):
|
||||
"""
|
||||
|
||||
message_list_response = self.json_get(self.session_url)
|
||||
if "empty" in message_list_response:
|
||||
self._fail("empty response, we expect 1 or more messages")
|
||||
msg_num = 0
|
||||
for message_o in message_list_response["messages"]:
|
||||
msg_url = message_o["_links"]
|
||||
print("Message url: "+msg_url)
|
||||
message_response = self.json_get(msg_url)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
for message_o in message_response["messages"]:
|
||||
msg_num += 1
|
||||
content_o = message_o
|
||||
print("id %s" % content_o["message_id"])
|
||||
print("key %s" % content_o["message"]["key"])
|
||||
print("content-type %s" % content_o["message"]["content-type"])
|
||||
print("message %s" % content_o["message"]["message"])
|
||||
if message_list_response:
|
||||
if "empty" in message_list_response:
|
||||
self._fail("empty response, we expect 1 or more messages")
|
||||
msg_num = 0
|
||||
for message_o in message_list_response["messages"]:
|
||||
msg_url = message_o["_links"]
|
||||
print("Message url: " + msg_url)
|
||||
message_response = self.json_get(msg_url)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
for content_o in message_response["messages"]:
|
||||
msg_num += 1
|
||||
print("id %s" % content_o["message_id"])
|
||||
print("key %s" % content_o["message"]["key"])
|
||||
print("content-type %s" % content_o["message"]["content-type"])
|
||||
print("message %s" % content_o["message"]["message"])
|
||||
|
||||
if msg_num != self.msg_count:
|
||||
self._fail("(stop) expected %s messages, saw %s" % (self.msg_count, msg_num))
|
||||
else:
|
||||
self._pass("saw correct number of messages")
|
||||
if msg_num != self.msg_count:
|
||||
self._fail("(stop) expected %s messages, saw %s" % (self.msg_count, msg_num))
|
||||
else:
|
||||
self._pass("saw correct number of messages")
|
||||
|
||||
def cleanup(self):
|
||||
"""delete messages and delete the session"""
|
||||
|
||||
message_list_response = self.json_get(self.session_url)
|
||||
if "empty" in message_list_response:
|
||||
self._fail("empty response, we expect 1 or more messages")
|
||||
last_link = ""
|
||||
msg_num = 0
|
||||
for message_o in message_list_response["messages"]:
|
||||
msg_url = message_o["_links"]
|
||||
# print("Delete Message url: "+msg_url)
|
||||
last_link = message_o["_links"]
|
||||
msg_num += 1
|
||||
if message_list_response:
|
||||
if "empty" in message_list_response:
|
||||
self._fail("empty response, we expect 1 or more messages")
|
||||
last_link = ""
|
||||
msg_num = 0
|
||||
for message_o in message_list_response["messages"]:
|
||||
# print("Delete Message url: "+msg_url)
|
||||
last_link = message_o["_links"]
|
||||
msg_num += 1
|
||||
|
||||
if msg_num != self.msg_count:
|
||||
self._fail("(cleanup) expected %s messages, saw %s" % (self.msg_count, msg_num))
|
||||
message_response = self.json_delete(last_link)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
if msg_num != self.msg_count:
|
||||
self._fail("(cleanup) expected %s messages, saw %s" % (self.msg_count, msg_num))
|
||||
message_response = self.json_delete(last_link)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
|
||||
# check message removal
|
||||
message_list_response = self.json_get(self.session_url)
|
||||
msg_num = len(message_list_response["messages"])
|
||||
if msg_num != (self.msg_count - 1):
|
||||
self._fail("(cleanup) expected %s messages, saw %s" % ((self.msg_count - 1), msg_num))
|
||||
else:
|
||||
self._pass("(cleanup) messages decreased by one")
|
||||
|
||||
all_url = self.session_url + "/all"
|
||||
message_response = self.json_delete(all_url)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
|
||||
message_list_response = self.json_get(self.session_url)
|
||||
if self.debug:
|
||||
pprint(message_list_response)
|
||||
if "messages" in message_list_response:
|
||||
if message_list_response:
|
||||
msg_num = len(message_list_response["messages"])
|
||||
elif "empty" in message_list_response:
|
||||
msg_num = 0
|
||||
if msg_num != (self.msg_count - 1):
|
||||
self._fail("(cleanup) expected %s messages, saw %s" % ((self.msg_count - 1), msg_num))
|
||||
else:
|
||||
self._pass("(cleanup) messages decreased by one")
|
||||
|
||||
if (msg_num == 0):
|
||||
self._pass("deleted all messages in session")
|
||||
else:
|
||||
self._fail("failed to delete all messages in session")
|
||||
all_url = self.session_url + "/all"
|
||||
message_response = self.json_delete(all_url)
|
||||
if self.debug:
|
||||
pprint(message_response)
|
||||
|
||||
# make sure we fail on removing session incorrectly
|
||||
try:
|
||||
message_list_response = self.json_get(self.session_url)
|
||||
if self.debug:
|
||||
print("--- del -------------------- -------------------- --------------------")
|
||||
self.exit_on_error=False
|
||||
message_response = self.json_delete(self.session_url, debug_=False)
|
||||
if self.debug:
|
||||
print("--- ~del -------------------- -------------------- --------------------")
|
||||
except ValueError as ve:
|
||||
print("- - - - - - - - - - - - - - - - - - - - - - -")
|
||||
print(ve)
|
||||
print("- - - - - - - - - - - - - - - - - - - - - - -")
|
||||
pprint(message_list_response)
|
||||
if "messages" in message_list_response:
|
||||
msg_num = len(message_list_response["messages"])
|
||||
elif "empty" in message_list_response:
|
||||
msg_num = 0
|
||||
|
||||
if msg_num == 0:
|
||||
return "deleted all messages in session"
|
||||
else:
|
||||
self._fail("failed to delete all messages in session")
|
||||
|
||||
if 'empty' in message_list_response.keys():
|
||||
if self.debug:
|
||||
print("--- del -------------------- -------------------- --------------------")
|
||||
self.exit_on_error = False
|
||||
self.json_delete("%s/this" % self.session_url, debug_=False)
|
||||
if self.debug:
|
||||
print("--- ~del -------------------- -------------------- --------------------")
|
||||
else:
|
||||
return 'ports deleted successfully'
|
||||
|
||||
sessions_list_response = self.json_get("/status-msg")
|
||||
if self.debug:
|
||||
@@ -189,12 +192,13 @@ class TestStatusMessage(LFCliBase):
|
||||
break
|
||||
if counter == 0:
|
||||
self._fail("session incorrectly deleted")
|
||||
else:
|
||||
return "Sessions properly deleted"
|
||||
|
||||
try:
|
||||
if self.debug:
|
||||
print("--- del -------------------- -------------------- --------------------")
|
||||
self.exit_on_error=False
|
||||
message_response = self.json_delete(self.session_url+"/this", debug_=False)
|
||||
self.json_delete(self.session_url + "/this", debug_=False)
|
||||
if self.debug:
|
||||
print("--- ~del -------------------- -------------------- --------------------")
|
||||
except ValueError as ve:
|
||||
@@ -208,7 +212,7 @@ class TestStatusMessage(LFCliBase):
|
||||
for session_o in session_list:
|
||||
if session_o["_links"] == self.session_url:
|
||||
counter += 1
|
||||
self._fail("session not deleted: "+session_o["_links"])
|
||||
self._fail("session not deleted: " + session_o["_links"])
|
||||
break
|
||||
if counter == 0:
|
||||
self._pass("session correctly deleted")
|
||||
@@ -222,14 +226,14 @@ class TestStatusMessage(LFCliBase):
|
||||
counter = 0
|
||||
for session_o in session_list:
|
||||
counter += 1
|
||||
self.json_delete(session_o["_links"]+"/all")
|
||||
self.json_delete(session_o["_links"] + "/all")
|
||||
print("cleaned %s sessions" % counter)
|
||||
counter = 0
|
||||
for session_o in session_list:
|
||||
if session_o["session-id"] == "0":
|
||||
continue
|
||||
counter += 1
|
||||
self.json_delete(session_o["_links"]+"/this")
|
||||
self.json_delete(session_o["_links"] + "/this")
|
||||
print("deleted %s sessions" % counter)
|
||||
|
||||
|
||||
@@ -248,6 +252,9 @@ Test the status message passing functions of /status-msg:
|
||||
- delete message: DELETE /status-msg/<new-session-id>/message-id
|
||||
- delete session: DELETE /status-msg/<new-session-id>/this
|
||||
- delete all messages in session: DELETE /status-msg/<new-session-id>/all
|
||||
|
||||
Example:
|
||||
./test_status_msg.py
|
||||
""")
|
||||
parser.add_argument('--action', default="run_test", help="""
|
||||
Actions can be:
|
||||
@@ -258,24 +265,24 @@ Actions can be:
|
||||
list : list messages from session
|
||||
delete : delete message, all messages using session/all or session using session/this
|
||||
""")
|
||||
parser.add_argument('--session', type=str, help='explicit session or session/message-id')
|
||||
parser.add_argument('--session', type=str, help='explicit session or session/message-id')
|
||||
parser.add_argument('--deep_clean', type=bool, help='remove all messages and all sessions')
|
||||
parser.add_argument('--key', type=str, help='how to key the message')
|
||||
parser.add_argument('--message', type=str, help='message to include')
|
||||
parser.add_argument('--key', type=str, help='how to key the message')
|
||||
parser.add_argument('--message', type=str, help='message to include')
|
||||
args = parser.parse_args()
|
||||
|
||||
status_messages = TestStatusMessage(args.mgr,
|
||||
args.mgr_port,
|
||||
_debug_on=False,
|
||||
_debug_on=args.debug,
|
||||
_exit_on_error=False,
|
||||
_exit_on_fail=False)
|
||||
if args.action == "new":
|
||||
if args.session is not None:
|
||||
status_messages.json_put("/status-msg/"+args.session, {})
|
||||
status_messages.json_put("/status-msg/" + args.session, {})
|
||||
else:
|
||||
a_uuid = uuid1()
|
||||
status_messages.json_put("/status-msg/"+str(a_uuid), {})
|
||||
print("created session /status-msg/"+str(a_uuid))
|
||||
status_messages.json_put("/status-msg/" + str(a_uuid), {})
|
||||
print("created session /status-msg/" + str(a_uuid))
|
||||
return
|
||||
|
||||
if args.action == "update":
|
||||
@@ -288,7 +295,7 @@ Actions can be:
|
||||
if args.message is None:
|
||||
print("requires --message")
|
||||
return
|
||||
status_messages.json_post("/status-msg/"+args.session, {
|
||||
status_messages.json_post("/status-msg/" + args.session, {
|
||||
"key": args.key,
|
||||
"content-type": "text/plain",
|
||||
"message": args.message
|
||||
@@ -300,7 +307,7 @@ Actions can be:
|
||||
response_o = status_messages.json_get("/status-msg/")
|
||||
pprint(response_o["sessions"])
|
||||
else:
|
||||
response_o = status_messages.json_get("/status-msg/"+args.session)
|
||||
response_o = status_messages.json_get("/status-msg/" + args.session)
|
||||
pprint(response_o["messages"])
|
||||
return
|
||||
|
||||
@@ -311,7 +318,7 @@ Actions can be:
|
||||
if args.key is None:
|
||||
print("requires --key")
|
||||
return
|
||||
response_o = status_messages.json_get("/status-msg/%s/%s"%(args.session, args.key))
|
||||
response_o = status_messages.json_get("/status-msg/%s/%s" % (args.session, args.key))
|
||||
pprint(response_o)
|
||||
return
|
||||
|
||||
@@ -319,11 +326,10 @@ Actions can be:
|
||||
if args.session is None:
|
||||
print("requires --session")
|
||||
return
|
||||
response_o = status_messages.json_delete("/status-msg/"+args.session)
|
||||
response_o = status_messages.json_delete("/status-msg/" + args.session)
|
||||
pprint(response_o)
|
||||
return
|
||||
|
||||
|
||||
if args.action == "run_test":
|
||||
if args.deep_clean:
|
||||
status_messages.deep_clean = True
|
||||
@@ -331,7 +337,7 @@ Actions can be:
|
||||
if not status_messages.passes():
|
||||
print(status_messages.get_fail_message())
|
||||
exit(1)
|
||||
status_messages.start(False, False)
|
||||
status_messages.start()
|
||||
status_messages.stop()
|
||||
if not status_messages.passes():
|
||||
print(status_messages.get_fail_message())
|
||||
@@ -341,5 +347,6 @@ Actions can be:
|
||||
print("Full test passed, all messages read and cleaned up")
|
||||
exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user