From 834c252b223f23ae9ed8e147255c879697bdd0c1 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Tue, 21 Feb 2023 16:48:24 +0100
Subject: [PATCH 1/3] Test: cts-scheduler: add regression test about a pending
 node that doesn't have an uname in node state yet

---
 cts/cts-scheduler.in                          |  1 +
 cts/scheduler/pending-node-no-uname.dot   |  7 ++++
 cts/scheduler/pending-node-no-uname.exp   | 38 +++++++++++++++++++
 .../pending-node-no-uname.scores       |  3 ++
 .../pending-node-no-uname.summary     | 26 +++++++++++++
 cts/scheduler/pending-node-no-uname.xml   | 26 +++++++++++++
 6 files changed, 101 insertions(+)
 create mode 100644 cts/scheduler/pending-node-no-uname.dot
 create mode 100644 cts/scheduler/pending-node-no-uname.exp
 create mode 100644 cts/scheduler/pending-node-no-uname.scores
 create mode 100644 cts/scheduler/pending-node-no-uname.summary
 create mode 100644 cts/scheduler/pending-node-no-uname.xml

Index: pacemaker-2.0.1+20190417.13d370ca9/cts/cts-scheduler.in
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/cts/cts-scheduler.in
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/cts-scheduler.in
@@ -957,6 +957,7 @@ do_test order-first-probes "cl#5301 - re
 
 do_test concurrent-fencing "Allow performing fencing operations in parallel"
 do_test priority-fencing-delay "Delay fencing targeting the more significant node"
+do_test pending-node-no-uname "Do not fence a pending node that doesn't have an uname in node state yet"
 
 echo ""
 do_test systemhealth1  "System Health ()               #1"
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.dot
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.dot
@@ -0,0 +1,7 @@
+ digraph "g" {
+"st-sbd_monitor_0 node-1" -> "st-sbd_start_0 node-1" [ style = bold]
+"st-sbd_monitor_0 node-1" [ style=bold color="green" fontcolor="black"]
+"st-sbd_start_0 node-1" [ style=bold color="green" fontcolor="black"]
+"stonith 'reboot' node-2" -> "st-sbd_start_0 node-1" [ style = bold]
+"stonith 'reboot' node-2" [ style=bold color="green" fontcolor="black"]
+}
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.exp
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.exp
@@ -0,0 +1,38 @@
+<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="start" operation_key="st-sbd_start_0" on_node="node-1" on_node_uuid="1">
+        <primitive id="st-sbd" class="stonith" type="external/sbd"/>
+        <attributes CRM_meta_on_node="node-1" CRM_meta_on_node_uuid="1" CRM_meta_timeout="20000" />
+      </rsc_op>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="1" operation="monitor" operation_key="st-sbd_monitor_0" on_node="node-1" on_node_uuid="1"/>
+      </trigger>
+      <trigger>
+        <crm_event id="3" operation="stonith" operation_key="stonith-node-2-reboot" on_node="node-2" on_node_uuid="2"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="1">
+    <action_set>
+      <rsc_op id="1" operation="monitor" operation_key="st-sbd_monitor_0" on_node="node-1" on_node_uuid="1">
+        <primitive id="st-sbd" class="stonith" type="external/sbd"/>
+        <attributes CRM_meta_on_node="node-1" CRM_meta_on_node_uuid="1" CRM_meta_op_target_rc="7" CRM_meta_timeout="20000" />
+      </rsc_op>
+    </action_set>
+    <inputs/>
+  </synapse>
+  <synapse id="2">
+    <action_set>
+      <crm_event id="3" operation="stonith" operation_key="stonith-node-2-reboot" on_node="node-2" on_node_uuid="2">
+        <attributes CRM_meta_on_node="node-2" CRM_meta_on_node_uuid="2" CRM_meta_stonith_action="reboot" />
+        <downed>
+          <node id="2"/>
+        </downed>
+      </crm_event>
+    </action_set>
+    <inputs/>
+  </synapse>
+</transition_graph>
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.scores
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.scores
@@ -0,0 +1,4 @@
+Allocation scores:
+Using the original execution date of: 2023-02-21 12:19:57Z
+native_color: st-sbd allocation score on node-1: 0
+native_color: st-sbd allocation score on node-2: 0
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.summary
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.summary
@@ -0,0 +1,26 @@
+Using the original execution date of: 2023-02-21 12:19:57Z
+Current cluster status:
+  * Node List:
+    * Node node-2: UNCLEAN (offline)
+    * Online: [ node-1 ]
+
+  * Full List of Resources:
+    * st-sbd	(stonith:external/sbd):	 Stopped
+
+Transition Summary:
+  * Fence (reboot) node-2 'node is unclean'
+  * Start      st-sbd     ( node-1 )
+
+Executing Cluster Transition:
+  * Resource action: st-sbd          monitor on node-1
+  * Fencing node-2 (reboot)
+  * Resource action: st-sbd          start on node-1
+Using the original execution date of: 2023-02-21 12:19:57Z
+
+Revised Cluster Status:
+  * Node List:
+    * Online: [ node-1 ]
+    * OFFLINE: [ node-2 ]
+
+  * Full List of Resources:
+    * st-sbd	(stonith:external/sbd):	 Started node-1
Index: pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.xml
===================================================================
--- /dev/null
+++ pacemaker-2.0.1+20190417.13d370ca9/cts/scheduler/pending-node-no-uname.xml
@@ -0,0 +1,26 @@
+<cib crm_feature_set="3.0.4" validate-with="pacemaker-2.10" epoch="5" num_updates="0" admin_epoch="0" cib-last-written="Tue Feb 21 13:19:57 2023" update-origin="node-1" update-client="cibadmin" update-user="root" have-quorum="true" dc-uuid="1" execution-date="1676981997">
+  <configuration>
+    <crm_config>
+      <cluster_property_set id="cib-bootstrap-options">
+        <nvpair id="cib-bootstrap-options-have-watchdog" name="have-watchdog" value="true"/>
+        <nvpair id="cib-bootstrap-options-cluster-infrastructure" name="cluster-infrastructure" value="corosync"/>
+      </cluster_property_set>
+    </crm_config>
+    <nodes>
+      <node id="1" uname="node-1"/>
+      <node id="2" uname="node-2"/>
+    </nodes>
+    <resources>
+      <primitive id="st-sbd" class="stonith" type="external/sbd"/>
+    </resources>
+    <constraints/>
+  </configuration>
+  <status>
+    <node_state id="1" uname="node-1" in_ccm="true" crmd="online" crm-debug-origin="post_cache_update" join="member" expected="member">
+      <lrm id="1">
+        <lrm_resources/>
+      </lrm>
+    </node_state>
+    <node_state id="2" in_ccm="true" crmd="offline" crm-debug-origin="post_cache_update"/>
+  </status>
+</cib>
