Blame SOURCES/bz1792946-01-tests-update-for-pacemaker-2.0.3-4.patch

bc4e95
From 9fbeeed4e43dc37800de3c3f0cf6f7520dc31ccf Mon Sep 17 00:00:00 2001
bc4e95
From: Tomas Jelinek <tojeline@redhat.com>
bc4e95
Date: Mon, 20 Jan 2020 12:34:55 +0100
bc4e95
Subject: [PATCH] tests: update for pacemaker-2.0.3-4
bc4e95
bc4e95
---
bc4e95
 pcs_test/tier0/test_resource.py | 59 +++++++++++++-------------
bc4e95
 pcs_test/tier0/test_stonith.py  | 75 +++++++++++++++++----------------
bc4e95
 pcs_test/tools/assertions.py    | 24 +++++++++--
bc4e95
 3 files changed, 88 insertions(+), 70 deletions(-)
bc4e95
bc4e95
diff --git a/pcs_test/tier0/test_resource.py b/pcs_test/tier0/test_resource.py
bc4e95
index b8b85dd2..45d98dff 100644
bc4e95
--- a/pcs_test/tier0/test_resource.py
bc4e95
+++ b/pcs_test/tier0/test_resource.py
bc4e95
@@ -10,6 +10,7 @@ from pcs_test.tier0.cib_resource.common import ResourceTest
bc4e95
 from pcs_test.tools.assertions import (
bc4e95
     ac,
bc4e95
     AssertPcsMixin,
bc4e95
+    assert_pcs_status,
bc4e95
 )
bc4e95
 from pcs_test.tools.bin_mock import get_mock_settings
bc4e95
 from pcs_test.tools.cib import get_assert_pcs_effect_mixin
bc4e95
@@ -953,11 +954,11 @@ monitor interval=20 (A-monitor-interval-20)
bc4e95
         o,r = pcs(temp_cib, "resource status")
