From 2d3fe6aa15c508c08a80ae4465f901216f326932 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 27 Oct 2017 15:41:31 +0100 Subject: [PATCH] host allocation: *_shared_mark_ready: Allow other states Generalise these functions so they can set the state to something other than `ready', and so that they can expect a state other than `prep'. No functional change with existing callers. Signed-off-by: Ian Jackson --- Osstest/Executive.pm | 19 +++++++++++-------- Osstest/JobDB/Executive.pm | 5 +++-- Osstest/TestSupport.pm | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm index 703f3d8..f0038f6 100644 --- a/Osstest/Executive.pm +++ b/Osstest/Executive.pm @@ -1050,11 +1050,14 @@ END return $shared; } -sub executive_resource_shared_mark_ready ($$$) { - my ($restype, $resname, $sharetype) = @_; +sub executive_resource_shared_mark_ready ($$$;$$) { + my ($restype, $resname, $sharetype, $oldstate, $newstate) = @_; # must run outside transaction my $oldshr; + $oldstate //= 'prep'; + $newstate //= 'ready'; + my $what= "resource $restype $resname"; $sharetype .= ' '.get_harness_rev(); @@ -1063,11 +1066,11 @@ sub executive_resource_shared_mark_ready ($$$) { if (defined $oldshr) { die "$what shared $oldshr->{Type} not $sharetype" unless $oldshr->{Type} eq $sharetype; - die "$what shared state $oldshr->{State} not prep" - unless $oldshr->{State} eq 'prep'; - my $nrows= $dbh_tests->do(<{State} not $oldstate" + unless $oldshr->{State} eq $oldstate; + my $nrows= $dbh_tests->do(<jobdb_resource_shared_mark_ready('host', $ho->{Name}, - $sharetype); + $sharetype, $oldstate, $newstate); } sub gitcache_setup ($) { -- 2.39.5