File 0001-Test-cts-ComponentFail-killed-corosync-doesn-t-respa-1.1.patch of Package pacemaker.19404

From a6a6ff883497c96bd6b1a1b1703c6d740a2c2260 Mon Sep 17 00:00:00 2001
From: aleksei-burlakov <aleksei.burlakov@suse.com>
Date: Tue, 22 Oct 2019 11:47:31 +0200
Subject: [PATCH] Test: cts: ComponentFail: killed corosync doesn't respawn
 immediatelly.

Backport the #1897. corosync doesn't respawn immediatelly when killed,
so that the fencing had more time to reboot the node.
---
 cts/CTS.py.in      | 19 +++++++++++++++++++
 cts/CTStests.py | 23 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)

Index: pacemaker-1.1.18+20180430.b12c320f5/cts/CTS.py.in
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/cts/CTS.py.in
+++ pacemaker-1.1.18+20180430.b12c320f5/cts/CTS.py.in
@@ -362,6 +362,25 @@ class ClusterManager(UserDict):
             self.rsh.cp(file_with_path, "root@%s:%s/%s" % (node, destdir, filename))
         return file_with_path
 
+    def uninstall_helper(self, filename, dir=None, nodes=None):
+        if not nodes:
+            nodes = self.Env["nodes"]
+
+        if not dir:
+            dir = CTSvars.CTS_home
+
+        for node in nodes:
+            self.debug("Uninstalling %s from %s on %s" % (filename, dir, repr(node)))
+            self.rsh(node, "rm -rf %s/%s" % (dir, filename))
+
+    def systemctl_daemon_reload(self, nodes=None):
+        if not nodes:
+            nodes = self.Env["nodes"]
+
+        for node in nodes:
+            self.debug("Reloading the system manager configuration on %s" % (repr(node)))
+            self.rsh(node, "systemctl daemon-reload")
+
     def install_config(self, node):
         return None
 
Index: pacemaker-1.1.18+20180430.b12c320f5/cts/CTStests.py
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/cts/CTStests.py
+++ pacemaker-1.1.18+20180430.b12c320f5/cts/CTStests.py
@@ -1416,6 +1416,23 @@ class ComponentFail(CTSTest):
             tmpPats, self.Env["DeadTime"] + self.Env["StableTime"] + self.Env["StartTime"])
         watch.setwatch()
 
+        if self.CM.Env["have_systemd"]:
+            temporary_corosync_service = """
+[Service]
+Restart=always
+RestartSec=70
+"""
+
+            (handle, keyfile) = tempfile.mkstemp(suffix=".conf", prefix="cts", dir="/tmp", text=True)
+            f = open(keyfile, "w")
+            f.write(temporary_corosync_service)
+            f.close()
+            os.close(handle)
+            self.CM.install_helper(os.path.basename(keyfile), destdir="/run/systemd/system/corosync.service.d/" \
+                , sourcedir=os.path.dirname(keyfile))
+            os.remove(keyfile)
+            self.CM.systemctl_daemon_reload()
+
         # kill the component
         chosen.kill(node)
 
@@ -1434,6 +1451,9 @@ class ComponentFail(CTSTest):
             self.debug("Found: " + repr(shot))
             self.okerrpatterns.append(self.templates["Pat:Fencing_start"] % node)
 
+            self.CM.uninstall_helper("", dir="/run/systemd/system/corosync.service.d")
+            self.CM.systemctl_daemon_reload()
+
             if self.Env["at-boot"] == 0:
                 self.CM.ShouldBeStatus[node] = "down"
 
@@ -1449,6 +1469,9 @@ class ComponentFail(CTSTest):
         self.debug("Waiting for the cluster to re-stabilize with all nodes")
         is_stable = self.CM.cluster_stable(self.Env["StartTime"])
 
+        self.CM.uninstall_helper("", dir="/run/systemd/system/corosync.service.d")
+        self.CM.systemctl_daemon_reload()
+
         if not matched:
             return self.failure("Didn't find all expected %s patterns" % chosen.name)
         elif not is_stable:
openSUSE Build Service is sponsored by