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

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