diff mbox

[OSSTEST,9/9] mg-allocate: In planner mode, pre-check the arguments

Message ID 1450371968-27997-9-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Dec. 17, 2015, 5:06 p.m. UTC
Now, attempting to allocate a nonexistent host fails immediately with
a sensible message, rather than queueing up and then reporting the
message only later:

mariner:testing.git> OSSTEST_CONFIG=/u/iwj/.xen-osstest/config:local-config.test-database_iwj ./mg-allocate -U 1h spong
2015-12-17 17:05:14 Z pre-checking resources (dry run)...
2015-12-17 17:05:14 Z (precheck) task 196916 static iwj@mariner: iwj@mariner manual
*** no candidates for spong! ***
mariner:testing.git>

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 mg-allocate |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Ian Campbell Dec. 17, 2015, 5:33 p.m. UTC | #1
On Thu, 2015-12-17 at 17:06 +0000, Ian Jackson wrote:
> Now, attempting to allocate a nonexistent host fails immediately with
> a sensible message, rather than queueing up and then reporting the
> message only later:
> 
> mariner:testing.git> OSSTEST_CONFIG=/u/iwj/.xen-osstest/config:local-
> config.test-database_iwj ./mg-allocate -U 1h spong
> 2015-12-17 17:05:14 Z pre-checking resources (dry run)...
> 2015-12-17 17:05:14 Z (precheck) task 196916 static iwj@mariner: iwj@mari
> ner manual
> *** no candidates for spong! ***
> mariner:testing.git>
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff mbox

Patch

diff --git a/mg-allocate b/mg-allocate
index 54a7af3..3730c23 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -238,7 +238,8 @@  sub loggot {
 	foreach @got;
 }
 
-sub execute () {
+sub execute (;$) {
+    my ($dryrun) = @_;
     my @got;
     db_retry($dbh_tests, \@all_lock_tables, sub {
 
@@ -259,10 +260,15 @@  sub execute () {
             }
         }
 
+	if ($dryrun) {
+	    db_retry_abort();
+	    return;
+	}
         if (!$allok) {
             die "allocation/deallocation unsuccessful\n";
         }
     });
+    return if $dryrun;
     loggot(@got);
     logm("done.");
 }
@@ -388,6 +394,11 @@  while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) {
 }
 
 if ($duration) {
+    {
+	logm("pre-checking resources (dry run)...");
+	local $Osstest::TestSupport::logm_prefix = $logm_prefix.' (precheck)';
+	execute(1);
+    };
     plan();
 } else {
     execute();