Hi,

Here is the updated version of the patch (more tests + fixed the issues of the first one) + patch 0017, that implements the necessary changes in the background code, i. e. patch 16 does not work without patch 17

On 11/18/2015 05:20 PM, Martin Basti wrote:


On 09.11.2015 15:09, Oleg Fayans wrote:
Hi guys,

Here are first two automated testcases from this (so far incomplete)
testplan: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan

Testplan review is highly appreciated




PATCH 16: NACK

1)
What is the reason to add an unused parameter to 'domain_level' to
install_topo()?
Also it is good practise to add new option as the last parameter.

2)
cab you in both tests specify a domain level with constant instead of
number literal?

3)
both test call install_topo with custom domain level, but it cannot work
because 1)  (did you run the test?)

4)
How the test "TestLevel1" is supposed to work?
Respectively why there is call of install_topo() that installs replica.
As this test just tests that ipa-replica-prepare is not working anymore,
is it worth to spend 20 minutes with installing replica and then just no
tot use it? IMO to install master in install step is enough.

Martin^2


--
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From e40484bee08091ce88881c058712a73040c9b0ce Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Wed, 25 Nov 2015 16:38:37 +0100
Subject: [PATCH] Prepared integration tests for replica promotion

---
 .../test_integration/test_replica_promotion.py     | 157 +++++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 ipatests/test_integration/test_replica_promotion.py

diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
new file mode 100644
index 0000000000000000000000000000000000000000..64cf9bc72fdb7a70f3161139eec3b5d4081d5add
--- /dev/null
+++ b/ipatests/test_integration/test_replica_promotion.py
@@ -0,0 +1,157 @@
+from ipatests.test_integration.base import IntegrationTest
+from ipatests.test_integration import tasks
+from ipatests.test_integration.test_caless import assert_error
+from ipalib.constants import MIN_DOMAIN_LEVEL
+from ipalib.constants import MAX_DOMAIN_LEVEL
+from env_config import get_global_config
+import pytest
+
+
+class Dummy(IntegrationTest):
+    config = get_global_config()
+    kra_install = ["ipa-kra-install", "-U", "-p", config.dirman_password]
+    kra_uninstall = ["ipa-kra-install", "--uninstall", "-U"]
+
+    @classmethod
+    def install(cls, mh):
+        tasks.install_master(cls.master, domain_level=cls.domain_level)
+
+    def teardown_method(self, method):
+        for host in self.replicas:
+            host.run_command(self.kra_uninstall, raiseonerr=False)
+            tasks.uninstall_master(host)
+
+    def test_kra_install_master(self):
+        self.master.run_command(self.kra_install)
+        tasks.kinit_admin(self.master)
+        result = self.master.run_command(["ipa", "vault-find"],
+                                        raiseonerr=False)
+        assert(result.stdout_text.find("0 vaults matched") > 0), result.stdout_text
+
+
+class TestLevel0(Dummy):
+
+    topology = 'line'
+    num_replicas = 1
+    domain_level = MIN_DOMAIN_LEVEL
+
+    def test_promotion_disabled(self):
+        """
+        Testcase http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan#
+        Test_case:_Make_sure_the_feature_is_unavailable_under_domain_level_0
+        """
+        client = self.replicas[0]
+        tasks.install_client(self.master, client)
+        args = ['ipa-replica-install', '-U',
+                '-p', self.master.config.dirman_password,
+                '-w', self.master.config.admin_password,
+                '--ip-address', client.ip]
+        result = client.run_command(args, raiseonerr=False)
+        assert_error(result,
+                     'You must provide a file generated by ipa-replica-prepare'
+                     ' to create a replica when the domain is at level 0', 1)
+
+    def test_backup_restore(self):
+        """
+        TestCase: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+        #Test_case:_ipa-restore_after_domainlevel_raise_restores_original_domain_level
+        """
+        command = ["ipa", "topologysegment-find", "realm"]
+        tasks.install_replica(self.master, self.replicas[0])
+        backup_file = tasks.ipa_backup(self.master)
+        self.master.run_command(["ipa", "domainlevel-set", "1"])
+        result = self.master.run_command(command)
+        assert(result.stdout_text.rfind("1 segment matched") > 0), result.stdout_text
+        tasks.ipa_restore(self.master, backup_file)
+        result2 = self.master.run_command(command, raiseonerr=False)
+        assert(result2.stdout_text.rfind("0 segments matched") > 0), result2.stdout_text
+
+
+class TestKRAInstall(IntegrationTest):
+    """
+    TestCase: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+    #Test_case:_ipa-kra-install_with_replica_file_works_only_on_domain_level_0
+
+    """
+    config = get_global_config()
+    topology = 'line'
+    num_clients = 0
+    domain_level = MIN_DOMAIN_LEVEL
+    num_replicas = 2
+    kra_install = ["ipa-kra-install", "-U", "-p", config.dirman_password]
+
+    @pytest.mark.xfail  # Ticket N 5455
+    def test_kra_install_without_replica_file(self):
+        self.master.run_command(self.kra_install)
+        replica1 = self.replicas[0]
+        replica2 = self.replicas[1]
+        self.replica1_filename = tasks.get_replica_filename(replica1)
+        self.replica2_filename = tasks.get_replica_filename(replica2)
+        result1 = replica1.run_command(self.kra_install, raiseonerr=False)
+        assert_error(result1, "A replica file is required", 1)
+        replica1.run_command(self.kra_install + [self.replica1_filename])
+        # Now prepare the replica file, copy it to the client and raise
+        # domain level on master to test the reverse situation
+        self.master.run_command(["ipa", "domainlevel-set", MAX_DOMAIN_LEVEL])
+        result2 = replica2.run_command(self.kra_install + [self.replica2_filename],
+                                       raiseonerr=False)
+        assert_error(result2, "supported only in 0-level IPA domain", 1)
+        replica2.run_command(self.kra_install)
+
+
+class TestCAInstall(IntegrationTest):
+    """
+    TestCase: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+    #Test_case:_ipa-ca-install_with_replica_file_works_only_on_domain_level_0
+    """
+    config = get_global_config()
+    topology = 'line'
+    num_clients = 0
+    domain_level = MIN_DOMAIN_LEVEL
+    num_replicas = 2
+    ca_install = ["ipa-ca-install", "-U", "-p", config.dirman_password]
+
+    @classmethod
+    def install(cls, mh):
+        tasks.install_master(cls.master)
+
+    @pytest.mark.xfail  # Ticket N 5455
+    def test_ca_install_without_replica_file(self):
+        for i in self.replicas:
+            tasks.setup_replica(self.master, i, setup_ca=False, setup_dns=True)
+        replica1 = self.replicas[0]
+        replica2 = self.replicas[1]
+        self.replica1_filename = tasks.get_replica_filename(replica1)
+        self.replica2_filename = tasks.get_replica_filename(replica2)
+        result1 = replica1.run_command(self.ca_install, raiseonerr=False)
+        assert_error(result1, "A replica file is required", 1)
+        replica1.run_command(self.ca_install + [self.replica1_filename])
+        # Now prepare the replica file, copy it to the client and raise
+        # domain level on master to test the reverse situation
+        self.master.run_command(["ipa", "domainlevel-set", MAX_DOMAIN_LEVEL])
+        result2 = replica2.run_command(self.ca_install + [self.replica2_filename],
+                                       raiseonerr=False)
+        assert_error(result2, "supported only in 0-level IPA domain", 1)
+        replica2.run_command(self.ca_install)
+
+
+class TestLevel1(Dummy):
+    """
+    TestCase: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan#
+    Test_case:_Make_sure_the_old_workflow_is_disabled_at_domain_level_1
+    """
+
+    topology = 'line'
+    num_clients = 0
+    num_replicas = 1
+    domain_level = MAX_DOMAIN_LEVEL
+
+    def test_replica_prepare_disabled(self):
+        config = self.master.config
+        replica = self.replicas[0]
+        args = ['ipa-replica-prepare',
+                '-p', config.dirman_password,
+                '--ip-address', replica.ip,
+                replica.hostname]
+        result = self.master.run_command(args, raiseonerr=False)
+        assert_error(result, 'supported only in 0-level IPA domain', 1)
-- 
2.4.3

