[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
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |