mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-22 21:14:55 +00:00
Merge /home/greearb/btbits/x64_btbits/server/lf_scripts
This commit is contained in:
@@ -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;
|
||||||
next;
|
|
||||||
}
|
|
||||||
push(@newlines, $key." ".$address_map{$key});
|
|
||||||
}
|
}
|
||||||
|
# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
@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
61
check_large_files.sh
Executable 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
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
164
py-json/realm.py
164
py-json/realm.py
@@ -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
|
||||||
@@ -2797,8 +2926,8 @@ class StationProfile:
|
|||||||
}
|
}
|
||||||
self.wifi_extra_data_modified = False
|
self.wifi_extra_data_modified = False
|
||||||
self.wifi_extra_data = {
|
self.wifi_extra_data = {
|
||||||
"shelf":1,
|
"shelf": 1,
|
||||||
"resource":1,
|
"resource": 1,
|
||||||
"port": None,
|
"port": None,
|
||||||
"key_mgmt": None,
|
"key_mgmt": None,
|
||||||
"eap": None,
|
"eap": None,
|
||||||
@@ -2810,8 +2939,8 @@ class StationProfile:
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.reset_port_extra_data = {
|
self.reset_port_extra_data = {
|
||||||
"shelf":1,
|
"shelf": 1,
|
||||||
"resource":1,
|
"resource": 1,
|
||||||
"port": None,
|
"port": None,
|
||||||
"test_duration": 0,
|
"test_duration": 0,
|
||||||
"reset_port_enable": False,
|
"reset_port_enable": False,
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
117
py-scripts/example_security_connection.py
Executable file
117
py-scripts/example_security_connection.py
Executable 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()
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
213
py-scripts/test_1k_clients_jedtest.py
Executable file
213
py-scripts/test_1k_clients_jedtest.py
Executable 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()
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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,29 +119,44 @@ 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()
|
||||||
|
|
||||||
self.mvlan_profile.num_macvlans = int(num_ports)
|
if self.use_macvlans:
|
||||||
self.mvlan_profile.desired_macvlans = self.port_list
|
self.mvlan_profile.num_macvlans = int(num_ports)
|
||||||
self.mvlan_profile.macvlan_parent = self.macvlan_parent
|
self.mvlan_profile.desired_macvlans = self.port_list
|
||||||
self.mvlan_profile.dhcp = dhcp
|
self.mvlan_profile.macvlan_parent = self.macvlan_parent
|
||||||
self.mvlan_profile.netmask = netmask
|
self.mvlan_profile.dhcp = dhcp
|
||||||
self.mvlan_profile.first_ip_addr = first_mvlan_ip
|
self.mvlan_profile.netmask = netmask
|
||||||
self.mvlan_profile.gateway = gateway
|
self.mvlan_profile.first_ip_addr = first_mvlan_ip
|
||||||
|
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")
|
||||||
|
|
||||||
|
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)
|
||||||
|
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
||||||
|
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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.endp_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
|
||||||
suppress_related_commands_=None)
|
|
||||||
self.ro_profile.create(ports=self.created_ports, sleep_time=.5, debug_=self.debug,
|
|
||||||
suppress_related_commands_=None)
|
|
||||||
|
|
||||||
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])
|
||||||
self.station_profile.admin_up()
|
if not self.use_macvlans:
|
||||||
self.mvlan_profile.admin_up()
|
self.station_profile.admin_up()
|
||||||
exit(1)
|
else:
|
||||||
if self.local_realm.wait_for_ip(temp_ports):
|
self.mvlan_profile.admin_up()
|
||||||
|
if self.local_realm.wait_for_ip(temp_ports, debug=self.debug):
|
||||||
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:
|
||||||
time.sleep(2)
|
if self.mode == "write":
|
||||||
self.ro_profile.start_cx()
|
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)
|
||||||
|
self.ro_profile.start_cx()
|
||||||
|
|
||||||
passes = 0
|
passes = 0
|
||||||
expected_passes = 0
|
expected_passes = 0
|
||||||
print("Starting Test...")
|
print("Starting Test...")
|
||||||
@@ -225,18 +349,51 @@ 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:
|
||||||
self.ro_profile.stop_cx()
|
if self.mode == "write":
|
||||||
self.station_profile.admin_down()
|
self.wo_tg_profile.stop_group(group_name=self.write_only_test_group)
|
||||||
self.mvlan_profile.admin_down()
|
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()
|
||||||
|
else:
|
||||||
|
self.wo_profile.stop_cx()
|
||||||
|
time.sleep(2)
|
||||||
|
self.ro_profile.stop_cx()
|
||||||
|
|
||||||
def cleanup(self, sta_list=None):
|
if not self.use_macvlans:
|
||||||
self.endp_profile.cleanup()
|
self.station_profile.admin_down()
|
||||||
|
else:
|
||||||
|
self.mvlan_profile.admin_down()
|
||||||
|
|
||||||
|
def cleanup(self, port_list=None):
|
||||||
|
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)
|
||||||
self.mvlan_profile.cleanup()
|
elif self.use_macvlans:
|
||||||
|
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():
|
||||||
@@ -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,27 +470,45 @@ 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:
|
||||||
num_ports = int(args.num_ports)
|
if args.use_ports is None:
|
||||||
if not args.use_macvlans:
|
num_ports = int(args.num_ports)
|
||||||
port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1,
|
if not args.use_macvlans:
|
||||||
padding_number=10000,
|
port_list = LFUtils.port_name_series(prefix="sta", start_id=0, end_id=num_ports - 1,
|
||||||
radio=args.radio)
|
padding_number=10000,
|
||||||
else:
|
radio=args.radio)
|
||||||
port_list = LFUtils.port_name_series(prefix=args.macvlan_parent + "#", start_id=0,
|
else:
|
||||||
|
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)
|
||||||
if args.first_mvlan_ip.lower() == "dhcp":
|
else:
|
||||||
dhcp = True
|
temp_list = args.use_ports.split(',')
|
||||||
else:
|
for port in temp_list:
|
||||||
dhcp = False
|
port_list.append(port.split('=')[0])
|
||||||
print(port_list)
|
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":
|
||||||
|
dhcp = True
|
||||||
|
else:
|
||||||
|
dhcp = False
|
||||||
|
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():
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -84,8 +84,8 @@ class GenTest(LFCliBase):
|
|||||||
if last_results['download'] is None and last_results['upload'] is None and last_results['ping'] is None:
|
if last_results['download'] is None and last_results['upload'] is None and last_results['ping'] is None:
|
||||||
return False, v['name']
|
return False, v['name']
|
||||||
elif last_results['download'] >= self.speedtest_min_dl and \
|
elif last_results['download'] >= self.speedtest_min_dl and \
|
||||||
last_results['upload'] >= self.speedtest_min_up and \
|
last_results['upload'] >= self.speedtest_min_up and \
|
||||||
last_results['ping'] <= self.speedtest_max_ping:
|
last_results['ping'] <= self.speedtest_max_ping:
|
||||||
return True, v['name']
|
return True, v['name']
|
||||||
|
|
||||||
def choose_generic_command(self):
|
def choose_generic_command(self):
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
0
py-scripts/test_l3_scenario_throughput.py
Normal file → Executable file
345
py-scripts/test_status_msg.py
Executable file
345
py-scripts/test_status_msg.py
Executable 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
140
py-scripts/testgroup.py
Executable 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()
|
||||||
0
py-scripts/wlan_capacity_calculator.py
Normal file → Executable file
0
py-scripts/wlan_capacity_calculator.py
Normal file → Executable file
0
py-scripts/ws_generic_monitor_test.py
Normal file → Executable file
0
py-scripts/ws_generic_monitor_test.py
Normal file → Executable file
Reference in New Issue
Block a user