[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 10/13] sg-report-host-history: Read cache entries


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 8 Nov 2019 18:49:58 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@xxxxxxxxxxxxx; spf=Pass smtp.mailfrom=Ian.Jackson@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 08 Nov 2019 18:50:28 +0000
  • Ironport-sdr: VJ/yjvYsLCAWisoLUxuc5rNBOyWwMd7I4cDzFHpGGwV4L9kOnZIFAaFGd6pWFxVDiZVOOKpWCK wdHLuBXSUFodI6bFvqDOuKvam6VDsgNM3+Q2QwMhx8UJkvV/o/7K5OPR3l53DJ5HX/Zn3iZGxa RILbzu0VLKsOJyuMurduSv5mnH4hF2jDlYDNncKYPG9/jXfp74K6X7kbvgUp6Fwg5lgjNIyG5U oe2iThxnAMkEx27SMBUROOMnIW4C05bVWP47/XHmv6IpuL6gwLT41oDU1EUvqlc0Iq6aywjbyJ C+E=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 7dcfac9a..e67c7346 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -31,6 +31,7 @@ use Osstest::Executive qw(:DEFAULT :colours);
 our $limit= 200;
 our $flightlimit;
 our $htmlout = ".";
+our $read_existing=1;
 our $doinstall=1;
 our @blessings;
 
@@ -52,6 +53,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         push @blessings, split ',', $1;
     } elsif (m/^--html-dir=(.*)$/) {
         $htmlout= $1;
+    } elsif (m/^--regenerate$/) {
+        $read_existing= 0;
     } elsif (m/^--no-install$/) {
         $doinstall= 0;
     } elsif (m/^--debug/) {
@@ -69,6 +72,41 @@ our $restrictflight_cond = restrictflight_cond();
 our $flightcond;
 our $minflight;
 
+our %hcaches;
+
+sub read_existing_logs ($) {
+    my ($hostname) = @_;
+    return unless $read_existing;
+    my $html_file = "$htmlout/$hostname.html";
+    if (!open H, $html_file) {
+        return if $!==ENOENT;
+        die "failed to open $html_file: $!";
+    }
+    my $tcache = { };
+    $hcaches{$hostname} = $tcache;
+    for (;;) {
+        $_ = <H> // last;
+        next unless m{^\<\!-- osstest-report-reuseable (.*)--\>$};
+       my $jr = {};
+       my $ch = $jr;
+       foreach (split / /, $1) {
+           if (m{^\w+$}) {
+               $ch = { };
+               $jr->{'%'.$&} = $ch;
+               next;
+           }
+           s{^(\w+)=}{} or die;
+           my $k = $1;
+           s{\%([0-9a-f]{2})}{ chr hex $1 }ge;
+           $ch->{$k} = $_;
+           print DEBUG "GOTCACHE $hostname $k\n";
+       }
+       print DEBUG "GOTCACHE $hostname \@ $jr->{flight} $jr->{job} 
$jr->{status},$jr->{name}\n";
+       $tcache->{$jr->{flight},$jr->{job},$jr->{status},$jr->{name}} = $jr;
+    }
+    close H;
+}
+
 sub computeflightsrange () {
     if (!$flightlimit) {
        my $flagscond =
@@ -225,16 +263,26 @@ END
     my $inrows = $hosts{$hostname};
     print DEBUG "FOUND ", (scalar @$inrows), " ROWS for $hostname\n";
 
+    my $tcache = $hcaches{$hostname};
+
     # Each entry in @$inrows is a $jr, which is a hash
     # It has keys for the result columns in mainquery
     # It also has keys '%<letter>' (yes, with a literal '%')
     # which are the results of per-job queries.
-    # The contents of $jr for each job is cached across runs. (TODO)
+    # The contents of $jr for each job is cached across runs.
 
     my @rows;
+    my $cachehits = 0;
     foreach my $jr (@$inrows) {
        print DEBUG "JOB $jr->{flight}.$jr->{job} ";
 
+       my $cacherow =
+           $tcache->{$jr->{flight},$jr->{job},$jr->{status},$jr->{name}};
+       if ($cacherow) {
+           $jr = $cacherow;
+           $cachehits++;
+       }
+
        my $endedrow = jobquery($endedq, $jr, 'e');
        if (!$endedrow) {
            print DEBUG "no-finished\n";
@@ -246,6 +294,9 @@ END
        push @rows, { %$jr, %$endedrow };
     }
 
+    print DEBUG "CACHE $hostname $cachehits / ".(scalar @rows)
+       ." of ".(scalar %$tcache)."\n";
+
     my $write_cache_entry = sub {
        my ($jr) = @_;
         print H "<!-- osstest-report-reuseable";
@@ -408,6 +459,10 @@ END
 
 exit 0 unless %hosts;
 
+foreach (keys %hosts) {
+    read_existing_logs($_);
+}
+
 db_retry($dbh_tests, [], sub {
     computeflightsrange();
 });
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.