bc4e95
         assert r == 0
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(o,"""\
bc4e95
+            assert_pcs_status(o,"""\
bc4e95
   * Resource Group: AGroup:
bc4e95
-    * A1\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * A2\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * A3\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+    * A1\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * A2\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * A3\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
 """)
bc4e95
         else:
bc4e95
             ac(o,"""\
bc4e95
@@ -1208,19 +1209,19 @@ monitor interval=20 (A-monitor-interval-20)
bc4e95
         output, returnVal = pcs(temp_cib, "resource")
bc4e95
         assert returnVal == 0
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(output, """\
bc4e95
-  * F\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-  * G\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-  * H\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+            assert_pcs_status(output, """\
bc4e95
+  * F\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+  * G\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+  * H\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
   * Resource Group: RGA:
bc4e95
-    * A\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * B\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * C\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * E\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * D\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * K\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * J\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * I\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+    * A\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * B\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * C\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * E\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * D\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * K\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * J\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * I\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
 """)
bc4e95
         else:
bc4e95
             ac(output, """\
bc4e95
@@ -2004,9 +2005,9 @@ monitor interval=20 (A-monitor-interval-20)
bc4e95
 
bc4e95
         o,r = pcs(temp_cib, "resource")
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(o,"""\
bc4e95
+            assert_pcs_status(o,"""\
bc4e95
   * Resource Group: AG:
bc4e95
-    * D1\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+    * D1\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
   * Clone Set: D0-clone [D0]:
bc4e95
 """)
bc4e95
         else:
bc4e95
@@ -2348,10 +2349,10 @@ monitor interval=20 (A-monitor-interval-20)
bc4e95
         o,r = pcs(temp_cib, "resource status")
bc4e95
         assert r == 0
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(o,"""\
bc4e95
+            assert_pcs_status(o,"""\
bc4e95
   * Resource Group: DGroup:
bc4e95
-    * D1\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-    * D2\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+    * D1\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+    * D2\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
 """)
bc4e95
         else:
bc4e95
             ac(o,"""\
bc4e95
@@ -3560,12 +3561,12 @@ Error: role must be: Stopped, Started, Slave or Master (use --force to override)
bc4e95
         assert retVal == 0
bc4e95
         output, retVal = pcs(temp_cib, "resource status")
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(output, outdent(
bc4e95
+            assert_pcs_status(output, outdent(
bc4e95
                 """\
bc4e95
                   * Resource Group: dummies:
bc4e95
-                    * dummy1\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-                    * dummy2\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-                    * dummy3\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+                    * dummy1\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+                    * dummy2\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+                    * dummy3\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
                 """
bc4e95
             ))
bc4e95
         else:
bc4e95
@@ -3652,12 +3653,12 @@ Error: role must be: Stopped, Started, Slave or Master (use --force to override)
bc4e95
         assert retVal == 0
bc4e95
         output, retVal = pcs(temp_cib, "resource status")
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
-            ac(output, outdent(
bc4e95
+            assert_pcs_status(output, outdent(
bc4e95
                 """\
bc4e95
                   * Resource Group: dummies:
bc4e95
-                    * dummy1\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-                    * dummy2\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
-                    * dummy3\t(ocf::heartbeat:Dummy):\t Stopped
bc4e95
+                    * dummy1\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+                    * dummy2\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
+                    * dummy3\t(ocf::heartbeat:Dummy):\tStopped
bc4e95
                 """
bc4e95
             ))
bc4e95
         else:
bc4e95
diff --git a/pcs_test/tier0/test_stonith.py b/pcs_test/tier0/test_stonith.py
bc4e95
index 46938e75..097a79b9 100644
bc4e95
--- a/pcs_test/tier0/test_stonith.py
bc4e95
+++ b/pcs_test/tier0/test_stonith.py
bc4e95
@@ -517,13 +517,13 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc3\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc2\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc2\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc3\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                    Level 2 - n1-apc1,n1-apc2,n2-apc2
bc4e95
@@ -531,7 +531,7 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                    Level 2 - n2-apc1,n2-apc2,n2-apc3
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -559,12 +559,12 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc3\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc2\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc3\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                    Level 2 - n1-apc1,n1-apc2
bc4e95
@@ -572,7 +572,7 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                    Level 2 - n2-apc1,n2-apc3
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -599,11 +599,11 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-apc3\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc2\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-apc3\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                    Level 2 - n1-apc1,n1-apc2
bc4e95
@@ -611,7 +611,7 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                    Level 2 - n2-apc3
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -637,17 +637,17 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc2\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                    Level 2 - n1-apc1,n1-apc2
bc4e95
                  Target: rh7-2
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -671,16 +671,16 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n1-apc2\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n1-apc2\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                    Level 2 - n1-apc2
bc4e95
                  Target: rh7-2
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -704,14 +704,14 @@ class StonithTest(TestCase, AssertPcsMixin):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
-                  * n1-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * n2-ipmi\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * n1-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
+                  * n2-ipmi\t(stonith:fence_apc):\tStopped
bc4e95
                  Target: rh7-1
bc4e95
                    Level 1 - n1-ipmi
bc4e95
                  Target: rh7-2
bc4e95
                    Level 1 - n2-ipmi
bc4e95
                 """
bc4e95
-            ))
bc4e95
+            ), despace=True)
bc4e95
         else:
