From 1952f36a834ac9d5491128a06d71d0ba73acd51b Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Tue, 10 May 2022 12:42:08 +0200
Subject: [PATCH 8/9] Test: scheduler: do not enforce resource stop on a
 rejoined node that was the target of a failed migrate_to

---
 cts/cts-pengine.in                          |  1 +
 .../probe-target-of-failed-migrate_to-1.dot   |  4 ++
 .../probe-target-of-failed-migrate_to-1.exp   | 20 ++++++++
 ...probe-target-of-failed-migrate_to-1.scores |  5 ++
 ...robe-target-of-failed-migrate_to-1.summary | 23 +++++++++
 .../probe-target-of-failed-migrate_to-1.xml   | 48 +++++++++++++++++++
 6 files changed, 101 insertions(+)
 create mode 100644 cts/pengine/probe-target-of-failed-migrate_to-1.dot
 create mode 100644 cts/pengine/probe-target-of-failed-migrate_to-1.exp
 create mode 100644 cts/pengine/probe-target-of-failed-migrate_to-1.scores
 create mode 100644 cts/pengine/probe-target-of-failed-migrate_to-1.summary
 create mode 100644 cts/pengine/probe-target-of-failed-migrate_to-1.xml

Index: pacemaker-2.0.1+20190417.13d370ca9/cts/cts-pengine.in
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/cts/cts-pengine.in
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/cts-pengine.in
@@ -697,6 +697,7 @@ do_test 11-a-then-bm-b-move-a-clone-star
 
 do_test a-promote-then-b-migrate "A promote then B start. migrate B"
 do_test a-demote-then-b-migrate "A demote then B stop. migrate B"
