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

[Xen-devel] [OSSTEST PATCH 12/13] Reporting: Provide report_find_push_age_info



This utility function provides information about how far behind the
push gate is right now.

I have tested it with this rune in the Cambridge instance:

  perl -we 'use Osstest::Executive; use Osstest; use Data::Dumper; open DEBUG, 
">&STDERR" or die $!; csreadconfig(); print Dumper 
report_find_push_age_info([qw(real)], undef, [qw(osstest linux-next)], 
"osstest", "280a18b2b2612174e473a1c1a137ddd47c49aab9", 
"cc8b79ce9586d2b0fbddbd4260e876eab1d408d4")'

Currently it produces this output:

$VAR1 = {
          'CountTip' => '4',
          'FirstTip' => {
                          'flight' => 37635,
                          'intended' => 'real',
                          'blessing' => 'real',
                          'started' => 1435460756,
                          'branch' => 'osstest'
                        },
          'LastTip' => {
                         'flight' => 37638,
                         'intended' => 'real',
                         'blessing' => 'real',
                         'started' => 1435538150,
                         'branch' => 'osstest'
                       },
          'Basis' => {
                       'flight' => 37629,
                       'intended' => 'real',
                       'blessing' => 'real',
                       'started' => 1435181770,
                       'branch' => 'osstest'
                     },
          'FirstAfterBasis' => {
                                 'flight' => 37630,
                                 'intended' => 'real',
                                 'blessing' => 'real',
                                 'started' => 1435314944,
                                 'branch' => 'osstest'
                               },
          'CountAfterBasis' => '9'
        };

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm |  142 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 1 deletion(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 9f90f67..cf15de4 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -47,7 +47,7 @@ BEGIN {
     @EXPORT      = qw(get_harness_rev grabrepolock_reexec
                       findtask @all_lock_tables
                       report_run_getinfo report_altcolour
-                      report_blessingscond
+                      report_blessingscond report_find_push_age_info
                       tcpconnect_queuedaemon plan_search
                       alloc_resources alloc_resources_rollback_begin_work
                       resource_check_allocated resource_shared_mark_ready
@@ -271,6 +271,146 @@ sub report_blessingscond ($$) {
     return $blessingscond;
 }
 
+sub report__find_test ($$$$$$$$) {
+    my ($blessings, $maxflight, $branches, $tree,
+       $revision, $selection, $extracond, $sortlimit) = @_;
+    # Reports information about a flight which tried to test $revision
+    # of $tree.  ($revision may be undef);
+
+    my @params;
+
+    my $querytext = <<END;
+        SELECT $selection
+        FROM flights f
+       WHERE
+END
+
+    if (defined $revision) {
+       if ($tree eq 'osstest') {
+           $querytext .= <<END;
+               EXISTS (
+                  SELECT 1
+                   FROM flights_harness_touched t
+                  WHERE t.harness=?
+                    AND t.flight=f.flight
+                )
+END
+            push @params, $revision;
+       } else {
+           $querytext .= <<END;
+               EXISTS (
+                  SELECT 1
+                   FROM runvars
+                  WHERE name=?
+                    AND val=?
+                    AND r.flight=f.flight
+                )
+END
+            push @params, "revision_$tree", $revision;
+        }
+    } else {
+       $querytext .= <<END;
+           TRUE
+END
+    }
+
+    my $blessingscond = report_blessingscond($blessings,$maxflight);
+    $querytext .= <<END;
+         AND $blessingscond
+END
+
+    my $branchescond = join ' OR ', map { "branch=?" } @$branches;
+    $querytext .= <<END;
+         AND ($branchescond)
+END
+    push @params, @$branches;
+
+    $querytext .= $extracond;
+    $querytext .= $sortlimit;
+
+    my $query = db_prepare($querytext);
+    $query->execute(@params);
+
+    my $row = $query->fetchrow_hashref();
+    $query->finish();
+    return $row;
+}
+
+sub report_find_push_age_info ($$$$$$) {
+    my ($blessings, $maxflight, $branches, $tree,
+       $basis_revision, $tip_revision) = @_;
+    # Reports information about tests of $tree.
+    # (Subject to @$blessings, $maxflight, @$branches)
+    # Returns {
+    #    Basis           =>  row for last test of basis
+    #    FirstAfterBasis =>  row for first test after basis
+    #    FirstTip        =>  row for first test of tip (after Basis)
+    #    LastTip         =>  row for last test of tip (after Basis)
+    #    CountAfterBasis =>  count of runs strictly after Basis
+    #    CountTip        =>  count of runs on Tip
+    #  }
+    # where
+    #  row for ... is from fetchrow_hashref of SELECT * FROM flights
+    #                 (or undef if no such thing exists)
+    #  Count       is a scalar integer.
+    #
+    # Only flights which specified the exact revision specified
+    # are considered (not ones which specified a tag, for example).
+
+    my $findtest = sub {
+       my ($revision,$selection,$extracond,$sortlimit) = @_;
+       report__find_test($blessings,$maxflight,$branches,$tree,
+                        $revision,$selection,$extracond,$sortlimit);
+    };
+
+    my $findcount = sub {
+       my ($revision,$extracond,$sortlimit) = @_;
+       my $row = $findtest->($revision, 'COUNT(*) AS count',
+                             $extracond, $sortlimit);
+       return $row->{count} // die "$revision $extracond $sortlimit ?";
+    };
+
+    my $out = { };
+    $out->{Basis} = $findtest->($basis_revision, '*', '', <<END);
+        ORDER BY flight DESC
+        LIMIT 1
+END
+
+    my $afterbasis = $out->{Basis} ? <<END : '';
+        AND flight > $out->{Basis}{flight}
+END
+
+    $out->{FirstAfterBasis} = $findtest->(undef, '*', $afterbasis, <<END)
+        ORDER BY flight ASC
+       LIMIT 1
+END
+        if $afterbasis;
+
+    $out->{FirstTip} = $findtest->($tip_revision, '*', $afterbasis, <<END);
+        ORDER BY flight ASC
+        LIMIT 1
+END
+
+    my $likelytip = $out->{FirstTip} ? <<END : '';
+        AND flight >= $out->{FirstTip}{flight}
+END
+
+    $out->{LastTip} = $findtest->($tip_revision, '*', $likelytip, <<END)
+        ORDER BY flight DESC
+        LIMIT 1
+END
+        if $out->{FirstTip};
+
+    $out->{CountAfterBasis} = $findcount->(undef, $afterbasis, '')
+        if $afterbasis;
+
+    $out->{CountTip} =
+       $out->{FirstTip} ? $findcount->($tip_revision, $likelytip, '')
+       : 0;
+
+    return $out;
+}
+
 #---------- host (and other resource) allocation ----------
 
 our $taskid;
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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