Blob Blame History Raw
From 36c14bf16eba793f37585b697bd1cb2750d68e36 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pviktori@redhat.com>
Date: Thu, 24 Oct 2013 12:14:58 +0200
Subject: [PATCH 11/11] test_integration: Support external names for hosts

The framework had a concept of external hostnames,
which the controller uses to contact the test machines,
but they were not loaded from configuration.

Load external names from configuration.

This makes tests pass in setups where internal and external
hostnames are different, and the internal hostnames are not
initially resolvable from the controller.

Martin Kosek:  this patch also contains squashed patch
"test_integration: Log external hostname in Host.ldap_connect" from
Petr Viktorin aiming for better debugability of the beaker tests.
---
 ipatests/test_integration/config.py | 14 ++++++++++----
 ipatests/test_integration/host.py   | 11 +++++++----
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/ipatests/test_integration/config.py b/ipatests/test_integration/config.py
index 3aa4d05d6cb5758cd0d6be64a1ac582adcc971b4..b8c5fdc7f9ce1877e34491964418a8d806168e73 100644
--- a/ipatests/test_integration/config.py
+++ b/ipatests/test_integration/config.py
@@ -236,8 +236,10 @@ def env_normalize(env):
     """Fill env variables from alternate variable names
 
     MASTER_env1 <- MASTER
-    REPLICA_env1 <- REPLICA
-    CLIENT_env1 <- CLIENT, SLAVE
+    REPLICA_env1 <- REPLICA, SLAVE
+    CLIENT_env1 <- CLIENT
+    similarly for BEAKER* variants: BEAKERMASTER1_env1 <- BEAKERMASTER, etc.
+
     CLIENT_env1 gets extended with CLIENT2 or CLIENT2_env1
     """
     def coalesce(name, *other_names):
@@ -253,8 +255,12 @@ def coalesce(name, *other_names):
             else:
                 env[name] = ''
     coalesce('MASTER_env1', 'MASTER')
-    coalesce('REPLICA_env1', 'REPLICA')
-    coalesce('CLIENT_env1', 'CLIENT', 'SLAVE')
+    coalesce('REPLICA_env1', 'REPLICA', 'SLAVE')
+    coalesce('CLIENT_env1', 'CLIENT')
+
+    coalesce('BEAKERMASTER1_env1', 'BEAKERMASTER')
+    coalesce('BEAKERREPLICA1_env1', 'BEAKERREPLICA', 'BEAKERSLAVE')
+    coalesce('BEAKERCLIENT1_env1', 'BEAKERCLIENT')
 
     def extend(name, name2):
         value = env.get(name2)
diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py
index 02c82b372ce2805c0ca922319f5de1cd29b0ed82..507e19ed62b3d0a76e6e2ff6286fd83f17a68627 100644
--- a/ipatests/test_integration/host.py
+++ b/ipatests/test_integration/host.py
@@ -32,7 +32,8 @@ class BaseHost(object):
     """Representation of a remote IPA host"""
     transport_class = None
 
-    def __init__(self, domain, hostname, role, index, ip=None):
+    def __init__(self, domain, hostname, role, index, ip=None,
+                 external_hostname=None):
         self.domain = domain
         self.role = role
         self.index = index
@@ -40,7 +41,7 @@ def __init__(self, domain, hostname, role, index, ip=None):
         shortname, dot, ext_domain = hostname.partition('.')
         self.shortname = shortname
         self.hostname = shortname + '.' + self.domain.name
-        self.external_hostname = hostname
+        self.external_hostname = external_hostname or hostname
 
         self.netbios = self.domain.name.split('.')[0].upper()
 
@@ -96,6 +97,8 @@ def remove_log_collector(self, collector):
     def from_env(cls, env, domain, hostname, role, index):
         ip = env.get('BEAKER%s%s_IP_env%s' %
                         (role.upper(), index, domain.index), None)
+        external_hostname = env.get(
+            'BEAKER%s%s_env%s' % (role.upper(), index, domain.index), None)
 
         # We need to determine the type of the host, this depends on the domain
         # type, as we assume all Unix machines are in the Unix domain and
@@ -106,7 +109,7 @@ def from_env(cls, env, domain, hostname, role, index):
         else:
             cls = Host
 
-        self = cls(domain, hostname, role, index, ip)
+        self = cls(domain, hostname, role, index, ip, external_hostname)
         return self
 
     @property
@@ -157,7 +160,7 @@ def put_file_contents(self, filename, contents):
     def ldap_connect(self):
         """Return an LDAPClient authenticated to this host as directory manager
         """
-        self.log.info('Connecting to LDAP')
+        self.log.info('Connecting to LDAP at %s', self.external_hostname)
         ldap = IPAdmin(self.external_hostname)
         binddn = self.config.dirman_dn
         self.log.info('LDAP bind as %s' % binddn)
-- 
1.8.3.1