mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
lf_check.py : run individual tests lf_check_config.ini used for lf_check.py
Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# NAME : config.ini
|
||||
#
|
||||
# PURPOSE : Configuration (config.ini) information for running lf_check.py
|
||||
#
|
||||
|
||||
|
||||
[AP_CONFIG]
|
||||
SSID = "jedway-wpa2-x2048-5-3"
|
||||
PASSWD ="jedway-wpa2-x2048-5-3"
|
||||
SECURITY= "wpa2"
|
||||
|
||||
[RADIO_CFG]
|
||||
RADIO_USED = "wiphy0"
|
||||
|
||||
[NUM_STATION]
|
||||
STATIONS = "4"
|
||||
|
||||
[TEST_IP]
|
||||
HTTP_TEST_IP = "10.40.0.1"
|
||||
FTP_TEST_IP = "10.40.0.1"
|
||||
|
||||
[LF_GUI]
|
||||
LF_MG= localhost
|
||||
LF_MGR_PORT=8080
|
||||
|
||||
[REPORTS]
|
||||
REPORT_DIR="/home/lanforge/html-reports"
|
||||
REPORT_DATA="/home/lanforge/report-data"
|
||||
|
||||
[TESTS_LIST_COMPLETE]
|
||||
test_list_complete: {
|
||||
"1":["example_security_connection"],
|
||||
"2":["test_ipv4_connection"],
|
||||
"3":["test_generic"],
|
||||
"4":["test_ipv4_l4_urls_per_ten"],
|
||||
"5":["test_ipv4_l4_wifi"],
|
||||
"6":["test_ipv4_l4"],
|
||||
"7":["test_ipv4_variable_time"],
|
||||
"8":["create_bridge"],
|
||||
"9":["create_l3"],
|
||||
"10":["create_l4"],
|
||||
"11":["create_macvlan"],
|
||||
"12":["create_station"],
|
||||
"13":["create_vap"],
|
||||
"14":["cpu_stats"],
|
||||
"15":["test_fileio"],
|
||||
"16":["testgroup"],
|
||||
"17":["test_ipv6_connection"],
|
||||
"18":["test_ipv6_variable_time"],
|
||||
"19":["test_l3_longevity"],
|
||||
"20":["test_l3_powersave_traffic"],
|
||||
"21":["test_l3_scenario_throughput"],
|
||||
"22":["test_status_msg"],
|
||||
"23":["test_wanlink"],
|
||||
"24":["wlan_theoretical_sta"],
|
||||
"25":["ws_generic_monitor_test"],
|
||||
"26":["sta_connect2"],
|
||||
"27":["wlan_capacity_calculator"],
|
||||
"28":["test_generic"],
|
||||
"29":["new_script"],
|
||||
"30":["sta_connect_example"]}
|
||||
|
||||
61
py-scripts/sandbox/lf_check_config.ini
Normal file
61
py-scripts/sandbox/lf_check_config.ini
Normal file
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# NAME : config.ini
|
||||
#
|
||||
# PURPOSE : Configuration (config.ini) information for running lf_check.py
|
||||
#
|
||||
|
||||
# radio configuraiton used below for test arguments
|
||||
[RADIO_DICTIONARY]
|
||||
RADIO_DICT: {
|
||||
"RADIO_0_CFG":{"KEY":"RADIO_0_CFG","RADIO":"wiphy0","STATIONS":"4","SSID":"jedway-wpa2-x2048-5-3","PASSWD":"jedway-wpa2-x2048-5-3","SECURITY":"wpa2"},
|
||||
"RADIO_1_CFG":{"KEY":"RADIO_1_CFG","RADIO":"wiphy1","STATIONS":"4","SSID":"jedway-wpa2-x2048-4-1","PASSWD":"jedway-wpa2-x2048-4-1","SECURITY":"wpa2"}
|
||||
}
|
||||
|
||||
[TEST_IP]
|
||||
HTTP_TEST_IP = "10.40.0.1"
|
||||
FTP_TEST_IP = "10.40.0.1"
|
||||
|
||||
[LF_GUI]
|
||||
LF_MG= localhost
|
||||
LF_MGR_PORT=8080
|
||||
|
||||
[REPORTS]
|
||||
REPORT_DIR="/home/lanforge/html-reports"
|
||||
REPORT_DATA="/home/lanforge/report-data"
|
||||
|
||||
[TEST_DICTIONARY]
|
||||
TEST_DICT: {
|
||||
"example_security_connection":{"enabled":"FALSE","command":"example_security_connection.py","args":""},
|
||||
"test_ipv4_connection":{"enabled":"FALSE","command":"test_generic.py","args":""},
|
||||
"test_generic":{"enabled":"FALSE","command":"test_generic.py","args":""},
|
||||
"test_ipv4_l4_urls_per_ten":{"enabled":"FALSE","command":"test_ipv4_l4_urls_per_ten.py","args":""},
|
||||
"test_ipv4_l4_wifi":{"enabled":"FALSE","command":"test_ipv4_l4_wifi.py","args":""},
|
||||
"test_ipv4_l4":{"enabled":"FALSE","command":"test_ipv4_l4.py","args":""},
|
||||
"test_ipv4_variable_time":{"enabled":"FALSE","command":"test_ipv4_variable_time.py","args":""},
|
||||
"create_bridge":{"enabled":"FALSE","command":"create_bridge.py","args":""},
|
||||
# replace RADIO_0 with args from above,
|
||||
# "create_l3":{"enabled":"TRUE","command":"create_l3.py","args":" --radio RADIO_0 --ssid RADIO_0_SSID --passwd RADIO_0 --security RADIO_0 --debug"},
|
||||
"create_l3":{"enabled":"TRUE","command":"create_l3.py","args":"RADIO_0_CFG --debug"},
|
||||
"create_l4":{"enabled":"TRUE","command":"create_l4.py","args":"RADIO_1_CFG --debug"},
|
||||
"create_macvlan":{"enabled":"FALSE","command":"create_macvlan.py","args":""},
|
||||
"create_station":{"enabled":"FALSE","command":"create_station.py","args":""},
|
||||
"create_vap":{"enabled":"FALSE","command":"create_vap.py","args":""},
|
||||
"cpu_stats":{"enabled":"FALSE","command":"cpu_stats.py","args":""},
|
||||
"test_fileio":{"enabled":"FALSE","command":"test_fileio.py","args":""},
|
||||
"testgroup":{"enabled":"FALSE","command":"testgroup.py","args":""},
|
||||
"test_ipv6_connection":{"enabled":"FALSE","command":"test_ipv6_connection.py","args":""},
|
||||
"test_ipv6_variable_time":{"enabled":"FALSE","command":"test_ipv6_variable_time.py","args":""},
|
||||
"test_l3_longevity":{"enabled":"FALSE","command":"test_l3_longevity.py","args":""},
|
||||
"test_l3_powersave_traffic":{"enabled":"FALSE","command":"test_l3_powersave_traffic.py","args":""},
|
||||
"test_l3_scenario_throughput":{"enabled":"FALSE","command":"test_l3_scenario_throughput.py","args":""},
|
||||
"test_status_msg":{"enabled":"FALSE","command":"test_status_msg.py","args":""},
|
||||
"test_wanlink":{"enabled":"FALSE","command":"test_wanlink.py","args":""},
|
||||
"wlan_theoretical_sta":{"enabled":"FALSE","command":"wlan_theoretical_sta.py","args":""},
|
||||
"ws_generic_monitor_test":{"enabled":"FALSE","command":"ws_generic_monitor_test.py","args":""},
|
||||
"sta_connect2":{"enabled":"FALSE","command":"sta_connect2.py","args":""},
|
||||
"wlan_capacity_calculator":{"enabled":"FALSE","command":"wlan_capacity_calculator.py","args":""},
|
||||
"test_generic":{"enabled":"FALSE","command":"test_generic.py","args":""},
|
||||
"new_script":{"enabled":"FALSE","command":"new_script.py","args":""},
|
||||
"sta_connect_example":{"enabled":"FALSE","command":"sta_connect_example.py","args":""},
|
||||
"create_vr.py":{"enabled":"TRUE","command":"create_vr.py","args":"--vr_name 2.vr0 --ports 2.br0,2.vap2 --services"}
|
||||
}
|
||||
@@ -5,9 +5,10 @@ NAME:
|
||||
lf_check.py
|
||||
|
||||
PURPOSE:
|
||||
Script is used to run a series of tests to verifiy realm changes.
|
||||
Configuration for lf_check.py , runs various tests
|
||||
|
||||
EXAMPLE:
|
||||
lf_check.py
|
||||
|
||||
NOTES:
|
||||
|
||||
@@ -23,16 +24,14 @@ import logging
|
||||
import time
|
||||
from time import sleep
|
||||
import argparse
|
||||
import pexpect
|
||||
import serial
|
||||
from pexpect_serial import SerialSpawn
|
||||
import json
|
||||
from json import load
|
||||
import configparser
|
||||
from pprint import *
|
||||
|
||||
|
||||
CONFIG_FILE = os.getcwd() + '/py-scripts/sandbox/config.ini'
|
||||
CONFIG_FILE = os.getcwd() + '/py-scripts/sandbox/lf_check_config.ini'
|
||||
RUN_CONDITION = 'ENABLE'
|
||||
|
||||
# see https://stackoverflow.com/a/13306095/11014343
|
||||
class FileAdapter(object):
|
||||
@@ -49,135 +48,51 @@ class FileAdapter(object):
|
||||
|
||||
class lf_check():
|
||||
def __init__(self):
|
||||
self.ssid =""
|
||||
self.passwd =""
|
||||
self.security =""
|
||||
self.radio_dict = {}
|
||||
self.test_dict = {}
|
||||
|
||||
# Functions in this section are/can be overridden by descendants
|
||||
def readConfigContents(self):
|
||||
def read_config_contents(self):
|
||||
config_file = configparser.ConfigParser()
|
||||
success = True
|
||||
success = config_file.read(CONFIG_FILE)
|
||||
print("{}".format(success))
|
||||
print("{}".format(config_file))
|
||||
|
||||
if 'AP_CONFIG' in config_file.sections():
|
||||
config_instance = config_file['AP_CONFIG']
|
||||
try:
|
||||
self.ssid = config_instance.get('SSID')
|
||||
self.passwd = config_instance.get('PASSWD')
|
||||
self.security = config_instance.get('SECURITY')
|
||||
# NOTE: this may need to be a list for ssi
|
||||
if 'RADIO_DICTIONARY' in config_file.sections():
|
||||
section = config_file['RADIO_DICTIONARY']
|
||||
self.radio_dict = json.loads(section.get('RADIO_DICT', self.radio_dict))
|
||||
|
||||
print("AP_CONFIG retrieved")
|
||||
print("ssid {}".format(self.ssid))
|
||||
print("passwd {}".format(self.passwd))
|
||||
print("security {}".format(self.security))
|
||||
except:
|
||||
print("no test list")
|
||||
if 'TEST_DICTIONARY' in config_file.sections():
|
||||
section = config_file['TEST_DICTIONARY']
|
||||
self.test_dict = json.loads(section.get('TEST_DICT', self.test_dict))
|
||||
#print("test_dict {}".format(self.test_dict))
|
||||
|
||||
def run_script_test(self):
|
||||
for test in self.test_dict:
|
||||
if self.test_dict[test]['enabled'] == "TRUE":
|
||||
# print("test: {} enable: {} command: {} args: {}".format(self.test_dict[test],self.test_dict[test]['enabled'],self.test_dict[test]['command'],self.test_dict[test]['args']))
|
||||
|
||||
def read_ap_stats(self):
|
||||
# 5ghz: wl -i wl1 bs_data 2.4ghz# wl -i wl0 bs_data
|
||||
stats_5ghz = "wl -i wl1 bs_data"
|
||||
stats_24ghz = "w1 -i wl0 bs_data"
|
||||
ap_data = ""
|
||||
ap_stats = []
|
||||
command = stats_5ghz
|
||||
'''if band == "5ghz":
|
||||
command = stats_5ghz
|
||||
else:
|
||||
command = stats_24ghz'''
|
||||
|
||||
#try:
|
||||
# configure the serial interface
|
||||
ser = serial.Serial("/dev/ttyUSB0", int(115200), timeout=5)
|
||||
egg = SerialSpawn(ser)
|
||||
egg.sendline(str(command))
|
||||
egg.expect([pexpect.TIMEOUT], timeout=2) # do not detete line, waits for output
|
||||
ap_data = egg.before.decode('utf-8','ignore')
|
||||
#except:
|
||||
# print("WARNING unable to read AP")
|
||||
|
||||
'''ap_stats = "\
|
||||
\
|
||||
" '''
|
||||
ap_stats.append("root@Docsis-Gateway:~# wl -i wl1 bs_data")
|
||||
ap_stats.append("Station Address PHY Mbps Data Mbps Air Use Data Use Retries bw mcs Nss ofdma mu-mimo")
|
||||
ap_stats.append("50:E0:85:87:AA:19 1016.6 48.9 6.5% 24.4% 16.6% 80 9.7 2 0.0% 0.0%")
|
||||
ap_stats.append("50:E0:85:84:7A:E7 880.9 52.2 7.7% 26.1% 20.0% 80 8.5 2 0.0% 0.0%")
|
||||
ap_stats.append("50:E0:85:89:5D:00 840.0 47.6 6.4% 23.8% 2.3% 80 8.0 2 0.0% 0.0%")
|
||||
ap_stats.append("50:E0:85:87:5B:F4 960.7 51.5 5.9% 25.7% 0.0% 80 9 2 0.0% 0.0%")
|
||||
ap_stats.append("(overall) - 200.2 26.5% - -")
|
||||
# TODO: Read real stats, comment out the example above.
|
||||
|
||||
|
||||
return ap_stats
|
||||
|
||||
'''root@Docsis-Gateway:~# wl -i wl1 bs_data
|
||||
Station Address PHY Mbps Data Mbps Air Use Data Use Retries bw mcs Nss ofdma mu-mimo
|
||||
50:E0:85:87:AA:19 1064.5 52.8 6.0% 25.0% 1.5% 80 10.0 2 0.0% 0.0%
|
||||
50:E0:85:84:7A:E7 927.1 53.6 7.0% 25.4% 5.7% 80 8.8 2 0.0% 0.0%
|
||||
50:E0:85:89:5D:00 857.5 51.8 6.8% 24.6% 0.8% 80 8 2 0.0% 0.0%
|
||||
50:E0:85:87:5B:F4 1071.7 52.8 6.0% 25.0% 1.3% 80 10 2 0.0% 0.0%
|
||||
(overall) - 210.9 25.8% - -'''
|
||||
|
||||
'''I have some un-tested code that is starting point for querying Comcast AP in the l3_longevity script.
|
||||
When still needs doing: query the data from the AP, and test that my parsing and CSV logic is working,
|
||||
also add cmd-line arg to enable this or not. Would you have time to work on this and coordinate test time on
|
||||
customer's system to test against their AP? Access to AP is probably ssh, possibly serial or telnet.
|
||||
Firas @ Comcast can help clarify that.'''
|
||||
|
||||
def parse_ap_stats(self):
|
||||
# Query AP for its stats. Result for /ax bcm APs looks something like this:
|
||||
ap_stats = self.read_ap_stats()
|
||||
ap_stats_rows = [] # Array of Arrays
|
||||
|
||||
for line in ap_stats:
|
||||
stats_row = line.split()
|
||||
ap_stats_rows.append(stats_row)
|
||||
# - is this needed ?m = re.search((r'(\S+)\s+(\S+)\s+(Data Mbps)\s+(Air Use)+'ap_stats[0]
|
||||
|
||||
# Query all of our ports
|
||||
#port_eids = self.gather_port_eids()
|
||||
#for eid_name in port_eids:
|
||||
# eid = self.name_to_eid(eid_name)
|
||||
# url = "/port/%s/%s/%s"%(eid[0], eid[1], eid[2])
|
||||
# response = self.json_get(url)
|
||||
# if (response is None) or ("interface" not in response):
|
||||
# print("query-port: %s: incomplete response:"%(url))
|
||||
# pprint(response)
|
||||
# else:
|
||||
# note changed the indent
|
||||
#p = response['interface']
|
||||
|
||||
mac = ["50:E0:85:87:AA:19","50:E0:85:84:7A:E7","50:E0:85:89:5D:00","50:E0:85:87:5B:F4"]
|
||||
#mac = "50:E0:85:87:AA:19"
|
||||
#mac = "50:E0:85:84:7A:E7"
|
||||
#mac = "50:E0:85:89:5D:00"
|
||||
#mac = "50:E0:85:87:5B:F4"
|
||||
|
||||
ap_row = []
|
||||
i = 0
|
||||
for row in ap_stats_rows:
|
||||
if row[0] in mac:
|
||||
#if row[0].lower == mac.lower():
|
||||
ap_row = row
|
||||
print("ap_row: {}".format(ap_row))
|
||||
|
||||
# p is map of key/values for this port
|
||||
#print("ap_row : {}".format(ap_row))
|
||||
#pprint(ap_row)
|
||||
# Find latency, jitter for connections using this port.
|
||||
#latency, jitter, tput = self.get_endp_stats_for_port(p["port"], endps)
|
||||
|
||||
# ap_stats_col_titles = ['Station Address','PHY Mbps','Data Mbps','Air Use','Data Use','Retries','bw','mcs','Nss','ofdma','mu-mimo'
|
||||
# self.write_port_csv(len(temp_stations_list), ul, dl, ul_pdu_str, dl_pdu_str, atten_val, eid_name, p,
|
||||
# latency, jitter, tput, ap_row, ap_stats_col_titles
|
||||
# Note: do not replace with a lambda function or (k), v for k, v in ... ,
|
||||
# loop through radios
|
||||
for radio in self.radio_dict:
|
||||
# Replace RADIO, SSID, PASSWD, SECURITY with actual config values (e.g. RADIO_0_CFG to values)
|
||||
if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.radio_dict[radio]["KEY"],'--radio {} --ssid {} --passwd {} --security {}'
|
||||
.format(self.radio_dict[radio]['RADIO'],self.radio_dict[radio]['SSID'],self.radio_dict[radio]['PASSWD'],self.radio_dict[radio]['SECURITY']))
|
||||
|
||||
|
||||
#print("test: {} enable: {} command: {} args: {}".format(self.test_dict[test],self.test_dict[test]['enabled'],self.test_dict[test]['command'],self.test_dict[test]['args']))
|
||||
#print("enable: {} command: {} args: {}".format(self.test_dict[test]['enabled'],self.test_dict[test]['command'],self.test_dict[test]['args']))
|
||||
command = "./{} {}".format(self.test_dict[test]['command'],self.test_dict[test]['args'])
|
||||
print("command: {}".format(command))
|
||||
def main():
|
||||
check = lf_check()
|
||||
#check.parse_ap_stats()
|
||||
check.readConfigContents()
|
||||
check.read_config_contents() # CMR need mode to just print out the test config and not run
|
||||
|
||||
check.run_script_test()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user