pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0011-test_integration-Support-external-names-for-hosts.patch

9991ea
From 36c14bf16eba793f37585b697bd1cb2750d68e36 Mon Sep 17 00:00:00 2001
9991ea
From: Petr Viktorin <pviktori@redhat.com>
9991ea
Date: Thu, 24 Oct 2013 12:14:58 +0200
9991ea
Subject: [PATCH 11/11] test_integration: Support external names for hosts
9991ea
9991ea
The framework had a concept of external hostnames,
9991ea
which the controller uses to contact the test machines,
9991ea
but they were not loaded from configuration.
9991ea
9991ea
Load external names from configuration.
9991ea
9991ea
This makes tests pass in setups where internal and external
9991ea
hostnames are different, and the internal hostnames are not
9991ea
initially resolvable from the controller.
9991ea
9991ea
Martin Kosek:  this patch also contains squashed patch
9991ea
"test_integration: Log external hostname in Host.ldap_connect" from
9991ea
Petr Viktorin aiming for better debugability of the beaker tests.
9991ea
---
9991ea
 ipatests/test_integration/config.py | 14 ++++++++++----
9991ea
 ipatests/test_integration/host.py   | 11 +++++++----
9991ea
 2 files changed, 17 insertions(+), 8 deletions(-)
9991ea
9991ea
diff --git a/ipatests/test_integration/config.py b/ipatests/test_integration/config.py
9991ea
index 3aa4d05d6cb5758cd0d6be64a1ac582adcc971b4..b8c5fdc7f9ce1877e34491964418a8d806168e73 100644
9991ea
--- a/ipatests/test_integration/config.py
9991ea
+++ b/ipatests/test_integration/config.py
9991ea
@@ -236,8 +236,10 @@ def env_normalize(env):
9991ea
     """Fill env variables from alternate variable names
9991ea
 
9991ea
     MASTER_env1 <- MASTER
9991ea
-    REPLICA_env1 <- REPLICA
9991ea
-    CLIENT_env1 <- CLIENT, SLAVE
9991ea
+    REPLICA_env1 <- REPLICA, SLAVE
9991ea
+    CLIENT_env1 <- CLIENT
9991ea
+    similarly for BEAKER* variants: BEAKERMASTER1_env1 <- BEAKERMASTER, etc.
9991ea
+
9991ea
     CLIENT_env1 gets extended with CLIENT2 or CLIENT2_env1
9991ea
     """
9991ea
     def coalesce(name, *other_names):
9991ea
@@ -253,8 +255,12 @@ def coalesce(name, *other_names):
9991ea
             else:
9991ea
                 env[name] = ''
9991ea
     coalesce('MASTER_env1', 'MASTER')
9991ea
-    coalesce('REPLICA_env1', 'REPLICA')
9991ea
-    coalesce('CLIENT_env1', 'CLIENT', 'SLAVE')
9991ea
+    coalesce('REPLICA_env1', 'REPLICA', 'SLAVE')
9991ea
+    coalesce('CLIENT_env1', 'CLIENT')
9991ea
+
9991ea
+    coalesce('BEAKERMASTER1_env1', 'BEAKERMASTER')
9991ea
+    coalesce('BEAKERREPLICA1_env1', 'BEAKERREPLICA', 'BEAKERSLAVE')
9991ea
+    coalesce('BEAKERCLIENT1_env1', 'BEAKERCLIENT')
9991ea
 
9991ea
     def extend(name, name2):
9991ea
         value = env.get(name2)
9991ea
diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py
9991ea
index 02c82b372ce2805c0ca922319f5de1cd29b0ed82..507e19ed62b3d0a76e6e2ff6286fd83f17a68627 100644
9991ea
--- a/ipatests/test_integration/host.py
9991ea
+++ b/ipatests/test_integration/host.py
9991ea
@@ -32,7 +32,8 @@ class BaseHost(object):
9991ea
     """Representation of a remote IPA host"""
9991ea
     transport_class = None
9991ea
 
9991ea
-    def __init__(self, domain, hostname, role, index, ip=None):
9991ea
+    def __init__(self, domain, hostname, role, index, ip=None,
9991ea
+                 external_hostname=None):
9991ea
         self.domain = domain
9991ea
         self.role = role
9991ea
         self.index = index
9991ea
@@ -40,7 +41,7 @@ def __init__(self, domain, hostname, role, index, ip=None):
9991ea
         shortname, dot, ext_domain = hostname.partition('.')
9991ea
         self.shortname = shortname
9991ea
         self.hostname = shortname + '.' + self.domain.name
9991ea
-        self.external_hostname = hostname
9991ea
+        self.external_hostname = external_hostname or hostname
9991ea
 
9991ea
         self.netbios = self.domain.name.split('.')[0].upper()
9991ea
 
9991ea
@@ -96,6 +97,8 @@ def remove_log_collector(self, collector):
9991ea
     def from_env(cls, env, domain, hostname, role, index):
9991ea
         ip = env.get('BEAKER%s%s_IP_env%s' %
9991ea
                         (role.upper(), index, domain.index), None)
9991ea
+        external_hostname = env.get(
9991ea
+            'BEAKER%s%s_env%s' % (role.upper(), index, domain.index), None)
9991ea
 
9991ea
         # We need to determine the type of the host, this depends on the domain
9991ea
         # type, as we assume all Unix machines are in the Unix domain and
9991ea
@@ -106,7 +109,7 @@ def from_env(cls, env, domain, hostname, role, index):
9991ea
         else:
9991ea
             cls = Host
9991ea
 
9991ea
-        self = cls(domain, hostname, role, index, ip)
9991ea
+        self = cls(domain, hostname, role, index, ip, external_hostname)
9991ea
         return self
9991ea
 
9991ea
     @property
9991ea
@@ -157,7 +160,7 @@ def put_file_contents(self, filename, contents):
9991ea
     def ldap_connect(self):
9991ea
         """Return an LDAPClient authenticated to this host as directory manager
9991ea
         """
9991ea
-        self.log.info('Connecting to LDAP')
9991ea
+        self.log.info('Connecting to LDAP at %s', self.external_hostname)
9991ea
         ldap = IPAdmin(self.external_hostname)
9991ea
         binddn = self.config.dirman_dn
9991ea
         self.log.info('LDAP bind as %s' % binddn)
9991ea
-- 
9991ea
1.8.3.1
9991ea