[pve-devel] [PATCH ha-manager 06/10] ensure test/sim.pl always use the currently developed code
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Dec 21 16:44:43 CET 2016
sim.pl suggested to be a perl script, but was a bash script which
called ../pve-ha-simulator
It set the include directory to '..' as its intended to use the
currently developed code, not the pve-ha-simulator installed on the
system.
This did not work correctly as pve-ha-simulator has a
use lib '/global/path/to/HA/Simulator'
directive.
Almost exactly duplicate pve-ha-simulators code as it's a really
small script which gets rarely touched, factoring out common
components would create more code and work than just adding a own
script.
Changes which differ from the pve-ha-simulator script include that we
fall back to the 'simtest' directory if none is given.
Also the 'batch' option does not exists here, use the ha-tester
script if you want this behavior.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/test/sim.pl | 45 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
diff --git a/src/test/sim.pl b/src/test/sim.pl
index 933c5ba..0924f34 100755
--- a/src/test/sim.pl
+++ b/src/test/sim.pl
@@ -1,5 +1,42 @@
-#!/bin/sh
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib '..';
+
+use JSON;
+use File::Path qw(remove_tree);
+
+use PVE::Tools;
+use PVE::HA::Sim::TestHardware;
+use PVE::HA::Sim::RTHardware;
+
+sub show_usage {
+ print "usage: $0 [testdir]\n";
+ exit(-1);
+};
+
+my $testdir = shift;
+
+if (!defined($testdir)) {
+ $testdir = "simtest";
+ remove_tree($testdir);
+ mkdir $testdir;
+}
+
+my $hardware = PVE::HA::Sim::RTHardware->new($testdir);
+
+$hardware->log('info', "starting simulation");
+
+eval { $hardware->run(); };
+if (my $err = $@) {
+ $hardware->log('err', "exit simulation - $err ");
+} else {
+ $hardware->log('info', "exit simulation - done");
+}
+
+exit(0);
+
+
-rm -rf simtest
-mkdir simtest
-perl -I .. ../pve-ha-simulator simtest
--
2.1.4
More information about the pve-devel
mailing list