From 3b89cb7ed6e21c5ae2ac6ae3049c99a2677ac5f2 Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Wed, 25 Nov 2015 16:27:32 +0100
Subject: [PATCH] Enabled setting domain_level per class derived from
 TestIntegration

---
 ipatests/test_integration/base.py  |  2 ++
 ipatests/test_integration/tasks.py | 21 +++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ipatests/test_integration/base.py b/ipatests/test_integration/base.py
index 4f57e959032a5fda0ad002fca95501da1160605b..0a3816b06c75357f438fefb5472d5a82a912f086 100644
--- a/ipatests/test_integration/base.py
+++ b/ipatests/test_integration/base.py
@@ -62,6 +62,8 @@ class IntegrationTest(object):
 
     @classmethod
     def install(cls, mh):
+        if hasattr(cls, "domain_level") and cls.master:
+            cls.master.config.domain_level = cls.domain_level
         if cls.topology is None:
             return
         else:
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 7bb4cbf286babffcb48c8e9e39691df636d89d4d..d20897d5ebd4a3c9b044a034b224239197556655 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -253,7 +253,9 @@ def enable_replication_debugging(host):
                      stdin_text=logging_ldif)
 
 
-def install_master(host, setup_dns=True, setup_kra=False):
+def install_master(host, setup_dns=True,
+                   setup_kra=False,
+                   domain_level=MAX_DOMAIN_LEVEL):
     host.collect_log(paths.IPASERVER_INSTALL_LOG)
     host.collect_log(paths.IPACLIENT_INSTALL_LOG)
     inst = host.domain.realm.replace('.', '-')
@@ -268,7 +270,7 @@ def install_master(host, setup_dns=True, setup_kra=False):
         '-r', host.domain.name,
         '-p', host.config.dirman_password,
         '-a', host.config.admin_password,
-        "--domain-level=%i" % host.config.domain_level
+        "--domain-level=%i" % domain_level
     ]
 
     if setup_dns:
@@ -370,7 +372,7 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False,
 
 def install_client(master, client, extra_args=()):
     client.collect_log(paths.IPACLIENT_INSTALL_LOG)
-
+    allow_sync_ptr(master)
     apply_common_fixes(client)
 
     client.run_command(['ipa-client-install', '-U',
@@ -805,7 +807,7 @@ def tree2_topo(master, replicas):
         master = replica
 
 
-def install_topo(topo, master, replicas, clients, domain_level=MAX_DOMAIN_LEVEL,
+def install_topo(topo, master, replicas, clients,
                  skip_master=False, setup_replica_cas=True):
     """Install IPA servers and clients in the given topology"""
     replicas = list(replicas)
@@ -921,3 +923,14 @@ def resolve_record(nameserver, query, rtype="SOA", retry=True, timeout=100):
             if not retry:
                 raise
         time.sleep(1)
+
+def ipa_backup(master):
+    result = master.run_command(["ipa-backup"])
+    myre = re.compile(".*Backed up to (?P<backup>.*?)\n.*")
+    matched = myre.search(result.stdout_text + result.stderr_text)
+    return matched.group("backup")
+
+def ipa_restore(master, backup_path):
+    master.run_command(["ipa-restore", "-U",
+                        "-p", master.config.dirman_password,
+                        backup_path])
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to