Blame SOURCES/bz2022463-01-fix-creating-empty-cib.patch

bcd546
From f0342f110bdb4a7421532b85ca0f49070c7e5c1e Mon Sep 17 00:00:00 2001
bcd546
From: Tomas Jelinek <tojeline@redhat.com>
bcd546
Date: Thu, 13 Jan 2022 17:32:38 +0100
bcd546
Subject: [PATCH 4/5] fix creating empty cib
bcd546
bcd546
---
bcd546
 pcs/utils.py                | 21 +++++++++++----------
bcd546
 pcs_test/tier1/test_misc.py | 25 ++++++++++++++++++++++++-
bcd546
 2 files changed, 35 insertions(+), 11 deletions(-)
bcd546
bcd546
diff --git a/pcs/utils.py b/pcs/utils.py
bcd546
index ad2d4452..423ffc43 100644
bcd546
--- a/pcs/utils.py
bcd546
+++ b/pcs/utils.py
bcd546
@@ -2067,16 +2067,17 @@ def write_empty_cib(cibfile):
bcd546
     """
bcd546
     Commandline options: no options
bcd546
     """
bcd546
-    empty_xml = """
bcd546
-<cib admin_epoch="0" epoch="1" num_updates="1" validate-with="pacemaker-1.2">
bcd546
-  <configuration>
bcd546
-    <crm_config/>
bcd546
-    <nodes/>
bcd546
-    <resources/>
bcd546
-    <constraints/>
bcd546
-  </configuration>
bcd546
-  <status/>
bcd546
-</cib>"""
bcd546
+    empty_xml = """
bcd546
+        <cib admin_epoch="0" epoch="1" num_updates="1" validate-with="pacemaker-3.1">
bcd546
+          <configuration>
bcd546
+            <crm_config/>
bcd546
+            <nodes/>
bcd546
+            <resources/>
bcd546
+            <constraints/>
bcd546
+          </configuration>
bcd546
+          <status/>
bcd546
+        </cib>
bcd546
+    """
bcd546
     with open(cibfile, "w") as f:
bcd546
         f.write(empty_xml)
bcd546
 
bcd546
diff --git a/pcs_test/tier1/test_misc.py b/pcs_test/tier1/test_misc.py
bcd546
index 29ca6a71..6e6f72fb 100644
bcd546
--- a/pcs_test/tier1/test_misc.py
bcd546
+++ b/pcs_test/tier1/test_misc.py
bcd546
@@ -1,8 +1,10 @@
bcd546
+import os
bcd546
 from unittest import TestCase
bcd546
 
bcd546
 from pcs_test.tools.assertions import AssertPcsMixin
bcd546
 from pcs_test.tools.misc import (
bcd546
     get_test_resource as rc,
bcd546
+    get_tmp_dir,
bcd546
     get_tmp_file,
bcd546
     outdent,
bcd546
     write_file_to_tmpfile,
bcd546
@@ -19,7 +21,7 @@ class ParseArgvDashDash(TestCase, AssertPcsMixin):
bcd546
     cmd = "constraint colocation add R1 with R2".split()
bcd546
 
bcd546
     def setUp(self):
bcd546
-        self.temp_cib = get_tmp_file("tier1_misc")
bcd546
+        self.temp_cib = get_tmp_file("tier1_misc_dashdash")
bcd546
         write_file_to_tmpfile(rc("cib-empty.xml"), self.temp_cib)
bcd546
         self.pcs_runner = PcsRunner(self.temp_cib.name)
bcd546
         self.allowed_roles = format_list(const.PCMK_ROLES)
bcd546
@@ -89,3 +91,24 @@ class ParseArgvDashDash(TestCase, AssertPcsMixin):
bcd546
                 """
bcd546
             ),
bcd546
         )
bcd546
+
bcd546
+
bcd546
+class EmptyCibIsPcmk2Compatible(TestCase, AssertPcsMixin):
bcd546
+    # This test verifies that a default empty CIB created by pcs when -f points
bcd546
+    # to an empty file conforms to minimal schema version supported by
bcd546
+    # pacemaker 2.0. If pcs prints a message that CIB schema has been upgraded,
bcd546
+    # then the test fails and shows there is a bug. Bundle with promoted-max
bcd546
+    # requires CIB compliant with schema 3.1, which was introduced in pacemaker
bcd546
+    # 2.0.0.
bcd546
+    def setUp(self):
bcd546
+        self.cib_dir = get_tmp_dir("tier1_misc_empty_cib")
bcd546
+        self.pcs_runner = PcsRunner(os.path.join(self.cib_dir.name, "cib.xml"))
bcd546
+
bcd546
+    def tearDown(self):
bcd546
+        self.cib_dir.cleanup()
bcd546
+
bcd546
+    def test_success(self):
bcd546
+        self.assert_pcs_success(
bcd546
+            "resource bundle create b container docker image=my.img promoted-max=1".split(),
bcd546
+            "",
bcd546
+        )
bcd546
-- 
bcd546
2.31.1
bcd546