Merge branch 'master' of github.com:greearb/lanforge-scripts

This commit is contained in:
Ben Greear
2020-12-10 12:06:03 -08:00
42 changed files with 3554 additions and 1560 deletions

View File

@@ -57,7 +57,11 @@ if (-f "$fname") {
open(FILE, ">$fname") or die "Couldn't open file: $fname for writing: $!\n\n"; open(FILE, ">$fname") or die "Couldn't open file: $fname for writing: $!\n\n";
my $foundit = 0; my $foundit = 0;
my $i; my $i;
chomp(@lines); # chomp is way to simplistic if we need to weed out \r\n characters as well
#chomp(@lines);
for( my $i=0; $i < @lines; $i++) {
($lines[$i]) = $lines[$i] =~ /^([^\r\n]+)\r?\n$/;
}
# we want to consolidate the $ip $hostname entry for MgrHostname # we want to consolidate the $ip $hostname entry for MgrHostname
my @newlines = (); my @newlines = ();
my %more_hostnames = (); my %more_hostnames = ();
@@ -65,7 +69,10 @@ if (-f "$fname") {
#my $blank = 0; #my $blank = 0;
#my $was_blank = 0; #my $was_blank = 0;
my $counter = 0; my $counter = 0;
my $debug = 1; my $debug = 0;
if ((exists $ENV{"DEBUG"}) && ($ENV{"DEBUG"} eq "1")) {
$debug = 1;
}
my %host_map = ( my %host_map = (
"localhost.localdomain" => "127.0.0.1", "localhost.localdomain" => "127.0.0.1",
"localhost" => "127.0.0.1", "localhost" => "127.0.0.1",
@@ -79,6 +86,8 @@ if (-f "$fname") {
"lanforge.localnet" => "192.168.1.101", "lanforge.localnet" => "192.168.1.101",
"lanforge.localdomain" => "192.168.1.101", "lanforge.localdomain" => "192.168.1.101",
); );
my %comment_map = ();
my %address_marker_map = ();
my %address_map = ( my %address_map = (
"127.0.0.1" => "localhost.localdomain localhost localhost4.localdomain4 localhost4", "127.0.0.1" => "localhost.localdomain localhost localhost4.localdomain4 localhost4",
"::1" => "localhost.localdomain localhost localhost6.loaldomain6 localhost6", "::1" => "localhost.localdomain localhost localhost6.loaldomain6 localhost6",
@@ -94,17 +103,27 @@ if (-f "$fname") {
my $previp = ""; my $previp = "";
for my $ln (@lines) { for my $ln (@lines) {
next if (!(defined $ln));
print "\nLN[$ln]\n" if ($debug); print "\nLN[$ln]\n" if ($debug);
next if ($ln =~ /^\s*$/); next if ($ln =~ /^\s*$/);
next if ($ln =~ /^\s*#/);
next if ($ln =~ /^###-LF-HOSTAME-NEXT-###/); # old typo next if ($ln =~ /^###-LF-HOSTAME-NEXT-###/); # old typo
next if ($ln =~ /^###-LF-HOSTNAME-NEXT-###/); next if ($ln =~ /^###-LF-HOSTNAME-NEXT-###/);
my $comment = undef;
print "PARSING IPv4 ln[$ln]\n" if ($debug); print "PARSING IPv4 ln[$ln]\n" if ($debug);
if ($ln =~ /#/) {
($comment) = $ln =~ /^[^#]+(#.*)$/;
($ln) = $ln =~ /^([^#]+)\s*#/;
print "line with comment becomes [$ln]\n" if ($debug);
}
@hunks = split(/\s+/, $ln); @hunks = split(/\s+/, $ln);
my $middleip = 0; my $middleip = 0;
my $counter2 = -1; my $counter2 = -1;
my $linehasip = 0; my $linehasip = 0;
my $lfhostname = 0; my $lfhostname = 0;
if ((defined $comment) && ($comment ne "")) {
$comment_map{$hunks[0]} = $comment;
}
for my $hunk (@hunks) { for my $hunk (@hunks) {
print "\n HUNK",$counter2,"-:$hunk:- " if ($debug); print "\n HUNK",$counter2,"-:$hunk:- " if ($debug);
$counter2++; $counter2++;
@@ -207,6 +226,7 @@ if (-f "$fname") {
print "NEWSTUFF $ip $address_map{$ip}\n" if ($debug); print "NEWSTUFF $ip $address_map{$ip}\n" if ($debug);
} }
# this might be premature
unshift(@newlines, "192.168.1.101 ".$address_map{"192.168.1.101"}); unshift(@newlines, "192.168.1.101 ".$address_map{"192.168.1.101"});
unshift(@newlines, "127.0.0.1 ".$address_map{"127.0.0.1"}); unshift(@newlines, "127.0.0.1 ".$address_map{"127.0.0.1"});
unshift(@newlines, "::1 ".$address_map{"::1"}); unshift(@newlines, "::1 ".$address_map{"::1"});
@@ -215,29 +235,74 @@ if (-f "$fname") {
delete($address_map{"127.0.0.1"}); delete($address_map{"127.0.0.1"});
delete($address_map{"::1"}); delete($address_map{"::1"});
print Dumper(\%address_map) if ($debug); if ($debug) {
print Dumper(\%host_map) if ($debug); print "# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n";
print "\nAddress map\n";
for my $key (sort keys %address_map){ print Dumper(\%address_map);
next if ($key eq $ip); print "\nHost map\n";
if ($address_map{$key} =~ /\s*$MgrHostname\s*/) { print Dumper(\%host_map);
print("SKIPPING $key / $address_map{$key}\n") print "# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n";
if ($debug); sleep 2;
}
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
# we want to maintain the original line ordering as faithfully as possible
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
for my $ln (@lines) {
$ln = "" if (!(defined $ln));
print "OLD[$ln]\n" if ($debug);
# if we are comments or blank lines, preserve them
if (($ln =~ /^\s*$/) || ($ln =~ /^\s*#/)) {
push(@newlines, $ln);
next; next;
} }
push(@newlines, $key." ".$address_map{$key}); @hunks = split(/\s+/, $ln);
if (exists $address_map{$hunks[0]}) {
if (exists $address_marker_map{$hunks[0]}) {
print "already printed $hunks[0]\n" if ($debug);
next;
} }
my $comment = "";
if (exists $comment_map{$hunks[0]}) {
$comment = " $comment_map{$hunks[0]}";
}
push(@newlines, "$hunks[0] $address_map{$hunks[0]}$comment");
$address_marker_map{$hunks[0]} = 1;
next;
}
else {
die("unknown IP $hunks[0]");
}
}
if ($debug) {
print "# ----- NEW ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n";
for my $ln (@newlines) {
print "$ln\n";
}
}
#for my $key (sort keys %address_map){
# next if ($key eq $ip);
# if ($address_map{$key} =~ /\s*$MgrHostname\s*/) {
# print("SKIPPING $key / $address_map{$key}\n")
# if ($debug);
# next;
# }
# push(@newlines, $key." ".$address_map{$key});
#}
push(@newlines, "###-LF-HOSTNAME-NEXT-###"); push(@newlines, "###-LF-HOSTNAME-NEXT-###");
push(@newlines, $ip." ".$address_map{$ip}); push(@newlines, $ip." ".$address_map{$ip});
print Dumper(\@newlines) if ($debug); if ($debug) {
sleep 5 if ($debug); print Dumper(\@newlines);
sleep 5;
}
for my $ln (@newlines) { for my $ln (@newlines) {
print FILE "$ln\n"; print FILE "$ln\n";
} }
print FILE "\n"; print FILE "\n";
close FILE; close FILE;
} } # ~if found file
my $local_crt =""; my $local_crt ="";
my $local_key =""; my $local_key ="";

61
check_large_files.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
set -x
set -e
eyedee=`id -u`
if (( eyedee != 0 )); then
echo "Please become root to use this script"
exit 1
fi
# Find core files
core_files=()
cd /
while read F; do
core_files+=("$F")
done < <(ls /core* /home/lanforge/core* 2>/dev/null)
# Find ath10k crash residue
ath10_files=()
while read F; do
ath10_files+=("$F")
done < <(ls /home/lanforge/ath10* 2>/dev/null)
# Find size of /mnt/lf that is not mounted
cd /mnt
usage_mnt=`du -shxc .`
# Find size of /lib/modules
cd /lib/modules
usage_libmod=`du -sh *`
# Find how many kernels are installed
cd /boot
boot_kernels=(`ls init*`)
boot_usage=`du -sh .`
HR="---------------------------------------"
# #
# report sizes here #
# #
if (( ${#core_files[@]} > 0 )); then
echo "Core Files:"
echo "$HR"
printf '%s\n' "${core_files[@]}"
echo "$HR"
fi
echo "Usage of /mnt: $usage_mnt"
echo "Usage of /lib/modules: $usage_libmod"
echo "Boot usage: $boot_usage"
if (( ${#boot_kernels[@]} > 4 )); then
echo "Boot ramdisks:"
echo "$HR"
printf '%s\n' "${boot_kernels[@]}"
echo "$HR"
fi
# delete extra things now #
# remove

View File

@@ -78,7 +78,7 @@ def main():
parser.add_argument("-t", "--tty", type=str, help="tty serial device") parser.add_argument("-t", "--tty", type=str, help="tty serial device")
parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console") parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console")
parser.add_argument("--action", type=str, help="perform action", parser.add_argument("--action", type=str, help="perform action",
choices=["logread", "journalctl", "lurk", "sysupgrade", "download", "upload", "reboot", "cmd" ]) choices=["logread", "journalctl", "lurk", "sysupgrade", "sysupgrade-n", "download", "upload", "reboot", "cmd" ])
parser.add_argument("--value", type=str, help="set value") parser.add_argument("--value", type=str, help="set value")
parser.add_argument("--value2", type=str, help="set value2") parser.add_argument("--value2", type=str, help="set value2")
tty = None tty = None
@@ -134,6 +134,9 @@ def main():
egg.sendline(NL) egg.sendline(NL)
try: try:
i = egg.expect([prompt, "Please press Enter to activate", "login:"], timeout=3) i = egg.expect([prompt, "Please press Enter to activate", "login:"], timeout=3)
if (i == 1):
egg.setdline(NL)
i = egg.expect([prompt, "Please press Enter to activate", "login:"], timeout=3)
if (i == 2): if (i == 2):
egg.sendline(user) egg.sendline(user)
egg.expect("Password:") egg.expect("Password:")
@@ -228,7 +231,7 @@ def main():
TO=1 TO=1
wait_forever = True wait_forever = True
if (args.action == "sysupgrade"): if ((args.action == "sysupgrade") or (args.action == "sysupgrade-n")):
command = "scp %s /tmp/new_img.bin"%(args.value) command = "scp %s /tmp/new_img.bin"%(args.value)
logg.info("Command[%s]"%command) logg.info("Command[%s]"%command)
egg.sendline(command); egg.sendline(command);
@@ -239,6 +242,9 @@ def main():
egg.expect("password:", timeout=5) egg.expect("password:", timeout=5)
egg.sendline("lanforge") egg.sendline("lanforge")
egg.expect(CCPROMPT, timeout=20) egg.expect(CCPROMPT, timeout=20)
if (args.action == "sysupgrade-n"):
egg.sendline("sysupgrade -n /tmp/new_img.bin")
else:
egg.sendline("sysupgrade /tmp/new_img.bin") egg.sendline("sysupgrade /tmp/new_img.bin")
egg.expect("link becomes ready", timeout=100) egg.expect("link becomes ready", timeout=100)
return return

View File

@@ -36,13 +36,23 @@ class LFRequest:
else: else:
self.requested_url = url self.requested_url = url
if self.requested_url is None:
raise Exception("Bad LFRequest of url[%s] uri[%s] -> None" % url, uri)
if self.requested_url.find('//'): if self.requested_url.find('//'):
protopos = self.requested_url.find("://") protopos = self.requested_url.find("://")
self.requested_url = self.requested_url[:protopos + 2] + self.requested_url[protopos + 2:].replace("//", "/") self.requested_url = self.requested_url[:protopos + 2] + self.requested_url[protopos + 2:].replace("//", "/")
# finding '#' prolly indicates a macvlan (eth1#0)
# finding ' ' prolly indicates a field name that should imply %20
if (self.requested_url.find('#') >= 1):
self.requested_url = self.requested_url.replace('#', '%23')
if (self.requested_url.find(' ') >= 1):
self.requested_url = self.requested_url.replace(' ', '+')
if self.debug: if self.debug:
print("new LFRequest[%s]" % self.requested_url ) print("new LFRequest[%s]" % self.requested_url )
if self.requested_url is None:
raise Exception("Bad LFRequest of url[%s] uri[%s] -> None" % url, uri)
# request first url on stack # request first url on stack
def formPost(self, show_error=True, debug=False, die_on_error_=False): def formPost(self, show_error=True, debug=False, die_on_error_=False):
@@ -105,7 +115,7 @@ class LFRequest:
def jsonPost(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None): def jsonPost(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None):
return self.json_post(show_error=show_error, debug=debug, die_on_error_=die_on_error_, response_json_list_=response_json_list_) return self.json_post(show_error=show_error, debug=debug, die_on_error_=die_on_error_, response_json_list_=response_json_list_)
def json_post(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None): def json_post(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None, method_='POST'):
if (debug == False) and (self.debug == True): if (debug == False) and (self.debug == True):
debug = True debug = True
if self.die_on_error: if self.die_on_error:
@@ -113,6 +123,7 @@ class LFRequest:
responses = [] responses = []
if ((self.post_data != None) and (self.post_data is not self.No_Data)): if ((self.post_data != None) and (self.post_data is not self.No_Data)):
request = urllib.request.Request(url=self.requested_url, request = urllib.request.Request(url=self.requested_url,
method=method_,
data=json.dumps(self.post_data).encode("utf-8"), data=json.dumps(self.post_data).encode("utf-8"),
headers=self.default_headers) headers=self.default_headers)
else: else:
@@ -124,7 +135,7 @@ class LFRequest:
resp = urllib.request.urlopen(request) resp = urllib.request.urlopen(request)
resp_data = resp.read().decode('utf-8') resp_data = resp.read().decode('utf-8')
if (debug): if (debug):
print("----- LFRequest::jsonPost:118 debug: --------------------------------------------") print("----- LFRequest::json_post:128 debug: --------------------------------------------")
print("URL: %s :%d "% (self.requested_url, resp.status)) print("URL: %s :%d "% (self.requested_url, resp.status))
LFUtils.debug_printer.pprint(resp.getheaders()) LFUtils.debug_printer.pprint(resp.getheaders())
print("----- resp_data -------------------------------------------------") print("----- resp_data -------------------------------------------------")
@@ -136,15 +147,15 @@ class LFRequest:
raise ValueError("reponse_json_list_ needs to be type list") raise ValueError("reponse_json_list_ needs to be type list")
j = json.loads(resp_data) j = json.loads(resp_data)
if debug: if debug:
print("----- LFRequest::jsonPost:129 debug: --------------------------------------------") print("----- LFRequest::json_post:140 debug: --------------------------------------------")
LFUtils.debug_printer.pprint(j) LFUtils.debug_printer.pprint(j)
print("-------------------------------------------------") print("-------------------------------------------------")
response_json_list_.append(j) response_json_list_.append(j)
return responses[0] return responses[0]
except urllib.error.HTTPError as error: except urllib.error.HTTPError as error:
if show_error or die_on_error_ or (error.code != 404): if show_error or die_on_error_ or (error.code != 404):
print("----- LFRequest::jsonPost:138 HTTPError: --------------------------------------------") print("----- LFRequest::json_post:147 HTTPError: --------------------------------------------")
print("<%s> HTTP %s: %s"%(request.get_full_url(), error.code, error.reason, )) print("<%s> HTTP %s: %s" % (request.get_full_url(), error.code, error.reason ))
print("Error: ", sys.exc_info()[0]) print("Error: ", sys.exc_info()[0])
print("Request URL:", request.get_full_url()) print("Request URL:", request.get_full_url())
@@ -167,21 +178,35 @@ class LFRequest:
exit(1) exit(1)
except urllib.error.URLError as uerror: except urllib.error.URLError as uerror:
if show_error: if show_error:
print("----- LFRequest::jsonPost:162 URLError: ---------------------------------------------") print("----- LFRequest::json_post:171 URLError: ---------------------------------------------")
print("Reason: %s; URL: %s"%(uerror.reason, request.get_full_url())) print("Reason: %s; URL: %s"%(uerror.reason, request.get_full_url()))
print("------------------------------------------------------------------------") print("------------------------------------------------------------------------")
if (die_on_error_ == True) or (self.die_on_error == True): if (die_on_error_ == True) or (self.die_on_error == True):
exit(1) exit(1)
return None return None
def get(self, debug=False, die_on_error_=False): def json_put(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None):
return self.json_post(show_error=show_error,
debug=debug,
die_on_error_=die_on_error_,
response_json_list_=response_json_list_,
method_='PUT')
def json_delete(self, show_error=True, debug=False, die_on_error_=False, response_json_list_=None):
return self.get_as_json(debug_=debug,
die_on_error_=die_on_error_,
method_='DELETE')
def get(self, debug=False, die_on_error_=False, method_='GET'):
if self.debug == True: if self.debug == True:
debug = True debug = True
if self.die_on_error == True: if self.die_on_error == True:
die_on_error_ = True die_on_error_ = True
if debug: if debug:
print("LFUtils.get: url: "+self.requested_url) print("LFUtils.get: url: "+self.requested_url)
myrequest = urllib.request.Request(url=self.requested_url, headers=self.default_headers) myrequest = urllib.request.Request(url=self.requested_url,
headers=self.default_headers,
method=method_)
myresponses = [] myresponses = []
try: try:
myresponses.append(urllib.request.urlopen(myrequest)) myresponses.append(urllib.request.urlopen(myrequest))
@@ -223,9 +248,9 @@ class LFRequest:
def getAsJson(self, die_on_error_=False, debug_=False): def getAsJson(self, die_on_error_=False, debug_=False):
return self.get_as_json(die_on_error_=die_on_error_, debug_=debug_) return self.get_as_json(die_on_error_=die_on_error_, debug_=debug_)
def get_as_json(self, die_on_error_=False, debug_=False): def get_as_json(self, die_on_error_=False, debug_=False, method_='GET'):
responses = [] responses = []
j = self.get(debug=debug_, die_on_error_=die_on_error_) j = self.get(debug=debug_, die_on_error_=die_on_error_, method_=method_)
responses.append(j) responses.append(j)
if len(responses) < 1: if len(responses) < 1:
return None return None

View File

@@ -281,16 +281,16 @@ def port_name_series(prefix="sta", start_id=0, end_id=1, padding_number=10000, r
""" """
eid = None eid = None
if radio != None: if radio is not None:
eid = name_to_eid(radio) eid = name_to_eid(radio)
name_list = [] name_list = []
for i in range((padding_number + start_id), (padding_number + end_id + 1)): for i in range((padding_number + start_id), (padding_number + end_id + 1)):
sta_name = prefix + str(i)[1:] sta_name = "%s%s" % (prefix, str(i)[1:])
if eid != None: if eid is None:
name_list.append("%i.%i.%s"%(eid[0], eid[1], sta_name))
else:
name_list.append(sta_name) name_list.append(sta_name)
else:
name_list.append("%i.%i.%s" % (eid[0], eid[1], sta_name))
return name_list return name_list
@@ -543,7 +543,7 @@ def wait_until_ports_appear(base_url="http://localhost:8080", port_list=(), debu
found_stations.append(port_name) found_stations.append(port_name)
else: else:
lf_r = LFRequest.LFRequest(base_url, ncshow_url) lf_r = LFRequest.LFRequest(base_url, ncshow_url)
lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "probe_flags": "1"}) lf_r.addPostData({"shelf": shelf, "resource": resource_id, "port": port_name, "probe_flags": 5})
lf_r.jsonPost() lf_r.jsonPost()
if (len(found_stations) < len(port_list)): if (len(found_stations) < len(port_list)):
sleep(2) sleep(2)

View File

@@ -1,16 +1,23 @@
#!env /usr/bin/python #!env /usr/bin/python
import sys import sys
import signal
import traceback import traceback
# Extend this class to use common set of debug and request features for your script # Extend this class to use common set of debug and request features for your script
from pprint import pprint from pprint import pprint
import time
import LANforge.LFUtils import LANforge.LFUtils
from LANforge.LFUtils import * from LANforge.LFUtils import *
import argparse import argparse
from LANforge import LFRequest
import LANforge.LFRequest import LANforge.LFRequest
class LFCliBase: class LFCliBase:
SHOULD_RUN = 0 # indicates normal operation
SHOULD_QUIT = 1 # indicates to quit loops, close files, send SIGQUIT to threads and return
SHOULD_HALT = 2 # indicates to quit loops, send SIGABRT to threads and exit
# do not use `super(LFCLiBase,self).__init__(self, host, port, _debug) # do not use `super(LFCLiBase,self).__init__(self, host, port, _debug)
# that is py2 era syntax and will force self into the host variable, making you # that is py2 era syntax and will force self into the host variable, making you
# very confused. # very confused.
@@ -19,7 +26,8 @@ class LFCliBase:
_halt_on_error=False, _halt_on_error=False,
_exit_on_error=False, _exit_on_error=False,
_exit_on_fail=False, _exit_on_fail=False,
_local_realm=False): _local_realm=False,
_capture_signal_list=[]):
self.fail_pref = "FAILED: " self.fail_pref = "FAILED: "
self.pass_pref = "PASSED: " self.pass_pref = "PASSED: "
self.lfclient_host = _lfjson_host self.lfclient_host = _lfjson_host
@@ -33,12 +41,110 @@ class LFCliBase:
self.halt_on_error = _halt_on_error self.halt_on_error = _halt_on_error
self.exit_on_error = _exit_on_error self.exit_on_error = _exit_on_error
self.exit_on_fail = _exit_on_fail self.exit_on_fail = _exit_on_fail
self.capture_signals = _capture_signal_list
# toggle using preexec_cli, preexec_method; the preexec_X parameters are useful # toggle using preexec_cli, preexec_method; the preexec_X parameters are useful
# when you desire the lfclient to check for existance of entities to run commands on, # when you desire the lfclient to check for existance of entities to run commands on,
# like when developing; you might toggle this with use_preexec = _debug # like when developing; you might toggle this with use_preexec = _debug
# Otherwise, preexec methods use more processing time because they add an extra CLI call # Otherwise, preexec methods use more processing time because they add an extra CLI call
# into the queue, and inspect it -- typically nc_show_port # into the queue, and inspect it -- typically nc_show_port
self.suppress_related_commands = None self.suppress_related_commands = None
self.finish = self.SHOULD_RUN
self.thread_map = {}
if len(_capture_signal_list) > 0:
for zignal in _capture_signal_list:
captured_signal(zignal, my_captured_signal)
#
def _finish(self):
"""
call this to indicate SIGQUIT
"""
self.finish = self.SHOULD_QUIT
def _halt(self):
"""
call this to indicate SIGABRT
"""
self.finish = self.SHOULD_HALT
def _should_finish(self):
"""
check this when in a run loop if SIGQUIT has been indicated
"""
if self.finish == self.SHOULD_RUN:
return False
if self.finish == self.SHOULD_QUIT:
return True
if self.finish == self.SHOULD_HALT:
return False
def _should_halt(self):
"""
check this when in a run loop if SIGABRT has been indicated
"""
if self.finish == self.SHOULD_RUN:
return False
if self.finish == self.SHOULD_QUIT:
return False
if self.finish == self.SHOULD_HALT:
return True
def track_thread(self, name, thread):
if self.thread_map is None:
self.thread_map = {}
self.thread_map[name] = thread
def get_thread(self, name):
if self.thread_map is None:
return None
if name in self.thread_map.keys():
return self.thread_map[name]
return None
def remove_thread(self, name):
if self.thread_map is None:
return None
if name not in self.thread_map.keys():
return None
thrud = self.thread_map[name]
del self.thread_map[name]
return thrud
def send_thread_signals(signum, fname):
if len(self.thread_map) < 1:
print("no threads to signal")
return
for (name, thread) in self.thread_map.items():
if self.debug:
print("sending signal %s to thread %s" % (signum, name))
# do a thing
def my_captured_signal(signum, frame):
"""
Override me to process signals, otherwise superclass signal handler is called.
You may use _finish() or _halt() to indicate finishing soon or halting immediately.
:return: True if we processed this signal
"""
print("my_captured_signal should be overridden")
return False
def caputured_signal(signum):
"""
Here is your opportunity to decide what to do on things like KeyboardInterrupt or other UNIX signals
Check that your subclass handled the signal or not. You may use _finish() or _halt() to indicate
finishing soon or halting immediately. Use signal.signal(signal.STOP) to enable this.
"""
if self.debug:
print("Captured signal %s" % signum)
if my_captured_signal(signum):
if self.debug:
print("subclass processed signal")
else:
if self.debug:
print("subclass ignored signal")
def clear_test_results(self): def clear_test_results(self):
self.test_results.clear() self.test_results.clear()
@@ -87,22 +193,55 @@ class LFCliBase:
pprint.pprint(response_json_list_) pprint.pprint(response_json_list_)
except Exception as x: except Exception as x:
if self.debug or self.halt_on_error or self.exit_on_error: if self.debug or self.halt_on_error or self.exit_on_error:
print("jsonPost posted to %s" % _req_url) print("json_post posted to %s" % _req_url)
pprint.pprint(_data) pprint.pprint(_data)
print("Exception %s:" % x) print("Exception %s:" % x)
traceback.print_exception(Exception, x, x.__traceback__, chain=True) traceback.print_exception(Exception, x, x.__traceback__, chain=True)
if self.halt_on_error or self.exit_on_error: if self.halt_on_error or self.exit_on_error:
exit(1) exit(1)
return json_response
def json_put(self, _req_url, _data, debug_=False, response_json_list_=None):
"""
Send a PUT request. This is presently used for data sent to /status-msg for
creating a new messaging session. It is not presently used for CLI scripting
so lacks suppress_x features.
:param _req_url: url to put
:param _data: data to place at URL
:param debug_: enable debug output
:param response_json_list_: array for json results in the response object, (alternative return method)
:return: http response object
"""
json_response = None
try:
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=self.debug, die_on_error_=self.exit_on_error)
lf_r.addPostData(_data)
if debug_ or self.debug:
LANforge.LFUtils.debug_printer.pprint(_data)
json_response = lf_r.json_put(show_error=self.debug,
debug=(self.debug or debug_),
response_json_list_=response_json_list_,
die_on_error_=self.exit_on_error)
if debug_ and (response_json_list_ is not None):
pprint.pprint(response_json_list_)
except Exception as x:
if self.debug or self.halt_on_error or self.exit_on_error:
print("json_put submitted to %s" % _req_url)
pprint.pprint(_data)
print("Exception %s:" % x)
traceback.print_exception(Exception, x, x.__traceback__, chain=True)
if self.halt_on_error or self.exit_on_error:
exit(1)
return json_response return json_response
def json_get(self, _req_url, debug_=False): def json_get(self, _req_url, debug_=False):
if self.debug or debug_: if self.debug or debug_:
print("URL: "+_req_url) print("GET: "+_req_url)
json_response = None json_response = None
# print("----- GET ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
try: try:
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=(self.debug or debug_), die_on_error_=self.exit_on_error) lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url, debug_=(self.debug or debug_), die_on_error_=self.exit_on_error)
json_response = lf_r.getAsJson(debug_=self.debug, die_on_error_=self.halt_on_error) json_response = lf_r.get_as_json(debug_=self.debug, die_on_error_=self.halt_on_error)
#debug_printer.pprint(json_response) #debug_printer.pprint(json_response)
if (json_response is None) and (self.debug or debug_): if (json_response is None) and (self.debug or debug_):
print("LFCliBase.json_get: no entity/response, probabily status 404") print("LFCliBase.json_get: no entity/response, probabily status 404")
@@ -117,6 +256,31 @@ class LFCliBase:
return json_response return json_response
def json_delete(self, _req_url, debug_=False):
if self.debug or debug_:
print("DELETE: "+_req_url)
json_response = None
try:
# print("----- DELETE ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
lf_r = LFRequest.LFRequest(self.lfclient_url, _req_url,
debug_=(self.debug or debug_),
die_on_error_=self.exit_on_error)
json_response = lf_r.json_delete(debug=self.debug,
die_on_error_=self.halt_on_error)
#debug_printer.pprint(json_response)
if (json_response is None) and (self.debug or debug_):
print("LFCliBase.json_delete: no entity/response, probabily status 404")
return None
except ValueError as ve:
if self.debug or self.halt_on_error or self.exit_on_error:
print("json_delete asked for " + _req_url)
print("Exception %s:" % ve)
traceback.print_exception(ValueError, ve, ve.__traceback__, chain=True)
if self.halt_on_error or self.exit_on_error:
sys.exit(1)
# print("----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ")
return json_response
@staticmethod @staticmethod
def response_list_to_map(json_list, key, debug_=False): def response_list_to_map(json_list, key, debug_=False):
reverse_map = {} reverse_map = {}
@@ -172,10 +336,11 @@ class LFCliBase:
if duration >= 300: if duration >= 300:
print("Could not connect to LANforge GUI") print("Could not connect to LANforge GUI")
sys.exit(1) sys.exit(1)
#return ALL messages in list form
def get_result_list(self): def get_result_list(self):
return self.test_results return self.test_results
#return ALL fail messages in list form
def get_failed_result_list(self): def get_failed_result_list(self):
fail_list = [] fail_list = []
for result in self.test_results: for result in self.test_results:
@@ -183,13 +348,29 @@ class LFCliBase:
fail_list.append(result) fail_list.append(result)
return fail_list return fail_list
#return ALL pass messages in list form
def get_passed_result_list(self):
pass_list = []
for result in self.test_results:
if result.startswith("PASS"):
pass_list.append(result)
return pass_list
def get_pass_message(self):
pass_messages = self.get_passed_result_list()
return "\n".join(pass_messages)
def get_fail_message(self): def get_fail_message(self):
fail_messages = self.get_failed_result_list() fail_messages = self.get_failed_result_list()
return "\n".join(fail_messages) return "\n".join(fail_messages)
def get_all_message(self): def get_all_message(self):
return "\n".join(self.test_results) return "\n".join(self.test_results)
#determines if overall test passes via comparing passes vs. fails
def passes(self): def passes(self):
pass_counter = 0 pass_counter = 0
fail_counter = 0 fail_counter = 0
@@ -202,7 +383,15 @@ class LFCliBase:
return True return True
return False return False
# use this inside the class to log a failure result #EXIT script with a fail
def exit_fail(self,message="%d out of %d tests failed. Exiting script."):
total_len=len(self.get_result_list())
fail_len=len(self.get_failed_result_list())
print(message %(fail_len,total_len))
sys.exit(1)
# use this inside the class to log a failure result and print it if wished
def _fail(self, message, print_=False): def _fail(self, message, print_=False):
self.test_results.append(self.fail_pref + message) self.test_results.append(self.fail_pref + message)
if print_ or self.exit_on_fail: if print_ or self.exit_on_fail:
@@ -210,7 +399,15 @@ class LFCliBase:
if self.exit_on_fail: if self.exit_on_fail:
sys.exit(1) sys.exit(1)
# use this inside the class to log a pass result #EXIT script with a success
def exit_success(self,message="%d out of %d tests passed successfully. Exiting script."):
num_total=len(self.get_result_list())
num_passing=len(self.get_passed_result_list())
print(message %(num_passing,num_total))
sys.exit(0)
# use this inside the class to log a pass result and print if wished.
def _pass(self, message, print_=False): def _pass(self, message, print_=False):
self.test_results.append(self.pass_pref + message) self.test_results.append(self.pass_pref + message)
if print_: if print_:
@@ -249,7 +446,7 @@ class LFCliBase:
parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2', default=None) parser.add_argument('--radio', help='radio EID, e.g: 1.wiphy2', default=None)
parser.add_argument('--security', help='WiFi Security protocol: <open | wep | wpa | wpa2 | wpa3 >', default=None) parser.add_argument('--security', help='WiFi Security protocol: <open | wep | wpa | wpa2 | wpa3 >', default=None)
parser.add_argument('--ssid', help='SSID for stations to associate to', default=None) parser.add_argument('--ssid', help='SSID for stations to associate to', default=None)
parser.add_argument('--passwd', '--passphrase', '--password', '--pwd', help='WiFi passphrase', default=None) parser.add_argument('--passwd', help='WiFi passphrase', default=None)
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('--test_id', help='Test ID (intended to use for ws events)', default="webconsole") parser.add_argument('--test_id', help='Test ID (intended to use for ws events)', default="webconsole")
parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true") parser.add_argument('--debug', help='Enable debugging', default=False, action="store_true")

View File

@@ -370,7 +370,7 @@ class Realm(LFCliBase):
# Returns map of all stations with port+type == WIFI-STATION # Returns map of all stations with port+type == WIFI-STATION
def station_map(self): def station_map(self):
response = super().json_get("/port/list?fields=_links,alias,device,port+type") response = super().json_get("/port/list?fields=port,_links,alias,device,port+type")
if (response is None) or ("interfaces" not in response): if (response is None) or ("interfaces" not in response):
pprint(response) pprint(response)
print("station_list: incomplete response, halting") print("station_list: incomplete response, halting")
@@ -554,6 +554,52 @@ class Realm(LFCliBase):
return not wait_more return not wait_more
def get_curr_num_ips(self,num_sta_with_ips=0,station_list=None, ipv4=True, ipv6=False, debug=False):
print("checking number of stations with ips...")
waiting_states = ["0.0.0.0", "NA", ""]
if (station_list is None) or (len(station_list) < 1):
raise ValueError("check for num curr ips expects non-empty list of ports")
for sta_eid in station_list:
if debug:
print("checking sta-eid: %s"%(sta_eid))
eid = self.name_to_eid(sta_eid)
response = super().json_get("/port/%s/%s/%s?fields=alias,ip,port+type,ipv6+address" %
(eid[0], eid[1], eid[2]))
if debug:
pprint(response)
if (response is None) or ("interface" not in response):
print("station_list: incomplete response:")
pprint(response)
#wait_more = True
break
if ipv4:
v = response['interface']
if (v['ip'] in waiting_states):
if debug:
print("Waiting for port %s to get IPv4 Address."%(sta_eid))
else:
if debug:
print("Found IP: %s on port: %s"%(v['ip'], sta_eid))
print("Incrementing stations with IP addresses found")
num_sta_with_ips+=1
else:
num_sta_with_ips+=1
if ipv6:
v = response['interface']
if (v['ip'] in waiting_states):
if debug:
print("Waiting for port %s to get IPv6 Address."%(sta_eid))
else:
if debug:
print("Found IP: %s on port: %s"%(v['ip'], sta_eid))
print("Incrementing stations with IP addresses found")
num_sta_with_ips+=1
else:
num_sta_with_ips+=1
return num_sta_with_ips
def duration_time_to_seconds(self, time_string): def duration_time_to_seconds(self, time_string):
if isinstance(time_string, str): if isinstance(time_string, str):
pattern = re.compile("^(\d+)([dhms]$)") pattern = re.compile("^(\d+)([dhms]$)")
@@ -733,6 +779,9 @@ class Realm(LFCliBase):
def new_mvlan_profile(self): def new_mvlan_profile(self):
return MACVLANProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) return MACVLANProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug)
def new_test_group_profile(self):
return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug)
class MULTICASTProfile(LFCliBase): class MULTICASTProfile(LFCliBase):
def __init__(self, lfclient_host, lfclient_port, local_realm, def __init__(self, lfclient_host, lfclient_port, local_realm,
report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False):
@@ -2169,6 +2218,74 @@ class DUTProfile(LFCliBase):
"text-64": notebytes.decode('ascii') "text-64": notebytes.decode('ascii')
}, self.debug) }, self.debug)
class TestGroupProfile(LFCliBase):
def __init__(self, lfclient_host, lfclient_port, local_realm, test_group_name=None, debug_=False):
super().__init__(lfclient_host, lfclient_port, debug_, _halt_on_error=True)
self.local_realm = local_realm
self.group_name = test_group_name
self.cx_list = []
def start_group(self):
if self.group_name is not None:
self.local_realm.json_post("/cli-json/start_group", {"name": self.group_name})
else:
raise ValueError("test_group name must be set.")
def quiesce_group(self):
if self.group_name is not None:
self.local_realm.json_post("/cli-json/quiesce_group", {"name": self.group_name})
else:
raise ValueError("test_group name must be set.")
def stop_group(self):
if self.group_name is not None:
self.local_realm.json_post("/cli-json/stop_group", {"name": self.group_name})
else:
raise ValueError("test_group name must be set.")
def create_group(self):
if self.group_name is not None:
self.local_realm.json_post("/cli-json/add_group", {"name": self.group_name})
else:
raise ValueError("test_group name must be set.")
def remove_group(self):
if self.group_name is not None:
self.local_realm.json_post("/cli-json/rm_group", {"name": self.group_name})
else:
raise ValueError("test_group name must be set.")
def add_cx(self, cx_name):
self.local_realm.json_post("/cli-json/add_tgcx", {"tgname": self.test_group_name, "cxname": cx_name})
def rm_cx_from_list(self, cx_name):
self.local_realm.json_post("/cli-json/add_tgcx", {"tgname": self.test_group_name, "cxname": cx_name})
def check_group_exists(self):
test_groups = self.local_realm.json_get("/testgroups")
if test_groups is not None:
test_groups = test_groups["groups"]
for group in test_groups:
for k,v in group.items():
if v['name'] == self.group_name:
return True
else:
return False
def list_groups(self):
test_groups = self.local_realm.json_get("/testgroups")
tg_list = []
if test_groups is not None:
test_groups = test_groups["groups"]
for group in test_groups:
for k, v in group.items():
tg_list.append(v['name'])
return tg_list
def list_cxs(self):
# TODO: List cxs in profile, use cx_list or query?
pass
class FIOEndpProfile(LFCliBase): class FIOEndpProfile(LFCliBase):
""" """
@@ -2212,7 +2329,6 @@ class FIOEndpProfile(LFCliBase):
self.created_cx = {} self.created_cx = {}
self.created_endp = [] self.created_endp = []
def start_cx(self): def start_cx(self):
print("Starting CXs...") print("Starting CXs...")
for cx_name in self.created_cx.keys(): for cx_name in self.created_cx.keys():
@@ -2304,12 +2420,13 @@ class FIOEndpProfile(LFCliBase):
"payload_pattern": self.pattern, "payload_pattern": self.pattern,
} }
# Read direction is copy of write only directory
if self.io_direction == "read": if self.io_direction == "read":
endp_data["prefix"] = "wo_" + name + "_fio" endp_data["prefix"] = "wo_" + name + "_fio"
endp_data["directory"] = "/mnt/lf/wo_" + name + "_fio" endp_data["directory"] = "/mnt/lf/wo_" + name + "_fio"
url = "cli-json/add_file_endp" url = "cli-json/add_file_endp"
self.local_realm.json_post(url, endp_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) self.local_realm.json_post(url, endp_data, debug_=True, suppress_related_commands_=suppress_related_commands_)
time.sleep(sleep_time) time.sleep(sleep_time)
data = { data = {
@@ -2320,6 +2437,13 @@ class FIOEndpProfile(LFCliBase):
self.local_realm.json_post("cli-json/set_fe_info", data, debug_=debug_, self.local_realm.json_post("cli-json/set_fe_info", data, debug_=debug_,
suppress_related_commands_=suppress_related_commands_) suppress_related_commands_=suppress_related_commands_)
self.local_realm.json_post("/cli-json/nc_show_endpoints", {"endpoint": "all"})
for port_name in ports:
if len(self.local_realm.name_to_eid(port_name)) == 3:
shelf = self.local_realm.name_to_eid(port_name)[0]
resource = self.local_realm.name_to_eid(port_name)[1]
name = self.local_realm.name_to_eid(port_name)[2]
endp_data = { endp_data = {
"alias": "CX_" + self.cx_prefix + name + "_fio", "alias": "CX_" + self.cx_prefix + name + "_fio",
"test_mgr": "default_tm", "test_mgr": "default_tm",
@@ -2329,6 +2453,7 @@ class FIOEndpProfile(LFCliBase):
cx_post_data.append(endp_data) cx_post_data.append(endp_data)
self.created_cx[self.cx_prefix + name + "_fio"] = "CX_" + self.cx_prefix + name + "_fio" self.created_cx[self.cx_prefix + name + "_fio"] = "CX_" + self.cx_prefix + name + "_fio"
# time.sleep(3)
for cx_data in cx_post_data: for cx_data in cx_post_data:
url = "/cli-json/add_cx" url = "/cli-json/add_cx"
self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_)
@@ -2358,8 +2483,8 @@ class MACVLANProfile(LFCliBase):
self.ip_list = [] self.ip_list = []
self.COMMANDS = ["set_port"] self.COMMANDS = ["set_port"]
self.desired_set_port_cmd_flags = [] self.desired_set_port_cmd_flags = []
self.desired_set_port_current_flags = ["if_down"] self.desired_set_port_current_flags = [] # do not default down, "if_down"
self.desired_set_port_interest_flags = ["current_flags", "ifdown"] self.desired_set_port_interest_flags = ["current_flags"] # do not default down, "ifdown"
self.set_port_data = { self.set_port_data = {
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
@@ -2481,7 +2606,7 @@ class MACVLANProfile(LFCliBase):
LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans) LFUtils.wait_until_ports_appear(base_url=self.lfclient_url, port_list=self.created_macvlans)
print(self.created_macvlans) print(self.created_macvlans)
# time.sleep(sleep_time) time.sleep(5)
for i in range(len(self.created_macvlans)): for i in range(len(self.created_macvlans)):
eid = self.local_realm.name_to_eid(self.created_macvlans[i]) eid = self.local_realm.name_to_eid(self.created_macvlans[i])
@@ -2503,7 +2628,7 @@ class MACVLANProfile(LFCliBase):
self.local_realm.rm_port(port_eid, check_exists=True) self.local_realm.rm_port(port_eid, check_exists=True)
time.sleep(.2) time.sleep(.2)
# And now see if they are gone # And now see if they are gone
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=self.created_macvlans)
def admin_up(self): def admin_up(self):
for macvlan in self.created_macvlans: for macvlan in self.created_macvlans:
@@ -2752,6 +2877,8 @@ class StationProfile:
number_template_="00000", number_template_="00000",
mode=0, mode=0,
up=True, up=True,
resource=1,
shelf=1,
dhcp=True, dhcp=True,
debug_=False, debug_=False,
use_ht160=False): use_ht160=False):
@@ -2761,6 +2888,8 @@ class StationProfile:
self.ssid_pass = ssid_pass self.ssid_pass = ssid_pass
self.mode = mode self.mode = mode
self.up = up self.up = up
self.resource=resource
self.shelf=shelf
self.dhcp = dhcp self.dhcp = dhcp
self.security = security self.security = security
self.local_realm = local_realm self.local_realm = local_realm
@@ -3020,8 +3149,6 @@ class StationProfile:
print("ERROR: StationProfile cleanup, list is empty") print("ERROR: StationProfile cleanup, list is empty")
return return
del_count = len(desired_stations)
# First, request remove on the list. # First, request remove on the list.
for port_eid in desired_stations: for port_eid in desired_stations:
self.local_realm.rm_port(port_eid, check_exists=True) self.local_realm.rm_port(port_eid, check_exists=True)
@@ -3073,16 +3200,25 @@ class StationProfile:
self.add_sta_data["radio"] = radio_port self.add_sta_data["radio"] = radio_port
self.add_sta_data["resource"] = radio_resource self.add_sta_data["resource"] = radio_resource
self.add_sta_data["shelf"] = radio_shelf
self.set_port_data["resource"] = radio_resource
self.set_port_data["shelf"] = radio_shelf
self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags, self.set_port_data["current_flags"] = self.add_named_flags(self.desired_set_port_current_flags,
set_port.set_port_current_flags) set_port.set_port_current_flags)
self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags, self.set_port_data["interest"] = self.add_named_flags(self.desired_set_port_interest_flags,
set_port.set_port_interest_flags) set_port.set_port_interest_flags)
self.wifi_extra_data["resource"]=radio_resource
self.wifi_extra_data["shelf"]=radio_shelf
self.reset_port_extra_data["resource"]=radio_resource
self.reset_port_extra_data["shelf"]=radio_shelf
# these are unactivated LFRequest objects that we can modify and # these are unactivated LFRequest objects that we can modify and
# re-use inside a loop, reducing the number of object creations # re-use inside a loop, reducing the number of object creations
add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta") add_sta_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/add_sta")
set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port") set_port_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_port")
wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra") wifi_extra_r = LFRequest.LFRequest(self.lfclient_url + "/cli-json/set_wifi_extra")
my_sta_names = [] my_sta_names = []
#add radio here
if num_stations > 0: if num_stations > 0:
my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template)) my_sta_names = LFUtils.portNameSeries("sta", 0, num_stations - 1, int("1" + self.number_template))
else: else:
@@ -3106,6 +3242,8 @@ class StationProfile:
self.add_sta_data["radio"] = radio_port self.add_sta_data["radio"] = radio_port
self.add_sta_data["sta_name"] = name # for create station calls self.add_sta_data["sta_name"] = name # for create station calls
self.set_port_data["port"] = name # for set_port calls. self.set_port_data["port"] = name # for set_port calls.
self.set_port_data["shelf"] = radio_shelf
self.set_port_data["resource"] = radio_resource
self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name)) self.station_names.append("%s.%s.%s" % (radio_shelf, radio_resource, name))
add_sta_r.addPostData(self.add_sta_data) add_sta_r.addPostData(self.add_sta_data)

