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

[OSSTEST PATCH 25/82] host allocation: *_shared_mark_ready: Make $sharetype check optional



From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

We are going to want to be able to set shares to other than ready,
without double-checking the sharetype.

The change to the UPDATE statement makes no difference because
resource_check_allocated_core has just got that sharetype out of the
db.  (This does remove one safety check against bugs, sadly.)

No functional change for existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index f0038f6b..fd975590 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -1059,21 +1059,25 @@ sub executive_resource_shared_mark_ready ($$$;$$) {
     $newstate //= 'ready';
 
     my $what= "resource $restype $resname";
-    $sharetype .= ' '.get_harness_rev();
+    if (defined $sharetype) {
+       $sharetype .= ' '.get_harness_rev();
+    } else {
+       die if $newstate eq 'ready';
+    }
 
     db_retry($dbh_tests, [qw(resources)], sub {
         $oldshr= resource_check_allocated_core($restype, $resname);
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
-                unless $oldshr->{Type} eq $sharetype;
+                unless !defined $sharetype or $oldshr->{Type} eq $sharetype;
             die "$what shared state $oldshr->{State} not $oldstate"
                 unless $oldshr->{State} eq $oldstate;
-            my $nrows= $dbh_tests->do(<<END,{}, $newstate, 
$restype,$resname,$sharetype);
+            my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname);
                 UPDATE resource_sharing
                    SET state=?
-                 WHERE restype=? AND resname=? AND sharetype=?
+                 WHERE restype=? AND resname=?
 END
-            die "unexpected not updated state $what $sharetype $nrows"
+            die "unexpected not updated state $what $nrows"
                 unless $nrows==1;
 
             $dbh_tests->do(<<END,{}, $oldshr->{ResType}, $resname);
-- 
2.20.1




 


Rackspace

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