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

[OSSTEST PATCH 2/7] resource allocation: Provide OSSTEST_ALLOC_FAKE_PLAN test facility


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Wed, 19 Aug 2020 17:01:38 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Wed, 19 Aug 2020 16:02:02 +0000
  • Ironport-sdr: v0FaXVvy1mbxHR0Z3z5WtampetuyWG/fWbcM3eay2agJQaRO2FP3PfNO3JFwJMPBWZ9gEL+fUy JdU8tWD9xrryVTMIc88jGAFy+2zLj9f5mSD6m5DYo/z8p9CjWxFKZQcRgnv60dwIW7S2qojkc9 Ln+tFDIZUCXr29yo410Mt67Ktk9XrFPAa/U4Nzhzr2ZHtAy5qk+PN+jRuAJ5HkZ3dNNZJ82b5T pMDmD2I0ihoLc22SLFF9gY53vMF4+YfxztnrOgGc2mh2eBdXuYf4ogg+7IesMqDc5fA7Lu/0oV 1LE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Set this variable (to a data-plan.final.pl, say) and it becomes
possible to test host allocation programs without actually allocating
anything and without engaging with the queue system.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 0808202b..d6b2736b 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -767,6 +767,32 @@ sub alloc_resources {
        ? sub { print $debugfh @_, "\n" or die $!; }
         : sub { };
 
+    my $fake_plan = $ENV{OSSTEST_ALLOC_FAKE_PLAN};
+    if (defined $fake_plan) {
+       my $fake_data = do {
+           local $/ = undef;
+           open FAKEPLAN, "<", $ENV{OSSTEST_ALLOC_FAKE_PLAN} or die $!;
+           my $r = <FAKEPLAN> // die $!;
+           close FAKEPLAN;
+           $r;
+       };
+       if ($fake_plan =~ m{\.pl$}) {
+           $fake_data = eval $fake_data;
+       } elsif ($fake_plan =~ m{\.json$}) {
+           $fake_data = from_json($fake_data);
+       } else {
+           die;
+       }
+       db_retry($flight,'running', $dbh_tests, [], sub {
+            logm("fake resourcecall..");
+           my ($ok, $bookinglist) = $resourcecall->($fake_data, 1);
+            logm("fake resourcecall ok=$ok");
+           $dbh_tests->rollback();
+           exit $ok;
+        });
+       die "unexpectedly left db_retry";
+    }
+
     my $set_info= sub {
         return if grep { !defined } @_;
         my @s;
-- 
2.11.0




 


Rackspace

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