View File

@@ -50,8 +50,14 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_param("set_port", "report_timer", 1500) 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.set_command_flag("set_port", "rpt_timer", 1)
self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug) self.station_profile.create(radio="wiphy0", sta_names_=self.sta_list, debug=self.debug)
self._pass("PASS: Station build finished")
self.station_profile.admin_up() 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.passed()
else:
self._fail("Stations not able to acquire IP. Please check network input.")
self.failed()
def cleanup(self, sta_list): def cleanup(self, sta_list):
self.station_profile.cleanup(sta_list) self.station_profile.cleanup(sta_list)

View File

@@ -0,0 +1,117 @@
#!/usr/bin/env python3
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'))
import LANforge
from LANforge.lfcli_base import LFCliBase
from LANforge import LFUtils
import realm
import argparse
import time
import pprint
class IPv4Test(LFCliBase):
def __init__(self, host, port, ssid, security, password, sta_list=None, number_template="00000", radio = "wiphy0",_debug_on=False,
_exit_on_error=False,
_exit_on_fail=False):
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
self.host = host
self.port = port
self.ssid = ssid
self.radio = radio
self.security = security
self.password = password
self.sta_list = sta_list
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.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.mode = 0
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.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.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.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():
lfjson_host = "localhost"
lfjson_port = 8080
parser = LFCliBase.create_basic_argparse(
prog='example_security_connection.py',
# formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter,
epilog='''\
Example flags and command line input to run the script.
''',
description='''\
example_security_connection.py
--------------------
This python script creates an inputted number of stations using user-inputted security. This verifies that the most basic form of security works with the LANforge device.
--------------------
Generic command example:
python3 ./example_security_connection.py \\
--host localhost (optional) \\
--port 8080 (optional) \\
--num_stations 6 \\
--radio wiphy2
--security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear-wpa3 \\
--passwd admin123-wpa3 \\
--debug
''')
args = parser.parse_args()
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,
radio=args.radio)
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio,
security=args.security, sta_list=station_list)
ip_test.cleanup(station_list)
ip_test.timeout = 60
ip_test.build()
if __name__ == "__main__":
main()

View File

@@ -51,7 +51,13 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_param("set_port", "report_timer", 1500) 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.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.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.passed()
else:
self._fail("Stations not able to acquire IP. Please check network input.")
self.failed()
def cleanup(self, sta_list): def cleanup(self, sta_list):
self.station_profile.cleanup(sta_list) self.station_profile.cleanup(sta_list)

View File

@@ -51,7 +51,13 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_param("set_port", "report_timer", 1500) 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.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.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.passed()
else:
self._fail("Stations not able to acquire IP. Please check network input.")
self.failed()
def cleanup(self, sta_list): def cleanup(self, sta_list):
self.station_profile.cleanup(sta_list) self.station_profile.cleanup(sta_list)
@@ -71,7 +77,7 @@ def main():
''', ''',
description='''\ description='''\
example_wpa_connection.py example_wpa2_connection.py
-------------------- --------------------
Generic command example: Generic command example:

View File

@@ -51,7 +51,14 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_param("set_port", "report_timer", 1500) 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.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.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.passed()
else:
self._fail("Stations not able to acquire IP. Please check network input.")
self.failed()
def cleanup(self, sta_list): def cleanup(self, sta_list):
self.station_profile.cleanup(sta_list) self.station_profile.cleanup(sta_list)

View File

@@ -52,8 +52,14 @@ class IPv4Test(LFCliBase):
self.station_profile.set_command_flag("set_port", "rpt_timer", 1) 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() 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.passed()
else:
self._fail("Stations not able to acquire IP. Please check network input.")
self.failed()
self._pass("PASS: Station build finished")
def cleanup(self, sta_list): def cleanup(self, sta_list):
self.station_profile.cleanup(sta_list) self.station_profile.cleanup(sta_list)

View File

