mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
Merge branch 'master' of github.com:greearb/lanforge-scripts
This commit is contained in:
@@ -20,17 +20,21 @@ test_rig: TR-398 test bed
|
||||
|
||||
Save this text to a file for later use: AP-Auto-ap-auto-32-64-dual.txt
|
||||
|
||||
# Save this text using the ../lf_testmod.pl script:
|
||||
# Save AP-Auto configuration text using the ../lf_testmod.pl script:
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action show --test_name AP-Auto-ap-auto-32-64-dual > test_configs/mytest.txt
|
||||
|
||||
# Save WiFi-Capacity configuration (saved as 'fb-192' using the ../lf_testmod.pl script:
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action show --test_name Wifi-Capacity-fb-192 > test_configs/mytest.txt
|
||||
|
||||
# Save Chamber View scenario:
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action show --test_name simpleThput --test_type Network-Connectivity > test_configs/myscenario.txt
|
||||
|
||||
|
||||
|
||||
# To load a test file into the LANforge server configuration:
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action set --test_name AP-Auto-ben --file test_configs/mytest.txt
|
||||
|
||||
|
||||
# Save print and scenario:
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action show --test_name simpleThput --test_type Network-Connectivity > test_configs/myscenario.txt
|
||||
|
||||
|
||||
# Load a scenario into the LANforge server configuration
|
||||
../lf_testmod.pl --mgr 192.168.100.156 --action set --test_type Network-Connectivity --test_name 64sta --file test_configs/myscenario.txt
|
||||
|
||||
@@ -246,3 +246,4 @@ then
|
||||
fi
|
||||
|
||||
echo "Done with regression test."
|
||||
echo "Results-Dir: $RSLTS_DIR"
|
||||
|
||||
@@ -150,11 +150,21 @@ if ($ttype ne "") {
|
||||
}
|
||||
else {
|
||||
# Copy some place it can be seen easily?
|
||||
print("LANforge GUI test complete, rpt-dest: $rpt_dest location: $loc\n");
|
||||
if ($rpt_dest ne "") {
|
||||
if (-d $loc) {
|
||||
# Must be on the local system
|
||||
my $cp = "cp -ar $loc $rpt_dest";
|
||||
print "Copy test results: $cp\n";
|
||||
system($cp);
|
||||
}
|
||||
else {
|
||||
# Must be on remote system, try scp to get it.
|
||||
my $cp = "scp -r lanforge\@$lfmgr_host:$loc $rpt_dest";
|
||||
print "Secure Copy test results: $cp\n";
|
||||
system($cp);
|
||||
}
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ passwd = ""
|
||||
ssid = "Test-SSID"
|
||||
security = "open"
|
||||
radio_strs = [] # Radios to modify: radio nss channel
|
||||
txpkts = 0 # 0 == Run forever
|
||||
txpkts = "0" # 0 == Run forever
|
||||
sniffer_radios = ""
|
||||
wait_sniffer = False
|
||||
|
||||
@@ -100,6 +100,7 @@ def usage():
|
||||
print("--duration: Duration to run traffic, in minutes")
|
||||
print("--ssid: AP's SSID")
|
||||
print("--passwd: Optional: password (do not add this option for OPEN)")
|
||||
print("--security: Default is 'open', or if passwd is configured, default is wpa2. wpa3 is also valid option")
|
||||
print("--txpkts: Optional: amount of packets to transmit (and then stop the data connections)")
|
||||
print("--sniffer_radios: Optional: list of radios to sniff wifi traffic \"1.wiphy2 1.wiphy4\")")
|
||||
print("--wait_sniffer: Optional: 1 means wait on sniffer to finish before existing script")
|
||||
@@ -128,6 +129,7 @@ def main():
|
||||
parser.add_argument("--duration", type=float, help="Duration to run traffic, in minutes. If txpkts is specified, that may stop the test earlier.")
|
||||
parser.add_argument("--ssid", type=str, help="AP's SSID")
|
||||
parser.add_argument("--passwd", type=str, help="AP's password if using PSK authentication, skip this argement for OPEN")
|
||||
parser.add_argument("--security", type=str, help="Default is 'open', or if passwd is configured, default is wpa2. wpa3 is also valid option")
|
||||
parser.add_argument("--txpkts", type=str, help="Optional: Packets (PDUs) to send before stopping data connections Default (0) means infinite")
|
||||
parser.add_argument("--sniffer_radios", type=str, help="Optional: list of radios to sniff wifi traffic \"1.wiphy2 1.wiphy4\"")
|
||||
parser.add_argument("--wait_sniffer", type=str, help="Optional: 1 means wait on sniffer to finish before existing script.\"")
|
||||
@@ -147,6 +149,8 @@ def main():
|
||||
if (args.passwd != None):
|
||||
passwd = args.passwd
|
||||
security = "wpa2"
|
||||
if (args.security != None):
|
||||
security = args.security
|
||||
if (args.outfile != None):
|
||||
outfile = args.outfile
|
||||
if (args.txpkts != None):
|
||||
|
||||
199
tos_plus_auto.py
199
tos_plus_auto.py
@@ -25,56 +25,178 @@ import pprint
|
||||
import telnetlib
|
||||
import argparse
|
||||
import pexpect
|
||||
import subprocess
|
||||
|
||||
ptype="QCA"
|
||||
tos="BE" #Allowed values are BE/BK/VI/VO
|
||||
|
||||
FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s'
|
||||
|
||||
def usage():
|
||||
print("$0 used connect to automated a test case using cisco controller and LANforge tos-plus script:")
|
||||
print("-p|--ptype: AP Hardware type")
|
||||
print("--tos: TOS type we are testing, used to find output in csv data: BE BK VI VO")
|
||||
print("-h|--help")
|
||||
print("-l|--log file: log messages here")
|
||||
|
||||
# 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
|
||||
|
||||
def main():
|
||||
global ptype
|
||||
|
||||
global tos
|
||||
|
||||
parser = argparse.ArgumentParser(description="TOS Plus automation script")
|
||||
parser.add_argument("-p", "--ptype", type=str, help="AP Hardware type")
|
||||
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console")
|
||||
parser.add_argument("-t", "--tos", type=str, help="TOS type we are testing, used to find output in csv data: BE BK VI VO")
|
||||
|
||||
args = None
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
if (args.ptype != None):
|
||||
ptype = args.ptype
|
||||
logfile = args.log
|
||||
|
||||
except Exception as e:
|
||||
logging.exception(e);
|
||||
usage()
|
||||
exit(2);
|
||||
|
||||
|
||||
console_handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter(FORMAT)
|
||||
logg = logging.getLogger(__name__)
|
||||
logg.setLevel(logging.DEBUG)
|
||||
file_handler = None
|
||||
if (logfile is not None):
|
||||
if (logfile != "stdout"):
|
||||
file_handler = logging.FileHandler(logfile, "w")
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(formatter)
|
||||
logg.addHandler(file_handler)
|
||||
logging.basicConfig(format=FORMAT, handlers=[file_handler])
|
||||
else:
|
||||
# stdout logging
|
||||
logging.basicConfig(format=FORMAT, handlers=[console_handler])
|
||||
|
||||
# Set up cisco controller. For now, variables are hard-coded.
|
||||
dest = 172.19.27.95
|
||||
port = 2013
|
||||
ap = AxelMain
|
||||
user = cisco
|
||||
passwd = Cisco123
|
||||
dest = '172.19.27.95'
|
||||
port = '2013'
|
||||
port_ap = '2014'
|
||||
ap = 'AxelMain'
|
||||
user = 'cisco'
|
||||
passwd = 'Cisco123'
|
||||
user_ap = 'cisco'
|
||||
passwd_ap = 'Cisco123'
|
||||
wlan = 'wlan_open'
|
||||
wlanID = '6'
|
||||
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w wlan_open -i 6 --action wlan"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w wlan_open -i 6 --action wlan_qos --value platinum"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s --action show --value \"wlan summary\""%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b b --action disable"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action disable"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action channel --value 149"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action bandwidth --value 80"%(dest, port, ap, user, passwd))
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action enable"%(dest, port, ap, user, passwd))
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-w", wlan, "-i", wlanID,
|
||||
"--action", "wlan"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-w", wlan, "-i", wlanID,
|
||||
"--action", "wlan_security"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-w", wlan, "-i", wlanID,
|
||||
"--action", "wlan_qos", "--value", "platinum"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-w", wlan, "-i", wlanID,
|
||||
"--action", "enable_wlan"], capture_output=True)
|
||||
output01 = subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "--action", "show",
|
||||
"--value", "wlan summary"], capture_output=True)
|
||||
#pss = output01.stdout.decode('utf-8', 'ignore');
|
||||
#print(pss)
|
||||
print(output01)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-b", "b", "--action",
|
||||
"disable"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-b", "a", "--action",
|
||||
"disable"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-b", "a", "--action",
|
||||
"channel", "--value", "149"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-b", "a", "--action",
|
||||
"bandwidth", "--value", "80"], capture_output=True)
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-b", "a", "--action",
|
||||
"enable"], capture_output=True)
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w %s -i %s --action wlan"%(dest, port, ap, user, passwd, wlan, wlanID))
|
||||
#subprocess.run("./cisco_wifi_ctl.py", "-d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w %s -i %s --action wlan_qos --value platinum"%(dest, port, ap, user, passwd, wlan, wlanID))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s --action show --value \"wlan summary\""%(dest, port, ap, user, passwd))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b b --action disable"%(dest, port, ap, user, passwd))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action disable"%(dest, port, ap, user, passwd))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action channel --value 149"%(dest, port, ap, user, passwd))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action bandwidth --value 80"%(dest, port, ap, user, passwd))
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -b a --action enable"%(dest, port, ap, user, passwd))
|
||||
|
||||
#Clear Stormbreaker stats on AP
|
||||
subprocess.run(["./cisco_ap.py", "-d", dest, "-o", port_ap, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "--action", "clear_counter"], capture_output=True)
|
||||
|
||||
# Run the tos plus script to generate traffic and grab capture files.
|
||||
# You may edit this command as needed for different behaviour.
|
||||
subprocess.run("./lf_tos_plus_test.py --dur 1 --lfmgr localhost --ssid 11ax-open --radio \"1.wiphy0 2 0\" --txpkts 10000 --wait_sniffer 1 --cx \"1.wiphy0 1.wlan0 anAX 1.eth2 udp 1024 10000 50000000 184\" --sniffer_radios \"1.wiphy2\"")
|
||||
os.system('python3 ./lf_tos_plus_test.py --dur 1 --lfmgr localhost --ssid wlan_open --radio "1.wiphy0 2 0" --txpkts 9999 --wait_sniffer 1 --cx "1.wiphy0 1.wlan0 anAX 1.eth2 udp 1024 10000 5000000000 184" --sniffer_radios "1.wiphy2"')
|
||||
#output02 = subprocess.run(["./lf_tos_plus_test.py", "--dur", "1", "--lfmgr", "localhost", "--ssid", wlan, "--radio", "1.wiphy0 2 0", "--txpkts", "10000",
|
||||
# "--wait_sniffer", "1", "--cx", "1.wiphy0 1.wlan0 anAX 1.eth2 udp 1024 10000 50000000 184", "--sniffer_radios", "1.wiphy2"], capture_output=True)
|
||||
|
||||
#Read Stormbreaker exported stats after the test
|
||||
output02 = subprocess.run(["./cisco_ap.py", "-d", dest, "-o", port_ap, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "--action", "show",
|
||||
"--value", "interfaces dot11Radio 1 traffic distribution periodic data exported"], capture_output=True)
|
||||
rslt = output02.stdout.decode('utf-8', 'ignore');
|
||||
|
||||
ap_at_us = -1
|
||||
ap_lat_us = -1
|
||||
in_pkg2 = False
|
||||
in_pkg3 = False
|
||||
pkg_prefix = ""
|
||||
if (tos == "BK"):
|
||||
pkg_prefix = "Background"
|
||||
elif (tos == "BE"):
|
||||
pkg_prefix = "Best"
|
||||
elif (tos == "VI"):
|
||||
pkg_prefix = "Video"
|
||||
elif (tos == "VO"):
|
||||
pkg_prefix = "Voice"
|
||||
|
||||
for line in rslt.splitlines():
|
||||
if line.startswith("Pkg 2"):
|
||||
in_pkg2 = True
|
||||
in_pkg3 = False
|
||||
elif line.startswith("Pkg 3"):
|
||||
in_pkg3 = True
|
||||
in_pkg2 = False
|
||||
else:
|
||||
toks = line.split()
|
||||
if toks[0] == "1": # Something like: 1 Background TX 11ax Good-RSSI 457013940 3683370
|
||||
us_idx = 6
|
||||
lat_idx = 4
|
||||
offset = 0
|
||||
if toks[1] == "Best":
|
||||
# Tokenization is broken due to space, work-around
|
||||
offset = 1
|
||||
|
||||
if toks[1] == pkg_prefix:
|
||||
if in_pkg2:
|
||||
if toks[2 + offset] == "TX" and toks[3 + offset] == "11ax":
|
||||
ap_at_us = int(toks[us_idx + offset])
|
||||
elif in_pkg3:
|
||||
ap_lat_us = int(toks[lat_idx + offset])
|
||||
|
||||
if ap_at_us == -1:
|
||||
print("ERROR: Could not find AP airtime, tos: %s pkg_prefix: %s"%(tos, pkg_prefix))
|
||||
exit(1)
|
||||
|
||||
if ap_lat_us == -1:
|
||||
print("ERROR: Could not find AP avg latency, tos: %s pkg_prefix: %s"%(tos, pkg_prefix))
|
||||
exit(2)
|
||||
|
||||
file1 = open('TOS_PLUS.sh', 'r')
|
||||
lines = file1.readlines()
|
||||
|
||||
|
||||
csv_file = ""
|
||||
capture_dir = ""
|
||||
# Strips the newline character
|
||||
@@ -82,27 +204,68 @@ def main():
|
||||
tok_val = line.split("=", 1)
|
||||
if tok_val[0] == "CAPTURE_DIR":
|
||||
capture_dir = tok_val[1]
|
||||
else if tok_val[0] == "CSV_FILE":
|
||||
elif tok_val[0] == "CSV_FILE":
|
||||
capture_dir = tok_val[1]
|
||||
|
||||
# Remove third-party tool's tmp file tmp file
|
||||
os.unlink("stormbreaker.log")
|
||||
|
||||
# Run third-party tool to process the capture files.
|
||||
subprocess.run("python3 sb -p %s -subdir %s"%(ptype, capture_dir))
|
||||
os.system('python3 sb -p %s -subdir %s'%(ptype, capture_dir))
|
||||
|
||||
# Print out one-way latency reported by LANforge
|
||||
file2 = open(csv_file, 'r')
|
||||
lines = file2.readlines()
|
||||
|
||||
avglat = 0 # Assumes single connection
|
||||
# Strips the newline character
|
||||
for line in lines:
|
||||
cols = line.split("\t")
|
||||
# Print out endp-name and avg latency
|
||||
print("%s\t%s"%(cols[1], cols[15]))
|
||||
if cols[1].endswith("-A"):
|
||||
avglat = cols[15]
|
||||
|
||||
# Compare pcap csv data
|
||||
file3 = open("airtime.csv", 'r')
|
||||
lines = file3.readlines()
|
||||
|
||||
at_row = []
|
||||
# Strips the newline character
|
||||
for line in lines:
|
||||
cols = line.split(",")
|
||||
if cols[0].endswith(tos):
|
||||
at_row = line.split(",")
|
||||
break
|
||||
|
||||
#at_row holds air-time fairness csv row created by pcap analyzer
|
||||
#avglat is AVG one-way download latency reported by LANforge
|
||||
#ap_at_lat is airtime in usec reported by AP for the specified type-of-service
|
||||
#ap_lat_us is latency in usec reported by AP for the specified type-of-service
|
||||
|
||||
# Check latency
|
||||
avglat *= 1000 # Convert LF latency to usec
|
||||
latdiff = abs(avglat - ap_lat_us)
|
||||
if latdiff <= 2000:
|
||||
# Assume 2ms is close enough
|
||||
print("AVG-LAT: PASSED ## Within 2ms, AP Reports: %ius Candela reports: %ius"%(ap_at_lat, avglat))
|
||||
else:
|
||||
upper = ap_lat_us * 1.2
|
||||
lower = ap_lat_us * 0.8
|
||||
|
||||
if avglat >= lower and avglat <= upper:
|
||||
print("AVG-LAT: PASSED ## Within +-20%, AP Reports: %ius LANforge reports: %ius"%(ap_at_lat, avglat))
|
||||
else:
|
||||
print("AVG-LAT: FAILED ## AP Reports: %ius LANforge reports: %ius"%(ap_at_lat, avglat))
|
||||
|
||||
# Check Airtime
|
||||
# TODO: Not sure what at_row column(s) to compare
|
||||
|
||||
|
||||
subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w wlan_open -i 6 --action delete_wlan"%(dest, port, ap, user, passwd))
|
||||
#Clear config on WLAN
|
||||
subprocess.run(["./cisco_wifi_ctl.py", "-d", dest, "-o", port, "-s", "telnet", "-l", "stdout", "-a", ap, "-u", "cisco", "-p", "Cisco123", "-w", wlan, "-i", wlanID,
|
||||
"--action", "delete_wlan"], capture_output=True)
|
||||
#subprocess.run("python3 cisco_wifi_ctl.py -d %s -o %s -s telnet -l stdout -a %s -u %s -p %s -w wlan_open -i 6 --action delete_wlan"%(dest, port, ap, user, passwd))
|
||||
|
||||
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user