diff --git a/cicd/README.txt b/cicd/README.txt index 9344361f7..3015f1865 100644 --- a/cicd/README.txt +++ b/cicd/README.txt @@ -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/ diff --git a/cicd/ferndale-basic-01/TESTBED_INFO.txt b/cicd/ferndale-basic-01/TESTBED_INFO.txt index 43abfcc4c..f3d6e6223 100644 --- a/cicd/ferndale-basic-01/TESTBED_INFO.txt +++ b/cicd/ferndale-basic-01/TESTBED_INFO.txt @@ -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 diff --git a/cicd/jfrog.pl b/cicd/jfrog.pl index 46d4f1d80..2e6a6972c 100755 --- a/cicd/jfrog.pl +++ b/cicd/jfrog.pl @@ -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); } diff --git a/cicd/testbed_poll.pl b/cicd/testbed_poll.pl index 275315560..dcfa7b970 100755 --- a/cicd/testbed_poll.pl +++ b/cicd/testbed_poll.pl @@ -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); }