@@ -37,7 +37,9 @@ class FileAdapter(object):
def flush(self): def flush(self):
pass # leave it to logging to flush properly pass # leave it to logging to flush properly
###################################### ################################################################################
# cisco controller class :This class in the future will be moved to its own file
################################################################################
class cisco_(): class cisco_():
def __init__(self, args): def __init__(self, args):
@@ -614,19 +616,20 @@ class cisco_():
logg.info("configure ap {} channel {} chan_width {}".format(self.args.cisco_ap,self.args.cisco_channel,self.args.cisco_chan_width)) logg.info("configure ap {} channel {} chan_width {}".format(self.args.cisco_ap,self.args.cisco_channel,self.args.cisco_chan_width))
# Verify channel and channel width. # Verify channel and channel width.
##########################################
# End of cisco controller class
########################################## ##########################################
class L3VariableTime(LFCliBase): class L3VariableTime(LFCliBase):
def __init__(self, host, port, endp_types, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list, def __init__(self, host, port, endp_type, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list,
ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile, ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile,
test_keys,test_config, test_keys,test_config,
reset_port_enable_list, reset_port_enable_list,
reset_port_time_min_list, reset_port_time_min_list,
reset_port_time_max_list, reset_port_time_max_list,
side_a_min_rate=560000, side_a_max_rate=0, side_a_min_bps=560000, side_a_max_bps=0,
side_a_min_pdu=1518,side_a_max_pdu=0, side_a_min_pdu=1518,side_a_max_pdu=0,
side_b_min_rate=560000, side_b_max_rate=0, side_b_min_bps=560000, side_b_max_bps=0,
side_b_min_pdu=1518,side_b_max_pdu=0, side_b_min_pdu=1518,side_b_max_pdu=0,
number_template="00", test_duration="256s", number_template="00", test_duration="256s",
polling_interval="60s", polling_interval="60s",
@@ -636,7 +639,7 @@ class L3VariableTime(LFCliBase):
self.host = host self.host = host
self.port = port self.port = port
self.tos = tos.split() self.tos = tos.split()
self.endp_types = endp_types.split() self.endp_type = endp_type
self.side_b = side_b self.side_b = side_b
self.ssid_list = ssid_list self.ssid_list = ssid_list
self.ssid_password_list = ssid_password_list self.ssid_password_list = ssid_password_list
@@ -667,14 +670,6 @@ class L3VariableTime(LFCliBase):
self.test_config_dict = dict(map(lambda x: x.split('=='), str(self.test_config).replace('[','').replace(']','').replace("'","").split())) self.test_config_dict = dict(map(lambda x: x.split('=='), str(self.test_config).replace('[','').replace(']','').replace("'","").split()))
# Some checking on the duration
#self.local_realm.parse_time(self.test_duration)
#if ( (radio_info_dict['reset_port_time_min'] >= args.test_duration)
# or (radio_info_dict['reset_port_time_max'] >= args.test_duration)):
# logg.info("port reset times min {} max {} mismatched with test duration {}"\
# .format(radio_info_dict['reset_port_time_min'],radio_info_dict['reset_port_time_max'],args.test_duration)))
# exit(1)
# Full spread-sheet data # Full spread-sheet data
if self.outfile is not None: if self.outfile is not None:
@@ -703,12 +698,12 @@ class L3VariableTime(LFCliBase):
self.cx_profile.host = self.host self.cx_profile.host = self.host
self.cx_profile.port = self.port self.cx_profile.port = self.port
self.cx_profile.name_prefix = self.name_prefix self.cx_profile.name_prefix = self.name_prefix
self.cx_profile.side_a_min_bps = side_a_min_rate self.cx_profile.side_a_min_bps = side_a_min_bps
self.cx_profile.side_a_max_bps = side_a_max_rate self.cx_profile.side_a_max_bps = side_a_min_bps
self.cx_profile.side_a_min_pdu = side_a_min_pdu self.cx_profile.side_a_min_pdu = side_a_min_pdu
self.cx_profile.side_a_max_pdu = side_a_max_pdu self.cx_profile.side_a_max_pdu = side_a_max_pdu
self.cx_profile.side_b_min_bps = side_b_min_rate self.cx_profile.side_b_min_bps = side_b_min_bps
self.cx_profile.side_b_max_bps = side_b_max_rate self.cx_profile.side_b_max_bps = side_b_min_bps
self.cx_profile.side_b_min_pdu = side_b_min_pdu self.cx_profile.side_b_min_pdu = side_b_min_pdu
self.cx_profile.side_b_max_pdu = side_b_max_pdu self.cx_profile.side_b_max_pdu = side_b_max_pdu
@@ -745,8 +740,15 @@ class L3VariableTime(LFCliBase):
csv_rx_drop_percent_data.append(self.test_config_dict[key]) csv_rx_drop_percent_data.append(self.test_config_dict[key])
csv_rx_drop_percent_data.extend([self.epoch_time, self.time_stamp(),'rx_drop_percent']) csv_rx_drop_percent_data.extend([self.epoch_time, self.time_stamp(),'rx_drop_percent'])
# remove multi cast since downstream only if selected
for key in [key for key in rx_drop_percent if "mtx" in key]: del rx_drop_percent[key] for key in [key for key in rx_drop_percent if "mtx" in key]: del rx_drop_percent[key]
if "upstream" in self.test_config_dict.values():
for key in [key for key in rx_drop_percent if "-A" in key]: del rx_drop_percent[key]
elif "downstream" in self.test_config_dict.values():
for key in [key for key in rx_drop_percent if "-B" in key]: del rx_drop_percent[key]
filtered_values = [v for _, v in rx_drop_percent.items() if v !=0] filtered_values = [v for _, v in rx_drop_percent.items() if v !=0]
average_rx_drop_percent = sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 average_rx_drop_percent = sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
@@ -774,13 +776,10 @@ class L3VariableTime(LFCliBase):
csv_rx_delta_row_data = [] csv_rx_delta_row_data = []
csv_rx_delta_dict = {} csv_rx_delta_dict = {}
# this may need to be a list as more monitoring takes place.
for key in self.test_keys: for key in self.test_keys:
csv_rx_row_data.append(self.test_config_dict[key]) csv_rx_row_data.append(self.test_config_dict[key])
csv_rx_delta_row_data.append(self.test_config_dict[key]) csv_rx_delta_row_data.append(self.test_config_dict[key])
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx'])
csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
for key in [key for key in old_list if "mtx" in key]: del old_list[key] for key in [key for key in old_list if "mtx" in key]: del old_list[key]
for key in [key for key in new_list if "mtx" in key]: del new_list[key] for key in [key for key in new_list if "mtx" in key]: del new_list[key]
@@ -788,27 +787,47 @@ class L3VariableTime(LFCliBase):
filtered_values = [v for _, v in new_list.items() if v !=0] filtered_values = [v for _, v in new_list.items() if v !=0]
average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
csv_performance_values=sorted(new_list.items(), key=lambda x: (x[1],x[0]), reverse=False)
# only evaluate upstream or downstream
new_evaluate_list = new_list.copy()
print("new_evaluate_list before",new_evaluate_list)
if "upstream" in self.test_config_dict.values():
for key in [key for key in new_evaluate_list if "-A" in key]: del new_evaluate_list[key]
print("upstream in dictionary values")
elif "downstream" in self.test_config_dict.values():
for key in [key for key in new_evaluate_list if "-B" in key]: del new_evaluate_list[key]
print("downstream in dictionary values")
'''print("new_evaluate_list after",new_evaluate_list)
csv_performance_values=sorted(new_evaluate_list.items(), key=lambda x: (x[1],x[0]), reverse=False)
csv_performance_values=self.csv_validate_list(csv_performance_values,5) csv_performance_values=self.csv_validate_list(csv_performance_values,5)
for i in range(5): for i in range(5):
csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';'))
for i in range(-1,-6,-1): for i in range(-1,-6,-1):
csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';'))
csv_rx_row_data.append(average_rx) csv_rx_row_data.append(average_rx)'''
if len(old_list) == len(new_list): old_evaluate_list = old_list.copy()
for item, value in old_list.items(): if "upstream" in self.test_config_dict.values():
for key in [key for key in old_evaluate_list if "-A" in key]: del old_evaluate_list[key]
print("upstream in dictionary values")
elif "downstream" in self.test_config_dict.values():
for key in [key for key in old_evaluate_list if "-B" in key]: del old_evaluate_list[key]
print("downstream in dictionary values")
if len(old_evaluate_list) == len(new_evaluate_list):
for item, value in old_evaluate_list.items():
expected_passes +=1 expected_passes +=1
if new_list[item] > old_list[item]: if new_evaluate_list[item] > old_evaluate_list[item]:
passes += 1 passes += 1
#if self.debug: logg.info(item, new_list[item], old_list[item], " Difference: ", new_list[item] - old_list[item]) #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
print(item, new_list[item], old_list[item], " Difference: ", new_list[item] - old_list[item]) print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
else: else:
print("Failed to increase rx data: ", item, new_list[item], old_list[item]) print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item])
if not self.csv_started: if not self.csv_started:
csv_rx_headers.append(item) csv_rx_headers.append(item)
csv_rx_delta_dict.update({item:(new_list[item] - old_list[item])}) csv_rx_delta_dict.update({item:(new_evaluate_list[item] - old_evaluate_list[item])})
if not self.csv_started: if not self.csv_started:
@@ -820,7 +839,25 @@ class L3VariableTime(LFCliBase):
# need to generate list first to determine worst and best # need to generate list first to determine worst and best
filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0] filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0]
average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 #average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0
max_tp_mbps = sum(filtered_values)
csv_rx_row_data.append(max_tp_mbps)
#To do needs to be read or passed in based on test type
expected_tp_mbps = max_tp_mbps
csv_rx_row_data.append(expected_tp_mbps)
# Todo pass or fail
if max_tp_mbps == expected_tp_mbps:
csv_rx_row_data.append("pass")
else:
csv_rx_row_data.append("fail")
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
'''
csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx'])
csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta'])
csv_performance_delta_values=sorted(csv_rx_delta_dict.items(), key=lambda x: (x[1],x[0]), reverse=False) csv_performance_delta_values=sorted(csv_rx_delta_dict.items(), key=lambda x: (x[1],x[0]), reverse=False)
csv_performance_delta_values=self.csv_validate_list(csv_performance_delta_values,5) csv_performance_delta_values=self.csv_validate_list(csv_performance_delta_values,5)
@@ -829,23 +866,24 @@ class L3VariableTime(LFCliBase):
for i in range(-1,-6,-1): for i in range(-1,-6,-1):
csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';')) csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';'))
csv_rx_delta_row_data.append(average_rx_delta) csv_rx_delta_row_data.append(average_rx_delta)'''
for item, value in old_list.items(): for item, value in old_evaluate_list.items():
expected_passes +=1 expected_passes +=1
if new_list[item] > old_list[item]: if new_evaluate_list[item] > old_evaluate_list[item]:
passes += 1 passes += 1
#if self.debug: logg.info(item, new_list[item], old_list[item], " Difference: ", new_list[item] - old_list[item]) #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
print(item, new_list[item], old_list[item], " Difference: ", new_list[item] - old_list[item]) print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item])
else: else:
print("Failed to increase rx data: ", item, new_list[item], old_list[item]) print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item])
if not self.csv_started: if not self.csv_started:
csv_rx_headers.append(item) csv_rx_headers.append(item)
csv_rx_row_data.append(new_list[item]) # note need to have all upstream and downstream in the csv table thus new_list and old_list
csv_rx_delta_row_data.append(new_list[item] - old_list[item]) #csv_rx_row_data.append(new_list[item])
csv_rx_row_data.append(new_list[item] - old_list[item])
self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file) self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file)
self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file) #self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file)
if passes == expected_passes: if passes == expected_passes:
return True return True
@@ -898,94 +936,6 @@ class L3VariableTime(LFCliBase):
if (int(sta_count) != int(self.total_stas)): if (int(sta_count) != int(self.total_stas)):
logg.info("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) logg.info("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas))
def verify_cac_on_ap(self):
pass
# Do this after you get the configuration Verify CAC
# use pySerial to check if the AP is configured:
# 1. You can grep for "DFS CAC timer enabled time 60"
# 2. and "changed to DFS channel 52, running CAC for 60 seconds
# Wait for 60 sec and check for this log "CAC_EXPIRY_EVT: CAC finished on DFS channel 52"
#"make a note of the time and check the CAC timer expired in 60-61 seconds."
# After CAC expires Verify Traffic. (the loop should start up may want some special detection)
def lf_hackrf_enable(self):
# hard coded for now
# need json and update to realm
#if os.path.isfile(self.args.hackrf):
# logg.info("hack rf file found {}".format(self.args.hackrf))
#else:
# logg.info("WARNING: hack rf file not found at {}".format(self.args.hackrf))
# look for lf_hackrf.py in local directory the look for in
pass
def verify_radar_detected_on_ap(self):
pass
#You will see logs as below in the AP:(show logging will help you getting this info)
#[*07/07/2020 23:44:27.7630] wcp/dfs :: RadarDetection: radar detected
#[*07/07/2020 23:44:27.7630] wcp/dfs :: RadarDetection: sending packet out to capwapd, slotId=1, msgLen=386, chanCnt=1 -100
#[*07/07/2020 23:44:27.7900] DOT11_DRV[1]: DFS CAC timer disabled time 0
#[*07/07/2020 23:44:27.7960] Enabling Channel and channel width Switch Announcement on current channel
#[*07/07/2020 23:44:27.8060] DOT11_DRV[1]: set_dfs Channel set to 36/20, CSA count 10
#[*07/07/2020 23:44:27.8620] DOT11_DRV[1]: DFS CAC timer enabled time 60
def verify_black_list_time_ap(self):
pass
def lf_hackrf_disable(self):
pass
#need to save the process id
# dfs dynamic frequency selection
def dfs(self):
if self.args == None:
return
if self.args.cisco_ctlr == None:
return
if self.args.cisco_dfs == False:
return
if self.args.cisco_channel == None:
return
if self.args.cisco_chan_width == None:
return
logg.info("testing dfs")
self.controller_show_ap_channel()
self.controller_disable_ap()
self.controller_set_channel_ap()
self.controller_set_chan_width_ap()
self.controller_enable_ap()
self.verify_cac_on_ap()
self.lf_hackrf_enable()
self.verify_radar_detected_on_ap()
self.verify_black_list_time_ap()
self.lf_hackrf_disable()
# For Testing only - since hackrf not causing channel changes
self.controller_disable_ap()
self.controller_set_channel_ap_36()
#self.dfs_set_chan_width_ap()
self.controller_enable_ap()
#check the AP for 52 is configured or not , check the CAC timer
# verify the clien can connect back to the AP once the CAC expires (check all connections)
def controller_channel_chan_width_config(self):
if self.args == None:
return
if self.args.cisco_ctlr == None:
return
if self.args.cisco_channel == None:
return
self.controller_disable_ap()
self.controller_set_channel_ap()
self.controller_set_chan_width_ap()
self.controller_enable_ap()
self.controller_show_ap_channel()
# need to actually check the CAC timer
time.sleep(60)
def reset_port_check(self): def reset_port_check(self):
for station_profile in self.station_profiles: for station_profile in self.station_profiles:
if station_profile.reset_port_extra_data['reset_port_enable']: if station_profile.reset_port_extra_data['reset_port_enable']:
@@ -1039,15 +989,16 @@ class L3VariableTime(LFCliBase):
station_profile.create(radio=self.radio_name_list[index], sta_names_=self.station_lists[index], debug=self.debug, sleep_time=0) station_profile.create(radio=self.radio_name_list[index], sta_names_=self.station_lists[index], debug=self.debug, sleep_time=0)
index += 1 index += 1
for etype in self.endp_types: # 12/4/2020 put back in multi cast
if etype == "mc_udp" or etype == "mc_udp6": #for etype in self.endp_types:
logg.info("Creating Multicast connections for endpoint type: %s"%(etype)) # if etype == "mc_udp" or etype == "mc_udp6":
self.multicast_profile.create_mc_tx(etype, self.side_b, etype) # logg.info("Creating Multicast connections for endpoint type: %s"%(etype))
self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names) # self.multicast_profile.create_mc_tx(etype, self.side_b, etype)
else: # self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names)
for _tos in self.tos: for _tos in self.tos:
logg.info("Creating connections for endpoint type: %s TOS: %s"%(etype, _tos)) logg.info("Creating connections for endpoint type: {} TOS: {} stations_names {}".format(self.endp_type, _tos, station_profile.station_names))
self.cx_profile.create(endp_type=etype, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos) self.cx_profile.create(endp_type=self.endp_type, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos)
self._pass("PASS: Stations build finished") self._pass("PASS: Stations build finished")
def start(self, print_pass=False, print_fail=False): def start(self, print_pass=False, print_fail=False):
@@ -1070,6 +1021,7 @@ class L3VariableTime(LFCliBase):
exit(1) # why continue exit(1) # why continue
time.sleep(30) time.sleep(30)
self.verify_controller() self.verify_controller()
# Multi cast may not be needed for scaling and performance
logg.info("Starting multicast traffic (if any configured)") logg.info("Starting multicast traffic (if any configured)")
self.multicast_profile.start_mc(debug_=self.debug) self.multicast_profile.start_mc(debug_=self.debug)
self.multicast_profile.refresh_mc(debug_=self.debug) self.multicast_profile.refresh_mc(debug_=self.debug)
@@ -1087,10 +1039,10 @@ class L3VariableTime(LFCliBase):
passes = 0 passes = 0
expected_passes = 0 expected_passes = 0
logg.info("polling_interval_seconds {}".format(self.polling_interval_seconds))
while cur_time < end_time: while cur_time < end_time:
#interval_time = cur_time + datetime.timedelta(seconds=5)
interval_time = cur_time + datetime.timedelta(seconds=self.polling_interval_seconds) interval_time = cur_time + datetime.timedelta(seconds=self.polling_interval_seconds)
#logg.info("polling_interval_seconds {}".format(self.polling_interval_seconds))
while cur_time < interval_time: while cur_time < interval_time:
cur_time = datetime.datetime.now() cur_time = datetime.datetime.now()
self.reset_port_check() self.reset_port_check()
@@ -1106,7 +1058,8 @@ class L3VariableTime(LFCliBase):
self._fail("FAIL: Not all stations increased traffic", print_fail) self._fail("FAIL: Not all stations increased traffic", print_fail)
old_rx_values = new_rx_values old_rx_values = new_rx_values
self.__record_rx_dropped_percent(rx_drop_percent) #percentage dropped not needed for scaling and performance , needed for longevity
#self.__record_rx_dropped_percent(rx_drop_percent)
cur_time = datetime.datetime.now() cur_time = datetime.datetime.now()
@@ -1129,12 +1082,13 @@ class L3VariableTime(LFCliBase):
def csv_generate_column_headers(self): def csv_generate_column_headers(self):
csv_rx_headers = self.test_keys.copy() csv_rx_headers = self.test_keys.copy()
csv_rx_headers.extend(['Time epoch','Time','Monitor']) csv_rx_headers.extend
for i in range(1,6): csv_rx_headers.extend(['Max TP Mbps','Expected TP','Pass Fail','Time epoch','Time','Monitor'])
'''for i in range(1,6):
csv_rx_headers.append("least_rx_data {}".format(i)) csv_rx_headers.append("least_rx_data {}".format(i))
for i in range(1,6): for i in range(1,6):
csv_rx_headers.append("most_rx_data_{}".format(i)) csv_rx_headers.append("most_rx_data_{}".format(i))
csv_rx_headers.append("average_rx_data") csv_rx_headers.append("average_rx_data")'''
return csv_rx_headers return csv_rx_headers
def csv_add_column_headers(self,headers): def csv_add_column_headers(self,headers):
@@ -1173,17 +1127,38 @@ def main():
#formatter_class=argparse.RawDescriptionHelpFormatter, #formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
epilog='''\ epilog='''\
Useful Information: Scaling and Performance
1. Polling interval for checking traffic is fixed at 1 minute
2. The test will generate csv file
3. The tx/rx rates are fixed at 256000 bits per second
4. Maximum stations per radio is 64
''', ''',
description='''\ description='''\
lf_cisco_snp.py: lf_cisco_snp.py:
-------------------- --------------------
##################################################################################
Task Description:
##################################################################################
-----------------
As we discussed, we need help in Candela SNP automation which involves cisco WLC controller and Candela automation. The framework we will build now will be used for years with all our new APs being added to this testbed.
Our ultimate aim is to achieve the following things:
1. 1 to 200 client SNP on 11ac (1, 50 and 200 client count tests)
1. 5 Ghz with different channel widths
2. Data encryption enabled/disabled
3. Local/central switching and authentication combinations
2. 1 to 37 client SNP on 11ax (1, 10 and 37 client count tests) eventually 200 clients
1. Different channel widths
2. Data encryption enabled/disabled
3. Local/central switching and authentication combinations
4. MU-MIMO and OFDMA enabled/disabled combination
3. CI/CD implementation
1. Download latest WLC images and upload them to the controller
2. Start the test suite
3. Generate a report per release
4. Display and graph all result data according to each release along with each testcase historical graph
5. Review overall AP performance across multiple AP platforms
Summary : Summary :
---------- ----------
create stations, create traffic between upstream port and stations, run traffic. create stations, create traffic between upstream port and stations, run traffic.
@@ -1197,7 +1172,7 @@ python .\\lf_cisco_snp.py --test_duration <duration> --endp_type <traffic types>
Multiple radios may be entered with individual --radio switches Multiple radios may be entered with individual --radio switches
generiic command with controller setting channel and channel width test duration 5 min generiic command with controller setting channel and channel width test duration 30 sec
python3 lf_cisco_snp.py --cisco_ctlr <IP> --cisco_dfs True/False --mgr <Lanforge IP> python3 lf_cisco_snp.py --cisco_ctlr <IP> --cisco_dfs True/False --mgr <Lanforge IP>
--cisco_channel <channel> --cisco_chan_width <20,40,80,120> --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port <1.ethX> --cisco_channel <channel> --cisco_chan_width <20,40,80,120> --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port <1.ethX>
--radio "radio==<radio 0 > stations==<number stations> ssid==<ssid> ssid_pw==<ssid password> security==<wpa2 , open> wifimode==<AUTO>" --radio "radio==<radio 0 > stations==<number stations> ssid==<ssid> ssid_pw==<ssid password> security==<wpa2 , open> wifimode==<AUTO>"
@@ -1283,29 +1258,14 @@ python3 lf_cisco_snp.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192.
--radio "radio==1.wiphy1 stations==16 ssid==test_candela ssid_pw==[BLANK] security==open" --radio "radio==1.wiphy1 stations==16 ssid==test_candela ssid_pw==[BLANK] security==open"
--test_duration 5m --test_duration 5m
TODO:
11a 5ghz
11b 24ghz
11g 24ghz
11bg 24ghz
11n 5ghz/24ghz
11ac 5ghz
TODO:
############################################################################## ##############################################################################
Detailed test loop description 10/9/2020 - Karthik Recommendation Detailed test loop description 10/9/2020 - Karthik Recommendation
############################################################################## ##############################################################################
Script logic loops: Script logic loops:
AP {Axel, Vanc} Dynamic AP {Axel, Vanc} Dynamic
frequency {24ghz, 5ghz} Common (band) frequency {24ghz, 5ghz} Common (band) : 24ghz == b , 5ghz == a
wifimode{11ax, 11ac, 11n, 11bg} Common (an anAX anAC abgn bg) wifimode{11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4 ghz or 5ghz), 11bg(2.4 ghz)} Common (an anAX anAC abgn bg)
Bandwidth {20, 40, 80, 160} Bandwidth {20, 40, 80, 160}
data-encryption {enable/disable} Common data-encryption {enable/disable} Common
AP-mode {local/flexconnect} Common AP-mode {local/flexconnect} Common
@@ -1316,8 +1276,9 @@ AP {Axel, Vanc} Dynamic
Time (4 iterations of 30 sec and get the best average TP out of it) Time (4 iterations of 30 sec and get the best average TP out of it)
Notes: Notes:
#############################################
CandelaTech Radios and what supports
#############################################
Radio descriptions: Radio descriptions:
ax200: so if AP is /n, then ax200 will connect at /n. But if AP is /AX, we have no way to force ax200 to act like /n ax200: so if AP is /n, then ax200 will connect at /n. But if AP is /AX, we have no way to force ax200 to act like /n
@@ -1329,31 +1290,31 @@ ath10K(9884) - wave-2 supports 4x4 802.11an-AC 5ghz (can act as ac , an)
Note: wave-2 radios can act as ac, an, (802.11an-AC) or legacy a/b/g (802.11bgn-AC) Note: wave-2 radios can act as ac, an, (802.11an-AC) or legacy a/b/g (802.11bgn-AC)
#############################################
wifimode: wifimodes needed to support
11ax, 11ac, 11n, 11bg #############################################
11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4ghz or 5 ghz), 11bg (2.4 ghz) (Cisco)
############################################# #############################################
5 Ghz 5 Ghz
############################################# #############################################
Wifi mode: ax - 5ghz Wifi mode: 11ax - 5ghz
Radios : ax200 : 802.11 /a/n/ac/AX Radios : ax200 : 802.11 /a/n/ac/AX
Wifi mode: 11ac - 5ghz Wifi mode: 11ac - 5ghz
Radios : ath10K(9984) 802.11an-AC Radios : ath10K(9984) 802.11an-AC (9984 are single band)
Wifi mode: 11n - 5ghz Wifi mode: 11n - 5ghz
Radios : ath10K(9984) 802.11an-AC Radios : ath10K(9984) 802.11an-AC (9984 are single band)
############################################# #############################################
24 Ghz 24 Ghz
############################################# #############################################
Wifi mode: 11ax - 24ghz Wifi mode: 11ax - 24ghz
Radios : ax200 - 802.11 /b/g/n/AX Radios : ax200 - 802.11 /b/g/n/AX
Wifi mode: 11ac - 24ghz Wifi mode: 11ac - 24ghz
Radios : ax200 802.11 /b/g/n/AX (2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway) Radios : ax200 802.11 /b/g/n/AX (2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway) (invalid)
Wifi mode: 11n - 24ghz Wifi mode: 11n - 24ghz
Radios : ax200 802.11 /b/g/n/AX Radios : ax200 802.11 /b/g/n/AX
@@ -1361,13 +1322,19 @@ Radios : ax200 802.11 /b/g/n/AX
Wifi mode: 11bg - 24ghz Wifi mode: 11bg - 24ghz
Radios : ax200 802.11 /b/g/n/AX Radios : ax200 802.11 /b/g/n/AX
Wifi mode: 11bg ############################################
Radio support for specific Modes
############################################
cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg":
radios = radio_AX200_abgn_ax_dict[cisco_client_density]
cisco_wifimode == "an" or cisco_wifimode == "anAC":
radios = radio_ath10K_9984_an_AC_dict[cisco_client_density]
############################################
Eventual Realm at Cisco
############################################
TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corresponds to the shelf
1.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn 1.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn
1.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn 1.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn
@@ -1458,10 +1425,10 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
parser.add_argument('-r','--radio', action='append', nargs=1, help='--radio \ parser.add_argument('-r','--radio', action='append', nargs=1, help='--radio \
\"radio==<number_of_wiphy stations=<=number of stations> ssid==<ssid> ssid_pw==<ssid password> security==<security> wifimode==<wifimode>\" '\ \"radio==<number_of_wiphy stations=<=number of stations> ssid==<ssid> ssid_pw==<ssid password> security==<security> wifimode==<wifimode>\" '\
, required=False) , required=False)
parser.add_argument('-amr','--side_a_min_rate', help='--side_a_min_rate, station min tx rate default 256000', default=256000) parser.add_argument('-amr','--side_a_min_bps', help='--side_a_min_bps, station min tx bits per second default 256000', default=256000)
#parser.add_argument('-bmr','--side_a_min_pdu', help='--side_a_min_pdu , station ipdu size default 1518', default=1518) parser.add_argument('-amp','--side_a_min_pdu', help='--side_a_min_pdu , station ipdu size default 1518', default=1518)
parser.add_argument('-bmr','--side_b_min_rate', help='--side_b_min_rate , upstream min tx rate default 256000', default=256000) parser.add_argument('-bmr','--side_b_min_bps', help='--side_b_min_bps , upstream min tx rate default 256000', default=256000)
#parser.add_argument('-bmr','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default=1518) parser.add_argument('-bmp','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default=1518)
# Parameters that allow for testing # Parameters that allow for testing
parser.add_argument('-noc','--no_controller', help='--no_controller no configuration of the controller', action='store_true') parser.add_argument('-noc','--no_controller', help='--no_controller no configuration of the controller', action='store_true')
@@ -1544,7 +1511,6 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] ['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radio_AX200_abgn_ax_dict_one = {'1' : radio_AX200_abgn_ax_list_001_one, radio_AX200_abgn_ax_dict_one = {'1' : radio_AX200_abgn_ax_list_001_one,
'8' : radio_AX200_abgn_ax_list_010_one} '8' : radio_AX200_abgn_ax_list_010_one}
@@ -1672,15 +1638,6 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
'50' : radio_ath10K_9984_an_AC_list_050, '50' : radio_ath10K_9984_an_AC_list_050,
'200' : radio_ath9K_9984_an_AC_list_200} '200' : radio_ath9K_9984_an_AC_list_200}
#radio_ath10K_9984_an_AC_dict = [['radio==6.wiphy8 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']]
radios1 = [['radio==1.wiphy1 stations==1 ssid==jedway-wpa2-x2048-4-1 ssid_pw==jedway-wpa2-x2048-4-1 security==wpa2 wifimode==abgn'],
['radio==1.wiphy2 stations==1 ssid==jedway-wpa2-x2048-5-1 ssid_pw==jedway-wpa2-x2048-5-1 security==wpa2 wifimode==an']]
MAX_NUMBER_OF_STATIONS = 200 MAX_NUMBER_OF_STATIONS = 200
radio_name_list = [] radio_name_list = []
@@ -1726,15 +1683,20 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
# cisco_ap_modes = "local flex".split() # cisco_ap_modes = "local flex".split()
cisco_ap_modes = "local".split() cisco_ap_modes = "local".split()
cisco_data_encryptions = "disable".split() cisco_data_encryptions = "disable".split()
endp_types = "lf_udp lf_tcp" cisco_packet_types = "lf_udp lf_tcp".split()
cisco_directions = "upstream downstream".split()
cisco_packet_sizes = "1518".split() cisco_packet_sizes = "1518".split()
cisco_client_densities = "1".split() cisco_client_densities = "1".split()
cisco_data_encryptions = "disable".split() cisco_data_encryptions = "disable".split()
cisco_side_a_min_bps = 500000000
cisco_side_b_min_bps = 500000000
radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_one radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_one
radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_one radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_one
elif args.cisco_test: elif args.cisco_test:
# Note the local system only supports 802.11-abgn , 802.11a
cisco_aps = "APA453.0E7B.CF9C".split() cisco_aps = "APA453.0E7B.CF9C".split()
cisco_bands = "a".split() cisco_bands = "a".split()
#cisco_wifimodes = "an anAX anAC abgn bg".split() #cisco_wifimodes = "an anAX anAC abgn bg".split()
@@ -1745,11 +1707,18 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
cisco_chan_widths = "20".split() cisco_chan_widths = "20".split()
cisco_ap_modes = "local".split() cisco_ap_modes = "local".split()
cisco_data_encryptions = "disable".split() cisco_data_encryptions = "disable".split()
endp_types = "lf_udp lf_tcp" cisco_packet_types = "lf_udp lf_tcp".split()
#cisco_packet_types = "lf_udp".split()
#cisco_directions = "upstream downstream".split()
cisco_directions = "upstream downstream".split()
cisco_packet_sizes = "88 512 1370 1518".split() cisco_packet_sizes = "88 512 1370 1518".split()
#cisco_packet_sizes = "1518".split()
cisco_client_densities = "1".split() cisco_client_densities = "1".split()
cisco_data_encryptions = "disable".split() cisco_data_encryptions = "disable".split()
cisco_side_a_min_bps = 500000000
cisco_side_b_min_bps = 500000000
radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_test radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_test
radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_test radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_test
@@ -1769,12 +1738,16 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
cisco_chan_widths = args.cisco_chan_width.split() cisco_chan_widths = args.cisco_chan_width.split()
cisco_ap_modes = args.cisco_ap_mode.split() cisco_ap_modes = args.cisco_ap_mode.split()
cisco_client_densities = args.cisco_client_density.split() cisco_client_densities = args.cisco_client_density.split()
endp_types = "lf_udp lf_tcp".split()
cisco_packet_types = args.endp_type.split() cisco_packet_types = args.endp_type.split()
cisco_directions = "upstream downstream".split()
cisco_packet_sizes = args.cisco_packet_size.split() cisco_packet_sizes = args.cisco_packet_size.split()
cisco_client_densities = args.cisco_client_density.split() cisco_client_densities = args.cisco_client_density.split()
cisco_data_encryptions = args.cisco_data_encryption.split() cisco_data_encryptions = args.cisco_data_encryption.split()
cisco_side_a_min_bps = args.side_a_min_bps
cisco_side_a_min_bps = args.side_b_min_bps
logg.info(cisco_aps) logg.info(cisco_aps)
logg.info(cisco_bands) logg.info(cisco_bands)
logg.info(cisco_wifimodes) logg.info(cisco_wifimodes)
@@ -1782,38 +1755,62 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
logg.info(cisco_chan_widths) logg.info(cisco_chan_widths)
logg.info(cisco_ap_modes) logg.info(cisco_ap_modes)
logg.info(cisco_client_densities) logg.info(cisco_client_densities)
logg.info(endp_types) logg.info(cisco_packet_types)
logg.info(cisco_packet_sizes) logg.info(cisco_packet_sizes)
logg.info(cisco_client_densities) logg.info(cisco_client_densities)
logg.info(cisco_data_encryptions) logg.info(cisco_data_encryptions)
ap_set = None
band_set = None
chan_width_set = None
ap_mode_set = None
tx_power_set = None
for cisco_ap in cisco_aps: for cisco_ap in cisco_aps:
for cisco_band in cisco_bands: # frequency for cisco_band in cisco_bands: # frequency
for cisco_wifimode in cisco_wifimodes: for cisco_wifimode in cisco_wifimodes:
# check for valid frequency and wifi_mode combination put here to simplify logic since all radios do not support all modes
# "an anAX anAC abgn bg"
if((cisco_band == "a" and cisco_wifimode == "bg") or (cisco_band == "b" and cisco_wifimode == "anAC")):
pass # invalid combination continue
else:
for cisco_chan_width in cisco_chan_widths: #bandwidth for cisco_chan_width in cisco_chan_widths: #bandwidth
for cisco_data_encryption in cisco_data_encryptions: for cisco_data_encryption in cisco_data_encryptions:
for cisco_ap_mode in cisco_ap_modes: for cisco_ap_mode in cisco_ap_modes:
for cisco_client_density in cisco_client_densities: for cisco_client_density in cisco_client_densities:
for cisco_packet_type in cisco_packet_types:
for cisco_direction in cisco_directions:
for cisco_packet_size in cisco_packet_sizes: for cisco_packet_size in cisco_packet_sizes:
logg.info("#####################################################")
logg.info("###########################################################################################################################################") logg.info("# TEST RUNNING , TEST RUNNING ######################")
logg.info("# TEST RUNNING , TEST RUNNING ############################################################################################################") logg.info("#####################################################")
logg.info("###########################################################################################################################################") test_config = "AP=={} Band=={} wifi_mode=={} BW=={} encryption=={} ap_mode=={} clients=={} packet_type=={} direction=={} packet_size=={}".format(cisco_ap,
test_config = "AP=={} Band=={} wifi_mode=={} BW=={} encryption=={} ap_mode=={} clients=={} packet_size=={}".format(cisco_ap, cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density,
cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density,cisco_packet_size) cisco_packet_type,cisco_direction,cisco_packet_size)
print(test_config) test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_type','direction','packet_size']
test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_size'] logg.info("# Cisco run settings: {}".format(test_config))
logg.info("# Cisco static settings: tx_power {} chan_5ghz {} chan_24ghz {} ".format(cisco_tx_power, cisco_chan_5ghz, cisco_chan_24ghz))
logg.info("# Cisco run Dynamic settings: {}".format(test_config))
logg.info("###########################################################################################################################################")
logg.info("###########################################################################################################################################")
# over write the configurations of args for controller
if(args.no_controller): if(args.no_controller):
logg.info("#########################################################################################################################################") logg.info("################################################")
logg.info("# NO CONTROLLER SET") logg.info("# NO CONTROLLER SET , TEST MODE")
logg.info("#########################################################################################################################################") logg.info("################################################")
else: else:
if( cisco_ap != ap_set or
cisco_band != band_set or
cisco_chan_width != chan_width_set or
cisco_ap_mode != ap_mode_set or
cisco_tx_power != tx_power_set
):
logg.info("###############################################")
logg.info("# NEW CONTROLLER CONFIG")
logg.info("###############################################")
ap_set = cisco_ap
band_set = cisco_band
chan_width_set = cisco_chan_width
ap_mode_set = cisco_ap_mode
tx_power_set = cisco_tx_power
#############################################
# configure cisco controller
#############################################
cisco_args.cisco_ap = cisco_ap cisco_args.cisco_ap = cisco_ap
cisco_args.cisco_band = cisco_band cisco_args.cisco_band = cisco_band
if cisco_band == "a": if cisco_band == "a":
@@ -1842,20 +1839,48 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
cisco.controller_create_wlan() cisco.controller_create_wlan()
cisco.controller_set_wireless_tag_policy() cisco.controller_set_wireless_tag_policy()
cisco.controller_enable_wlan() cisco.controller_enable_wlan()
if cisco_band == "a":
cisco.controller_enable_network_5ghz() cisco.controller_enable_network_5ghz()
else:
cisco.controller_enable_network_24ghz() cisco.controller_enable_network_24ghz()
cisco.controller_enable_ap() cisco.controller_enable_ap()
# need to actually check the CAC timer # need to actually check the CAC timer
time.sleep(30) time.sleep(30)
####################################
# TODO may need a static list of radios read for scaling and performance # end of cisco controller code
####################################
else:
logg.info("###############################################")
logg.info("# NO CHANGE TO CONTROLLER CONFIG")
logg.info("###############################################")
logg.info("cisco_wifi_mode {}".format(cisco_wifimode)) logg.info("cisco_wifi_mode {}".format(cisco_wifimode))
if args.radio: if args.radio:
radios = args.radio radios = args.radio
elif cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg": elif cisco_band == "a":
if cisco_wifimode == "anAX" or cisco_wifimode == "abgn":
#AX200 dual band
radios = radio_AX200_abgn_ax_dict[cisco_client_density] radios = radio_AX200_abgn_ax_dict[cisco_client_density]
elif cisco_wifimode == "an" or cisco_wifimode == "anAC": elif cisco_wifimode == "an" or cisco_wifimode == "anAC" or cisco_wifimode =="auto":
#ath10K only supports 5Ghz
radios = radio_ath10K_9984_an_AC_dict[cisco_client_density] radios = radio_ath10K_9984_an_AC_dict[cisco_client_density]
else:
logg.info("##################################")
logg.info("# INVALID COMBINATION 5ghz")
logg.info("# Cisco run settings: {}".format(test_config))
logg.info("##################################")
exit(1)
else: # cisco_band == "b"
if cisco_wifimode == "an" or cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg" or cisco_wifimode == "auto":
#AX200 dual band
radios = radio_AX200_abgn_ax_dict[cisco_client_density]
else:
logg.info("##################################")
logg.info("# INVALID COMBINATION 24 ghz")
logg.info("# Cisco run settings: {}".format(test_config))
logg.info("##################################")
exit(1)
logg.info("radios {}".format(radios)) logg.info("radios {}".format(radios))
for radio_ in radios: for radio_ in radios:
radio_keys = ['radio','stations','ssid','ssid_pw','security','wifimode'] radio_keys = ['radio','stations','ssid','ssid_pw','security','wifimode']
@@ -1875,7 +1900,6 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
else: else:
number_of_stations_per_radio_list.append(radio_info_dict['stations']) number_of_stations_per_radio_list.append(radio_info_dict['stations'])
wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']])) wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']]))
optional_radio_reset_keys = ['reset_port_enable'] optional_radio_reset_keys = ['reset_port_enable']
radio_reset_found = True radio_reset_found = True
for key in optional_radio_reset_keys: for key in optional_radio_reset_keys:
@@ -1892,16 +1916,12 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
reset_port_enable_list.append(False) reset_port_enable_list.append(False)
reset_port_time_min_list.append('0s') reset_port_time_min_list.append('0s')
reset_port_time_max_list.append('0s') reset_port_time_max_list.append('0s')
# no stations for testing reconfiguration of the controller -
if(args.no_stations): if(args.no_stations):
logg.info("###########################################################################################################################################") logg.info("##################################")
logg.info("# NO STATIONS") logg.info("# NO STATIONS")
logg.info("###########################################################################################################################################") logg.info("##################################")
else: else:
#####################
# temp removal of loop
######################
index = 0 index = 0
station_lists = [] station_lists = []
for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list): for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list):
@@ -1913,8 +1933,14 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
padding_number_=10000, radio=radio_name_) padding_number_=10000, radio=radio_name_)
station_lists.append(station_list) station_lists.append(station_list)
index += 1 index += 1
#logg.info("endp-types: %s"%(endp_types)) # Run Traffic Upstream (STA to AP)
#enstanciate the if(cisco_direction == "upstream"):
side_a_min_bps = cisco_side_a_min_bps
side_b_min_bps = 0
# Run Traffic Downstream (AP to STA)
else:
side_a_min_bps = 0
side_b_min_bps = cisco_side_b_min_bps
# current default is to have a values # current default is to have a values
ip_var_test = L3VariableTime( ip_var_test = L3VariableTime(
lfjson_host, lfjson_host,
@@ -1923,7 +1949,7 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
number_template="00", number_template="00",
station_lists= station_lists, station_lists= station_lists,
name_prefix="LT-", name_prefix="LT-",
endp_types=endp_types, endp_type=cisco_packet_type,
tos=args.tos, tos=args.tos,
side_b=side_b, side_b=side_b,
radio_name_list=radio_name_list, radio_name_list=radio_name_list,
@@ -1937,10 +1963,10 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
reset_port_enable_list=reset_port_enable_list, reset_port_enable_list=reset_port_enable_list,
reset_port_time_min_list=reset_port_time_min_list, reset_port_time_min_list=reset_port_time_min_list,
reset_port_time_max_list=reset_port_time_max_list, reset_port_time_max_list=reset_port_time_max_list,
side_a_min_rate=args.side_a_min_rate, side_a_min_bps=side_a_min_bps,
side_a_min_pdu =args.cisco_packet_size, side_a_min_pdu =cisco_packet_size,
side_b_min_rate=args.side_b_min_rate, side_b_min_bps=side_b_min_bps,
side_b_min_pdu =args.cisco_packet_size, side_b_min_pdu =cisco_packet_size,
debug_on=debug_on, debug_on=debug_on,
outfile=csv_outfile, outfile=csv_outfile,
test_keys=test_keys, test_keys=test_keys,
@@ -1964,17 +1990,11 @@ TODO: Radio descriptions in realm , the 1. refers to the chassi hopefully corres
ssid_security_list = [] ssid_security_list = []
wifimode_list = [] wifimode_list = []
ip_var_test.cleanup() ip_var_test.cleanup()
if ( args.no_stations): if ( args.no_stations):
pass pass
else: else:
ip_var_test.passes() ip_var_test.passes()
logg.info("Full test passed, all connections increased rx bytes") logg.info("Full test passed, all connections increased rx bytes")
################################
# end of commented out loop
################################
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -0,0 +1,213 @@
#!/usr/bin/env python3
import sys
if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
import os
if 'py-json' not in sys.path:
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
from realm import Realm
from LANforge.lfcli_base import LFCliBase
from LANforge import LFUtils
import argparse
import time
import datetime
import pprint
class Test1KClients(LFCliBase):
def __init__(self,
host,
port,
upstream,
side_a_min_rate=0, side_a_max_rate=56000,
side_b_min_rate=0, side_b_max_rate=56000,
num_sta_=200,
_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),
_halt_on_error=_exit_on_error,
_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.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.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.upstream=upstream
self.name_prefix = "1k"
self.cx_profile = self.local_realm.new_l3_cx_profile()
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
self.station_profile_map = {}
def build(self):
for (radio, name_series) in self.station_radio_map.items():
print("building stations for %s"%radio)
if (name_series is None) or len(name_series) < 1:
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,
sta_names_=self.station_radio_map[radio],
dry_run=False,
up_=False,
debug=self.debug,
suppress_related_commands_=True,
use_radius=False,
hs20_enable=False,
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._pass("built stations on %s radios" % len(self.station_radio_map))
def __get_rx_values(self):
cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug)
# print(self.cx_profile.created_cx.values())
#print("==============\n", cx_list, "\n==============")
cx_rx_map = {}
for cx_name in cx_list['endpoint']:
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
return cx_rx_map
def __compare_vals(self, old_list, new_list):
passes = 0
expected_passes = 0
if len(old_list) == len(new_list):
for item, value in old_list.items():
expected_passes += 1
if new_list[item] > old_list[item]:
passes += 1
# print(item, new_list[item], old_list[item], passes, expected_passes)
if passes == expected_passes:
return True
else:
return False
else:
return False
def start(self):
print("Bringing stations up...")
prev_ip_num=0
total_num_sta=6*self.num_sta
for (radio, station_profile) in self.station_profile_map.items():
station_profile.admin_up()
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=60)
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)
if curr_ip_num == total_num_sta:
self._pass("stations on radio %s up" % radio)
else:
self._fail("FAIL: Not all stations on radio %s up" % radio)
exit(1)
cur_time = datetime.datetime.now()
# old_cx_rx_values = self.__get_rx_values() #
end_time = self.local_realm.parse_time("3m") + cur_time
self.cx_profile.start_cx() #
passes = 0
expected_passes = 0
while cur_time < end_time:
interval_time = cur_time + datetime.timedelta(minutes=1)
while cur_time < interval_time:
cur_time = datetime.datetime.now()
time.sleep(1)
cur_time = datetime.datetime.now()
if passes == expected_passes:
self._pass("PASS: All tests passed", print_pass)
def stop(self):
pass
def cleanup(self):
#self.cx_profile.cleanup_prefix()
for (radio, name_series) in self.station_radio_map.items():
sta_list= self.station_radio_map[radio]
for sta in sta_list:
self.local_realm.rm_port(sta, check_exists=True)
def main():
num_sta=200
lfjson_host = "localhost"
lfjson_port = 8080
argparser = LFCliBase.create_basic_argparse(prog=__file__,
description="creates lots of stations across multiple radios",
formatter_class=argparse.RawTextHelpFormatter)
argparser.add_argument("--sta_per_radio",
type=int,
help="number of stations per radio")
argparser.add_argument("--test_duration",
type=int,
help="length of test duration")
args = argparser.parse_args()
kilo_test = Test1KClients(lfjson_host,
lfjson_port,
upstream=args.upstream_port,
num_sta_=args.sta_per_radio,
_debug_on=args.debug)
kilo_test.cleanup()
kilo_test.build()
if not kilo_test.passes():
print("test fails")
exit(1)
kilo_test.start()
if not kilo_test.passes():
print("test fails")
exit(1)
kilo_test.stop()
if not kilo_test.passes():
print("test fails")
exit(1)
kilo_test.cleanup()
if __name__ == "__main__":
main()

