@@ -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();
});
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> --- sg-report-host-history | 57 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)