cicd: work towards auto-updating DUT.

jfrog.pl can generate the work item.
testbed_poll.pl can find the work-item and attempt to update DUT and run test.
  Still need to tweak a few things and test this fully.
  Still need to be able to re-apply DUT overlay (for files sysupgrade blew away)
This commit is contained in:
Ben Greear
2020-05-07 16:43:28 -07:00
parent e64d10d990
commit 1320328ccf
4 changed files with 114 additions and 13 deletions

View File

@@ -48,3 +48,49 @@ CICD_GITHASH=046ab4f
************* Installation / Usage ***************
The jfrog.pl runs on the web server. Create a directory structure looking similar to this:
[greearb@ben-dt4 html]$ find tip -name "*" -print
tip
tip/testbeds
tip/testbeds/ferndale-basic-01
tip/testbeds/ferndale-basic-01/pending_work
tip/testbeds/ferndale-basic-01/reports
Copy the TESTBED_INFO from wlan-testing git to the tip/testbeds directory:
[greearb@ben-dt4 testbeds]$ pwd
/var/www/html/tip/testbeds
cp -ar /home/greearb/git/tip/wlan-testing/cicd/ferndale-basic-01/ ./
Run the jfrog.pl script from the tip/testbeds directory:
/ome/greearb/git/tip/wlan-testing/cicd/jfrog.pl --passwd secret --tb_url_base greearb@192.168.100.195:/var/www/html/tip/testbeds/
A work-item file will be created as needed, in my case, it is here:
[greearb@ben-dt4 testbeds]$ cat ferndale-basic-01/pending_work/CICD_TEST-ea8300
CICD_RPT=greearb@192.168.100.195:/var/www/html/tip/testbeds//ferndale-basic-01/reports/ea8300
CICD_HW=ea8300
CICD_FILEDATE=
CICD_GITHASH=
CICD_URL=https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/
CICD_FILE_NAME=ea8300
CICD_URL_DATE=24-Apr-2020 16:32
************ Installation / Usage on Test Controller **************
# Set up OS
sudo chmod a+rwx /dev/ttyUSB*
sudo pip3 install pexpect-serial
Run testbed_poll.pl from the cicd testbed directory:
cd ~/tip/wlan-testing/cicd/ferndale-basic-01
../testbed_poll.pl --jfrog_passwd secret --url http://192.168.100.195/tip/testbeds/testbed-ferndale-01/pending_work/

View File

@@ -1,4 +1,4 @@
TESTBED_HW=ea8300
# Controller's view of the test bed.
TESTBED_DIR=/home/greearb/git/tip/wlan-testing/testbeds/ferndale-basic-01
# Controller's view of the test bed, from wlan-testing/cicd/[testbed] directory
TESTBED_DIR=../../testbeds/ferndale-basic-01

View File

@@ -90,8 +90,8 @@ for ($i = 0; $i<@lines; $i++) {
$githash = $3;
}
else {
print "ERROR: Un-handled filename syntax: $fname\n";
exit(1);
print "ERROR: Un-handled filename syntax: $fname, assuming file-name is hardware name.\n";
$hw = $fname;
}
# Find the least used testbed for this hardware.
@@ -143,12 +143,14 @@ for ($i = 0; $i<@lines; $i++) {
$fname_nogz = $1;
}
open(FILE, ">", "$best_tb/pending_work/$cicd_prefix-$fname_nogz");
my $work_fname = "$best_tb/pending_work/$cicd_prefix-$fname_nogz";
open(FILE, ">", "$work_fname");
system("mkdir -p $best_tb/reports");
# In case we run different types of tests, report dir would need to be unique per test run
print FILE "CICD_RPT=$tb_url_base/$best_tb/reports/fname_nogz\n";
print FILE "CICD_RPT=$tb_url_base/$best_tb/reports/$fname_nogz\n";
print FILE "CICD_HW=$hw\nCICD_FILEDATE=$fdate\nCICD_GITHASH=$githash\n";
print FILE "CICD_URL=$url\nCICD_FILE_NAME=$fname\nCICD_URL_DATE=$date\n";
@@ -156,7 +158,8 @@ for ($i = 0; $i<@lines; $i++) {
close(FILE);
print("Next: File Name: $fname Display Name: $name Date: $date\n");
print("To download: curl --location -o /tmp/$fname -u $user:$passwd $url/$fname\n");
print("Work item placed at: $work_fname\n");
#print("To download: curl --location -o /tmp/$fname -u $user:$passwd $url/$fname\n");
exit(0);
}