bc4e95
             self.assert_pcs_success("stonith", outdent(
bc4e95
                 """\
bc4e95
@@ -1219,9 +1219,9 @@ class LevelConfig(LevelTestsBase):
bc4e95
         if PCMK_2_0_3_PLUS:
bc4e95
             result = outdent(
bc4e95
                 """\
bc4e95
-                  * F1\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * F2\t(stonith:fence_apc):\t Stopped
bc4e95
-                  * F3\t(stonith:fence_apc):\t Stopped
bc4e95
+                  * F1\t(stonith:fence_apc):\tStopped
bc4e95
+                  * F2\t(stonith:fence_apc):\tStopped
bc4e95
+                  * F3\t(stonith:fence_apc):\tStopped
bc4e95
                 """
bc4e95
             )
bc4e95
         else:
bc4e95
@@ -1234,7 +1234,8 @@ class LevelConfig(LevelTestsBase):
bc4e95
             )
bc4e95
         self.assert_pcs_success(
bc4e95
             "stonith",
bc4e95
-            result + "\n".join(indent(self.config_lines, 1)) + "\n"
bc4e95
+            result + "\n".join(indent(self.config_lines, 1)) + "\n",
bc4e95
+            despace=True
bc4e95
         )
bc4e95
         self.pcs_runner.mock_settings["corosync_conf_file"] = rc(
bc4e95
             "corosync.conf"
bc4e95
diff --git a/pcs_test/tools/assertions.py b/pcs_test/tools/assertions.py
bc4e95
index db8f4df5..a2b7b4ac 100644
bc4e95
--- a/pcs_test/tools/assertions.py
bc4e95
+++ b/pcs_test/tools/assertions.py
bc4e95
@@ -59,7 +59,8 @@ class AssertPcsMixin:
bc4e95
                 )
bc4e95
 
bc4e95
     def assert_pcs_success(
bc4e95
-        self, command, stdout_full=None, stdout_start=None, stdout_regexp=None
bc4e95
+        self, command, stdout_full=None, stdout_start=None, stdout_regexp=None,
bc4e95
+        despace=False
bc4e95
     ):
bc4e95
         full = stdout_full
bc4e95
         if (
bc4e95
@@ -75,7 +76,8 @@ class AssertPcsMixin:
bc4e95
             stdout_full=full,
bc4e95
             stdout_start=stdout_start,
bc4e95
             stdout_regexp=stdout_regexp,
bc4e95
-            returncode=0
bc4e95
+            returncode=0,
bc4e95
+            despace=despace,
bc4e95
         )
bc4e95
 
bc4e95
     def assert_pcs_fail(
bc4e95
@@ -99,7 +101,7 @@ class AssertPcsMixin:
bc4e95
 
bc4e95
     def assert_pcs_result(
bc4e95
         self, command, stdout_full=None, stdout_start=None, stdout_regexp=None,
bc4e95
-        returncode=0
bc4e95
+        returncode=0, despace=False
bc4e95
     ):
bc4e95
         msg = (
bc4e95
             "Please specify exactly one: stdout_start or stdout_full or"
bc4e95
@@ -162,7 +164,11 @@ class AssertPcsMixin:
bc4e95
                 )
bc4e95
         else:
bc4e95
             expected_full = self.__prepare_output(stdout_full)
bc4e95
-            if stdout != expected_full:
bc4e95
+            if (
bc4e95
+                (despace and _despace(stdout) != _despace(expected_full))
bc4e95
+                or
bc4e95
+                (not despace and stdout != expected_full)
bc4e95
+            ):
bc4e95
                 self.assertEqual(
bc4e95
                     stdout,
bc4e95
                     expected_full,
bc4e95
@@ -386,3 +392,13 @@ def __report_item_equal(real_report_item, report_item_info):
bc4e95
             )
bc4e95
         )
bc4e95
     )
bc4e95
+
bc4e95
+def assert_pcs_status(status1, status2):
bc4e95
+    if _despace(status1) != _despace(status2):
bc4e95
+        raise AssertionError(
bc4e95
+            "strings not equal:\n{0}".format(prepare_diff(status1, status2))
bc4e95
+        )
bc4e95
+
bc4e95
+def _despace(string):
bc4e95
+    # ignore whitespace changes between various pacemaker versions
bc4e95
+    return re.sub(r"[ \t]+", " ", string)
bc4e95
-- 
bc4e95
2.20.1
bc4e95