]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
tests: add one for service set to be & stay ignored from the start
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Jul 2021 15:26:13 +0000 (17:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 2 Jul 2021 18:08:12 +0000 (20:08 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/HA/LRM.pm
src/test/test-service-ignore3/README [new file with mode: 0644]
src/test/test-service-ignore3/cmdlist [new file with mode: 0644]
src/test/test-service-ignore3/hardware_status [new file with mode: 0644]
src/test/test-service-ignore3/log.expect [new file with mode: 0644]
src/test/test-service-ignore3/manager_status [new file with mode: 0644]
src/test/test-service-ignore3/service_config [new file with mode: 0644]

index 97aa1e0cc7c12202dbded2afb8b523426de47ac3..b3074d5a7641fa72283c6096d374a7e3b73bfa02 100644 (file)
@@ -242,13 +242,11 @@ sub active_service_count {
     my ($self) = @_;
 
     my $haenv = $self->{haenv};
-
     my $nodename = $haenv->nodename();
 
     my $ss = $self->{service_status};
 
     my $count = 0;
-
     foreach my $sid (keys %$ss) {
        my $sd = $ss->{$sid};
        next if !$sd->{node};
@@ -256,6 +254,7 @@ sub active_service_count {
        my $req_state = $sd->{state};
        next if !defined($req_state);
        next if $req_state eq 'stopped';
+       # NOTE: 'ignored' ones are already dropped by the manager from service_status
        next if $req_state eq 'freeze';
        # erroneous services are not managed by HA, don't count them as active
        next if $req_state eq 'error';
diff --git a/src/test/test-service-ignore3/README b/src/test/test-service-ignore3/README
new file mode 100644 (file)
index 0000000..489b1ce
--- /dev/null
@@ -0,0 +1,2 @@
+A ignored service should not count towards active node services, so the LRM
+should stay in the wait_for_agent_lock state.
diff --git a/src/test/test-service-ignore3/cmdlist b/src/test/test-service-ignore3/cmdlist
new file mode 100644 (file)
index 0000000..3bfad44
--- /dev/null
@@ -0,0 +1,3 @@
+[
+    [ "power node1 on", "power node2 on", "power node3 on"]
+]
diff --git a/src/test/test-service-ignore3/hardware_status b/src/test/test-service-ignore3/hardware_status
new file mode 100644 (file)
index 0000000..451beb1
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "node1": { "power": "off", "network": "off" },
+  "node2": { "power": "off", "network": "off" },
+  "node3": { "power": "off", "network": "off" }
+}
diff --git a/src/test/test-service-ignore3/log.expect b/src/test/test-service-ignore3/log.expect
new file mode 100644 (file)
index 0000000..586ea14
--- /dev/null
@@ -0,0 +1,18 @@
+info      0     hardware: starting simulation
+info     20      cmdlist: execute power node1 on
+info     20    node1/crm: status change startup => wait_for_quorum
+info     20    node1/lrm: status change startup => wait_for_agent_lock
+info     20      cmdlist: execute power node2 on
+info     20    node2/crm: status change startup => wait_for_quorum
+info     20    node2/lrm: status change startup => wait_for_agent_lock
+info     20      cmdlist: execute power node3 on
+info     20    node3/crm: status change startup => wait_for_quorum
+info     20    node3/lrm: status change startup => wait_for_agent_lock
+info     20    node1/crm: got lock 'ha_manager_lock'
+info     20    node1/crm: status change wait_for_quorum => master
+info     20    node1/crm: node 'node1': state changed from 'unknown' => 'online'
+info     20    node1/crm: node 'node2': state changed from 'unknown' => 'online'
+info     20    node1/crm: node 'node3': state changed from 'unknown' => 'online'
+info     22    node2/crm: status change wait_for_quorum => slave
+info     24    node3/crm: status change wait_for_quorum => slave
+info    620     hardware: exit simulation - done
diff --git a/src/test/test-service-ignore3/manager_status b/src/test/test-service-ignore3/manager_status
new file mode 100644 (file)
index 0000000..0967ef4
--- /dev/null
@@ -0,0 +1 @@
+{}
diff --git a/src/test/test-service-ignore3/service_config b/src/test/test-service-ignore3/service_config
new file mode 100644 (file)
index 0000000..8066aab
--- /dev/null
@@ -0,0 +1,3 @@
+{
+    "vm:103": { "node": "node3", "state": "ignored" }
+}