--
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From c0a41ec0fbfb70ac33fd97beb1641ecfa126a87d Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Thu, 22 Oct 2015 14:05:24 +0200
Subject: [PATCH] Updated the tests according to the new replica installation
 workflow

As of 4.3 the replica installation is performed without preparing a gpg file on
master, but rather enrolling a future replica as a client with subsequent
promotion of the client. This required the corresponding change in the
integration tests

https://fedorahosted.org/freeipa/ticket/5379
---
 ipatests/test_integration/tasks.py | 50 +++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index e241454a984aac97eb2d0955f55bb83d85bf9d4c..02daa2ad768d24ff3d4e781f4e286e2f926eeac7 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -61,12 +61,14 @@ def check_arguments_are(slice, instanceof):
         return wrapped
     return wrapper
 
+
 def prepare_reverse_zone(host, ip):
     zone = get_reverse_zone_default(ip)
     host.run_command(["ipa",
                       "dnszone-add",
                       zone], raiseonerr=False)
 
+
 def prepare_host(host):
     if isinstance(host, Host):
         env_filename = os.path.join(host.config.test_dir, 'env.sh')
@@ -79,6 +81,12 @@ def prepare_host(host):
         host.put_file_contents(env_filename, env_to_script(host.to_env()))
 
 
+def allow_sync_ptr(host):
+    kinit_admin(host, raiseonerr=False)
+    host.run_command(["ipa", "dnsconfig-mod", "--allow-sync-ptr=true"],
+                     raiseonerr=False)
+
+
 def apply_common_fixes(host):
     fix_etc_hosts(host)
     fix_hostname(host)
@@ -246,7 +254,7 @@ 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, domainlevel=1):
     host.collect_log(paths.IPASERVER_INSTALL_LOG)
     host.collect_log(paths.IPACLIENT_INSTALL_LOG)
     inst = host.domain.realm.replace('.', '-')
@@ -260,7 +268,8 @@ def install_master(host, setup_dns=True, setup_kra=False):
         'ipa-server-install', '-U',
         '-r', host.domain.name,
         '-p', host.config.dirman_password,
-        '-a', host.config.admin_password
+        '-a', host.config.admin_password,
+        '--domain-level=%i' % domainlevel
     ]
 
     if setup_dns:
@@ -288,6 +297,16 @@ def get_replica_filename(replica):
     return os.path.join(replica.config.test_dir, 'replica-info.gpg')
 
 
+def domainlevel(host):
+    result = host.run_command(['ipa', 'domainlevel-get'], raiseonerr=False)
+    level = 0
+    domlevel_re = re.compile('.*(\d)')
+    if result.returncode == 0:
+        # "domainlevel-get" command doesn't exist on ipa versions prior to 4.3
+        level = int(domlevel_re.findall(result.stdout_text)[0])
+    return level
+
+
 def replica_prepare(master, replica):
     apply_common_fixes(replica)
     fix_apache_semaphores(replica)
@@ -306,15 +325,25 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False,
                     setup_kra=False):
     replica.collect_log(paths.IPAREPLICA_INSTALL_LOG)
     replica.collect_log(paths.IPAREPLICA_CONNCHECK_LOG)
-
-    replica_prepare(master, replica)
-
-    replica_filename = get_replica_filename(replica)
+    allow_sync_ptr(master)
+    # Otherwise ipa-client-install would not create a PTR
+    # and replica installation would fail
+    apply_common_fixes(replica)
+    fix_apache_semaphores(replica)
+    domain_level = domainlevel(master)
     args = ['ipa-replica-install', '-U',
             '-p', replica.config.dirman_password,
             '-w', replica.config.admin_password,
-            '--ip-address', replica.ip,
-            replica_filename]
+            '--ip-address', replica.ip]
+    if domain_level == 0:
+        # prepare the replica file on master and put it to replica, AKA "old way"
+	replica_prepare(master, replica)
+        replica_filename = get_replica_filename(replica)
+        args.append(replica_filename)
+    else:
+        # install client on a replica machine and then promote it to replica
+        install_client(master, replica)
+
     if setup_ca:
         args.append('--setup-ca')
     if setup_dns:
@@ -326,7 +355,6 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False,
 
     enable_replication_debugging(replica)
     setup_sssd_debugging(replica)
-
     if setup_kra:
         assert setup_ca, "CA must be installed on replica with KRA"
         args = [
@@ -336,7 +364,6 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False,
             "-U",
         ]
         replica.run_command(args)
-
     kinit_admin(replica)
 
 
@@ -344,15 +371,14 @@ def install_client(master, client, extra_args=()):
     client.collect_log(paths.IPACLIENT_INSTALL_LOG)
 
     apply_common_fixes(client)
-
     client.run_command(['ipa-client-install', '-U',
                         '--domain', client.domain.name,
                         '--realm', client.domain.realm,
+                        '--ip-address', client.ip,
                         '-p', client.config.admin_name,
                         '-w', client.config.admin_password,
                         '--server', master.hostname]
                        + list(extra_args))
-
     setup_sssd_debugging(client)
     kinit_admin(client)
 
-- 
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