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

[OSSTEST PATCH 04/60] history reporting (nfc): Refactor to generalise, cache_read_existing


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2020 18:21:09 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 14 Aug 2020 17:22:20 +0000
  • Ironport-sdr: MlOk7mvYTrWJ2MacOCGhA+a7t/6PeGH6nlGF6cx8cqRH+L7gR+dr7pr46eJz7470Tv2TKggzk3 gvozQQvCa84qDPDO/8OTHtjfhTZoE7xuOpufy9dCaTgqPlk5Ekaqxd5tRTCwMEKKmGihOxMmB3 9g98GFCMh0OegL4qSUxyc7+m37iG0p4R0oofrhQpSIoC1fUSL5Q3uxoNt+JWaVSGfZuyguJQYs KWuxuhS6vUEfxfbghiu+XLxIOQv5nEfZdu8/Le8l71uc0owvcCCCOSs026WnoIDTSS7pmqCEgY We8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

* Introduce @cache_row_key_cols and cache_row_key
* Handle $html_file pathname construction and $read_existing
  at the call site.
* Rename cache_read_existing.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 4c0022e8..83344a40 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -77,11 +77,15 @@ our $flightcond;
 our $minflight;
 
 our %cache;
+our @cache_row_key_cols = qw(flight job status name);
 
-sub read_existing_logs ($) {
-    my ($hostname) = @_;
-    return unless $read_existing;
-    my $html_file = "$htmlout/$hostname.html";
+sub cache_row_key ($) {
+    my ($jr) = @_;
+    return join $; , map { $jr->{$_} } @cache_row_key_cols;
+}
+
+sub cache_read_existing ($) {
+    my ($html_file) = @_;
     if (!open H, $html_file) {
         return if $!==ENOENT;
         die "failed to open $html_file: $!";
@@ -103,7 +107,7 @@ sub read_existing_logs ($) {
            s{\%([0-9a-f]{2})}{ chr hex $1 }ge;
            $ch->{$k} = $_;
        }
-       $cache{$jr->{flight},$jr->{job},$jr->{status},$jr->{name}} = $jr;
+       $cache{cache_row_key($jr)} = $jr;
     }
     close H;
 }
@@ -261,8 +265,7 @@ END
     foreach my $jr (@$inrows) {
        #print DEBUG "JOB $jr->{flight}.$jr->{job} ";
 
-       my $cacherow =
-           $cache{$jr->{flight},$jr->{job},$jr->{status},$jr->{name}};
+       my $cacherow = $cache{cache_row_key($jr)};
        if ($cacherow) {
            $jr = $cacherow;
            $cachehits++;
@@ -492,7 +495,7 @@ foreach my $host (sort keys %hosts) {
     my $pid = fork // die $!;
     if (!$pid) {
        opendb_tests();
-       read_existing_logs($host);
+       cache_read_existing("$htmlout/$host.html") if $read_existing;
        db_retry($dbh_tests, [], sub {
             mainquery($host);
            reporthost $host;
-- 
2.11.0




 


Rackspace

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