+do_test probe-target-of-failed-migrate_to-1 "Failed migrate_to, target rejoins"
 
 if [ $DO_VERSIONED_TESTS -eq 1 ]; then
     do_test migrate-versioned "Disable migration for versioned resources"
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.dot
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.dot
@@ -0,0 +1,4 @@
+ digraph "g" {
+"dummy1_monitor_0 node2" [ style=bold color="green" fontcolor="black"]
+"st-sbd_monitor_0 node2" [ style=bold color="green" fontcolor="black"]
+}
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.exp
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.exp
@@ -0,0 +1,20 @@
+<transition_graph cluster-delay="60s" stonith-timeout="60s" failed-stop-offset="INFINITY" failed-start-offset="INFINITY"  transition_id="0">
+  <synapse id="0">
+    <action_set>
+      <rsc_op id="2" operation="monitor" operation_key="st-sbd_monitor_0" on_node="node2" on_node_uuid="2">
+        <primitive id="st-sbd" class="stonith" type="external/sbd"/>
+        <attributes CRM_meta_on_node="node2" CRM_meta_on_node_uuid="2" CRM_meta_op_target_rc="7" CRM_meta_timeout="20000" />
+      </rsc_op>
+    </action_set>
+    <inputs/>
+  </synapse>
+  <synapse id="1">
+    <action_set>
+      <rsc_op id="3" operation="monitor" operation_key="dummy1_monitor_0" on_node="node2" on_node_uuid="2">
+        <primitive id="dummy1" class="ocf" provider="pacemaker" type="Dummy"/>
+        <attributes CRM_meta_on_node="node2" CRM_meta_on_node_uuid="2" CRM_meta_op_target_rc="7" CRM_meta_timeout="20000" />
+      </rsc_op>
+    </action_set>
+    <inputs/>
+  </synapse>
+</transition_graph>
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.scores
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.scores
@@ -0,0 +1,6 @@
+Allocation scores:
+Using the original execution date of: 2022-05-09 10:28:56Z
+native_color: dummy1 allocation score on node1: INFINITY
+native_color: dummy1 allocation score on node2: 0
+native_color: st-sbd allocation score on node1: 0
+native_color: st-sbd allocation score on node2: 0
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.summary
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.summary
@@ -0,0 +1,21 @@
+Using the original execution date of: 2022-05-09 10:28:56Z
+
+Current cluster status:
+Online: [ node1 node2 ]
+
+ st-sbd	(stonith:external/sbd):	 Started node1
+ dummy1	(ocf::pacemaker:Dummy):	 Started node1
+
+Transition Summary:
+
+Executing cluster transition:
+  * Resource action: st-sbd          monitor on node2
+  * Resource action: dummy1          monitor on node2
+Using the original execution date of: 2022-05-09 10:28:56Z
+
+Revised cluster status:
+Online: [ node1 node2 ]
+
+ st-sbd	(stonith:external/sbd):	 Started node1
+ dummy1	(ocf::pacemaker:Dummy):	 Started node1
+
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.xml
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/pengine/probe-target-of-failed-migrate_to-1.xml
@@ -0,0 +1,48 @@
+<cib crm_feature_set="3.0.10" validate-with="pacemaker-2.7" epoch="54" num_updates="7" admin_epoch="0" cib-last-written="Mon May  9 12:26:45 2022" update-origin="node1" update-client="cibadmin" update-user="root" have-quorum="1" dc-uuid="1" execution-date="1652092136">
+  <configuration>
+    <crm_config>
+      <cluster_property_set id="cib-bootstrap-options">
+        <nvpair name="have-watchdog" value="true" id="cib-bootstrap-options-have-watchdog"/>
+        <nvpair name="dc-version" value="2.1.2+20220509.89fa32d09-150300.1378.1-2.1.2+20220509.89fa32d09" id="cib-bootstrap-options-dc-version"/>
+        <nvpair name="cluster-infrastructure" value="corosync" id="cib-bootstrap-options-cluster-infrastructure"/>
+        <nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1648809766"/>
+      </cluster_property_set>
+    </crm_config>
+    <nodes>
+      <node id="1" uname="node1"/>
+      <node id="2" uname="node2"/>
+    </nodes>
+    <resources>
+      <primitive id="st-sbd" class="stonith" type="external/sbd"/>
+      <primitive id="dummy1" class="ocf" provider="pacemaker" type="Dummy">
+        <meta_attributes id="dummy1-meta_attributes">
+          <nvpair name="allow-migrate" value="true" id="dummy1-meta_attributes-allow-migrate"/>
+        </meta_attributes>
+      </primitive>
+    </resources>
+    <constraints>
+      <rsc_location id="cli-prefer-dummy1" rsc="dummy1" role="Started" score="INFINITY" node="node1"/>
+    </constraints>
+    <rsc_defaults/>
+  </configuration>
+  <status>
+    <node_state id="1" uname="node1" in_ccm="true" crmd="online" crm-debug-origin="do_state_transition" join="member" expected="member">
+      <lrm id="1">
+        <lrm_resources>
+          <lrm_resource id="st-sbd" type="external/sbd" class="stonith">
+            <lrm_rsc_op id="st-sbd_last_0" operation_key="st-sbd_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.15.0" transition-key="3:1:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" transition-magic="0:0;3:1:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" exit-reason="" on_node="node1" call-id="10" rc-code="0" op-status="0" interval="0" last-rc-change="1652091783" exec-time="1344" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="dummy1" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="dummy1_last_failure_0" operation_key="dummy1_migrate_to_0" operation="migrate_to" crm-debug-origin="build_active_RAs" crm_feature_set="3.15.0" transition-key="5:2:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" transition-magic="0:1;5:2:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" exit-reason="" on_node="node1" call-id="12" rc-code="1" op-status="0" interval="0" last-rc-change="1652091880" exec-time="142" queue-time="0" migrate_source="node1" migrate_target="node2" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+            <lrm_rsc_op id="dummy1_last_0" operation_key="dummy1_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.15.0" transition-key="5:4:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" transition-magic="0:0;5:4:0:dbc3dbdf-240c-4c26-8cfc-0d86416529e6" exit-reason="" on_node="node1" call-id="14" rc-code="0" op-status="0" interval="0" last-rc-change="1652091894" exec-time="61" queue-time="0" migrate_source="node1" migrate_target="node2" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart="  state  " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-secure-params="  passwd  " op-secure-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+        </lrm_resources>
+      </lrm>
+    </node_state>
+    <node_state id="2" in_ccm="true" crmd="online" crm-debug-origin="do_state_transition" uname="node2" join="member" expected="member">
+      <lrm id="2">
+        <lrm_resources/>
+      </lrm>
+    </node_state>
+  </status>
+</cib>
