diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-07-10 16:24:26 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-07-15 15:49:16 +0200 |
commit | 23d3fde05960d6e47485e246e11bec701b30cb59 (patch) | |
tree | c3790f3e75beb637fc07e2c14eae66ef3d7b3685 /ipatests | |
parent | 0db6fb9ec51f7cd1b4fc29a5e1a13cd3fe7657e1 (diff) | |
download | freeipa-23d3fde05960d6e47485e246e11bec701b30cb59.tar.gz freeipa-23d3fde05960d6e47485e246e11bec701b30cb59.tar.xz freeipa-23d3fde05960d6e47485e246e11bec701b30cb59.zip |
Integration test config: Make it possible to specify host IP
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/test_integration/config.py | 15 | ||||
-rw-r--r-- | ipatests/test_integration/host.py | 33 |
2 files changed, 28 insertions, 20 deletions
diff --git a/ipatests/test_integration/config.py b/ipatests/test_integration/config.py index adc39965c..d43812c51 100644 --- a/ipatests/test_integration/config.py +++ b/ipatests/test_integration/config.py @@ -85,6 +85,8 @@ class Config(object): CLIENT_env1: space-separated FQDNs of the clients OTHER_env1: space-separated FQDNs of other hosts (same for _env2, _env3, etc) + BEAKERREPLICA1_IP_env1: IP address of replica 1 in env 1 + (same for MASTER, CLIENT) Also see env_normalize() for alternate variable names """ @@ -165,9 +167,10 @@ class Config(object): # tests. This means no _env<NUM> suffix. if self.domains: default_domain = self.domains[0] - env['MASTER'] = default_domain.master.hostname - env['BEAKERMASTER'] = default_domain.master.external_hostname - env['MASTERIP'] = default_domain.master.ip + if default_domain.master: + env['MASTER'] = default_domain.master.hostname + env['BEAKERMASTER'] = default_domain.master.external_hostname + env['MASTERIP'] = default_domain.master.ip env['SLAVE'] = env['REPLICA'] = env['REPLICA_env1'] env['BEAKERSLAVE'] = env['BEAKERREPLICA_env1'] env['SLAVEIP'] = env['BEAKERREPLICA_IP_env1'] @@ -258,8 +261,8 @@ class Domain(object): for role in 'master', 'replica', 'client', 'other': value = env.get('%s%s' % (role.upper(), self._env), '') - for hostname in value.split(): - host = Host.from_env(env, self, hostname, role, 1) + for index, hostname in enumerate(value.split(), start=1): + host = Host.from_env(env, self, hostname, role, index) self.hosts.append(host) if not self.hosts: @@ -300,7 +303,7 @@ class Domain(object): def host_by_name(self, name): for host in self.hosts: - if host.hostname == name or host.external_hostname == name: + if name in (host.hostname, host.external_hostname, host.shortname): return host raise LookupError(name) diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py index 9accdf035..0d363f93a 100644 --- a/ipatests/test_integration/host.py +++ b/ipatests/test_integration/host.py @@ -119,7 +119,7 @@ class RemoteCommand(object): class Host(object): """Representation of a remote IPA host""" - def __init__(self, domain, hostname, role, index): + def __init__(self, domain, hostname, role, index, ip=None): self.domain = domain self.role = role self.index = index @@ -133,20 +133,23 @@ class Host(object): self.__module__, type(self).__name__, shortname) self.log = log_mgr.get_logger(self.logger_name) - if self.config.ipv6: - # $(dig +short $M $rrtype|tail -1) - stdout, stderr, returncode = ipautil.run( - ['dig', '+short', self.external_hostname, 'AAAA']) - self.ip = stdout.splitlines()[-1].strip() + if ip: + self.ip = ip else: - try: - self.ip = socket.gethostbyname(self.external_hostname) - except socket.gaierror: - self.ip = None + if self.config.ipv6: + # $(dig +short $M $rrtype|tail -1) + stdout, stderr, returncode = ipautil.run( + ['dig', '+short', self.external_hostname, 'AAAA']) + self.ip = stdout.splitlines()[-1].strip() + else: + try: + self.ip = socket.gethostbyname(self.external_hostname) + except socket.gaierror: + self.ip = None - if not self.ip: - self.ip = '' - self.role = 'other' + if not self.ip: + raise RuntimeError('Could not determine IP address of %s' % + self.external_hostname) self.root_password = self.config.root_password self.root_ssh_key_filename = self.config.root_ssh_key_filename @@ -164,7 +167,9 @@ class Host(object): @classmethod def from_env(cls, env, domain, hostname, role, index): - self = cls(domain, hostname, role, index) + ip = env.get('BEAKER%s%s_IP_env%s' % + (role.upper(), index, domain.index), None) + self = cls(domain, hostname, role, index, ip) return self @property |