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

[Xen-devel] [OSSTEST PATCH 07/10] mg-anoint: Make readonly operations "work" in standalone mode



This makes `mg-anoint' in standalone mode a view onto an empty set of
anointments.  So now it becomes ok to call mg-anoint in make-*-flight.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 Osstest/JobDB/Executive.pm  |  2 ++
 Osstest/JobDB/Standalone.pm |  2 ++
 mg-anoint                   | 20 +++++++++++++++++++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index a7a6696..fe8e7f6 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -409,4 +409,6 @@ sub jobdb_db_glob ($$) { #method
     return "LIKE E'$str'";
 }
 
+sub can_anoint ($) { return 1; }
+
 1;
diff --git a/Osstest/JobDB/Standalone.pm b/Osstest/JobDB/Standalone.pm
index d9a90fc..4f320cc 100644
--- a/Osstest/JobDB/Standalone.pm
+++ b/Osstest/JobDB/Standalone.pm
@@ -133,4 +133,6 @@ sub jobdb_db_glob ($) { #method
     return "GLOB '$str'";
 }
 
+sub can_anoint ($) { return 0; }
+
 1;
diff --git a/mg-anoint b/mg-anoint
index b007ab4..522cbdd 100755
--- a/mg-anoint
+++ b/mg-anoint
@@ -66,7 +66,6 @@ use DBI;
 BEGIN { unshift @INC, qw(.); }
 use Osstest;
 use Osstest::TestSupport;
-use Osstest::Executive;
 use IO::Handle;
 use Text::Glob qw(glob_to_regex);
 
@@ -93,6 +92,15 @@ END
 our $task_q;
 our $mostrecent_q;
 
+sub empty_unless_can_anoint () {
+    return if $mjobdb->can_anoint();
+    exit 0;
+}
+sub fail_unless_can_anoint () {
+    return if $mjobdb->can_anoint();
+    die "anointments not supported in this mode ($c{JobDB})\n"
+}
+
 sub prep_queries {
     $task_q = $dbh_tests->prepare(<<END);
         SELECT taskid, refinfo FROM tasks WHERE type='anoint' AND refkey=?
@@ -121,6 +129,9 @@ sub cmd_prepare {
     }
     die "usage: mg-anoint prepare [OPTIONS] 'SCOPE DETAILS...' DESCRIPTION"
        unless @ARGV==2 || $ARGV[0] =~ m/ /;
+
+    fail_unless_can_anoint();
+
     my ($refkey, $description) = @ARGV;
     my $dq = $dbh_tests->prepare(<<END);
         DELETE FROM tasks WHERE type='anoint' AND refkey=?
@@ -142,6 +153,7 @@ sub cmd_destroy {
     die unless @ARGV==1;
     die if $ARGV[0] =~ m/^-/;
     my ($refkey) = @ARGV;
+    fail_unless_can_anoint();
     my $rdq = $dbh_tests->prepare(<<END);
         DELETE FROM resources
               WHERE restype='share-flight'
@@ -178,6 +190,7 @@ sub cmd_anoint {
     die unless @ARGV==3;
     my ($refkey, $flight, $job) = @ARGV;
 
+    fail_unless_can_anoint();
     prep_queries();
 
     my $newflight_q = $dbh_tests->prepare(<<END);
@@ -285,6 +298,7 @@ sub cmd_retrieve {
     die if $ARGV[0] =~ m/^-/;
     my ($refkey) = @ARGV;
 
+    empty_unless_can_anoint();
     prep_queries();
 
     db_retry($dbh_tests, [], sub {
@@ -307,6 +321,8 @@ sub cmd_retrieve {
 sub cmd_list {
     die "no options to list" if @ARGV;
 
+    empty_unless_can_anoint();
+
     my $tq = $dbh_tests->prepare(<<END);
         SELECT *
           FROM tasks
@@ -347,6 +363,8 @@ sub cmd_list_prepared {
     my ($pat) = @ARGV;
     my $re = glob_to_regex $pat;
 
+    empty_unless_can_anoint();
+
     my $tq = $dbh_tests->prepare(<<END);
         SELECT *
           FROM tasks
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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