View File

@@ -1,79 +1,90 @@
#!/bin/bash #!/bin/bash
#Security connection examples######################################### #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 "Beginning example_wpa_connection.py test..." # OPTION ONE: ./test_all_scripts.sh : this command runs all the scripts in the array "testCommands"
chmod +x example_wpa2_connection.py # OPTION TWO: ./test_all_scripts.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.
./example_wpa2_connection.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 #Variables
chmod +x scenario.py NUM_STA=4
./scenario.py --load BLANK SSID_USED="jedway-wpa2-x2048-5-3"
chmod +x example_wep_connection.py PASSWD_USED="jedway-wpa2-x2048-5-3"
./example_wep_connection.py --ssid jedway-wep-48 --passwd jedway-wep-48 --radio wiphy1 RADIO_USED="wiphy1"
./scenario.py --load BLANK SECURITY="wpa2"
chmod +x example_wpa3_connection.py CURR_TEST_NAME="BLANK"
./example_wpa3_connection.py CURR_TEST_NUM=0
./scenario.py --load BLANK STOP_NUM=9
chmod +x example_wpa_connection.py START_NUM=0
./example_wpa_connection.py --radio wiphy1 #Test array
./scenario.py --load BLANK testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa"
#test generic and test fileio###################################################### "./example_wpa2_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2"
#chmod +x test_fileio.py "./example_wep_connection.py --num_stations $NUM_STA --ssid jedway-wep-48 --passwd jedway-wep-48 --radio $RADIO_USED --security wep"
#./test_fileio.py "./example_wpa3_connection.py --num_stations $NUM_STA --ssid jedway-wpa3-1 --passwd jedway-wpa3-1 --radio $RADIO_USED --security wpa3"
chmod +x test_generic.py "./test_ipv4_connection.py --radio wiphy2 --num_stations $NUM_STA --ssid $SSID_USED --passwd $PASSWD_USED --security $SECURITY --debug --upstream_port eth1"
#lfping "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type lfping --dest 10.40.0.1 --security $SECURITY"
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 "./test_generic.py --mgr localhost --mgr_port 4122 --radio $RADIO_USED --ssid $SSID_USED --passwd $PASSWD_USED --num_stations $NUM_STA --type speedtest --speedtest_min_up 20 --speedtest_min_dl 20 --speedtest_max_ping 150 --security $SECURITY"
#lfcurl "./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 --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"
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 "./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m"
#generic "./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug"
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 )
#speedtest function ret_case_num(){
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 case $1 in
#iperf3 "example_wpa_connection")
./test_generic.py --num_stations 3 --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio wiphy0 echo 1 ;;
#Ipv4 connection tests########################################## "example_wpa2_connection")
chmod +x test_ipv4_connection.py echo 2 ;;
./test_ipv4_connection.py "example_wpa3_connection")
chmod +x test_ipv4_l4_ftp_upload.py echo 4 ;;
./test_ipv4_l4_ftp_upload.py "example_wep_connection")
chmod +x test_ipv4_l4_ftp_urls_per_ten.py echo 3 ;;
./test_ipv4_l4_ftp_urls_per_ten.py "test_ipv4_connection")
chmod +x test_ipv4_l4_ftp_wifi.py echo 5 ;;
./test_ipv4_l4_ftp_wifi.py "test_generic")
chmod +x test_ipv4_l4_urls_per_ten.py echo 6 ;;
./test_ipv4_l4_urls_per_ten.py "test_ipv4_l4_urls_per_ten")
chmod +x test_ipv4_l4_wifi.py echo 7 ;;
./test_ipv4_l4_wifi.py "test_ipv4_l4_wifi")
chmod +x test_ipv4_l4 echo 8 ;;
./test_ipv4_l4.py "test_ipv4_l4")
chmod +x test_ipv4_ps.py echo 9 ;;
./test_ipv4_l4_ps.py esac
chmod +x test_ipv4_ttls.py }
./test_ipv4_l4_ttls.py function blank_db() {
chmod +x test_ipv4_variable_time.py echo "Loading blank scenario..." >> ~/test_all_output_file.txt
./test_ipv4_variable_time.py ./scenario.py --load BLANK >> ~/test_all_output_file.txt
#Layer 3 tests################################################ #check_blank.py
chmod +x test_l3_longevity.py }
./test_l3_longevity.py function echo_print(){
chmod +x test_l3_powersave_traffic echo "Beginning $CURR_TEST_NAME test..." >> ~/test_all_output_file.txt
./test_l3_powersave_traffic.py }
chmod +x test_l3_scenario_traffic.py function run_test(){
./test_l3_scenario_traffic.py for i in "${testCommands[@]}"; do
chmod +x test_l3_unicast_traffic_gen.py CURR_TEST_NAME=${i%%.py*}
./test_l3_unicast_traffic_gen.py CURR_TEST_NAME=${CURR_TEST_NAME#./*}
chmod +x test_l3_WAN_LAN.py CURR_TEST_NUM=$(ret_case_num $CURR_TEST_NAME)
./test_l3_WAN_LAN.py if [[ $CURR_TEST_NUM -gt $STOP_NUM ]] || [[ $STOP_NUM -eq $CURR_NUM && $STOP_NUM -ne 0 ]]; then
#WANlink###################################################### exit 1
chmod +x test_wanlink.py fi
./test_wanlink.py if [[ $CURR_TEST_NUM -gt $START_NUM ]] || [[ $CURR_TEST_NUM -eq $START_NUM ]]; then
#IPv6 connection tests######################################## echo_print
chmod +x test_ipv6_connection.py eval $i >> ~/test_all_output_file.txt
./test_ipv6_variable_connection.py if [ $? -ne 0 ]; then
chmod +x test_ipv6_variable_time.py echo $CURR_TEST_NAME failure
./test_ipv6_variable_time.py else
#STA Connect examples######################################### echo $CURR_TEST_NAME success
chmod +x sta_connect_example.py fi
./sta_connect_example.py if [[ "${CURR_TEST_NAME}" = @(example_wpa_connection|example_wpa2_connection|example_wpa3_connection|example_wep_connection) ]]; then
chmod +x sta_connect_multi_example.py blank_db
./sta_connect_multi_example.py fi
chmod +x sta_connect.py fi
./sta_connect.py done
chmod +x sta_connect2.py }
./sta_connect2.py function check_args(){
if [ ! -z $1 ]; then
START_NUM=$1
fi
if [ ! -z $2 ]; then
STOP_NUM=$2
fi
}
true > ~/test_all_output_file.txt
check_args $1 $2
run_test
#test generic and fileio are for macvlans

View File

@@ -18,6 +18,7 @@ import argparse
import realm import realm
import time import time
import datetime import datetime
import pprint
class FileIOTest(LFCliBase): class FileIOTest(LFCliBase):
@@ -44,7 +45,12 @@ class FileIOTest(LFCliBase):
gateway=None, gateway=None,
dhcp=True, dhcp=True,
use_macvlans=False, use_macvlans=False,
use_test_groups=False,
write_only_test_group=None,
read_only_test_group=None,
port_list=[], port_list=[],
ip_list=None,
mode=None,
_debug_on=False, _debug_on=False,
_exit_on_error=False, _exit_on_error=False,
_exit_on_fail=False): _exit_on_fail=False):
@@ -58,14 +64,39 @@ class FileIOTest(LFCliBase):
self.password = password self.password = password
self.number_template = number_template self.number_template = number_template
self.test_duration = test_duration self.test_duration = test_duration
self.sta_list = [] self.port_list = []
self.use_macvlans = use_macvlans self.use_macvlans = use_macvlans
self.mode = mode
self.ip_list = ip_list
self.netmask = netmask
self.gateway = gateway
if self.use_macvlans: if self.use_macvlans:
if macvlan_parent != None: if macvlan_parent is not None:
self.macvlan_parent = macvlan_parent self.macvlan_parent = macvlan_parent
self.port_list = port_list self.port_list = port_list
else: else:
self.sta_list = port_list self.port_list = port_list
self.use_test_groups = use_test_groups
if self.use_test_groups:
if self.mode == "write":
if write_only_test_group is not None:
self.write_only_test_group = write_only_test_group
else:
raise ValueError("--write_only_test_group must be used to set test group name")
if self.mode == "read":
if read_only_test_group is not None:
self.read_only_test_group = read_only_test_group
else:
raise ValueError("--read_only_test_group must be used to set test group name")
if self.mode == "both":
if write_only_test_group is not None and read_only_test_group is not None:
self.write_only_test_group = write_only_test_group
self.read_only_test_group = read_only_test_group
else:
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.min_rw_size = self.parse_size(min_rw_size)
#self.max_rw_size = self.parse_size(max_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)
@@ -76,10 +107,10 @@ class FileIOTest(LFCliBase):
#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.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port)
self.endp_profile = self.local_realm.new_fio_endp_profile() self.wo_profile = self.local_realm.new_fio_endp_profile()
self.mvlan_profile = self.local_realm.new_mvlan_profile() self.mvlan_profile = self.local_realm.new_mvlan_profile()
if len(self.sta_list) > 0: if not self.use_macvlans and len(self.port_list) > 0:
self.station_profile = self.local_realm.new_station_profile() self.station_profile = self.local_realm.new_station_profile()
self.station_profile.lfclient_url = self.lfclient_url self.station_profile.lfclient_url = self.lfclient_url
self.station_profile.ssid = self.ssid self.station_profile.ssid = self.ssid
@@ -88,20 +119,21 @@ class FileIOTest(LFCliBase):
self.station_profile.number_template_ = self.number_template self.station_profile.number_template_ = self.number_template
self.station_profile.mode = 0 self.station_profile.mode = 0
self.endp_profile.fs_type = fs_type self.wo_profile.fs_type = fs_type
self.endp_profile.min_rw_size = LFUtils.parse_size(min_rw_size) self.wo_profile.min_rw_size = LFUtils.parse_size(min_rw_size)
self.endp_profile.max_rw_size = LFUtils.parse_size(max_rw_size) self.wo_profile.max_rw_size = LFUtils.parse_size(max_rw_size)
self.endp_profile.min_file_size = LFUtils.parse_size(min_file_size) self.wo_profile.min_file_size = LFUtils.parse_size(min_file_size)
self.endp_profile.min_file_size = LFUtils.parse_size(min_file_size) self.wo_profile.max_file_size = LFUtils.parse_size(max_file_size)
self.endp_profile.min_read_rate_bps = LFUtils.parse_size(min_read_rate_bps) self.wo_profile.min_read_rate_bps = LFUtils.parse_size(min_read_rate_bps)
self.endp_profile.max_read_rate_bps = LFUtils.parse_size(max_read_rate_bps) self.wo_profile.max_read_rate_bps = LFUtils.parse_size(max_read_rate_bps)
self.endp_profile.min_write_rate_bps = LFUtils.parse_size(min_write_rate_bps) self.wo_profile.min_write_rate_bps = LFUtils.parse_size(min_write_rate_bps)
self.endp_profile.max_write_rate_bps = LFUtils.parse_size(max_write_rate_bps) self.wo_profile.max_write_rate_bps = LFUtils.parse_size(max_write_rate_bps)
self.endp_profile.directory = directory self.wo_profile.directory = directory
self.endp_profile.server_mount = server_mount self.wo_profile.server_mount = server_mount
self.ro_profile = self.endp_profile.create_ro_profile() self.ro_profile = self.wo_profile.create_ro_profile()
if self.use_macvlans:
self.mvlan_profile.num_macvlans = int(num_ports) self.mvlan_profile.num_macvlans = int(num_ports)
self.mvlan_profile.desired_macvlans = self.port_list self.mvlan_profile.desired_macvlans = self.port_list
self.mvlan_profile.macvlan_parent = self.macvlan_parent self.mvlan_profile.macvlan_parent = self.macvlan_parent
@@ -111,6 +143,20 @@ class FileIOTest(LFCliBase):
self.mvlan_profile.gateway = gateway self.mvlan_profile.gateway = gateway
self.created_ports = [] self.created_ports = []
if self.use_test_groups:
if self.mode is not None:
if self.mode.lower() == "write":
self.wo_tg_profile = self.local_realm.new_test_group_profile()
elif self.mode.lower() == "read":
self.ro_tg_profile = self.local_realm.new_test_group_profile()
elif self.mode.lower() == "both":
self.wo_tg_profile = self.local_realm.new_test_group_profile()
self.ro_tg_profile = self.local_realm.new_test_group_profile()
else:
raise ValueError("Unknown mode given ", self.mode)
else:
raise ValueError("Mode (read,write,both) must be specified")
def __compare_vals(self, val_list): def __compare_vals(self, val_list):
passes = 0 passes = 0
expected_passes = 0 expected_passes = 0
@@ -121,18 +167,18 @@ class FileIOTest(LFCliBase):
if item[0] == 'r': if item[0] == 'r':
# print("TEST", item, # print("TEST", item,
# val_list[item]['read-bps'], # val_list[item]['read-bps'],
# self.endp_profile.min_read_rate_bps, # self.ro_profile.min_read_rate_bps,
# val_list[item]['read-bps'] > self.endp_profile.min_read_rate_bps) # val_list[item]['read-bps'] > self.ro_profile.min_read_rate_bps)
if val_list[item]['read-bps'] > self.endp_profile.min_read_rate_bps: if val_list[item]['read-bps'] > self.wo_profile.min_read_rate_bps:
passes += 1 passes += 1
else: else:
# print("TEST", item, # print("TEST", item,
# val_list[item]['write-bps'], # val_list[item]['write-bps'],
# self.endp_profile.min_write_rate_bps, # self.wo_profile.min_write_rate_bps,
# val_list[item]['write-bps'] > self.endp_profile.min_write_rate_bps) # val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps)
if val_list[item]['write-bps'] > self.endp_profile.min_write_rate_bps: if val_list[item]['write-bps'] > self.wo_profile.min_write_rate_bps:
passes += 1 passes += 1
if passes == expected_passes: if passes == expected_passes:
return True return True
@@ -143,11 +189,20 @@ class FileIOTest(LFCliBase):
def __get_values(self): def __get_values(self):
time.sleep(3) time.sleep(3)
cx_list = self.json_get("fileio/%s,%s?fields=write-bps,read-bps" % (','.join(self.endp_profile.created_cx.keys()), ','.join(self.ro_profile.created_cx.keys())), if self.mode == "write":
debug_=self.debug) cx_list = self.json_get("fileio/%s?fields=write-bps,read-bps" % (
','.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)
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)
# print(cx_list) # print(cx_list)
# print("==============\n", cx_list, "\n==============") # print("==============\n", cx_list, "\n==============")
cx_map = {} cx_map = {}
# pprint.pprint(cx_list)
if cx_list is not None: if cx_list is not None:
cx_list = cx_list['endpoint'] cx_list = cx_list['endpoint']
for i in cx_list: for i in cx_list:
@@ -159,45 +214,114 @@ class FileIOTest(LFCliBase):
def build(self): def build(self):
# Build stations # Build stations
# print(self.min_tx_bps, self.min_rx_bps)
# TODO: Check for upstream port as child to bridge before macvlan create
if self.use_macvlans: if self.use_macvlans:
self.mvlan_profile.create(admin_down=True, sleep_time=.5, debug=self.debug) print("Creating MACVLANs")
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 self.created_ports += self.mvlan_profile.created_macvlans
elif not self.use_macvlans and self.ip_list is None:
if len(self.sta_list) > 0:
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) self.station_profile.set_number_template(self.number_template)
print("Creating stations") print("Creating stations")
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) 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_param("set_port", "report_timer", 1500)
self.station_profile.set_command_flag("set_port", "rpt_timer", 1) 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.port_list, debug=self.debug)
self._pass("PASS: Station build finished") self._pass("PASS: Station build finished")
self.created_ports += self.station_profile.station_names self.created_ports += self.station_profile.station_names
if self.ip_list is not None:
if self.gateway is not None and self.netmask is not None:
for num_port in range(len(self.port_list)):
shelf = self.local_realm.name_to_eid(self.port_list[num_port])[0]
resource = self.local_realm.name_to_eid(self.port_list[num_port])[1]
port = self.local_realm.name_to_eid(self.port_list[num_port])[2]
req_url = "/cli-json/set_port"
data = {
"shelf": shelf,
"resource": resource,
"port": port,
"ip_addr": self.ip_list[num_port],
"netmask": self.netmask,
"gateway": self.gateway
}
self.local_realm.json_post(req_url, data)
self.created_ports.append("%s.%s.%s" % (shelf, resource, port))
else:
raise ValueError("Netmask and gateway must be specified")
self.endp_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug, if self.mode is not None:
if self.mode.lower() == "write":
print("Creating Write Only CXs")
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
suppress_related_commands_=None)
elif self.mode.lower() == "read":
print("Creating Read Only CXs")
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
suppress_related_commands_=None)
elif self.mode.lower() == "both":
print("Creating Write Only CXs")
print("Creating Read Only CXs")
self.wo_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
suppress_related_commands_=None) suppress_related_commands_=None)
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug, self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
suppress_related_commands_=None) suppress_related_commands_=None)
if self.use_test_groups:
print("Creating test groups...")
if self.mode is not None:
if self.mode.lower() == "write":
self.wo_tg_profile.cx_list = self.wo_profile.created_cx.values()
self.wo_tg_profile.create_group(group_name=self.write_only_test_group)
elif self.mode.lower() == "read":
self.ro_tg_profile.cx_list = self.ro_profile.created_cx.values()
self.ro_tg_profile.create_group(group_name=self.read_only_test_group)
elif self.mode.lower() == "both":
self.ro_tg_profile.cx_list = self.ro_profile.created_cx.values()
self.wo_tg_profile.cx_list = self.wo_profile.created_cx.values()
self.ro_tg_profile.create_group(group_name=self.read_only_test_group)
self.wo_tg_profile.create_group(group_name=self.write_only_test_group)
else:
raise ValueError("Unknown mode given ", self.mode)
else:
raise ValueError("Mode (read,write,both) must be specified")
def start(self, print_pass=False, print_fail=False): def start(self, print_pass=False, print_fail=False):
temp_ports = self.port_list.copy() 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() self.station_profile.admin_up()
else:
self.mvlan_profile.admin_up() self.mvlan_profile.admin_up()
exit(1) if self.local_realm.wait_for_ip(temp_ports, debug=self.debug):
if self.local_realm.wait_for_ip(temp_ports):
self._pass("All ports got IPs", print_pass) self._pass("All ports got IPs", print_pass)
else: else:
self._fail("Ports failed to get IPs", print_fail) self._fail("Ports failed to get IPs", print_fail)
cur_time = datetime.datetime.now() cur_time = datetime.datetime.now()
# print("Got Values") # print("Got Values")
end_time = self.local_realm.parse_time(self.test_duration) + cur_time end_time = self.local_realm.parse_time(self.test_duration) + cur_time
self.endp_profile.start_cx() if self.use_test_groups:
if self.mode == "write":
self.wo_tg_profile.start_group(group_name=self.write_only_test_group)
elif self.mode == "read":
self.ro_tg_profile.start_group(group_name=self.read_only_test_group)
else:
self.wo_tg_profile.start_group(group_name=self.write_only_test_group)
time.sleep(2)
self.ro_tg_profile.start_group(group_name=self.read_only_test_group)
else:
if self.mode == "write":
self.wo_profile.start_cx()
elif self.mode == "read":
self.ro_profile.start_cx()
else:
self.wo_profile.start_cx()
time.sleep(2) time.sleep(2)
self.ro_profile.start_cx() self.ro_profile.start_cx()
passes = 0 passes = 0
expected_passes = 0 expected_passes = 0
print("Starting Test...") print("Starting Test...")
@@ -225,19 +349,52 @@ class FileIOTest(LFCliBase):
self._pass("PASS: All tests passes", print_pass) self._pass("PASS: All tests passes", print_pass)
def stop(self): def stop(self):
self.endp_profile.stop_cx() if self.use_test_groups:
if self.mode == "write":
self.wo_tg_profile.stop_group(group_name=self.write_only_test_group)
elif self.mode == "read":
self.ro_tg_profile.stop_group(group_name=self.read_only_test_group)
else:
self.wo_tg_profile.stop_group(group_name=self.write_only_test_group)
time.sleep(2)
self.ro_tg_profile.stop_group(group_name=self.read_only_test_group)
else:
if self.mode == "write":
self.wo_profile.stop_cx()
elif self.mode == "read":
self.ro_profile.stop_cx() self.ro_profile.stop_cx()
else:
self.wo_profile.stop_cx()
time.sleep(2)
self.ro_profile.stop_cx()
if not self.use_macvlans:
self.station_profile.admin_down() self.station_profile.admin_down()
else:
self.mvlan_profile.admin_down() self.mvlan_profile.admin_down()
def cleanup(self, sta_list=None): def cleanup(self, port_list=None):
self.endp_profile.cleanup() if self.use_test_groups:
if self.mode == "read":
self.ro_tg_profile.remove_group(group_name=self.read_only_test_group)
elif self.mode == "write":
self.wo_tg_profile.remove_group(group_name=self.write_only_test_group)
else:
self.ro_tg_profile.remove_group(group_name=self.read_only_test_group)
self.wo_tg_profile.remove_group(group_name=self.write_only_test_group)
time.sleep(1)
self.wo_profile.cleanup()
self.ro_profile.cleanup() self.ro_profile.cleanup()
if len(self.sta_list) > 0:
self.station_profile.cleanup(sta_list) if not self.use_macvlans and self.ip_list is None:
LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, debug=self.debug) self.station_profile.cleanup(port_list)
elif self.use_macvlans:
self.mvlan_profile.cleanup() self.mvlan_profile.cleanup()
# LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=port_list, debug=self.debug)
def main(): def main():
lfjson_host = "localhost" lfjson_host = "localhost"
@@ -253,9 +410,11 @@ def main():
test_fileio.py: test_fileio.py:
-------------------- --------------------
Generic command layout: Generic command layout:
python ./test_fileio.py --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> --debug ./test_fileio.py --macvlan_parent <port> --num_ports <num ports> --use_macvlans
--first_mvlan_ip <first ip in series> --netmask <netmask to use> --gateway <gateway ip addr>
python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbps --min_write 1Gbps --server_mount 192.168.93.195:/tmp/test ./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
''') ''')
parser.add_argument('--test_duration', help='sets the duration of the test', default="5m") parser.add_argument('--test_duration', help='sets the duration of the test', default="5m")
@@ -268,7 +427,8 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
parser.add_argument('--max_read_rate_bps', help='maximum 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) parser.add_argument('--min_write_rate_bps', help='minimum bps write rate', default=10e9)
parser.add_argument('--max_write_rate_bps', help='maximum bps write rate', default="1G") parser.add_argument('--max_write_rate_bps', help='maximum bps write rate', default="1G")
parser.add_argument('--directory', help='--directory directory to read/write in. Absolute path suggested', default="AUTO") parser.add_argument('--directory', help='--directory directory to read/write in. Absolute path suggested',
default="AUTO")
parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1', parser.add_argument('--server_mount', help='--server_mount The server to mount, ex: 192.168.100.5/exports/test1',
default="10.40.0.1:/var/tmp/test") default="10.40.0.1:/var/tmp/test")
parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None) parser.add_argument('--macvlan_parent', help='specifies parent port for macvlan creation', default=None)
@@ -278,13 +438,21 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
parser.add_argument('--first_mvlan_ip', help='specifies first static ip address to be used or dhcp', 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('--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('--gateway', help='specifies default gateway to be used with static addressing', default=None)
parser.add_argument('--use_test_groups', help='will use test groups to start/stop instead of single endps/cxs',
action='store_true', default=False)
parser.add_argument('--read_only_test_group', help='specifies name to use for read only test group', default=None)
parser.add_argument('--write_only_test_group', help='specifies name to use for write only test group', default=None)
parser.add_argument('--mode', help='write,read,both', default='both', type=str)
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 }', default=None)
args = parser.parse_args() args = parser.parse_args()
port_list = [] port_list = []
if args.first_port is not None: ip_list = []
if args.first_port is not None and args.use_ports is not None:
if args.first_port.startswith("sta"): if args.first_port.startswith("sta"):
if (args.num_ports is not None) and (int(args.num_ports) > 0): if (args.num_ports is not None) and (int(args.num_ports) > 0):
start_num = int(args.first_port[4:]) start_num = int(args.first_port[3:])
num_ports = int(args.num_ports) 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, port_list = LFUtils.port_name_series(prefix="sta", start_id=start_num, end_id=start_num+num_ports-1,
padding_number=10000, padding_number=10000,
@@ -302,6 +470,7 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
"first_port must contain parent port and num_ports must be greater than 0" "first_port must contain parent port and num_ports must be greater than 0"
% (args.num_ports, args.macvlan_parent, args.first_port)) % (args.num_ports, args.macvlan_parent, args.first_port))
else: else:
if args.use_ports is None:
num_ports = int(args.num_ports) num_ports = int(args.num_ports)
if not args.use_macvlans: if not args.use_macvlans:
port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1, port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1,
@@ -311,18 +480,35 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0, port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0,
end_id=num_ports - 1, padding_number=100000, end_id=num_ports - 1, padding_number=100000,
radio=args.radio) radio=args.radio)
else:
temp_list = args.use_ports.split(',')
for port in temp_list:
port_list.append(port.split('=')[0])
ip_list.append(port.split('=')[1])
if len(port_list) != len(ip_list):
raise ValueError(temp_list, " ports must have matching ip addresses!")
print(port_list)
print(ip_list)
if args.first_mvlan_ip is not None:
if args.first_mvlan_ip.lower() == "dhcp": if args.first_mvlan_ip.lower() == "dhcp":
dhcp = True dhcp = True
else: else:
dhcp = False dhcp = False
print(port_list) else:
dhcp = True
# print(port_list)
# exit(1)
ip_test = FileIOTest(args.mgr, ip_test = FileIOTest(args.mgr,
args.mgr_port, args.mgr_port,
ssid=args.ssid, ssid=args.ssid,
password=args.passwd, password=args.passwd,
security=args.security, security=args.security,
port_list=port_list, port_list=port_list,
ip_list=ip_list,
test_duration=args.test_duration, test_duration=args.test_duration,
upstream_port=args.upstream_port, upstream_port=args.upstream_port,
_debug_on=args.debug, _debug_on=args.debug,
@@ -344,7 +530,11 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
max_write_rate_bps=args.max_write_rate_bps, max_write_rate_bps=args.max_write_rate_bps,
directory=args.directory, directory=args.directory,
server_mount=args.server_mount, server_mount=args.server_mount,
num_ports=args.num_ports num_ports=args.num_ports,
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,
mode=args.mode
# want a mount options param # want a mount options param
) )
@@ -352,7 +542,6 @@ python3 ./test_fileio.py --upstream_port eth1 --fio_type fe_nfs4 --min_read 1Mbp
ip_test.build() ip_test.build()
if not ip_test.passes(): if not ip_test.passes():
print(ip_test.get_fail_message()) print(ip_test.get_fail_message())
exit(1)
ip_test.start(False, False) ip_test.start(False, False)
ip_test.stop() ip_test.stop()
if not ip_test.passes(): if not ip_test.passes():

