From f7f47848e6f3346161547a54f3961688bfeb827b Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 24 Apr 2020 16:32:17 -0700 Subject: [PATCH] Add basic HTML page generation for automated test bed run. --- gui/basic_regression.bash | 6 +- gui/index_template.html | 55 +++++++++++++++ gui/lf_gui_report_summary.pl | 125 +++++++++++++++++++++++++++++++++++ lf_gui_cmd.pl | 2 +- lf_testmod.pl | 2 +- 5 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 gui/index_template.html create mode 100755 gui/lf_gui_report_summary.pl diff --git a/gui/basic_regression.bash b/gui/basic_regression.bash index 752a9860..3ec226ec 100755 --- a/gui/basic_regression.bash +++ b/gui/basic_regression.bash @@ -166,12 +166,12 @@ sleep 20 # Tell GUI to load and build the scenario ../lf_gui_cmd.pl --manager $GMANAGER --port $GMPORT --scenario $SCENARIO -# Clean out temp report directory +# Clean out temp report directory on local system and remote if [ -d $RPT_TMPDIR ] then rm -fr $RPT_TMPDIR/* fi - +ssh lanforge\@GMANAGER "test -d $RPT_TMPDIR && rm -fr $RPT_TMPDIR"; # Do dataplane pkt size test echo "Checking if we should run Dataplane packet size test." @@ -325,5 +325,7 @@ then mv $MY_TMPDIR/dut_console_log.txt $RSLTS_DIR/ fi +./lf_gui_report_summary.pl --title "TIP Test Bed Results" --dir $RSLTS_DIR < index_template.html > $RSLTS_DIR/index.html + echo "Done with regression test." echo "Results-Dir: $RSLTS_DIR" diff --git a/gui/index_template.html b/gui/index_template.html new file mode 100644 index 00000000..a8141ca3 --- /dev/null +++ b/gui/index_template.html @@ -0,0 +1,55 @@ + + + + + + ___TITLE___ + + + + + +
+

___TITLE___


+


___DATE___

+ +
+ +
+ +

Individual test results and logs.

+ + + ___TR_TESTS___ +
+

+ + + + + ___TR_DUT___ +
Test RigDUT HardwareDUT SoftwareDUT ModelDUT Serial
+ +

+ + + + + ___TR_KPI___ +
Test-IDShort DescriptionPass/FailNumeric ResultTest Details
+ +

+
Generated by Candela Technologies LANforge network testing tool.
+ www.candelatech.com +
+

+ + diff --git a/gui/lf_gui_report_summary.pl b/gui/lf_gui_report_summary.pl new file mode 100755 index 00000000..10094244 --- /dev/null +++ b/gui/lf_gui_report_summary.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w +# Generate HTML summary page for a collection of GUI reports (with kpi.csv) +# (C) 2020 Candela Technologies Inc. +# + +use strict; +use warnings; +use diagnostics; +use Carp; +$SIG{ __DIE__ } = sub { Carp::confess( @_ ) }; +$SIG{ __WARN__ } = sub { Carp::confess( @_ ) }; + +# Un-buffer output +$| = 1; + +# use lib prepends to @INC, so put lower priority first +# This is before run-time, so cannot condition this with normal 'if' logic. +use lib '/home/lanforge/scripts'; +use lib "../"; +use lib "./"; + +use Getopt::Long; + +our $dir = ""; +our $title = "Automated test results."; + + +######################################################################## +# Nothing to configure below here, most likely. +######################################################################## + +our $usage = <<"__EndOfUsage__"; +$0 [ --dir directory-to-process ] + +Example: + $0 --dir ~/tmp/results --title "My Title" +__EndOfUsage__ + +my $i = 0; +my $show_help = 0; + +GetOptions +( + 'dir|d=s' => \$::dir, + 'title|t=s' => \$::title, + 'help|h' => \$show_help, +) || die("$::usage"); + +if ($show_help) { + print $usage; + exit 0; +} + +chdir($dir); + +my @files = `ls`; +chomp(@files); + +my $line; + +# Find some html helpers and copy them to current dir. +foreach $line (@files) { + if ( -d $line) { + if ( -f "$line/canvil.ico") { + `cp $line/canvil.ico ./`; + `cp $line/*.css ./`; + `cp $line/candela_swirl* ./`; + `cp $line/CandelaLogo* ./`; + last; + } + } +} + +my $dut_tr = ""; +my $kpi_tr = ""; +my $tests_tr = ""; + +foreach my $line (@files) { + if ( -d $line) { + if ( -d "$line/logs") { + $tests_tr .= "$lineLogs\n"; + } + else { + $tests_tr .= "$line\n"; + } + + if ( -f "$line/kpi.csv") { + my @kpi = `cat $line/kpi.csv`; + chomp(@kpi); + my $i = 0; + foreach my $k (@kpi) { + $i++; + if ($i == 1) { + next; # skip header + } + + my @cols = split(/\t/, $k); + if ($dut_tr eq "") { + $dut_tr = "$cols[1]$cols[2]$cols[3]$cols[4]$cols[5]\n"; + } + + $kpi_tr .= "$cols[7]$cols[8]$cols[9]$cols[10]$cols[11]\n"; + } + } + } +} + +my $date = `date`; + +while (<>) { + my $ln = $_; + chomp($ln); + + $ln =~ s/___TITLE___/$title/g; + $ln =~ s/___DATE___/$date/g; + $ln =~ s/___TR_DUT___/$dut_tr/g; + $ln =~ s/___TR_KPI___/$kpi_tr/g; + $ln =~ s/___TR_TESTS___/$tests_tr/g; + print "$ln\n"; +} + +exit(0); + +# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- +# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- diff --git a/lf_gui_cmd.pl b/lf_gui_cmd.pl index 1cf172f4..5079ed81 100755 --- a/lf_gui_cmd.pl +++ b/lf_gui_cmd.pl @@ -152,7 +152,7 @@ if ($ttype ne "") { # Copy some place it can be seen easily? print("LANforge GUI test complete, rpt-dest: $rpt_dest location: $loc\n"); if ($rpt_dest ne "") { - if (-d $loc) { + if ($lfmgr_host eq "localhost" || $lfmgr_host eq "127.0.0.1") { # Must be on the local system my $cp = "cp -ar $loc $rpt_dest"; print "Copy test results: $cp\n"; diff --git a/lf_testmod.pl b/lf_testmod.pl index e0ac51bc..5d1879a7 100755 --- a/lf_testmod.pl +++ b/lf_testmod.pl @@ -184,7 +184,7 @@ elsif ($::action eq "set") { $cmd = "add_text_blob '$test_type' '$test_name' $ln"; print("$cmd\n"); - if ($i % 25 == 0) { + if (($i % 25) != 0) { $::utils->doCmd($cmd, 1); # send and do not wait for result } else {