@@ -389,6 +389,53 @@ END
}
}
+sub jobdb_set_hosts_infraprioritygroup ($$$$;$) { # method
+ my ($mo, $flight, $job, $group_key, $rref) = @_;
+ # Sets the runvar hosts_infraprioritygroup in $flight,$job
+ # The runvar values are NUM:GROUPKEY
+ # such that each GROUPKEY always has the same NUM, within the flight
+ # $rref is \%r (for use within a ts-*) or undef
+
+ my $vn = 'hosts_infraprioritygroup';
+
+ my $queryq = $dbh_tests->prepare(<<END);
+ SELECT job, val,
+ (job = ?) AS thisjob
+ FROM runvars
+ WHERE flight=?
+ AND name=?
+ ORDER BY thisjob DESC
+END
+ my $insertq = $dbh_tests->prepare(<<END);
+ INSERT INTO runvars (flight,job, name,val, synth)
+ VALUES (?, ?, ?, ?, 't')
+END
+
+ my $resulting;
+ db_retry($dbh_tests,[],sub {
+ my $use = 1;
+ $resulting = undef;
+ $queryq->execute($job, $flight, $vn);
+ while (my ($tjob, $tval, $thisjob) = $queryq->fetchrow_array()) {
+ if ($thisjob) {
+ logm("$vn: job is already in group $tval");
+ return;
+ }
+ $tval =~ m/^(\d+)\:/ or die "$flight $job $tval ?";
+ if ($' eq $group_key) {
+ $use = $1;
+ last;
+ } elsif ($1 >= $use) {
+ $use = $1 + 1;
+ }
+ }
+ $resulting = "$use:$group_key";
+ logm("$vn: inserting job into group $resulting");
+ $insertq->execute($flight,$job,$vn, $resulting);
+ });
+ $rref->{$vn} = $resulting if $rref && defined $resulting;
+}
+
sub jobdb_flight_started_for_log_capture ($$) { #method
my ($mo, $flight) = @_;
my $started= $dbh_tests->selectrow_array(<<END);
@@ -118,6 +118,8 @@ sub jobdb_resource_shared_mark_ready { } #method
sub jobdb_check_other_job { } #method
+sub jobdb_set_hosts_infraprioritygroup { } # method
+
sub jobdb_flight_started_for_log_capture ($$) { #method
my ($mo, $flight) = @_;
return time - 60*60; # just the most recent serial log then,
@@ -141,6 +141,7 @@ sub act_prealloc () {
compute_test_sharetype();
$ho = selecthost($whhost, undef, 1);
set_runtime_hostflag($ho->{Ident}, "reuse-$sharetype");
+ $mjobdb->jobdb_set_hosts_infraprioritygroup($flight, $job, $sharetype, \%r);
}
sub act_start_test () {
@@ -733,9 +733,13 @@ sub alloc_hosts () {
? -10000
: -10 * @hids;
+ my $infrapriority =
+ ($r{hosts_infraprioritygroup} // '') =~ m/^(\d+):/ ? $1 : undef;
+
my $ok = alloc_resources(WaitStart =>
($ENV{OSSTEST_RESOURCE_WAITSTART} || $fi->{started}),
WaitStartAdjust => $waitstartadjust,
+ InfraPriority => $infrapriority,
DebugFh => \*DEBUG,
\&attempt_allocation);