View File

@@ -19,7 +19,7 @@ import datetime
import json import json
class GenTest(LFCliBase): class GenTest(LFCliBase):
def __init__(self, host, port, ssid, security, password, sta_list, name_prefix, upstream, def __init__(self, host, port, ssid, security, passwd, sta_list, name_prefix, upstream,
number_template="000", test_duration="5m", type="lfping", dest=None, cmd =None, number_template="000", test_duration="5m", type="lfping", dest=None, cmd =None,
interval=1, radio=None, speedtest_min_up=None, speedtest_min_dl=None, speedtest_max_ping=None, interval=1, radio=None, speedtest_min_up=None, speedtest_min_dl=None, speedtest_max_ping=None,
_debug_on=False, _debug_on=False,
@@ -31,7 +31,7 @@ class GenTest(LFCliBase):
self.upstream = upstream self.upstream = upstream
self.sta_list = sta_list self.sta_list = sta_list
self.security = security self.security = security
self.password = password self.passwd = passwd
self.number_template = number_template self.number_template = number_template
self.name_prefix = name_prefix self.name_prefix = name_prefix
self.test_duration = test_duration self.test_duration = test_duration
@@ -48,7 +48,7 @@ class GenTest(LFCliBase):
self.station_profile.lfclient_url = self.lfclient_url self.station_profile.lfclient_url = self.lfclient_url
self.station_profile.ssid = self.ssid self.station_profile.ssid = self.ssid
self.station_profile.ssid_pass = self.password, self.station_profile.ssid_pass = self.passwd,
self.station_profile.security = self.security self.station_profile.security = self.security
self.station_profile.number_template_ = self.number_template self.station_profile.number_template_ = self.number_template
self.station_profile.mode = 0 self.station_profile.mode = 0
@@ -155,7 +155,7 @@ class GenTest(LFCliBase):
self.station_profile.admin_down() self.station_profile.admin_down()
def build(self): def build(self):
self.station_profile.use_security(self.security, self.ssid, self.password) self.station_profile.use_security(self.security, self.ssid, self.passwd)
self.station_profile.set_number_template(self.number_template) self.station_profile.set_number_template(self.number_template)
print("Creating stations") print("Creating stations")
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
@@ -194,6 +194,20 @@ python3 ./test_generic.py --upstream_port eth1
--test_duration 2m --test_duration 2m
--interval 1s --interval 1s
--debug --debug
Example commands:
LFPING:
./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy0 --num_stations 3 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --type lfping --dest 10.40.0.1 --security wpa2
LFCURL (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 lfcurl --dest 10.40.0.1
GENERIC:
./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 generic
SPEEDTEST:
./test_generic.py --mgr localhost --mgr_port 4122 --radio wiphy2 --num_stations 3 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --type speedtest --speedtest_min_up 20
--speedtest_min_dl 20 --speedtest_max_ping 150 --security wpa2
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
''') ''')
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")
@@ -228,7 +242,7 @@ python3 ./test_generic.py --upstream_port eth1
interval=1, interval=1,
ssid=args.ssid, ssid=args.ssid,
upstream=args.upstream_port, upstream=args.upstream_port,
password=args.passwd, passwd=args.passwd,
security=args.security, security=args.security,
test_duration=args.test_duration, test_duration=args.test_duration,
speedtest_min_up=args.speedtest_min_up, speedtest_min_up=args.speedtest_min_up,

View File

@@ -126,12 +126,9 @@ Generic command example:
./test_ipv4_connection.py --upstream_port eth1 \\ ./test_ipv4_connection.py --upstream_port eth1 \\
--radio wiphy0 \\ --radio wiphy0 \\
--num_stations 3 \\ --num_stations 3 \\
--security {open|wep|wpa|wpa2|wpa3} \\ --security open {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear \\ --ssid netgear \\
--passwd admin123 \\ --passwd BLANK \\
--dest 10.40.0.1 \\
--test_duration 2m \\
--interval 1s \\
--debug --debug
''') ''')
@@ -142,7 +139,6 @@ Generic command example:
num_stations_converted = int(args.num_stations) num_stations_converted = int(args.num_stations)
num_sta = num_stations_converted num_sta = num_stations_converted
ws_event = LFCliBase("192.168.200.15", 8080)
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)
ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd, ip_test = IPv4Test(lfjson_host, lfjson_port, ssid=args.ssid, password=args.passwd,
@@ -152,19 +148,20 @@ Generic command example:
ip_test.build() ip_test.build()
if not ip_test.passes(): if not ip_test.passes():
print(ip_test.get_fail_message()) print(ip_test.get_fail_message())
ws_event.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message()) ip_test.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message())
exit(1) exit(1)
ip_test.start(station_list, False, False) ip_test.start(station_list, False, False)
ip_test.stop() ip_test.stop()
if not ip_test.passes(): if not ip_test.passes():
print(ip_test.get_fail_message()) print(ip_test.get_fail_message())
ws_event.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message()) ip_test.add_event(name="test_ipv4_connection.py", message=ip_test.get_fail_message())
exit(1) exit(1)
time.sleep(30) time.sleep(30)
ip_test.cleanup(station_list) ip_test.cleanup(station_list)
if ip_test.passes(): if ip_test.passes():
print("Full test passed, all stations associated and got IP") print("Full test passed, all stations associated and got IP")
ws_event.add_event(name="test_ipv4_connection.py", message="Full test passed, all stations associated and got IP") ip_test.add_event(name="test_ipv4_connection.py", message="Full test passed, all stations associated and got IP")
#exit(1)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -173,7 +173,7 @@ def main():
--num_stations 3 \\ --num_stations 3 \\
--security {open|wep|wpa|wpa2|wpa3} \\ --security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear \\ --ssid netgear \\
--url dl http://10.40.0.1 /dev/null \\ --url "dl http://10.40.0.1 /dev/null" \\
--password admin123 \\ --password admin123 \\
--test_duration 2m \\ --test_duration 2m \\
--debug --debug

View File

@@ -165,15 +165,13 @@ def main():
test_ipv4_l4_ftp_upload.py test_ipv4_l4_ftp_upload.py
-------------------- --------------------
Generic command example: Generic command example:
python3 ./test_ipv4_l4_ftp_wifi.py --upstream_port eth1 \\ ./test_ipv4_l4_ftp_upload.py --upstream_port eth1 \\
--radio wiphy0 \\ --radio wiphy0 \\
--num_stations 3 \\ --num_stations 3 \\
--security {open|wep|wpa|wpa2|wpa3} \\ --security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear \\ --ssid netgear \\
--passwd admin123 \\ --passwd admin123 \\
--dest 10.40.0.1 \\
--test_duration 2m \\ --test_duration 2m \\
--interval 1s \\
--url "ul ftp://10.40.0.1 /dev/null" \\ --url "ul ftp://10.40.0.1 /dev/null" \\
--requests_per_ten 600 \\ --requests_per_ten 600 \\
--debug --debug

View File

@@ -33,11 +33,11 @@ class IPV4L4(LFCliBase):
self.security = security self.security = security
self.password = password self.password = password
self.url = url self.url = url
self.requests_per_ten = requests_per_ten self.requests_per_ten = int(requests_per_ten)
self.number_template = number_template self.number_template = number_template
self.sta_list = station_list self.sta_list = station_list
self.num_tests = num_tests self.num_tests = int(num_tests)
self.target_requests_per_ten = target_requests_per_ten self.target_requests_per_ten = int(target_requests_per_ten)
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 = self.local_realm.new_station_profile()
@@ -63,7 +63,7 @@ class IPV4L4(LFCliBase):
if name in self.cx_profile.created_cx.keys(): if name in self.cx_profile.created_cx.keys():
expected_passes += 1 expected_passes += 1
if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9: if info['urls/s'] * self.requests_per_ten >= self.target_requests_per_ten * .9:
# print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9) print(name, info['urls/s'], info['urls/s'] * self.requests_per_ten, self.target_requests_per_ten * .9)
passes += 1 passes += 1
return passes == expected_passes return passes == expected_passes
@@ -84,7 +84,7 @@ class IPV4L4(LFCliBase):
temp_stas = self.sta_list.copy() temp_stas = self.sta_list.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])
cur_time = datetime.datetime.now() cur_time = datetime.datetime.now()
interval_time = cur_time + datetime.timedelta(minutes=10) interval_time = cur_time + datetime.timedelta(minutes=2)
passes = 0 passes = 0
expected_passes = 0 expected_passes = 0
self.station_profile.admin_up() self.station_profile.admin_up()
@@ -99,6 +99,7 @@ class IPV4L4(LFCliBase):
expected_passes += 1 expected_passes += 1
while cur_time < interval_time: while cur_time < interval_time:
time.sleep(1) time.sleep(1)
print(".",end="")
cur_time = datetime.datetime.now() cur_time = datetime.datetime.now()
if self.cx_profile.check_errors(self.debug): if self.cx_profile.check_errors(self.debug):
@@ -110,7 +111,7 @@ class IPV4L4(LFCliBase):
else: else:
self._fail("FAIL: Errors found getting to %s " % self.url, print_fail) self._fail("FAIL: Errors found getting to %s " % self.url, print_fail)
break break
interval_time = cur_time + datetime.timedelta(minutes=10) interval_time = cur_time + datetime.timedelta(minutes=2)
if passes == expected_passes: if passes == expected_passes:
self._pass("PASS: All tests passes", print_pass) self._pass("PASS: All tests passes", print_pass)
@@ -146,9 +147,6 @@ python3 ./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 \\
--security {open|wep|wpa|wpa2|wpa3} \\ --security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear \\ --ssid netgear \\
--passwd admin123 \\ --passwd admin123 \\
--dest 10.40.0.1 \\
--test_duration 2m \\
--interval 1s \\
--requests_per_ten 600 \\ --requests_per_ten 600 \\
--num_tests 1 \\ --num_tests 1 \\
--url "dl http://10.40.0.1 /dev/null" \\ --url "dl http://10.40.0.1 /dev/null" \\
@@ -173,7 +171,7 @@ python3 ./test_ipv4_l4_urls_per_ten.py --upstream_port eth1 \\
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) radio=args.radio)
ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, upstream_port=args.upstream_port, ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio, upstream_port=args.upstream_port,
security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests, security=args.security, station_list=station_list, url=args.url, num_tests=args.num_tests,
target_requests_per_ten=args.target_per_ten, target_requests_per_ten=args.target_per_ten,
requests_per_ten=args.requests_per_ten) requests_per_ten=args.requests_per_ten)

View File

@@ -173,12 +173,10 @@ python3 ./test_ipv4_l4_wifi.py --upstream_port eth1 \\
--security {open|wep|wpa|wpa2|wpa3} \\ --security {open|wep|wpa|wpa2|wpa3} \\
--ssid netgear \\ --ssid netgear \\
--passwd admin123 \\ --passwd admin123 \\
--dest 10.40.0.1 \\
--test_duration 2m \\ --test_duration 2m \\
--interval 1s \\
--requests_per_ten 600 \\ --requests_per_ten 600 \\
--direction {ul | dl} \\ --direction {ul | dl} \\
--dest /dev/null \\ --dest /dev/null (or 10.40.0.1)\\
--debug --debug
''') ''')
@@ -197,7 +195,7 @@ python3 ./test_ipv4_l4_wifi.py --upstream_port eth1 \\
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) radio=args.radio)
ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, ip_test = IPV4L4(args.mgr, lfjson_port, ssid=args.ssid, password=args.passwd, radio=args.radio,
security=args.security, station_list=station_list, direction=args.direction,dest=args.dest, security=args.security, station_list=station_list, direction=args.direction,dest=args.dest,
test_duration=args.test_duration, upstream_port=args.upstream_port, test_duration=args.test_duration, upstream_port=args.upstream_port,
requests_per_ten=args.requests_per_ten, _debug_on=args.debug) requests_per_ten=args.requests_per_ten, _debug_on=args.debug)

View File

@@ -66,8 +66,6 @@ class IPV4VariableTime(LFCliBase):
def __get_rx_values(self): def __get_rx_values(self):
cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug) cx_list = self.json_get("endp?fields=name,rx+bytes", debug_=self.debug)
# print(self.cx_profile.created_cx.values())
# print("==============\n", cx_list, "\n==============")
cx_rx_map = {} cx_rx_map = {}
for cx_name in cx_list['endpoint']: for cx_name in cx_list['endpoint']:
if cx_name != 'uri' and cx_name != 'handler': if cx_name != 'uri' and cx_name != 'handler':
@@ -85,8 +83,6 @@ class IPV4VariableTime(LFCliBase):
expected_passes += 1 expected_passes += 1
if new_list[item] > old_list[item]: if new_list[item] > old_list[item]:
passes += 1 passes += 1
# print(item, new_list[item], old_list[item], passes, expected_passes)
if passes == expected_passes: if passes == expected_passes:
return True return True
else: else:
@@ -142,10 +138,6 @@ class IPV4VariableTime(LFCliBase):
time.sleep(1) time.sleep(1)
new_cx_rx_values = self.__get_rx_values() new_cx_rx_values = self.__get_rx_values()
# print(old_cx_rx_values, new_cx_rx_values)
# print("\n-----------------------------------")
# print(cur_time, end_time, cur_time + datetime.timedelta(minutes=1))
# print("-----------------------------------\n")
expected_passes += 1 expected_passes += 1
if self.__compare_vals(old_cx_rx_values, new_cx_rx_values): if self.__compare_vals(old_cx_rx_values, new_cx_rx_values):
passes += 1 passes += 1
@@ -183,24 +175,22 @@ def main():
prog='test_ipv4_variable_time.py', prog='test_ipv4_variable_time.py',
# formatter_class=argparse.RawDescriptionHelpFormatter, # formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
epilog='''\
Useful Information:
1. TBD
''',
description='''\ description='''\
test_ipv4_variable_time.py: test_ipv4_variable_time.py:
-------------------- ---------------------
TBD
Generic command layout: Generic command layout:
python ./test_ipv4_variable_time.py --upstream_port <port> --radio <radio 0> <stations> <ssid> <ssid password> <security type: wpa2, open, wpa3> --debug ./test_ipv4_variable_time.py
--upstream_port eth1
Note: multiple --radio switches may be entered up to the number of radios available: --radio wiphy3
--radio <radio 0> <stations> <ssid> <ssid password> --radio <radio 01> <number of last station> <ssid> <ssid password> --num_stations 4
-ssid jedway-wpa2-x2048-4-1
python3 ./test_ipv4_variable_time.py --upstream_port eth1 --radio wiphy0 32 candelaTech-wpa2-x2048-4-1 candelaTech-wpa2-x2048-4-1 wpa2 --radio wiphy1 64 candelaTech-wpa2-x2048-5-3 candelaTech-wpa2-x2048-5-3 wpa2 -passwd jedway-wpa2-x2048-4-1
--security {wpa2|open|wpa|wpa3}
--a_min 250000
--b_min 260000
--test_duration 2m
--debug
''') ''')
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)

View File

@@ -288,7 +288,6 @@ test_ipv4_ttls.py:
enable_pkc=args.enable_pkc, enable_pkc=args.enable_pkc,
) )
ttls_test.cleanup(station_list) ttls_test.cleanup(station_list)
#ttls_test.timeout = 60
ttls_test.build() ttls_test.build()
if not ttls_test.passes(): if not ttls_test.passes():
print(ttls_test.get_fail_message()) print(ttls_test.get_fail_message())

0
py-scripts/test_l3_scenario_throughput.py Normal file → Executable file
View File

345
py-scripts/test_status_msg.py Executable file
View File

