@@ -1012,16 +1012,21 @@ END
#---------- duration estimator ----------
-sub duration_estimator ($$;$) {
- my ($branch, $blessing, $debug) = @_;
+sub duration_estimator ($$;$$) {
+ my ($branch, $blessing, $debug, $will_uptoincl_testid) = @_;
# returns a function which you call like this
- # $durest->($job, $hostidname, $onhost)
+ # $durest->($job, $hostidname, $onhost [, $uptoincl_testid])
# and returns one of
# ($seconds, $samehostlaststarttime, $samehostlaststatus)
# ($seconds, undef, undef)
# ()
# $debug should be something like sub { print DEBUG "@_\n"; }.
# Pass '' for $hostidname and $onhost for asking about on any host
+ #
+ # $uptincl_testid must be passed iff $will_uptoincl_testid, in
+ # which case the duration up to and including that step will be
+ # estimated (and only jobs which contained that step will be
+ # considered).
my $recentflights_q= $dbh_tests->prepare(<<END);
SELECT f.flight AS flight,
@@ -1068,11 +1073,20 @@ END
FROM tsteps
WHERE step != 'ts-hosts-allocate'
END
+
+ if ($will_uptoincl_testid) {
+ $duration_duration_qtxt .= <<END;
+ AND finished <=
+ (SELECT finished
+ FROM tsteps
+ WHERE tsteps.testid = ?)
+END
+ }
my $duration_duration_q = $dbh_tests->prepare($duration_duration_qtxt);
return sub {
- my ($job, $hostidname, $onhost) = @_;
+ my ($job, $hostidname, $onhost, $uptoincl_testid) = @_;
my $dbg= $debug ? sub {
$debug->("DUR $branch $blessing $job $hostidname $onhost @_");
@@ -1108,6 +1122,7 @@ END
my $duration_max= 0;
foreach my $ref (@$refs) {
my @d_d_args = ($ref->{flight}, $job);
+ push @d_d_args, $uptoincl_testid if $will_uptoincl_testid;
$duration_duration_q->execute(@d_d_args);
my ($duration) = $duration_duration_q->fetchrow_array();
$duration_duration_q->finish();
If this is passed, we are interested only in the duration up to and including the specified test step. (If the specified test step is not present or didn't have a recorded finish, we look at the whole job.) Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- Osstest/Executive.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)