View File

@@ -26,8 +26,7 @@ my $usage = qq($0
Example:
$0 --user to_user --passwd secret --jfrog_user cicd_user --jfrog_passwd secret2 \
--url https://tip.cicd.mycloud.com/testbed-ferndale-01/ \
--next_info jfrog_files_next.txt
--url https://tip.cicd.mycloud.com/testbed-ferndale-01/
);
@@ -66,13 +65,13 @@ if ($user eq "") {
my $cmd = "curl $cuser $url";
print ("Calling command: $cmd\n");
$listing = `$cmd`;
@lines = split(/\n/, $listing);
my $listing = `$cmd`;
my @lines = split(/\n/, $listing);
for ($i = 0; $i<@lines; $i++) {
my $ln = $lines[$i];
chomp($ln);
if ($ln =~ /href=\"(CICD_TEST_.*)\">(.*)<\/a>\s+(.*)\s+\S+\s+\S+/) {
if ($ln =~ /href=\"(CICD_TEST-.*)\">(.*)<\/a>\s+(.*)\s+\S+\s+\S+/) {
my $fname = $1;
my $name = $2;
my $date = $3;
@@ -110,10 +109,63 @@ for ($i = 0; $i<@lines; $i++) {
my $cmd = "curl --location -o $jfile -u $jfrog_user:$jfrog_passwd $jurl/$jfile";
system($cmd);
`rm -f openwrt-*.bin`;
`rm -f *sysupgrade.bin`; # just in case openwrt prefix changes.
`tar xf $jfile`;
# Next steps here are to put the OpenWrt file on the LANforge system
my $tb_info = `cat TESTBED_INFO.txt`;
my $tb_dir = "";
if ($tb_info =~ /TESTBED_DIR=(.*)/g) {
$tb_dir = $1;
}
my $env = `. $tb_dir/test_bed_cfg.bash && env`;
my $lfmgr = "";
my $serial = "";
if ($tb_info =~ /LFMANAGER=(.*)/g) {
$lfmgr = $1;
}
else {
print("ERRROR: Could not find LFMANAGER in environment, configuration error!\n");
exit(1);
}
if ($tb_info =~ /AP_SERIAL=(.*)/g) {
$serial = $1;
}
else {
print("ERRROR: Could not find AP_SERIAL in environment, configuration error!\n");
exit(1);
}
# and then get it onto the DUT, reboot DUT, re-configure as needed,
`scp *sysupgrade.bin jfile lanforge@$LFMANAGER/tip-$jfile`;
# and then kick off automated regression test.
# When complete, upload the results to the requested location.
# Default gateway on the AP should be one of the ports on the LANforge system, so we can use
# that to scp the file to the DUT, via serial-console connection this controller has to the DUT.
my $ap_route = `../../lanforge/lanforge-scripts/openwrt_ctl.py --scheme serial --tty /dev/ttyUSB1 --action cmd --value "ip route show"`;
my $ap_gw = "";
if ($ap_route =~ /default via (\S+)/g) {
$ap_gw = $1;
}
if ($ap_gw eq "") {
print("ERROR: Could not find default gateway for AP, route info:\n$ap_route\n");
exit(1);
}
my $ap_out = `../../lanforge/lanforge-scripts/openwrt_ctl.py --scheme serial --tty /dev/ttyUSB1 --action sysupgrade --value "lanforge@$ap_gw:tip-$jfile"`;
# System should be rebooted at this point.
# TODO: Re-apply overlay
# TODO: Allow specifying other tests.
`cd $tb_dir && ./run_basic.bash`;
# TODO: When complete, upload the results to the requested location.
exit(0);
}