@@ -0,0 +1,345 @@
#!/usr/bin/env python3
import os
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'))
import argparse
from LANforge.lfcli_base import LFCliBase
import time
from uuid import uuid1
import pprint
from pprint import pprint
class TestStatusMessage(LFCliBase):
def __init__(self, host, port,
_deep_clean=False,
_debug_on=False,
_exit_on_error=False,
_exit_on_fail=False):
super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
self.deep_clean = _deep_clean
self.check_connect()
def build(self):
"""create a new session"""
new_session = uuid1()
self.status_msg_url = "/status-msg"
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 ----- ----- ----- ----- ----- ----- ")
session_response = self.json_get(self.status_msg_url)
if self.debug:
pprint(session_response)
if "sessions" not in session_response:
print("----- ----- ----- ----- ----- BAD ----- ----- ----- ----- ----- ----- ")
self._fail("response lacks sessions element")
if len(session_response["sessions"]) < 2:
self._fail("why do we have less than two sessions?")
for session in session_response["sessions"]:
#print("----- ----- ----- ----- ----- SESSION ----- ----- ----- ----- ----- ----- ")
pprint(session)
self._pass("session created")
except ValueError as ve:
print("----- ----- ----- ----- ----- what??? ----- ----- ----- ----- ----- ----- ")
self._fail(ve)
return
def start(self, print_pass=False, print_fail=False):
"""
create a series of messages
:return: None
"""
#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")
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
})
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)
self._pass("created and listed %s messages counted"%msg_num)
def stop(self):
"""
make sure we read those messages
:return: None
"""
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 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 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:
msg_num = len(message_list_response["messages"])
elif "empty" in message_list_response:
msg_num = 0
if (msg_num == 0):
self._pass("deleted all messages in session")
else:
self._fail("failed to delete all messages in session")
# make sure we fail on removing session incorrectly
try:
if self.debug:
print("--- del -------------------- -------------------- --------------------")
self.exit_on_error=False
self.halt_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("- - - - - - - - - - - - - - - - - - - - - - -")
sessions_list_response = self.json_get("/status-msg")
if self.debug:
pprint(sessions_list_response)
session_list = sessions_list_response["sessions"]
counter = 0
for session_o in session_list:
if self.debug:
print("session %s link %s " % (self.session_url, session_o["_links"]))
if session_o["_links"] == self.session_url:
counter += 1
self._pass("session not deleted")
break
if counter == 0:
self._fail("session incorrectly deleted")
try:
if self.debug:
print("--- del -------------------- -------------------- --------------------")
self.exit_on_error=False
self.halt_on_error=False
message_response = self.json_delete(self.session_url+"/this", debug_=False)
if self.debug:
print("--- ~del -------------------- -------------------- --------------------")
except ValueError as ve:
print(ve)
sessions_list_response = self.json_get("/status-msg")
if self.debug:
pprint(sessions_list_response)
session_list = sessions_list_response["sessions"]
counter = 0
for session_o in session_list:
if session_o["_links"] == self.session_url:
counter += 1
self._fail("session not deleted: "+session_o["_links"])
break
if counter == 0:
self._pass("session correctly deleted")
# make sure we fail on removing session zero
if not self.deep_clean:
return True
print("Deleting all sessions...")
counter = 0
for session_o in session_list:
counter += 1
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")
print("deleted %s sessions" % counter)
def main():
lfjson_port = 8080
parser = LFCliBase.create_bare_argparse(
prog=__file__,
# formatter_class=argparse.RawDescriptionHelpFormatter,
formatter_class=argparse.RawTextHelpFormatter,
description="""
Test the status message passing functions of /status-msg:
- create a session: PUT /status-msg/<new-session-id>
- post message: POST /status-msg/<new-session-id>
- list sessions: GET /status-msg/
- list messages for session: GET /status-msg/<new-session-id>
- 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
""")
parser.add_argument('--action', default="run_test", help="""
Actions can be:
run_test : run a messaging test
new : create new session
update : add message to session, requires --session, --key, --message
read : read message(s) from session, requires --session
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('--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')
args = parser.parse_args()
status_messages = TestStatusMessage(args.mgr,
lfjson_port,
_debug_on=False,
_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, {})
else:
u = uuid1()
status_messages.json_put("/status-msg/"+u, {})
print("created session /status-msg/"+u)
return
if args.action == "update":
if args.session is None:
print("requires --session")
return
if args.key is None:
print("requires --key")
return
if args.message is None:
print("requires --message")
return
status_messages.json_post("/status-msg/"+args.session, {
"key": args.key,
"content-type": "text/plain",
"message": args.message
})
return
if args.action == "list":
if args.session is None:
response_o = status_messages.json_get("/status-msg/")
pprint(response_o["sessions"])
else:
response_o = status_messages.json_get("/status-msg/"+args.session)
pprint(response_o["messages"])
return
if args.action == "read":
if args.session is None:
print("requires --session")
return
response_o = status_messages.json_get("/status-msg/"+args.session)
pprint(response_o)
return
if args.action == "delete":
if args.session is None:
print("requires --session")
return
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
status_messages.build()
if not status_messages.passes():
print(status_messages.get_fail_message())
exit(1)
status_messages.start(False, False)
status_messages.stop()
if not status_messages.passes():
print(status_messages.get_fail_message())
exit(1)
status_messages.cleanup()
if status_messages.passes():
print("Full test passed, all messages read and cleaned up")
exit(0)
if __name__ == "__main__":
main()

140
py-scripts/testgroup.py Executable file
View File

@@ -0,0 +1,140 @@
#!/usr/bin/env python3
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('../py-json')
from LANforge.lfcli_base import LFCliBase
from LANforge.LFUtils import *
from LANforge import LFUtils
import argparse
import realm
class TestGroup(LFCliBase):
def __init__(self, host, port,
group_name=None,
add_cx_list=[],
rm_cx_list=[],
tg_action=None,
cx_action=None,
list_groups=None,
show_group=None):
self.local_realm = realm.Realm(lfclient_host=host, lfclient_port=port)
self.tg_profile = self.local_realm.new_test_group_profile()
if group_name is None and list_groups is None and (tg_action is not None or cx_action is not None or
add_cx_list is not None or rm_cx_list is not None or show_group is not None):
raise ValueError("Group name must be set if manipulating test groups")
else:
self.tg_profile.group_name = group_name
self.tg_action = tg_action
self.cx_action = cx_action
self.list_groups = list_groups
self.show_group = show_group
self.add_cx_list = add_cx_list
self.rm_cx_list = rm_cx_list
def do_cx_action(self):
if self.cx_action == 'start':
print("Starting %s" % self.tg_profile.group_name)
self.tg_profile.start_group()
elif self.cx_action == 'stop':
print("Stopping %s" % self.tg_profile.group_name)
self.tg_profile.stop_group()
elif self.cx_action == 'quiesce':
print("Quiescing %s" % self.tg_profile.group_name)
self.tg_profile.quiesce_group()
def do_tg_action(self):
if self.tg_action == 'add':
print("Creating %s" % self.tg_profile.group_name)
self.tg_profile.create_group()
if self.tg_action == 'del':
print("Removing %s" % self.tg_profile.group_name)
if self.tg_profile.check_group_exists():
self.tg_profile.remove_group()
else:
print("%s not found, no action taken" % self.tg_profile.group_name)
def show_info(self):
if self.list_groups:
print("Current Test Groups: ")
for group in self.tg_profile.list_groups():
print(group)
if self.show_group:
print("show_group not yet implemented")
def update_cxs(self):
if len(self.add_cx_list) > 0:
for cx in self.add_cx_list:
self.tg_profile.add_cx(cx)
self.tg_profile.cx_list.append(cx)
if len(self.rm_cx_list) > 0:
for cx in self.rm_cx_list:
self.tg_profile.rm_cx(cx)
if cx in self.tg_profile.cx_list:
self.tg_profile.cx_list.remove(cx)
def main():
parser = LFCliBase.create_bare_argparse(
prog='testgroup.py',
formatter_class=argparse.RawTextHelpFormatter,
epilog='''Control and query test groups\n''',
description='''testgroup.py
--------------------
Generic command example:
''')
parser.add_argument('--group_name', help='specify the name of the test group to use', default=None)
parser.add_argument('--list_groups', help='list all existing test groups', action='store_true', default=False)
tg_group = parser.add_mutually_exclusive_group()
tg_group.add_argument('--add_group', help='add new test group', action='store_true', default=False)
tg_group.add_argument('--del_group', help='delete test group', action='store_true', default=False)
parser.add_argument('--show_group', help='show connections in current test group', action='store_true', default=False)
cx_group = parser.add_mutually_exclusive_group()
cx_group.add_argument('--start_group', help='start all cxs in chosen test group', default=None)
cx_group.add_argument('--stop_group', help='stop all cxs in chosen test group', default=None)
cx_group.add_argument('--quiesce_group', help='quiesce all cxs in chosen test groups', default=None)
parser.add_argument('--add_cx', help='add cx to chosen test group', nargs='*', default=[])
parser.add_argument('--remove_cx', help='remove cx from chosen test group', nargs='*', default=[])
args = parser.parse_args()
tg_action = None
cx_action = None
if args.add_group:
tg_action = 'add'
elif args.del_group:
tg_action = 'del'
if args.start_group:
cx_action = 'start'
elif args.stop_group:
cx_action = 'stop'
elif args.quiesce_group:
cx_action = 'quiesce'
tg = TestGroup(host=args.mgr, port=args.mgr_port,
group_name=args.group_name,
add_cx_list=args.add_cx, rm_cx_list=args.remove_cx, cx_action=cx_action,
tg_action=tg_action, list_groups=args.list_groups, show_group=args.show_group)
tg.do_tg_action()
tg.update_cxs()
tg.do_cx_action()
tg.show_info()
if __name__ == "__main__":
main()

View File

@@ -32,6 +32,7 @@ from shutil import copyfile
# For finding files # For finding files
# https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory # https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
import glob import glob
# external_results_dir=/var/tmp/lanforge # external_results_dir=/var/tmp/lanforge
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
@@ -41,10 +42,14 @@ if 'py-json' not in sys.path:
sys.path.append('../../py-json') sys.path.append('../../py-json')
from LANforge.LFUtils import * from LANforge.LFUtils import *
# if you lack __init__.py in this directory you will not find sta_connect module# # if you lack __init__.py in this directory you will not find sta_connect module#
import test_connect2 if 'py-json' not in sys.path:
from test_connect2 import TestConnect2 sys.path.append('../../py-scripts')
import sta_connect2
from sta_connect2 import StaConnect2
import testrail_api import testrail_api
from testrail_api import APIClient from testrail_api import APIClient
import eap_connect import eap_connect
@@ -55,9 +60,6 @@ from cloudsdk import CloudSDK
import ap_ssh import ap_ssh
from ap_ssh import ssh_cli_active_fw from ap_ssh import ssh_cli_active_fw
from ap_ssh import iwinfo_status from ap_ssh import iwinfo_status
import cluster_version
print(os.environ)
### Set CloudSDK URL ### ### Set CloudSDK URL ###
cloudSDK_url = os.getenv('CLOUD_SDK_URL') cloudSDK_url = os.getenv('CLOUD_SDK_URL')
@@ -65,7 +67,7 @@ cloudSDK_url=os.getenv('CLOUD_SDK_URL')
local_dir = os.getenv('SANITY_LOG_DIR') local_dir = os.getenv('SANITY_LOG_DIR')
report_path = os.getenv('SANITY_REPORT_DIR') report_path = os.getenv('SANITY_REPORT_DIR')
report_template = os.getenv('REPORT_TEMPLATE') report_template = os.getenv('REPORT_TEMPLATE')
print(report_path)
## TestRail Information ## TestRail Information
tr_user = os.getenv('TR_USER') tr_user = os.getenv('TR_USER')
tr_pw = os.getenv('TR_PWD') tr_pw = os.getenv('TR_PWD')
@@ -102,7 +104,6 @@ class GetBuild:
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
def get_latest_image(self, url): def get_latest_image(self, url):
auth = str( auth = str(
base64.b64encode( base64.b64encode(
bytes('%s:%s' % (self.user, self.password), 'utf-8') bytes('%s:%s' % (self.user, self.password), 'utf-8')
@@ -123,35 +124,38 @@ class GetBuild:
latest_fw = latest_file.replace('.tar.gz', '') latest_fw = latest_file.replace('.tar.gz', '')
return latest_fw return latest_fw
###Class for Tests ###Class for Tests
class RunTest: class RunTest:
def Single_Client_Connectivity(self, port, radio, ssid_name, ssid_psk, security, station, test_case, rid): def Single_Client_Connectivity(self, port, radio, ssid_name, ssid_psk, security, station, test_case, rid):
'''SINGLE CLIENT CONNECTIVITY using test_connect2.py''' '''SINGLE CLIENT CONNECTIVITY using test_connect2.py'''
testConnect = TestConnect2("10.10.10.201", 8080, debug_=False) staConnect = StaConnect2("10.10.10.201", 8080, debug_=False)
testConnect.sta_mode = 0 staConnect.sta_mode = 0
testConnect.upstream_resource = 1 staConnect.upstream_resource = 1
testConnect.upstream_port = port staConnect.upstream_port = port
testConnect.radio = radio staConnect.radio = radio
testConnect.resource = 1 staConnect.resource = 1
testConnect.dut_ssid = ssid_name staConnect.dut_ssid = ssid_name
testConnect.dut_passwd = ssid_psk staConnect.dut_passwd = ssid_psk
testConnect.dut_security = security staConnect.dut_security = security
testConnect.station_names = station staConnect.station_names = station
testConnect.runtime_secs = 10 staConnect.sta_prefix = 'test'
testConnect.cleanup_on_exit = True staConnect.runtime_secs = 10
# testConnect.cleanup() staConnect.bringup_time_sec = 60
testConnect.setup() staConnect.cleanup_on_exit = True
testConnect.start() # staConnect.cleanup()
print("napping %f sec" % testConnect.runtime_secs) staConnect.setup()
time.sleep(testConnect.runtime_secs) staConnect.start()
testConnect.stop() print("napping %f sec" % staConnect.runtime_secs)
testConnect.cleanup() time.sleep(staConnect.runtime_secs)
run_results = testConnect.get_result_list() staConnect.stop()
staConnect.cleanup()
run_results = staConnect.get_result_list()
for result in run_results: for result in run_results:
print("test result: " + result) print("test result: " + result)
# result = 'pass' # result = 'pass'
print("Single Client Connectivity :", testConnect.passes) print("Single Client Connectivity :", staConnect.passes)
if testConnect.passes() == True: if staConnect.passes() == True:
print("Single client connection to", ssid_name, "successful. Test Passed") print("Single client connection to", ssid_name, "successful. Test Passed")
client.update_testrail(case_id=test_case, run_id=rid, status_id=1, msg='Client connectivity passed') client.update_testrail(case_id=test_case, run_id=rid, status_id=1, msg='Client connectivity passed')
logger.info("Client connectivity to " + ssid_name + " Passed") logger.info("Client connectivity to " + ssid_name + " Passed")
@@ -199,10 +203,12 @@ class RunTest:
return ("failed") return ("failed")
def testrail_retest(self, test_case, rid, ssid_name): def testrail_retest(self, test_case, rid, ssid_name):
client.update_testrail(case_id=test_case, run_id=rid, status_id=4, msg='Error in Client Connectivity Test. Needs to be Re-run') client.update_testrail(case_id=test_case, run_id=rid, status_id=4,
msg='Error in Client Connectivity Test. Needs to be Re-run')
print("Error in test for single client connection to", ssid_name) print("Error in test for single client connection to", ssid_name)
logger.warning("ERROR testing Client connectivity to " + ssid_name) logger.warning("ERROR testing Client connectivity to " + ssid_name)
######Testrail Project and Run ID Information ############################## ######Testrail Project and Run ID Information ##############################
Test: RunTest = RunTest() Test: RunTest = RunTest()
@@ -220,18 +226,9 @@ ap_latest_dict = {
"ecw5410": "unknown" "ecw5410": "unknown"
} }
#All values start empty
ap_updated_dict = {
"ec420": "",
"ea8300": "",
"ecw5211": "",
"ecw5410": ""
}
# import json file used by throughput test # import json file used by throughput test
sanity_status = json.load(open("sanity_status.json")) sanity_status = json.load(open("sanity_status.json"))
##Equipment IDs for Lab APs under test ##Equipment IDs for Lab APs under test
from lab_ap_info import equipment_id_dict from lab_ap_info import equipment_id_dict
from lab_ap_info import profile_info_dict from lab_ap_info import profile_info_dict
@@ -239,7 +236,6 @@ from lab_ap_info import cloud_sdk_models
from lab_ap_info import equipment_ip_dict from lab_ap_info import equipment_ip_dict
from lab_ap_info import eqiupment_credentials_dict from lab_ap_info import eqiupment_credentials_dict
##Test Cases to be included in Test Runs ##Test Cases to be included in Test Runs
test_cases = [ test_cases = [
2233, 2233,
@@ -262,92 +258,22 @@ test_cases = [
5250, 5250,
5251, 5251,
5252, 5252,
5253 5253,
5540,
5541,
5542,
5543,
5544,
5545,
5546,
5547,
5548
] ]
##AP models for jfrog ##AP models for jfrog
ap_models = ["ec420", "ea8300", "ecw5211", "ecw5410"] ap_models = ["ec420", "ea8300", "ecw5211", "ecw5410"]
# ap_models = ["ecw5410"] # ap_models = ["ecw5410"]
#############################################################################
##################### CloudSDK Version ###############################
print("Getting CloudSDK version information...")
try:
cluster_ver = cluster_version.main()
#print(cluster_ver)
print("CloudSDK Version Information:")
print("-------------------------------------------")
print(cluster_ver)
print("-------------------------------------------")
cloudsdk_cluster_info = {}
for line in cluster_ver.splitlines():
(key, val) = line.split("=")
cloudsdk_cluster_info[key] = val
except:
cluster_ver = 'error'
print("ERROR: CloudSDK Version Unavailable")
cloudsdk_cluster_info = {
"date" : "unknown",
"commitId" : "unknown",
"projectVersion" : "unknown"
}
###Get Cloud Bearer Token
bearer = CloudSDK.get_bearer(cloudSDK_url)
#############################################################################
##################### CloudSDK Firmware Check ###############################
### 1) Get Token for CloudSDK ###############################################
### 2) Find Latest FW on jfrog for each AP Model ############################
### 3) Find Available FW on CloudSDK --> if Latest FW not present, upload ###
#############################################################################
###Check Latest FW Version on jfrog and CloudSDK for each model
for model in ap_models:
apModel = model
cloudModel = cloud_sdk_models[apModel]
#print(cloudModel)
###Check Latest FW on jFrog
jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
url = jfrog_url + apModel + "/dev/"
Build: GetBuild = GetBuild()
latest_image = Build.get_latest_image(url)
print(model,"Latest FW on jFrog:",latest_image)
###Check images already on CloudSDK
firmware_list_by_model = CloudSDK.CloudSDK_images(cloudModel,cloudSDK_url, bearer)
print("Available",cloudModel,"Firmware on CloudSDK:",firmware_list_by_model)
if latest_image in firmware_list_by_model:
print("Latest Firmware",latest_image,"is on CloudSDK!")
ap_latest_dict[model] = latest_image
ap_updated_dict[model] = "Up to Date"
else:
print("Latest Firmware is not on CloudSDK! Uploading...")
fw_url = "https://"+jfrog_user+":"+jfrog_pwd+"@tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + apModel + "/dev/" + latest_image + ".tar.gz"
#print(fw_url)
commit = latest_image.split("-")[-1]
fw_upload_status = CloudSDK.firwmare_upload(commit, cloudModel,latest_image,fw_url,cloudSDK_url, bearer)
#print(fw_upload_status)
fw_id = fw_upload_status['id']
print("Upload Complete.",latest_image,"FW ID is",fw_id)
ap_latest_dict[model] = latest_image
ap_updated_dict[model] = "Outdated"
sleep(1)
#print(ap_updated_dict)
if (ap_updated_dict["ec420"] == "Up to Date") and (ap_updated_dict["ea8300"] == "Up to Date") and (ap_updated_dict["ecw5211"] == "Up to Date") and (ap_updated_dict["ecw5410"] == "Up to Date"):
print("All AP FW loads up to date on CloudSDK")
logger.info("Newest builds on jfrog already loaded to CloudSDK")
else:
print("All new FW loads created on CloudSDK")
logger.info("New loads have been created on CloudSDK")
#print("Latest FW List:",ap_latest_dict)
############################################################################ ############################################################################
#################### Create Report ######################################### #################### Create Report #########################################
############################################################################ ############################################################################
@@ -361,14 +287,41 @@ except OSError:
else: else:
print("Successfully created the directory %s " % report_path) print("Successfully created the directory %s " % report_path)
#Copy report template to folder logger.info('Report data can be found here: ' + report_path + today)
# Copy report template to folder. If template doesn't exist, continue anyway with log
try:
copyfile(report_template, report_path + today + '/report.php') copyfile(report_template, report_path + today + '/report.php')
except:
print("No report template created. Report data will still be saved. Continuing with tests...")
##Create report_data dictionary ##Create report_data dictionary
tc_results = dict.fromkeys(test_cases, "not run") tc_results = dict.fromkeys(test_cases, "not run")
report_data = dict() report_data = dict()
report_data['cloud_sdk'] = cloudsdk_cluster_info report_data['cloud_sdk'] = {
"ea8300": {
"date": "unknown",
"commitId": "unknown",
"projectVersion": "unknown"
},
"ecw5211": {
"date": "unknown",
"commitId": "unknown",
"projectVersion": "unknown"
},
"ecw5410": {
"date": "unknown",
"commitId": "unknown",
"projectVersion": "unknown"
},
"ec420": {
"date": "unknown",
"commitId": "unknown",
"projectVersion": "unknown"
}
}
report_data["fw_available"] = dict.fromkeys(ap_models, "Unknown") report_data["fw_available"] = dict.fromkeys(ap_models, "Unknown")
report_data["fw_under_test"] = dict.fromkeys(ap_models, "N/A") report_data["fw_under_test"] = dict.fromkeys(ap_models, "N/A")
report_data['pass_percent'] = dict.fromkeys(ap_models, "") report_data['pass_percent'] = dict.fromkeys(ap_models, "")
@@ -381,12 +334,31 @@ report_data['tests'] = {
for key in ap_models: for key in ap_models:
report_data['tests'][key] = dict.fromkeys(test_cases, "not run") report_data['tests'][key] = dict.fromkeys(test_cases, "not run")
print(report_data)
# write to report_data contents to json file so it has something in case of unexpected fail # write to report_data contents to json file so it has something in case of unexpected fail
with open(report_path + today + '/report_data.json', 'w') as report_json_file: with open(report_path + today + '/report_data.json', 'w') as report_json_file:
json.dump(report_data, report_json_file) json.dump(report_data, report_json_file)
#################################################################################### ###Get Cloud Bearer Token
bearer = CloudSDK.get_bearer(cloudSDK_url)
############################################################################
#################### Jfrog Firmware Check ##################################
############################################################################
for model in ap_models:
apModel = model
cloudModel = cloud_sdk_models[apModel]
# print(cloudModel)
###Check Latest FW on jFrog
jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
url = jfrog_url + apModel + "/dev/"
Build: GetBuild = GetBuild()
latest_image = Build.get_latest_image(url)
print(model, "Latest FW on jFrog:", latest_image)
ap_latest_dict[model] = latest_image
#################################################################################### ####################################################################################
############ Update FW and Run Test Cases on Each AP Variant ####################### ############ Update FW and Run Test Cases on Each AP Variant #######################
#################################################################################### ####################################################################################
@@ -396,10 +368,6 @@ for key in equipment_id_dict:
##Get Bearer Token to make sure its valid (long tests can require re-auth) ##Get Bearer Token to make sure its valid (long tests can require re-auth)
bearer = CloudSDK.get_bearer(cloudSDK_url) bearer = CloudSDK.get_bearer(cloudSDK_url)
# create dictionary to track test case pass/fail
#tc_results = dict.fromkeys(test_cases, "Not Run")
#print(tc_results)
###Get Current AP Firmware and upgrade ###Get Current AP Firmware and upgrade
customer_id = "2" customer_id = "2"
equipment_id = equipment_id_dict[key] equipment_id = equipment_id_dict[key]
@@ -419,16 +387,20 @@ for key in equipment_id_dict:
fw_model = ap_cli_fw.partition("-")[0] fw_model = ap_cli_fw.partition("-")[0]
print('Current Active AP FW from CLI:', ap_cli_fw) print('Current Active AP FW from CLI:', ap_cli_fw)
###Find Latest FW for Current AP Model and Get FW ID ###Find Latest FW for Current AP Model and Get FW ID
latest_ap_image = ap_latest_dict[fw_model]
model_firmware_id = CloudSDK.get_firmware_id(latest_ap_image, cloudSDK_url, bearer)
latest_firmware_id = str(model_firmware_id)
print("Latest FW ID is:", latest_firmware_id)
##Compare Latest and Current AP FW and Upgrade ##Compare Latest and Current AP FW and Upgrade
latest_ap_image = ap_latest_dict[fw_model]
if ap_cli_fw == latest_ap_image: if ap_cli_fw == latest_ap_image:
print('FW does not require updating') print('FW does not require updating')
report_data['fw_available'][key] = "No" report_data['fw_available'][key] = "No"
logger.info(fw_model + " does not require upgrade. Not performing sanity tests for this AP variant") logger.info(fw_model + " does not require upgrade. Not performing sanity tests for this AP variant")
cloudsdk_cluster_info = {
"date": "N/A",
"commitId": "N/A",
"projectVersion": "N/A"
}
report_data['cloud_sdk'][key] = cloudsdk_cluster_info
else: else:
print('FW needs updating') print('FW needs updating')
report_data['fw_available'][key] = "Yes" report_data['fw_available'][key] = "Yes"
@@ -437,31 +409,118 @@ for key in equipment_id_dict:
###Create Test Run ###Create Test Run
today = str(date.today()) today = str(date.today())
test_run_name = "Daily_Sanity_" + fw_model + "_" + today + "_" + latest_ap_image test_run_name = "Daily_Sanity_" + fw_model + "_" + today + "_" + latest_ap_image
client.create_testrun(name=test_run_name, case_ids=test_cases, project_id=projId, milestone_id=milestoneId) client.create_testrun(name=test_run_name, case_ids=test_cases, project_id=projId, milestone_id=milestoneId,
description="Automated Nightly Sanity test run for new firmware build")
rid = client.get_run_id(test_run_name="Daily_Sanity_" + fw_model + "_" + today + "_" + latest_ap_image) rid = client.get_run_id(test_run_name="Daily_Sanity_" + fw_model + "_" + today + "_" + latest_ap_image)
print("TIP run ID is:", rid) print("TIP run ID is:", rid)
###GetCloudSDK Version
print("Getting CloudSDK version information...")
try:
cluster_ver = CloudSDK.get_cloudsdk_version(cloudSDK_url, bearer)
print("CloudSDK Version Information:")
print("-------------------------------------------")
print(cluster_ver)
print("-------------------------------------------")
cloudsdk_cluster_info = {}
cloudsdk_cluster_info['date'] = cluster_ver['commitDate']
cloudsdk_cluster_info['commitId'] = cluster_ver['commitID']
cloudsdk_cluster_info['projectVersion'] = cluster_ver['projectVersion']
report_data['cloud_sdk'][key] = cloudsdk_cluster_info
client.update_testrail(case_id="5540", run_id=rid, status_id=1,
msg='Read CloudSDK version from API successfully')
report_data['tests'][key][5540] = "passed"
except:
cluster_ver = 'error'
print("ERROR: CloudSDK Version Unavailable")
logger.info('CloudSDK version Unavailable')
cloudsdk_cluster_info = {
"date": "unknown",
"commitId": "unknown",
"projectVersion": "unknown"
}
client.update_testrail(case_id="5540", run_id=rid, status_id=5,
msg='Could not read CloudSDK version from API')
report_data['cloud_sdk'][key] = cloudsdk_cluster_info
report_data['tests'][key][5540] = "failed"
with open(report_path + today + '/report_data.json', 'w') as report_json_file:
json.dump(report_data, report_json_file)
###Test Create Firmware Version
latest_image = ap_latest_dict[key]
cloudModel = cloud_sdk_models[key]
print(cloudModel)
firmware_list_by_model = CloudSDK.CloudSDK_images(cloudModel, cloudSDK_url, bearer)
print("Available", cloudModel, "Firmware on CloudSDK:", firmware_list_by_model)
if latest_image in firmware_list_by_model:
print("Latest Firmware", latest_image, "is already on CloudSDK, need to delete to test create FW API")
old_fw_id = CloudSDK.get_firmware_id(latest_image, cloudSDK_url, bearer)
delete_fw = CloudSDK.delete_firmware(str(old_fw_id), cloudSDK_url, bearer)
fw_url = "https://" + jfrog_user + ":" + jfrog_pwd + "@tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + key + "/dev/" + latest_image + ".tar.gz"
commit = latest_image.split("-")[-1]
try:
fw_upload_status = CloudSDK.firwmare_upload(commit, cloudModel, latest_image, fw_url, cloudSDK_url,
bearer)
fw_id = fw_upload_status['id']
print("Upload Complete.", latest_image, "FW ID is", fw_id)
client.update_testrail(case_id="5548", run_id=rid, status_id=1,
msg='Create new FW version by API successful')
report_data['tests'][key][5548] = "passed"
except:
fw_upload_status = 'error'
print("Unable to upload new FW version. Skipping Sanity on AP Model")
client.update_testrail(case_id="5548", run_id=rid, status_id=5,
msg='Error creating new FW version by API')
report_data['tests'][key][5548] = "failed"
continue
else:
print("Latest Firmware is not on CloudSDK! Uploading...")
fw_url = "https://" + jfrog_user + ":" + jfrog_pwd + "@tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + key + "/dev/" + latest_image + ".tar.gz"
commit = latest_image.split("-")[-1]
try:
fw_upload_status = CloudSDK.firwmare_upload(commit, cloudModel, latest_image, fw_url, cloudSDK_url,
bearer)
fw_id = fw_upload_status['id']
print("Upload Complete.", latest_image, "FW ID is", fw_id)
client.update_testrail(case_id="5548", run_id=rid, status_id=1,
msg='Create new FW version by API successful')
report_data['tests'][key][5548] = "passed"
except:
fw_upload_status = 'error'
print("Unable to upload new FW version. Skipping Sanity on AP Model")
client.update_testrail(case_id="5548", run_id=rid, status_id=5,
msg='Error creating new FW version by API')
report_data['tests'][key][5548] = "failed"
continue
# Upgrade AP firmware # Upgrade AP firmware
upgrade_fw = CloudSDK.update_firmware(equipment_id, latest_firmware_id, cloudSDK_url, bearer) print("Upgrading...firmware ID is: ", fw_id)
upgrade_fw = CloudSDK.update_firmware(equipment_id, str(fw_id), cloudSDK_url, bearer)
logger.info("Lab " + fw_model + " Requires FW update") logger.info("Lab " + fw_model + " Requires FW update")
print(upgrade_fw) print(upgrade_fw)
if upgrade_fw["success"] == True: if upgrade_fw["success"] == True:
print("CloudSDK Upgrade Request Success") print("CloudSDK Upgrade Request Success")
report_data['tests'][key][2233] = "running" report_data['tests'][key][5547] = "passed"
#print(report_data) client.update_testrail(case_id="5547", run_id=rid, status_id=1, msg='Upgrade request using API successful')
logger.info('Firmware upgrade API successfully sent')
else: else:
print("Cloud SDK Upgrade Request Error!") print("Cloud SDK Upgrade Request Error!")
# mark upgrade test case as failed with CloudSDK error # mark upgrade test case as failed with CloudSDK error
client.update_testrail(case_id="2233", run_id=rid, status_id=5, msg='Error calling CloudSDK firmware upgrade API') client.update_testrail(case_id="5547", run_id=rid, status_id=5, msg='Error requesting upgrade via API')
report_data['tests'][key][2233] = "failed" report_data['tests'][key][5547] = "failed"
logger.warning('Firmware upgrade API failed to send')
continue continue
print("Wait for AP Upgrade")
time.sleep(300) time.sleep(300)
# Check if upgrade success is displayed on CloudSDK # Check if upgrade success is displayed on CloudSDK
cloud_ap_fw = CloudSDK.ap_firmware(customer_id, equipment_id, cloudSDK_url, bearer) cloud_ap_fw = CloudSDK.ap_firmware(customer_id, equipment_id, cloudSDK_url, bearer)
print('Current AP Firmware from CloudSDK:', cloud_ap_fw) print('Current AP Firmware from CloudSDK:', cloud_ap_fw)
logger.info('AP Firmware from CloudSDK: ' + cloud_ap_fw)
if cloud_ap_fw == "ERROR": if cloud_ap_fw == "ERROR":
print("AP FW Could not be read from CloudSDK") print("AP FW Could not be read from CloudSDK")
@@ -476,16 +535,21 @@ for key in equipment_id_dict:
ap_cli_info = ssh_cli_active_fw(ap_ip, ap_username, ap_password) ap_cli_info = ssh_cli_active_fw(ap_ip, ap_username, ap_password)
ap_cli_fw = ap_cli_info['active_fw'] ap_cli_fw = ap_cli_info['active_fw']
print("CLI reporting AP Active FW as:", ap_cli_fw) print("CLI reporting AP Active FW as:", ap_cli_fw)
logger.info('Firmware from CLI: ' + ap_cli_fw)
except: except:
ap_cli_info = "ERROR" ap_cli_info = "ERROR"
print("Cannot Reach AP CLI to confirm upgrade!") print("Cannot Reach AP CLI to confirm upgrade!")
client.update_testrail(case_id="2233", run_id=rid, status_id=4, msg='Cannot reach AP after upgrade to check CLI - re-test required') logger.warning('Cannot Reach AP CLI to confirm upgrade!')
client.update_testrail(case_id="2233", run_id=rid, status_id=4,
msg='Cannot reach AP after upgrade to check CLI - re-test required')
continue continue
if cloud_ap_fw == latest_ap_image and ap_cli_fw == latest_ap_image: if cloud_ap_fw == latest_ap_image and ap_cli_fw == latest_ap_image:
print("CloudSDK and AP CLI both show upgrade success, passing upgrade test case") print("CloudSDK and AP CLI both show upgrade success, passing upgrade test case")
client.update_testrail(case_id="2233", run_id=rid, status_id=1, msg='Upgrade to ' + latest_ap_image + ' successful') client.update_testrail(case_id="2233", run_id=rid, status_id=1,
client.update_testrail(case_id="5247", run_id=rid, status_id=1, msg='CLOUDSDK reporting correct firmware version.') msg='Upgrade to ' + latest_ap_image + ' successful')
client.update_testrail(case_id="5247", run_id=rid, status_id=1,
msg='CLOUDSDK reporting correct firmware version.')
report_data['tests'][key][2233] = "passed" report_data['tests'][key][2233] = "passed"
report_data['tests'][key][5247] = "passed" report_data['tests'][key][5247] = "passed"
print(report_data['tests'][key]) print(report_data['tests'][key])
@@ -493,8 +557,10 @@ for key in equipment_id_dict:
elif cloud_ap_fw != latest_ap_image and ap_cli_fw == latest_ap_image: elif cloud_ap_fw != latest_ap_image and ap_cli_fw == latest_ap_image:
print("AP CLI shows upgrade success - CloudSDK reporting error!") print("AP CLI shows upgrade success - CloudSDK reporting error!")
##Raise CloudSDK error but continue testing ##Raise CloudSDK error but continue testing
client.update_testrail(case_id="2233", run_id=rid, status_id=1, msg='Upgrade to ' + latest_ap_image + ' successful.') client.update_testrail(case_id="2233", run_id=rid, status_id=1,
client.update_testrail(case_id="5247", run_id=rid, status_id=5,msg='CLOUDSDK reporting incorrect firmware version.') msg='Upgrade to ' + latest_ap_image + ' successful.')
client.update_testrail(case_id="5247", run_id=rid, status_id=5,
msg='CLOUDSDK reporting incorrect firmware version.')
report_data['tests'][key][2233] = "passed" report_data['tests'][key][2233] = "passed"
report_data['tests'][key][5247] = "failed" report_data['tests'][key][5247] = "failed"
print(report_data['tests'][key]) print(report_data['tests'][key])
@@ -502,8 +568,10 @@ for key in equipment_id_dict:
elif cloud_ap_fw == latest_ap_image and ap_cli_fw != latest_ap_image: elif cloud_ap_fw == latest_ap_image and ap_cli_fw != latest_ap_image:
print("AP CLI shows upgrade failed - CloudSDK reporting error!") print("AP CLI shows upgrade failed - CloudSDK reporting error!")
# Testrail TC fail # Testrail TC fail
client.update_testrail(case_id="2233", run_id=rid, status_id=5, msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed') client.update_testrail(case_id="2233", run_id=rid, status_id=5,
client.update_testrail(case_id="5247", run_id=rid, status_id=5,msg='CLOUDSDK reporting incorrect firmware version.') msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed')
client.update_testrail(case_id="5247", run_id=rid, status_id=5,
msg='CLOUDSDK reporting incorrect firmware version.')
report_data['tests'][key][2233] = "failed" report_data['tests'][key][2233] = "failed"
report_data['tests'][key][5247] = "failed" report_data['tests'][key][5247] = "failed"
print(report_data['tests'][key]) print(report_data['tests'][key])
@@ -512,7 +580,8 @@ for key in equipment_id_dict:
elif cloud_ap_fw != latest_ap_image and ap_cli_fw != latest_ap_image: elif cloud_ap_fw != latest_ap_image and ap_cli_fw != latest_ap_image:
print("Upgrade Failed! Confirmed on CloudSDK and AP CLI. Upgrade test case failed.") print("Upgrade Failed! Confirmed on CloudSDK and AP CLI. Upgrade test case failed.")
##fail TR testcase and exit ##fail TR testcase and exit
client.update_testrail(case_id="2233", run_id=rid, status_id=5, msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed') client.update_testrail(case_id="2233", run_id=rid, status_id=5,
msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed')
report_data['tests'][key][2233] = "failed" report_data['tests'][key][2233] = "failed"
print(report_data['tests'][key]) print(report_data['tests'][key])
continue continue
@@ -520,7 +589,8 @@ for key in equipment_id_dict:
else: else:
print("Unable to determine upgrade status. Skipping AP variant") print("Unable to determine upgrade status. Skipping AP variant")
# update TR testcase as error # update TR testcase as error
client.update_testrail(case_id="2233", run_id=rid, status_id=4, msg='Cannot determine upgrade status - re-test required') client.update_testrail(case_id="2233", run_id=rid, status_id=4,
msg='Cannot determine upgrade status - re-test required')
report_data['tests'][key][2233] = "error" report_data['tests'][key][2233] = "error"
print(report_data['tests'][key]) print(report_data['tests'][key])
continue continue
@@ -574,6 +644,54 @@ for key in equipment_id_dict:
### Wait for Profile Push ### Wait for Profile Push
time.sleep(180) time.sleep(180)
###Check if VIF Config and VIF State reflect AP Profile from CloudSDK
## VIF Config
try:
ssid_config = profile_info_dict[key]["ssid_list"]
print("SSIDs in AP Profile:", ssid_config)
ssid_list = ap_ssh.get_vif_config(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF Config:", ssid_list)
if set(ssid_list) == set(ssid_config):
print("SSIDs in Wifi_VIF_Config Match AP Profile Config")
client.update_testrail(case_id="5541", run_id=rid, status_id=1,
msg='SSIDs in VIF Config matches AP Profile Config')
report_data['tests'][key][5541] = "passed"
else:
print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config")
client.update_testrail(case_id="5541", run_id=rid, status_id=5,
msg='SSIDs in VIF Config do not match AP Profile Config')
report_data['tests'][key][5541] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5541", run_id=rid, status_id=4,
msg='Cannot determine VIF Config - re-test required')
report_data['tests'][key][5541] = "error"
# VIF State
try:
ssid_state = ap_ssh.get_vif_state(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF State:", ssid_state)
if set(ssid_state) == set(ssid_config):
print("SSIDs properly applied on AP")
client.update_testrail(case_id="5544", run_id=rid, status_id=1,
msg='SSIDs in VIF Config applied to VIF State')
report_data['tests'][key][5544] = "passed"
else:
print("SSIDs not applied on AP")
client.update_testrail(case_id="5544", run_id=rid, status_id=5,
msg='SSIDs in VIF Config not applied to VIF State')
report_data['tests'][key][5544] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF State from AP CLI")
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5544", run_id=rid, status_id=4,
msg='Cannot determine VIF State - re-test required')
report_data['tests'][key][5544] = "error"
### Set LANForge port for tests ### Set LANForge port for tests
port = "eth2" port = "eth2"
@@ -582,7 +700,7 @@ for key in equipment_id_dict:
print(iwinfo) print(iwinfo)
###Run Client Single Connectivity Test Cases for Bridge SSIDs ###Run Client Single Connectivity Test Cases for Bridge SSIDs
# TC5215 - 2.4 GHz WPA2-Enterprise # TC5214 - 2.4 GHz WPA2-Enterprise
test_case = "5214" test_case = "5214"
radio = "wiphy0" radio = "wiphy0"
sta_list = ["eap5214"] sta_list = ["eap5214"]
@@ -590,7 +708,8 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
try: try:
test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, test_case, rid) test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password, test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -609,7 +728,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -628,7 +748,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -639,18 +760,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 2234 - 2.4 GHz Open
# test_case = "2234"
# radio = "wiphy0"
# station = ["test2234"]
# ssid_name = profile_info_dict[fw_model]["twoFourG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid)
# report_data['tests'][key][int(test_case)] = test_result
# time.sleep(10)
# TC5215 - 5 GHz WPA2-Enterprise # TC5215 - 5 GHz WPA2-Enterprise
test_case = "5215" test_case = "5215"
radio = "wiphy3" radio = "wiphy3"
@@ -659,7 +768,8 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
try: try:
test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, test_case, rid) test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password, test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -677,7 +787,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -696,7 +807,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -707,16 +819,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 2235 - 5 GHz Open
# test_case = "2235"
# radio = "wiphy3"
# station = ["test2235"]
# ssid_name = profile_info_dict[fw_model]["fiveG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# test_result = Test.Single_Client_Connectivity(radio, ssid_name, ssid_psk, security, station, test_case, rid)
# report_data['tests'][key][int(test_case)] = test_result
logger.info("Testing for " + fw_model + "Bridge Mode SSIDs Complete") logger.info("Testing for " + fw_model + "Bridge Mode SSIDs Complete")
with open(report_path + today + '/report_data.json', 'w') as report_json_file: with open(report_path + today + '/report_data.json', 'w') as report_json_file:
json.dump(report_data, report_json_file) json.dump(report_data, report_json_file)
@@ -733,6 +835,54 @@ for key in equipment_id_dict:
### Wait for Profile Push ### Wait for Profile Push
time.sleep(180) time.sleep(180)
###Check if VIF Config and VIF State reflect AP Profile from CloudSDK
## VIF Config
try:
ssid_config = profile_info_dict[fw_model + '_nat']["ssid_list"]
print("SSIDs in AP Profile:", ssid_config)
ssid_list = ap_ssh.get_vif_config(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF Config:", ssid_list)
if set(ssid_list) == set(ssid_config):
print("SSIDs in Wifi_VIF_Config Match AP Profile Config")
client.update_testrail(case_id="5542", run_id=rid, status_id=1,
msg='SSIDs in VIF Config matches AP Profile Config')
report_data['tests'][key][5542] = "passed"
else:
print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config")
client.update_testrail(case_id="5542", run_id=rid, status_id=5,
msg='SSIDs in VIF Config do not match AP Profile Config')
report_data['tests'][key][5542] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5542", run_id=rid, status_id=4,
msg='Cannot determine VIF Config - re-test required')
report_data['tests'][key][5542] = "error"
# VIF State
try:
ssid_state = ap_ssh.get_vif_state(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF State:", ssid_state)
if set(ssid_state) == set(ssid_config):
print("SSIDs properly applied on AP")
client.update_testrail(case_id="5545", run_id=rid, status_id=1,
msg='SSIDs in VIF Config applied to VIF State')
report_data['tests'][key][5545] = "passed"
else:
print("SSIDs not applied on AP")
client.update_testrail(case_id="5545", run_id=rid, status_id=5,
msg='SSIDs in VIF Config not applied to VIF State')
report_data['tests'][key][5545] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF State from AP CLI")
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5545", run_id=rid, status_id=4,
msg='Cannot determine VIF State - re-test required')
report_data['tests'][key][5545] = "error"
### Set LANForge port for tests ### Set LANForge port for tests
port = "eth2" port = "eth2"
@@ -749,7 +899,8 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
try: try:
test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, test_case, rid) test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password, test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -759,7 +910,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 4325 - 2.4 GHz WPA2 NAT # TC 4325 - 2.4 GHz WPA2 NAT
test_case = "4325" test_case = "4325"
radio = "wiphy0" radio = "wiphy0"
@@ -768,7 +918,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -787,7 +938,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid) test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -797,18 +949,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 4321 - 2.4 GHz Open NAT
# test_case = "4321"
# radio = "wiphy0"
# station = ["test4321"]
# ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid)
# report_data['tests'][key][int(test_case)] = test_result
# time.sleep(10)
# TC5108 - 5 GHz WPA2-Enterprise NAT # TC5108 - 5 GHz WPA2-Enterprise NAT
test_case = "5217" test_case = "5217"
radio = "wiphy3" radio = "wiphy3"
@@ -817,7 +957,8 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
try: try:
test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, test_case, rid) test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password, test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -835,7 +976,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -854,7 +996,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -865,16 +1008,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 4322 - 5 GHz Open NAT
# test_case = "4322"
# radio = "wiphy3"
# station = ["test4322"]
# ssid_name = profile_info_dict[fw_model+'_nat']["fiveG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid)
# report_data['tests'][key][int(test_case)] = test_result
logger.info("Testing for " + fw_model + "NAT Mode SSIDs Complete") logger.info("Testing for " + fw_model + "NAT Mode SSIDs Complete")
with open(report_path + today + '/report_data.json', 'w') as report_json_file: with open(report_path + today + '/report_data.json', 'w') as report_json_file:
json.dump(report_data, report_json_file) json.dump(report_data, report_json_file)
@@ -891,6 +1024,54 @@ for key in equipment_id_dict:
### Wait for Profile Push ### Wait for Profile Push
time.sleep(180) time.sleep(180)
###Check if VIF Config and VIF State reflect AP Profile from CloudSDK
## VIF Config
try:
ssid_config = profile_info_dict[fw_model + '_vlan']["ssid_list"]
print("SSIDs in AP Profile:", ssid_config)
ssid_list = ap_ssh.get_vif_config(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF Config:", ssid_list)
if set(ssid_list) == set(ssid_config):
print("SSIDs in Wifi_VIF_Config Match AP Profile Config")
client.update_testrail(case_id="5543", run_id=rid, status_id=1,
msg='SSIDs in VIF Config matches AP Profile Config')
report_data['tests'][key][5543] = "passed"
else:
print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config")
client.update_testrail(case_id="5543", run_id=rid, status_id=5,
msg='SSIDs in VIF Config do not match AP Profile Config')
report_data['tests'][key][5543] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5543", run_id=rid, status_id=4,
msg='Cannot determine VIF Config - re-test required')
report_data['tests'][key][5543] = "error"
# VIF State
try:
ssid_state = ap_ssh.get_vif_state(ap_ip, ap_username, ap_password)
print("SSIDs in AP VIF State:", ssid_state)
if set(ssid_state) == set(ssid_config):
print("SSIDs properly applied on AP")
client.update_testrail(case_id="5546", run_id=rid, status_id=1,
msg='SSIDs in VIF Config applied to VIF State')
report_data['tests'][key][5546] = "passed"
else:
print("SSIDs not applied on AP")
client.update_testrail(case_id="5546", run_id=rid, status_id=5,
msg='SSIDs in VIF Config not applied to VIF State')
report_data['tests'][key][5546] = "failed"
except:
ssid_list = "ERROR"
print("Error accessing VIF State from AP CLI")
print("Error accessing VIF Config from AP CLI")
client.update_testrail(case_id="5546", run_id=rid, status_id=4,
msg='Cannot determine VIF State - re-test required')
report_data['tests'][key][5546] = "error"
### Set port for LANForge ### Set port for LANForge
port = "vlan100" port = "vlan100"
@@ -926,7 +1107,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -945,7 +1127,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid) test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case, rid)
except: except:
test_result = "error" test_result = "error"
Test.testrail_retest(test_case, rid, ssid_name) Test.testrail_retest(test_case, rid, ssid_name)
@@ -955,18 +1138,6 @@ for key in equipment_id_dict:
time.sleep(10) time.sleep(10)
# TC 4321 - 2.4 GHz Open VLAN
# test_case = "4321"
# radio = "wiphy0"
# station = ["test4321"]
# ssid_name = profile_info_dict[fw_model+'_vlan']["twoFourG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, rid)
# report_data['tests'][key][int(test_case)] = test_result
# time.sleep(10)
# TC5108 - 5 GHz WPA2-Enterprise VLAN # TC5108 - 5 GHz WPA2-Enterprise VLAN
test_case = "5250" test_case = "5250"
radio = "wiphy3" radio = "wiphy3"
@@ -994,7 +1165,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"]
security = "wpa2" security = "wpa2"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -1013,7 +1185,8 @@ for key in equipment_id_dict:
ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"]
security = "wpa" security = "wpa"
try: try:
test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station, test_case, test_result = Test.Single_Client_Connectivity(port, radio, ssid_name, ssid_psk, security, station,
test_case,
rid) rid)
except: except:
test_result = "error" test_result = "error"
@@ -1028,9 +1201,8 @@ for key in equipment_id_dict:
logger.info("Testing for " + fw_model + "Complete") logger.info("Testing for " + fw_model + "Complete")
# Add indication of complete TC pass/fail to sanity_status for pass to external json used by Throughput Test # Add indication of complete TC pass/fail to sanity_status for pass to external json used by Throughput Test
x = all(status == "not run" for status in report_data["tests"][key].values()) x = all(status == "passed" for status in report_data["tests"][key].values())
print(x) print(x)
if x == True: if x == True:
@@ -1048,7 +1220,6 @@ for key in equipment_id_dict:
with open('sanity_status.json', 'w') as json_file: with open('sanity_status.json', 'w') as json_file:
json.dump(sanity_status, json_file) json.dump(sanity_status, json_file)
# write to report_data contents to json file so it has something in case of unexpected fail # write to report_data contents to json file so it has something in case of unexpected fail
print(report_data) print(report_data)
with open(report_path + today + '/report_data.json', 'w') as report_json_file: with open(report_path + today + '/report_data.json', 'w') as report_json_file:
@@ -1071,7 +1242,6 @@ for key in ap_models:
print(key, "pass rate is", str(percent_pass) + "%") print(key, "pass rate is", str(percent_pass) + "%")
report_data["pass_percent"][key] = str(percent_pass) + '%' report_data["pass_percent"][key] = str(percent_pass) + '%'
# write to report_data contents to json file # write to report_data contents to json file
print(report_data) print(report_data)
with open(report_path + today + '/report_data.json', 'w') as report_json_file: with open(report_path + today + '/report_data.json', 'w') as report_json_file:

View File

@@ -0,0 +1,61 @@
# TIP CICD Sanity Scripts
This directory contains scripts and modules designed for wlan sanity testing.
## Nightly Sanity
This script is used to look for and test new firmware available for the APs. AP equipment IDs and SSID information used in test is stored in the lab_ap_info file
1. Check current CloudSDK version
2. Find latest dev firmware on TIP jfrog and create instances on CloudSDK (if necessary)
3. Create report_data.json file with information about versions and test case pass/fail
4. For each AP model:
1. Check current AP firmware *(If AP already running newest firmware, test will skip)*
2. Create Testrail test run with required test cases included
3. Upgrade AP via CloudSDK API
4. Check if AP upgrade and CloudSDK connection successful
5. Test client connectivity on SSID modes, marking TestRail and report_data.json with pass/fail
6. Update sanity_status.json with **overall** pass/fail
## Throughput Test
This script is used to test UDP and TCP throughput on different modes of SSIDs, on multiple AP models. It is designed to run on APs that have successfully passed through Nightly_Sanity test.
For each AP model:
1) Read sanity_status.json to see if throughput should be run, if yes:
1) Run throughput tests on SSIDs modes
2) Record results to CSV file
2) Update sanity_status.json that throughput tests have been run
## Environment Variables
Environment variables required to run scripts and modules in this directory
#### Nightly_Sanity.py
CLOUD_SDK_URL: CloudSDK URL for API calls
SANITY_LOG_DIR: Logger file directory
SANITY_REPORT_DIR: Report file directory
REPORT_TEMPLATE: Report template path
TR_USER: TestRail Username
TR_PWD: TestRail Password
MILESTONE: TestRail Milestone ID
PROJECT_ID: TestRail Project ID
EAP_IDENTITY: EAP identity for testing
EAP_PWD: EAP password for testing
AP_USER: Username for AP
JFROG_USER: Jfrog username
JFROG_PWD: Jfrog password
#### cloudsdk.py
CLOUDSDK_USER: CloudSDK username
CLOUDSDK_PWD: CloudSDK password
#### cluster_version.py
AWS_USER: CloudSDK username
AWS_PWD: CloudSDK password
#### testrail_api.py
TR_USER tr_user TestRail Username
TR_PWD tr_pw TestRail Password
#### Throughput_Test.py
CLOUD_SDK_URL: CloudSDK URL for API calls
CSV_PATH: Path for CSV file
EAP_IDENTITY: EAP identity for testing
EAP_PWD: EAP password for testing
TPUT_LOG_DIR: Logger file directory

View File

@@ -16,6 +16,9 @@ cloudSDK_url=os.getenv('CLOUD_SDK_URL')
station = ["tput5000"] station = ["tput5000"]
runtime = 10 runtime = 10
csv_path=os.getenv('CSV_PATH') csv_path=os.getenv('CSV_PATH')
bridge_upstream_port = "eth2"
nat_upstream_port = "eth2"
vlan_upstream_port = "vlan100"
#EAP Credentials #EAP Credentials
identity=os.getenv('EAP_IDENTITY') identity=os.getenv('EAP_IDENTITY')
@@ -121,6 +124,9 @@ for key in equipment_id_dict:
print('-----------------PROFILE PUSH -------------------') print('-----------------PROFILE PUSH -------------------')
time.sleep(180) time.sleep(180)
##Set port for LANForge
port = bridge_upstream_port
# 5G WPA2 Enterprise UDP DS/US and TCP DS/US # 5G WPA2 Enterprise UDP DS/US and TCP DS/US
ap_model = fw_model ap_model = fw_model
firmware = ap_fw firmware = ap_fw
@@ -131,7 +137,7 @@ for key in equipment_id_dict:
eap_type = "TTLS" eap_type = "TTLS"
mode = "Bridge" mode = "Bridge"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password) client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port)
print(fw_model, "5 GHz WPA2-EAP throughput:\n", client_tput) print(fw_model, "5 GHz WPA2-EAP throughput:\n", client_tput)
security = "wpa2-eap" security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -145,7 +151,7 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
mode = "Bridge" mode = "Bridge"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "5 GHz WPA2 throughput:\n",client_tput) print(fw_model, "5 GHz WPA2 throughput:\n",client_tput)
security = "wpa2-psk" security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -159,7 +165,7 @@ for key in equipment_id_dict:
security = "wpa" security = "wpa"
mode = "Bridge" mode = "Bridge"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "5 GHz WPA throughput:\n",client_tput) print(fw_model, "5 GHz WPA throughput:\n",client_tput)
security = "wpa-psk" security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -173,7 +179,7 @@ for key in equipment_id_dict:
# security = "open" # security = "open"
#mode = "Bridge" #mode = "Bridge"
#mimo = mimo_5g[fw_model] #mimo = mimo_5g[fw_model]
# client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
#print(fw_model, "5 GHz Open throughput:\n",client_tput) #print(fw_model, "5 GHz Open throughput:\n",client_tput)
#throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) #throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -182,13 +188,13 @@ for key in equipment_id_dict:
firmware = ap_fw firmware = ap_fw
sta_list = station sta_list = station
radio = "wiphy0" radio = "wiphy0"
ssid_name = profile_info_dict[fw_model]["twofourG_WPA2-EAP_SSID"] ssid_name = profile_info_dict[fw_model]["twoFourG_WPA2-EAP_SSID"]
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
mode = "Bridge" mode = "Bridge"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password) ttls_password, port)
print(fw_model, "2.4 GHz WPA2-EAP throughput:\n", client_tput) print(fw_model, "2.4 GHz WPA2-EAP throughput:\n", client_tput)
security = "wpa2-eap" security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -202,7 +208,7 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
mode = "Bridge" mode = "Bridge"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "2.4 GHz WPA2 throughput:\n",client_tput) print(fw_model, "2.4 GHz WPA2 throughput:\n",client_tput)
security = "wpa2-psk" security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -216,7 +222,7 @@ for key in equipment_id_dict:
security = "wpa" security = "wpa"
mode = "Bridge" mode = "Bridge"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "2.4 GHz WPA throughput:\n",client_tput) print(fw_model, "2.4 GHz WPA throughput:\n",client_tput)
security = "wpa-psk" security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -230,7 +236,7 @@ for key in equipment_id_dict:
# security = "open" # security = "open"
#mode = "Bridge" #mode = "Bridge"
#mimo = mimo_2dot4g[fw_model] #mimo = mimo_2dot4g[fw_model]
#client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, csv_file) #client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
#print(fw_model, "2.4 GHz Open throughput:\n",client_tput) #print(fw_model, "2.4 GHz Open throughput:\n",client_tput)
#throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) #throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -248,6 +254,9 @@ for key in equipment_id_dict:
print('-----------------PROFILE PUSH -------------------') print('-----------------PROFILE PUSH -------------------')
time.sleep(180) time.sleep(180)
##Set port for LANForge
port = nat_upstream_port
# 5G WPA2 Enterprise UDP DS/US and TCP DS/US # 5G WPA2 Enterprise UDP DS/US and TCP DS/US
ap_model = fw_model ap_model = fw_model
firmware = ap_fw firmware = ap_fw
@@ -259,7 +268,7 @@ for key in equipment_id_dict:
mode = "NAT" mode = "NAT"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity,
ttls_password) ttls_password, port)
print(fw_model, "5 GHz WPA2-EAP NAT throughput:\n", client_tput) print(fw_model, "5 GHz WPA2-EAP NAT throughput:\n", client_tput)
security = "wpa2-eap" security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -273,10 +282,9 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
mode = "NAT" mode = "NAT"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
security = "wpa2-psk" client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station,
runtime)
print(fw_model, "5 GHz WPA2 NAT throughput:\n", client_tput) print(fw_model, "5 GHz WPA2 NAT throughput:\n", client_tput)
security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 5G WPA UDP DS/US and TCP DS/US # 5G WPA UDP DS/US and TCP DS/US
@@ -288,8 +296,7 @@ for key in equipment_id_dict:
security = "wpa" security = "wpa"
mode = "NAT" mode = "NAT"
mimo = mimo_5g[fw_model] mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
runtime)
print(fw_model, "5 GHz WPA NAT throughput:\n", client_tput) print(fw_model, "5 GHz WPA NAT throughput:\n", client_tput)
security = "wpa-psk" security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -303,7 +310,7 @@ for key in equipment_id_dict:
# security = "open" # security = "open"
# mode = "NAT" # mode = "NAT"
#mimo = mimo_5g[fw_model] #mimo = mimo_5g[fw_model]
# client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime) # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
# print(fw_model, "5 GHz Open NAT throughput:\n",client_tput) # print(fw_model, "5 GHz Open NAT throughput:\n",client_tput)
# throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -312,13 +319,12 @@ for key in equipment_id_dict:
firmware = ap_fw firmware = ap_fw
sta_list = station sta_list = station
radio = "wiphy0" radio = "wiphy0"
ssid_name = profile_info_dict[fw_model+'_nat']["twofourG_WPA2-EAP_SSID"] ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_WPA2-EAP_SSID"]
security = "wpa2" security = "wpa2"
eap_type = "TTLS" eap_type = "TTLS"
mode = "NAT" mode = "NAT"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port)
ttls_password)
print(fw_model, "2.4 GHz WPA2-EAP NAT throughput:\n", client_tput) print(fw_model, "2.4 GHz WPA2-EAP NAT throughput:\n", client_tput)
security = "wpa2-eap" security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -332,8 +338,7 @@ for key in equipment_id_dict:
security = "wpa2" security = "wpa2"
mode = "NAT" mode = "NAT"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
runtime)
print(fw_model, "2.4 GHz WPA2 NAT throughput:\n", client_tput) print(fw_model, "2.4 GHz WPA2 NAT throughput:\n", client_tput)
security = "wpa2-psk" security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -347,8 +352,7 @@ for key in equipment_id_dict:
security = "wpa" security = "wpa"
mode = "NAT" mode = "NAT"
mimo = mimo_2dot4g[fw_model] mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
runtime)
print(fw_model, "2.4 GHz WPA NAT throughput:\n", client_tput) print(fw_model, "2.4 GHz WPA NAT throughput:\n", client_tput)
security = "wpa-psk" security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
@@ -362,10 +366,140 @@ for key in equipment_id_dict:
# security = "open" # security = "open"
# mode = "NAT" # mode = "NAT"
#mimo = mimo_2dot4g[fw_model] #mimo = mimo_2dot4g[fw_model]
# client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, csv_file) # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
# print(fw_model, "2.4 GHz Open NAT throughput:\n",client_tput) # print(fw_model, "2.4 GHz Open NAT throughput:\n",client_tput)
# throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
###########################################################################
################# Custom VLAN Mode Throughput Testing #####################
###########################################################################
print('Testing for Custom VLAN SSIDs')
logger.info("Starting Custom VLAN SSID tput tests on " + key)
###Set Proper AP Profile for NAT SSID Tests
test_profile_id = profile_info_dict[fw_model + '_vlan']["profile_id"]
print(test_profile_id)
ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer)
### Wait for Profile Push
print('-----------------PROFILE PUSH -------------------')
time.sleep(180)
##Set port for LANForge
port = vlan_upstream_port
# 5G WPA2 Enterprise UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
sta_list = station
radio = "wiphy3"
ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2-EAP_SSID"]
security = "wpa2"
eap_type = "TTLS"
mode = "VLAN"
mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port)
print(fw_model, "5 GHz WPA2-EAP VLAN throughput:\n", client_tput)
security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 5G WPA2 VLAN UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
radio = "wiphy3"
ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_SSID"]
ssid_psk = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_PSK"]
security = "wpa2"
mode = "VLAN"
mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "5 GHz WPA2 VLAN throughput:\n", client_tput)
security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 5G WPA UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
radio = "wiphy3"
ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA_SSID"]
ssid_psk = profile_info_dict[fw_model + '_vlan']["fiveG_WPA_PSK"]
security = "wpa"
mode = "VLAN"
mimo = mimo_5g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "5 GHz WPA VLAN throughput:\n", client_tput)
security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 5G Open UDP DS/US and TCP DS/US
# ap_model = fw_model
# firmware = ap_fw
# radio = "wiphy3"
# ssid_name = profile_info_dict[fw_model+'_vlan']["fiveG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# mode = "VLAN"
# mimo = mimo_5g[fw_model]
# client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
# print(fw_model, "5 GHz Open VLAN throughput:\n",client_tput)
# throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 2.4G WPA2 Enterprise UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
sta_list = station
radio = "wiphy0"
ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2-EAP_SSID"]
security = "wpa2"
eap_type = "TTLS"
mode = "VLAN"
mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port)
print(fw_model, "2.4 GHz WPA2-EAP VLAN throughput:\n", client_tput)
security = "wpa2-eap"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 2.4G WPA2 UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
radio = "wiphy0"
ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_SSID"]
ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"]
security = "wpa2"
mode = "VLAN"
mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "2.4 GHz WPA2 VLAN throughput:\n", client_tput)
security = "wpa2-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 2.4G WPA UDP DS/US and TCP DS/US
ap_model = fw_model
firmware = ap_fw
radio = "wiphy0"
ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_SSID"]
ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"]
security = "wpa"
mode = "VLAN"
mimo = mimo_2dot4g[fw_model]
client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
print(fw_model, "2.4 GHz WPA VLAN throughput:\n", client_tput)
security = "wpa-psk"
throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
# 2.4G Open VLAN UDP DS/US and TCP DS/US
# ap_model = fw_model
# firmware = ap_fw
# radio = "wiphy3"
# ssid_name = profile_info_dict[fw_model+'_vlan']["twoFourG_OPEN_SSID"]
# ssid_psk = "BLANK"
# security = "open"
# mode = "VLAN"
# mimo = mimo_2dot4g[fw_model]
# client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port)
# print(fw_model, "2.4 GHz Open VLAN throughput:\n",client_tput)
# throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput)
#Indicates throughput has been run for AP model #Indicates throughput has been run for AP model
sanity_status['sanity_status'][key] = "tput run" sanity_status['sanity_status'][key] = "tput run"
logger.info("Trhoughput tests complete on " + key) logger.info("Trhoughput tests complete on " + key)

View File

@@ -1,3 +1,9 @@
##################################################################################
# Module contains functions to get specific data from AP CLI using SSH
#
# Used by Nightly_Sanity and Throughput_Test #####################################
##################################################################################
import paramiko import paramiko
from paramiko import SSHClient from paramiko import SSHClient
import socket import socket
@@ -63,3 +69,49 @@ def iwinfo_status(ap_ip, username, password):
except socket.timeout: except socket.timeout:
print("AP Unreachable") print("AP Unreachable")
return "ERROR" return "ERROR"
def get_vif_config(ap_ip, username, password):
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ap_ip, username=username, password=password, timeout=5)
stdin, stdout, stderr = client.exec_command(
"/usr/opensync/bin/ovsh s Wifi_VIF_Config -c | grep 'ssid :'")
output = str(stdout.read(), 'utf-8')
ssid_output = output.splitlines()
ssid_list = [s.strip('ssid : ') for s in ssid_output]
return ssid_list
except paramiko.ssh_exception.AuthenticationException:
print("Authentication Error, Check Credentials")
return "ERROR"
except paramiko.SSHException:
print("Cannot SSH to the AP")
return "ERROR"
except socket.timeout:
print("AP Unreachable")
return "ERROR"
def get_vif_state(ap_ip, username, password):
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ap_ip, username=username, password=password, timeout=5)
stdin, stdout, stderr = client.exec_command(
"/usr/opensync/bin/ovsh s Wifi_VIF_Config -c | grep 'ssid :'")
output = str(stdout.read(), 'utf-8')
ssid_output = output.splitlines()
ssid_list = [s.strip('ssid : ') for s in ssid_output]
return ssid_list
except paramiko.ssh_exception.AuthenticationException:
print("Authentication Error, Check Credentials")
return "ERROR"
except paramiko.SSHException:
print("Cannot SSH to the AP")
return "ERROR"
except socket.timeout:
print("AP Unreachable")
return "ERROR"

View File

@@ -1,5 +1,12 @@
#!/usr/bin/python3 #!/usr/bin/python3
##################################################################################
# Module contains functions to interact with CloudSDK using APIs
# Start by calling get_bearer to obtain bearer token, then other APIs can be used
#
# Used by Nightly_Sanity and Throughput_Test #####################################
##################################################################################
import base64 import base64
import urllib.request import urllib.request
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@@ -112,6 +119,15 @@ class CloudSDK:
latest_fw_id = fw_data['id'] latest_fw_id = fw_data['id']
return latest_fw_id return latest_fw_id
def delete_firmware(fw_id, cloudSDK_url, bearer):
url = cloudSDK_url + '/portal/firmware/version?firmwareVersionId=' + fw_id
payload = {}
headers = {
'Authorization': 'Bearer ' + bearer
}
response = requests.request("DELETE", url, headers=headers, data=payload)
return(response)
def update_firmware(equipment_id, latest_firmware_id, cloudSDK_url, bearer): def update_firmware(equipment_id, latest_firmware_id, cloudSDK_url, bearer):
url = cloudSDK_url+"/portal/equipmentGateway/requestFirmwareUpdate?equipmentId="+equipment_id+"&firmwareVersionId="+latest_firmware_id url = cloudSDK_url+"/portal/equipmentGateway/requestFirmwareUpdate?equipmentId="+equipment_id+"&firmwareVersionId="+latest_firmware_id
@@ -150,3 +166,16 @@ class CloudSDK:
response = requests.request("PUT", url, headers=headers, data=json.dumps(equipment_info)) response = requests.request("PUT", url, headers=headers, data=json.dumps(equipment_info))
#print(response) #print(response)
def get_cloudsdk_version(cloudSDK_url, bearer):
#print(latest_ap_image)
url = cloudSDK_url+"/ping"
payload = {}
headers = {
'Authorization': 'Bearer ' + bearer
}
response = requests.request("GET", url, headers=headers, data=payload)
cloud_sdk_version = response.json()
return cloud_sdk_version

View File

@@ -1,69 +0,0 @@
import time
from threading import Thread
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import os
import subprocess
user=os.getenv('AWS_USER')
password=os.getenv('AWS_PWD')
def main():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path='/home/netex/chromedriver', options=chrome_options)
driver.get("https://telecominfraproject.awsapps.com/start#")
time.sleep(10);
elem = driver.find_element_by_xpath('//*[@id="awsui-input-0"]')
elem.send_keys(user);
elem.send_keys(Keys.ENTER)
time.sleep(5);
elem2 = driver.find_element_by_xpath('//*[@id="awsui-input-1"]')
elem2.send_keys(password)
elem2.send_keys(Keys.ENTER)
time.sleep(10);
driver.find_element_by_xpath("//*[@id=\"app-03e8643328913682\"]").click()
time.sleep(2);
driver.find_element_by_xpath("//*[@id=\"ins-9f89e35be3e67abf\"]/div/div/img").click()
time.sleep(5);
driver.find_element_by_xpath("//*[@id=\"temp-credentials-button\"]").click()
time.sleep(2);
AWS_ACCESS_KEY_ID = driver.find_element_by_xpath("//*[@id=\"env-var-linux\"]/div[1]").text
AWS_ACCESS_KEY_ID = AWS_ACCESS_KEY_ID[26:-1]
AWS_SECRET_ACCESS_KEY = driver.find_element_by_xpath("//*[@id=\"env-var-linux\"]/div[2]").text
AWS_SECRET_ACCESS_KEY = AWS_SECRET_ACCESS_KEY[30:-1]
AWS_SESSION_TOKEN = driver.find_element_by_xpath("//*[@id=\"env-var-linux\"]/div[3]").text
AWS_SESSION_TOKEN = AWS_SESSION_TOKEN[26:-1]
driver.close()
#print (AWS_ACCESS_KEY_ID)
#print(AWS_SECRET_ACCESS_KEY)
#print(AWS_SESSION_TOKEN)
# //*[@id="env-var-linux"]/div[2]/text()
# //*[@id="env-var-linux"]/div[3]/text()
#os.chdir('/Users/bealla/.kube')
os.environ['AWS_ACCESS_KEY_ID'] = AWS_ACCESS_KEY_ID
os.environ['AWS_SECRET_ACCESS_KEY'] = AWS_SECRET_ACCESS_KEY
os.environ['AWS_SESSION_TOKEN'] = AWS_SESSION_TOKEN
get_pods = subprocess.check_output("kubectl -n tip get pods | grep tip-wlan-opensync-gw-cloud", shell=True, universal_newlines=True)
#print(get_pods)
opensync = str(get_pods.split()[0])
#print(opensync)
version_info = subprocess.check_output("kubectl exec -it -n tip "+opensync+" -- cat commit.properties", shell=True, universal_newlines=True)
return version_info

View File

@@ -1,5 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#########################################################################################################
# Built to allow connection and test of clients using EAP-TTLS.
# Functions can be called to create a station, create TCP and UDP traffic, run it a short amount of time.
#
# Used by Nightly_Sanity and Throughput_Test ############################################################
#########################################################################################################
# This will create a station, create TCP and UDP traffic, run it a short amount of time, # This will create a station, create TCP and UDP traffic, run it a short amount of time,
# and verify whether traffic was sent and received. It also verifies the station connected # and verify whether traffic was sent and received. It also verifies the station connected
# to the requested BSSID if bssid is specified as an argument. # to the requested BSSID if bssid is specified as an argument.

View File

@@ -33,10 +33,10 @@ sanity_status = {
##Equipment IDs for Lab APs under test ##Equipment IDs for Lab APs under test
equipment_id_dict = { equipment_id_dict = {
"ea8300": "13", "ea8300": "19",
"ecw5410": "12", "ecw5410": "20",
"ecw5211": "6", "ecw5211": "21",
"ec420": "11" "ec420": "27"
} }
equipment_ip_dict = { equipment_ip_dict = {
@@ -67,7 +67,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA", "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP" "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP",
"ssid_list": [
"ECW5410_5G_WPA2",
"ECW5410_5G_WPA",
"ECW5410_5G_WPA2-EAP",
"ECW5410_2dot4G_WPA2",
"ECW5410_2dot4G_WPA",
"ECW5410_2dot4G_WPA2-EAP"
]
}, },
"ea8300": { "ea8300": {
@@ -83,7 +91,19 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EA8300_2dot4G_WPA", "twoFourG_WPA_SSID":"EA8300_2dot4G_WPA",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP" "twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP",
#EA8300 has 2x 5GHz SSIDs because it is a tri-radio AP!
"ssid_list": [
"EA8300_5G_WPA2",
"EA8300_5G_WPA2",
"EA8300_5G_WPA",
"EA8300_5G_WPA",
"EA8300_5G_WPA2-EAP",
"EA8300_5G_WPA2-EAP",
"EA8300_2dot4G_WPA2",
"EA8300_2dot4G_WPA",
"EA8300_2dot4G_WPA2-EAP"
]
}, },
"ec420": { "ec420": {
@@ -99,7 +119,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EC420_2dot4G_WPA", "twoFourG_WPA_SSID":"EC420_2dot4G_WPA",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP" "twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP",
"ssid_list": [
"EC420_5G_WPA2",
"EC420_5G_WPA",
"EC420_5G_WPA2-EAP",
"EC420_2dot4G_WPA2",
"EC420_2dot4G_WPA",
"EC420_2dot4G_WPA2-EAP"
]
}, },
"ecw5211": { "ecw5211": {
@@ -115,7 +143,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA", "twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP" "twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP",
"ssid_list": [
"ECW5211_5G_WPA2",
"ECW5211_5G_WPA",
"ECW5211_5G_WPA2-EAP",
"ECW5211_2dot4G_WPA2",
"ECW5211_2dot4G_WPA",
"ECW5211_2dot4G_WPA2-EAP"
]
}, },
"ecw5410_nat": { "ecw5410_nat": {
@@ -131,7 +167,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"ECW5410_2dot4G_WPA_NAT", "twoFourG_WPA_SSID":"ECW5410_2dot4G_WPA_NAT",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_NAT" "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_NAT",
"ssid_list": [
"ECW5410_5G_WPA2_NAT",
"ECW5410_5G_WPA_NAT",
"ECW5410_5G_WPA2-EAP_NAT",
"ECW5410_2dot4G_WPA2_NAT",
"ECW5410_2dot4G_WPA_NAT",
"ECW5410_2dot4G_WPA2-EAP_NAT"
]
}, },
"ea8300_nat": { "ea8300_nat": {
@@ -147,7 +191,19 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EA8300_2dot4G_WPA_NAT", "twoFourG_WPA_SSID":"EA8300_2dot4G_WPA_NAT",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP_NAT" "twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP_NAT",
#EA8300 has 2x 5GHz SSIDs because it is a tri-radio AP!
"ssid_list": [
"EA8300_5G_WPA2_NAT",
"EA8300_5G_WPA2_NAT",
"EA8300_5G_WPA_NAT",
"EA8300_5G_WPA_NAT",
"EA8300_5G_WPA2-EAP_NAT",
"EA8300_5G_WPA2-EAP_NAT",
"EA8300_2dot4G_WPA2_NAT",
"EA8300_2dot4G_WPA_NAT",
"EA8300_2dot4G_WPA2-EAP_NAT"
]
}, },
"ec420_nat": { "ec420_nat": {
@@ -163,7 +219,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EC420_2dot4G_WPA_NAT", "twoFourG_WPA_SSID":"EC420_2dot4G_WPA_NAT",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP_NAT" "twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP_NAT",
"ssid_list": [
"EC420_5G_WPA2_NAT",
"EC420_5G_WPA_NAT",
"EC420_5G_WPA2-EAP_NAT",
"EC420_2dot4G_WPA2_NAT",
"EC420_2dot4G_WPA_NAT",
"EC420_2dot4G_WPA2-EAP_NAT"
]
}, },
"ecw5211_nat": { "ecw5211_nat": {
@@ -179,7 +243,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA_NAT", "twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA_NAT",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP_NAT" "twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP_NAT",
"ssid_list": [
"ECW5211_5G_WPA2_NAT",
"ECW5211_5G_WPA_NAT",
"ECW5211_5G_WPA2-EAP_NAT",
"ECW5211_2dot4G_WPA2_NAT",
"ECW5211_2dot4G_WPA_NAT",
"ECW5211_2dot4G_WPA2-EAP_NAT"
]
}, },
"ecw5410_vlan": { "ecw5410_vlan": {
@@ -195,7 +267,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"ECW5410_2dot4G_WPA_VLAN", "twoFourG_WPA_SSID":"ECW5410_2dot4G_WPA_VLAN",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_VLAN" "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_VLAN",
"ssid_list": [
"ECW5410_5G_WPA2_VLAN",
"ECW5410_5G_WPA_VLAN",
"ECW5410_5G_WPA2-EAP_VLAN",
"ECW5410_2dot4G_WPA2_VLAN",
"ECW5410_2dot4G_WPA_VLAN",
"ECW5410_2dot4G_WPA2-EAP_VLAN"
]
}, },
"ea8300_vlan": { "ea8300_vlan": {
@@ -211,7 +291,19 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EA8300_2dot4G_WPA_VLAN", "twoFourG_WPA_SSID":"EA8300_2dot4G_WPA_VLAN",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP_VLAN" "twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP_VLAN",
#EA8300 has 2x 5GHz SSIDs because it is a tri-radio AP!
"ssid_list": [
"EA8300_5G_WPA2_VLAN",
"EA8300_5G_WPA2_VLAN",
"EA8300_5G_WPA_VLAN",
"EA8300_5G_WPA_VLAN",
"EA8300_5G_WPA2-EAP_VLAN",
"EA8300_5G_WPA2-EAP_VLAN",
"EA8300_2dot4G_WPA2_VLAN",
"EA8300_2dot4G_WPA_VLAN",
"EA8300_2dot4G_WPA2-EAP_VLAN"
]
}, },
"ec420_vlan": { "ec420_vlan": {
@@ -227,7 +319,15 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"EC420_2dot4G_WPA_VLAN", "twoFourG_WPA_SSID":"EC420_2dot4G_WPA_VLAN",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP_VLAN" "twoFourG_WPA2-EAP_SSID": "EC420_2dot4G_WPA2-EAP_VLAN",
"ssid_list": [
"EC420_5G_WPA2_VLAN",
"EC420_5G_WPA_VLAN",
"EC420_5G_WPA2-EAP_VLAN",
"EC420_2dot4G_WPA2_VLAN",
"EC420_2dot4G_WPA_VLAN",
"EC420_2dot4G_WPA2-EAP_VLAN"
]
}, },
"ecw5211_vlan": { "ecw5211_vlan": {
@@ -243,6 +343,14 @@ profile_info_dict = {
"twoFourG_WPA2_PSK": "Connectus123$", "twoFourG_WPA2_PSK": "Connectus123$",
"twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA_VLAN", "twoFourG_WPA_SSID":"ECW5211_2dot4G_WPA_VLAN",
"twoFourG_WPA_PSK": "Connectus123$", "twoFourG_WPA_PSK": "Connectus123$",
"twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP_VLAN" "twoFourG_WPA2-EAP_SSID": "ECW5211_2dot4G_WPA2-EAP_VLAN",
"ssid_list": [
"ECW5211_5G_WPA2_VLAN",
"ECW5211_5G_WPA_VLAN",
"ECW5211_5G_WPA2-EAP_VLAN",
"ECW5211_2dot4G_WPA2_VLAN",
"ECW5211_2dot4G_WPA_VLAN",
"ECW5211_2dot4G_WPA2-EAP_VLAN"
]
} }
} }

View File

@@ -0,0 +1,401 @@
<! DOCTYPE html>
<html>
<head>
<title>Testing Report</title>
<head>
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
$results = file_get_contents('report_data.json');
$json = json_decode($results, true);
?>
<body bgcolor="grey">
<style>
.tab1 {
tab-size: 8;
}
.tab2 {
tab-size: 14;
}
.tab4 {
margin-left: 188;
}
div.sanity {
background-color: lightgray;
width: 975px;
border-style: ridge;
padding: 10px;
left: 0;
font-size: 15px;
line-height: 25px
}
</style>
<header>
<h1 style="color:green; font-size:40px; text-align: center">CICD Nightly Sanity Report - <?php echo basename(dirname(__FILE__)) ?></h1>
</header>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="4" CELLSPACING="3" Style="background-color: lightgray; font-size:16px">
<TR>
<TH COLSPAN="7"><BR><H3>Test Results</H3>
</TH>
</TR>
<TR>
<TH COLSPAN="2" ROWSPAN="7"></TH>
<TH></TH>
<TH WIDTH="150px">EA8300 Result</TH>
<TH WIDTH="150px">ECW5211 Result</TH>
<TH WIDTH="150px">ECW5410 Result</TH>
<TH WIDTH="150px">EC420 Result</TH>
</TR>
<TR ALIGN="CENTER">
<TD ALIGN="LEFT" style="font-weight:bold">New FW Available</TD>
<TD style="font-weight:bold"><?php echo print_r($json['fw_available']['ea8300'],true) ?></TD>
<TD style="font-weight:bold"><?php echo print_r($json['fw_available']['ecw5211'],true) ?></TD>
<TD style="font-weight:bold"><?php echo print_r($json['fw_available']['ecw5410'],true) ?></TD>
<TD style="font-weight:bold"><?php echo print_r($json['fw_available']['ec420'],true) ?></TD>
</TR>
<TR ALIGN="CENTER" style="font-weight:bold">
<TD ALIGN="LEFT" >FW Under Test</TD>
<TD style="font-size:12px"><?php echo print_r($json['fw_under_test']['ea8300'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['fw_under_test']['ecw5211'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['fw_under_test']['ecw5410'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['fw_under_test']['ec420'],true) ?></TD>
</TR>
<TR ALIGN="CENTER" style="font-weight:bold">
<TD ALIGN="LEFT" >CloudSDK Commit Date</TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ea8300']['date'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ecw5211']['date'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ecw5410']['date'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ec420']['date'],true) ?></TD>
</TR>
<TR ALIGN="CENTER" style="font-weight:bold">
<TD ALIGN="LEFT" >CloudSDK Commit ID</TD>
<TD style="font-size:10px"><?php echo print_r($json['cloud_sdk']['ea8300']['commitId'],true) ?></TD>
<TD style="font-size:10px"><?php echo print_r($json['cloud_sdk']['ecw5211']['commitId'],true) ?></TD>
<TD style="font-size:10px"><?php echo print_r($json['cloud_sdk']['ecw5410']['commitId'],true) ?></TD>
<TD style="font-size:10px"><?php echo print_r($json['cloud_sdk']['ec420']['commitId'],true) ?></TD>
</TR>
<TR ALIGN="CENTER" style="font-weight:bold">
<TD ALIGN="LEFT" >CloudSDK Project Version</TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ea8300']['projectVersion'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ecw5211']['projectVersion'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ecw5410']['projectVersion'],true) ?></TD>
<TD style="font-size:12px"><?php echo print_r($json['cloud_sdk']['ec420']['projectVersion'],true) ?></TD>
</TR>
<TR ALIGN="CENTER" style="font-weight:bold">
<TD ALIGN="LEFT">Test Pass Rate</TD>
<TD style="font-size:14px"><?php echo print_r($json['pass_percent']['ea8300'],true) ?></TD>
<TD style="font-size:14px"><?php echo print_r($json['pass_percent']['ecw5211'],true) ?></TD>
<TD style="font-size:14px"><?php echo print_r($json['pass_percent']['ecw5410'],true) ?></TD>
<TD style="font-size:14px"><?php echo print_r($json['pass_percent']['ec420'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TH>Test Case</TH>
<TH WIDTH= 7%">Category</TH>
<TH>Description</TH>
<TH></TH>
<TH></TH>
<TH></TH>
<TH></TH>
<TR ALIGN="CENTER">
<TD>5540</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">Get CloudSDK Version with API</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5540'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5540'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5540'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5540'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5548</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">Create FW version on CloudSDK using API</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5548'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5548'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5548'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5548'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5547</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">Request AP Upgrade using API</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5547'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5547'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5547'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5547'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>2233</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">AP Upgrade Successful</TD>
<TD><?php echo print_r($json['tests']['ea8300']['2233'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['2233'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['2233'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['2233'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5247</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">CloudSDK Reports Correct FW</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5247'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5247'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5247'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5247'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5222</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">AP-CloudSDK Connection Active </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5222'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5222'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5222'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5222'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5541</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">CloudSDK Pushes Correct AP Profile - Bridge Mode </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5541'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5541'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5541'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5541'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5544</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">AP Applies Correct AP Profile - Bridge Mode </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5544'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5544'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5544'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5544'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5214</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2-EAP - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5214'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5214'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5214'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5214'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>2237</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2 - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['2237'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['2237'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['2237'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['2237'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>2420</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['2420'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['2420'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['2420'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['2420'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5215</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2-EAP - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5215'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5215'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5215'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5215'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>2236</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2 - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['2236'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['2236'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['2236'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['2236'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>2419</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA - Bridge Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['2419'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['2419'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['2419'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['2419'],true) ?></TD>
<TR ALIGN="CENTER">
<TD>5542</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">CloudSDK Pushes Correct AP Profile - NAT Mode </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5542'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5542'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5542'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5542'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5545</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">AP Applies Correct AP Profile - NAT Mode </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5545'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5545'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5545'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5545'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5216</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2-EAP - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5216'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5216'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5216'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5216'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>4325</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2 - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['4325'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['4325'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['4325'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['4325'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>4323</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['4323'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['4323'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['4323'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['4323'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5217</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2-EAP - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5217'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5217'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5217'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5217'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>4326</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2 - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['4326'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['4326'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['4326'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['4326'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>4324</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA - NAT Mode</TD>
<TD><?php echo print_r($json['tests']['ea8300']['4324'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['4324'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['4324'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['4324'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5543</TD>
<TD>CloudSDK</TD>
<TD ALIGN="LEFT">CloudSDK Pushes Correct AP Profile - Custom VLAN </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5543'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5543'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5543'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5543'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5546</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">AP Applies Correct AP Profile - Custom VLAN </TD>
<TD><?php echo print_r($json['tests']['ea8300']['5546'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5546'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5546'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5546'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5253</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2-EAP - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5253'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5253'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5253'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5253'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5251</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA2 - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5251'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5251'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5251'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5251'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5252</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 2.4 GHz WPA - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5252'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5252'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5252'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5252'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5250</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2-EAP - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5250'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5250'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5250'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5250'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5248</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA2 - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5248'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5248'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5248'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5248'],true) ?></TD>
</TR>
<TR ALIGN="CENTER">
<TD>5249</TD>
<TD>AP</TD>
<TD ALIGN="LEFT">Client connects to 5 GHz WPA - Custom VLAN</TD>
<TD><?php echo print_r($json['tests']['ea8300']['5249'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5211']['5249'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ecw5410']['5249'],true) ?></TD>
<TD><?php echo print_r($json['tests']['ec420']['5249'],true) ?></TD>
</TR>
</TABLE>
</body>

View File

@@ -1,5 +1,18 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
####################################################################################
# Script is based off of LANForge sta_connect2.py
# Script built for max throughput testing on a single client
# The main function of the script creates a station, then tests:
# 1. UDP Downstream (AP to STA)
# 2. UDP Upstream (STA to AP)
# 3. TCP Downstream (AP to STA)
# 4. TCP Upstream (STA to AP)
# The script will clean up the station and connections at the end of the test.
#
# Used by Throughput_Test ###########################################################
####################################################################################
# Script is based off of sta_connect2.py # Script is based off of sta_connect2.py
# Script built for max throughput testing on a single client # Script built for max throughput testing on a single client
# The main function of the script creates a station, then tests: # The main function of the script creates a station, then tests:
@@ -489,7 +502,7 @@ class SingleClientEAP(LFCliBase):
self.upstream_url = None # defer construction self.upstream_url = None # defer construction
self.sta_url_map = None self.sta_url_map = None
self.upstream_resource = None self.upstream_resource = None
self.upstream_port = "eth2" self.upstream_port = None
self.station_names = [] self.station_names = []
if _sta_name is not None: if _sta_name is not None:
self.station_names = [_sta_name] self.station_names = [_sta_name]
@@ -614,7 +627,7 @@ class SingleClientEAP(LFCliBase):
# station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl()))
duration = 0 duration = 0
maxTime = 100 maxTime = 30
ip = "0.0.0.0" ip = "0.0.0.0"
ap = "" ap = ""
print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="") print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="")
@@ -863,12 +876,12 @@ class SingleClientEAP(LFCliBase):
##Main will perform 4 throughput tests on SSID provided by input and return a list with the values ##Main will perform 4 throughput tests on SSID provided by input and return a list with the values
def main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime): def main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, upstream_port):
######## Establish Client Connection ######################### ######## Establish Client Connection #########################
singleClient = SingleClient("10.10.10.201", 8080, debug_=False) singleClient = SingleClient("10.10.10.201", 8080, debug_=False)
singleClient.sta_mode = 0 singleClient.sta_mode = 0
singleClient.upstream_resource = 1 singleClient.upstream_resource = 1
singleClient.upstream_port = "eth2" singleClient.upstream_port = upstream_port
singleClient.radio = radio singleClient.radio = radio
singleClient.resource = 1 singleClient.resource = 1
singleClient.dut_ssid = ssid_name singleClient.dut_ssid = ssid_name
@@ -957,10 +970,10 @@ def main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runt
return(tput_data) return(tput_data)
def eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password): def eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, upstream_port):
eap_connect = SingleClientEAP("10.10.10.201", 8080, _debug_on=True) eap_connect = SingleClientEAP("10.10.10.201", 8080, _debug_on=False)
eap_connect.upstream_resource = 1 eap_connect.upstream_resource = 1
eap_connect.upstream_port = "eth2" eap_connect.upstream_port = upstream_port
eap_connect.security = security eap_connect.security = security
eap_connect.sta_list = sta_list eap_connect.sta_list = sta_list
eap_connect.station_names = sta_list eap_connect.station_names = sta_list

View File

@@ -1,441 +0,0 @@
#!/usr/bin/env python3
# Custom NetExperience version of sta_connect2.py - which changest he script to look for prefix "test" instead of "sta"
# This will create a station, create TCP and UDP traffic, run it a short amount of time,
# and verify whether traffic was sent and received. It also verifies the station connected
# to the requested BSSID if bssid is specified as an argument.
# The script will clean up the station and connections at the end of the test.
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('../../py-json')
import argparse
import LANforge
from LANforge import LFUtils
# from LANforge import LFCliBase
from LANforge import lfcli_base
from LANforge.lfcli_base import LFCliBase
from LANforge.LFUtils import *
import realm
from realm import Realm
import pprint
OPEN="open"
WEP="wep"
WPA="wpa"
WPA2="wpa2"
MODE_AUTO=0
class TestConnect2(LFCliBase):
def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="",
_user="", _passwd="", _sta_mode="0", _radio="wiphy0",
_resource=1, _upstream_resource=1, _upstream_port="eth1",
_sta_name=None, debug_=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=debug_, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail)
self.debug = debug_
self.dut_security = _dut_security
self.dut_ssid = _dut_ssid
self.dut_passwd = _dut_passwd
self.dut_bssid = _dut_bssid
self.user = _user
self.passwd = _passwd
self.sta_mode = _sta_mode # See add_sta LANforge CLI users guide entry
self.radio = _radio
self.resource = _resource
self.upstream_resource = _upstream_resource
self.upstream_port = _upstream_port
self.runtime_secs = _runtime_sec
self.cleanup_on_exit = _cleanup_on_exit
self.sta_url_map = None # defer construction
self.upstream_url = None # defer construction
self.station_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.resulting_stations = {}
self.resulting_endpoints = {}
self.station_profile = None
self.l3_udp_profile = None
self.l3_tcp_profile = None
# def get_realm(self) -> Realm: # py > 3.6
def get_realm(self):
return self.localrealm
def get_station_url(self, sta_name_=None):
if sta_name_ is None:
raise ValueError("get_station_url wants a station name")
if self.sta_url_map is None:
self.sta_url_map = {}
for sta_name in self.station_names:
self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, sta_name)
return self.sta_url_map[sta_name_]
def get_upstream_url(self):
if self.upstream_url is None:
self.upstream_url = "port/1/%s/%s" % (self.upstream_resource, self.upstream_port)
return self.upstream_url
# Compare pre-test values to post-test values
def compare_vals(self, name, postVal, print_pass=False, print_fail=True):
# print(f"Comparing {name}")
if postVal > 0:
self._pass("%s %s" % (name, postVal), print_pass)
else:
self._fail("%s did not report traffic: %s" % (name, postVal), print_fail)
def remove_stations(self):
for name in self.station_names:
LFUtils.removePort(self.resource, name, self.lfclient_url)
def num_associated(self, bssid):
counter = 0
# print("there are %d results" % len(self.station_results))
fields = "_links,port,alias,ip,ap,port+type"
self.station_results = self.localrealm.find_ports_like("test*", 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)
if record["ap"] == bssid:
counter += 1
#print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")
return counter
def clear_test_results(self):
self.resulting_stations = {}
self.resulting_endpoints = {}
super().clear_test_results()
#super(StaConnect, self).clear_test_results().test_results.clear()
def setup(self):
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)
if upstream_json is None:
self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True)
return False
if upstream_json['interface']['ip'] == "0.0.0.0":
if self.debug:
pprint.pprint(upstream_json)
self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True)
return False
# remove old stations
print("Removing old stations")
for sta_name in self.station_names:
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)
LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names)
# Create stations and turn dhcp on
self.station_profile = self.localrealm.new_station_profile()
if self.dut_security == WPA2:
self.station_profile.use_security(security_type="wpa2", ssid=self.dut_ssid, passwd=self.dut_passwd)
elif self.dut_security == OPEN:
self.station_profile.use_security(security_type="open", ssid=self.dut_ssid, passwd="[BLANK]")
elif self.dut_security == WPA:
self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd)
elif self.dut_security == WEP:
self.station_profile.use_security(security_type="wep", ssid=self.dut_ssid, passwd=self.dut_passwd)
self.station_profile.set_command_flag("add_sta", "create_admin_down", 1)
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)
LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug)
# Create UDP endpoints
self.l3_udp_profile = self.localrealm.new_l3_cx_profile()
self.l3_udp_profile.side_a_min_bps = 128000
self.l3_udp_profile.side_b_min_bps = 128000
self.l3_udp_profile.side_a_min_pdu = 1200
self.l3_udp_profile.side_b_min_pdu = 1500
self.l3_udp_profile.report_timer = 1000
self.l3_udp_profile.name_prefix = "udp"
self.l3_udp_profile.create(endp_type="lf_udp",
side_a=list(self.localrealm.find_ports_like("test+")),
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()
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.localrealm.find_ports_like("test+")),
side_b="%d.%s" % (self.resource, self.upstream_port),
suppress_related_commands=True)
def start(self):
if self.station_profile is None:
self._fail("Incorrect setup")
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:
print("\nBringing ports up...")
data = {"shelf": 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)
# station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl()))
duration = 0
maxTime = 90
ip = "0.0.0.0"
ap = ""
print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="")
connected_stations = {}
while (len(connected_stations.keys()) < len(self.station_names)) and (duration < maxTime):
duration += 3
time.sleep(3)
print(".", end="")
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")
# LFUtils.debug_printer.pprint(station_info)
if (station_info is not None) and ("interface" in station_info):
if "ip" in station_info["interface"]:
ip = station_info["interface"]["ip"]
if "ap" in station_info["interface"]:
ap = station_info["interface"]["ap"]
if (ap == "Not-Associated") or (ap == ""):
if self.debug:
print(" -%s," % sta_name, end="")
else:
if ip == "0.0.0.0":
if self.debug:
print(" %s (0.0.0.0)" % sta_name, end="")
else:
connected_stations[sta_name] = sta_url
data = {
"shelf":1,
"resource": self.resource,
"port": "ALL",
"probe_flags": 1
}
self.json_post("/cli-json/nc_show_ports", data)
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")
if station_info is None:
print("unable to query %s" % sta_url)
self.resulting_stations[sta_url] = station_info
ap = station_info["interface"]["ap"]
ip = station_info["interface"]["ip"]
if (ap != "") and (ap != "Not-Associated"):
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.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))
else:
self._fail(sta_name+" did not connect to AP")
return False
if ip == "0.0.0.0":
self._fail("%s did not get an ip. Ending test" % sta_name)
else:
self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip))
if self.passes() == False:
if self.cleanup_on_exit:
print("Cleaning up...")
self.remove_stations()
return False
# start cx traffic
print("\nStarting CX Traffic")
self.l3_udp_profile.start_cx()
self.l3_tcp_profile.start_cx()
time.sleep(1)
# Refresh stats
self.l3_udp_profile.refresh_cx()
self.l3_tcp_profile.refresh_cx()
def collect_endp_stats(self, endp_map):
print("Collecting Data")
fields="?fields=name,tx+bytes,rx+bytes"
for (cx_name, endps) in endp_map.items():
try:
endp_url = "/endp/%s%s" % (endps[0], fields)
endp_json = self.json_get(endp_url)
self.resulting_endpoints[endp_url] = endp_json
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"])
endp_url = "/endp/%s%s" % (endps[1], fields)
endp_json = self.json_get(endp_url)
self.resulting_endpoints[endp_url] = endp_json
ptest_b_tx = endp_json['endpoint']['tx bytes']
ptest_b_rx = endp_json['endpoint']['rx bytes']
self.compare_vals("testTCP-A TX", ptest_a_tx)
self.compare_vals("testTCP-A RX", ptest_a_rx)
self.compare_vals("testTCP-B TX", ptest_b_tx)
self.compare_vals("testTCP-B RX", ptest_b_rx)
except Exception as e:
self.error(e)
def stop(self):
# stop cx traffic
print("Stopping CX Traffic")
self.l3_udp_profile.stop_cx()
self.l3_tcp_profile.stop_cx()
# Refresh stats
print("\nRefresh CX stats")
self.l3_udp_profile.refresh_cx()
self.l3_tcp_profile.refresh_cx()
print("Sleeping for 5 seconds")
time.sleep(5)
# get data for endpoints JSON
self.collect_endp_stats(self.l3_udp_profile.created_cx)
self.collect_endp_stats(self.l3_tcp_profile.created_cx)
# print("\n")
def cleanup(self):
# remove all endpoints and cxs
if self.cleanup_on_exit:
for sta_name in self.station_names:
LFUtils.removePort(self.resource, sta_name, self.lfclient_url)
curr_endp_names = []
removeCX(self.lfclient_url, self.l3_udp_profile.get_cx_names())
removeCX(self.lfclient_url, self.l3_tcp_profile.get_cx_names())
for (cx_name, endp_names) in self.l3_udp_profile.created_cx.items():
curr_endp_names.append(endp_names[0])
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)
# ~class
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def main():
lfjson_host = "localhost"
lfjson_port = 8080
parser = argparse.ArgumentParser(
description="""LANforge Unit Test: Connect Station to AP
Example:
./sta_connect2.py --dest 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_security", type=str, help="DUT security: openLF, wpa, wpa2, wpa3")
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("--debug", type=str, help="enable debugging")
args = parser.parse_args()
if args.dest is not None:
lfjson_host = args.dest
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,
_exit_on_fail=True,
_exit_on_error=False)
staConnect.station_names = [ "sta0000" ]
if args.user is not None:
staConnect.user = args.user
if args.passwd is not None:
staConnect.passwd = args.passwd
if args.sta_mode is not None:
staConnect.sta_mode = args.sta_mode
if args.upstream_resource is not None:
staConnect.upstream_resource = args.upstream_resource
if args.upstream_port is not None:
staConnect.upstream_port = args.upstream_port
if args.radio is not None:
staConnect.radio = args.radio
if args.resource is not None:
staConnect.resource = args.resource
if args.dut_ssid is not None:
staConnect.dut_ssid = args.dut_ssid
if args.dut_passwd is not None:
staConnect.dut_passwd = args.dut_passwd
if args.dut_bssid is not None:
staConnect.dut_bssid = args.dut_bssid
if args.dut_security is not None:
staConnect.dut_security = args.dut_security
# 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()
is_passing = staConnect.passes()
if is_passing == False:
print("FAIL: Some tests failed")
else:
print("PASS: All tests pass")
print(staConnect.get_all_message())
staConnect.cleanup()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == "__main__":
main()

