[pve-devel] [RFC v2 pve-ha-manager 5/9] TestHardware: add a more deterministic delay possibility

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 14 15:29:57 CET 2015


With this patch we can add a command to be executed after the
current command and some specified delay, e.g. the following
cmdlist line:
[ "power nodeX shutdown", "delay 5", "power nodeX on"]

This works more deterministic as it gets added to the helper
command list, which gets executed on every loop cycle from the
node processing loop and thus with a higher frequency,
whereas time between two comandlist commands can be undefined
and is mostly bigger. We need this for example to simulate a short
shutdown - power on cycle.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Sim/TestHardware.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/HA/Sim/TestHardware.pm b/src/PVE/HA/Sim/TestHardware.pm
index 5c8a0cd..9bf2936 100644
--- a/src/PVE/HA/Sim/TestHardware.pm
+++ b/src/PVE/HA/Sim/TestHardware.pm
@@ -290,12 +290,19 @@ sub run {
 		# end sumulation (500 seconds after last command)
 		return if (($self->{cur_time} - $last_command_time) > 500);
 	    }
-
+	    my $delay_next_commands;
 	    foreach my $cmd (@$list) {
 		$last_command_time = $self->{cur_time};
 
 		if ($cmd =~ m/^delay\s+(\d+)\s*$/) {
 		    $next_cmd_at = $self->{cur_time} + $1;
+		    $delay_next_commands = 1;
+		} elsif ($delay_next_commands) {
+		    # after an delay add all following commands, if any, to
+		    # the helper cmd list, as they need to be executed more
+		    # deterministic and faster than with the cmdlist possible
+		    &$add_helper_cmd($self, $next_cmd_at, $cmd);
+		    $next_cmd_at = $self->{cur_time};
 		} else {
 		    $self->sim_hardware_cmd($cmd, 'cmdlist');
 		}
-- 
2.1.4




More information about the pve-devel mailing list