View File

@@ -2,6 +2,12 @@
""" """
####################################################################
# Custom version of testrail_api module
#
# Used by Nightly_Sanity ###########################################
####################################################################
import base64 import base64
import json import json
@@ -166,42 +172,13 @@ class APIClient:
return update_flag return update_flag
def create_testrun(self, name, case_ids, project_id, milestone_id): def create_testrun(self, name, case_ids, project_id, milestone_id, description):
result = client.send_post( result = client.send_post(
'add_run/%s' % (project_id), 'add_run/%s' % (project_id),
{'name': name, 'case_ids': case_ids, 'milestone_id': milestone_id, 'include_all': False}) {'name': name, 'case_ids': case_ids, 'milestone_id': milestone_id, 'description': description, 'include_all': False})
print("result in post", result) print("result in post", result)
client: APIClient = APIClient('https://telecominfraproject.testrail.com') client: APIClient = APIClient('https://telecominfraproject.testrail.com')
client.user = 'syama.devi@connectus.ai'
client.password = 'Connectus123$'
###Old Demo Code
#case = client.send_get('get_case/936')
#print("---------TEST CASE 1---------")
#pprint(case)
#case = client.send_get('get_case/937')
#print("---------TEST CASE 2---------")
#pprint(case)
#print ("----------TEST Project ID----------")
#proj_id = client.get_project_id(project_name= "WLAN")
#pprint(proj_id)
#REST API POSTMAN PROJECT
#projId = client.get_project_id(project_name= "REST-API-POSTMAN")
#pprint("REST API POSTMAN PROJECT ID IS :", projId)
#print("---------TEST RUN ID-----------")
#rid = client.get_run_id(test_run_name='Master',project_name='WLAN')
#rid=client.get_run_id(test_run_name= 'Master-Run3')
#pprint(rid)
#result: bool= client.update_testrail(case_id = 1, run_id=rid, status_id = 5, msg ='Test Failed')
#result = client.send_get('get_attachment/:1', '/Users/syamadevi/Desktop/syama/python-test/TestRail/testreport.pdf')
#print(result)
#project_report= client.send_get("get_reports/:%s" %proj_id)
#print(project_report)
class APIError(Exception): class APIError(Exception):
pass pass

0
py-scripts/wlan_capacity_calculator.py Normal file → Executable file
View File

0
py-scripts/ws_generic_monitor_test.py Normal file → Executable file
View File