summaryrefslogtreecommitdiffstats
path: root/ipatests/test_integration/base.py
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2013-10-16 13:54:26 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-10-31 16:52:12 +0100
commitb1bffb5ecad0fdaa2f560efd2b75c76bedc4423c (patch)
tree791e5708660c6b873e497f345b9c6639af108852 /ipatests/test_integration/base.py
parent44998feace93a01b3dfda8fce6ff7aa35fffbabf (diff)
downloadfreeipa-b1bffb5ecad0fdaa2f560efd2b75c76bedc4423c.tar.gz
freeipa-b1bffb5ecad0fdaa2f560efd2b75c76bedc4423c.tar.xz
freeipa-b1bffb5ecad0fdaa2f560efd2b75c76bedc4423c.zip
ipatests: Add support for extra roles referenced by a keyword
Adds support for host definition by a environment variables of the following form: ROLE_<keyword>_envX, where X is the number of the environment for which host referenced by a role <keyword> should be defined. Adds a required_extra_roles attribute to the IntegrationTest class, which can test developer use to specify the extra roles that this particular test requires. If not all required extra roles are available, the test will be skipped. All extra (and static) roles are accessible to the IntegrationTests via the host_by_role method, which returns a host of given role. Part of: https://fedorahosted.org/freeipa/ticket/3833
Diffstat (limited to 'ipatests/test_integration/base.py')
-rw-r--r--ipatests/test_integration/base.py41
1 files changed, 34 insertions, 7 deletions
diff --git a/ipatests/test_integration/base.py b/ipatests/test_integration/base.py
index 1bed7d55b..a24a577d6 100644
--- a/ipatests/test_integration/base.py
+++ b/ipatests/test_integration/base.py
@@ -19,8 +19,6 @@
"""Base class for FreeIPA integration tests"""
-import os
-
import nose
from ipapython.ipa_log_manager import log_mgr
@@ -36,6 +34,7 @@ class IntegrationTest(object):
num_replicas = 0
num_clients = 0
num_ad_domains = 0
+ required_extra_roles = []
topology = None
@classmethod
@@ -54,16 +53,29 @@ class IntegrationTest(object):
cls.logs_to_collect = {}
- domain = config.domains[0]
+ cls.domain = config.domains[0]
- cls.master = domain.master
- cls.replicas = get_resources(domain.replicas, 'replicas',
+ # Check that we have enough resources available
+ cls.master = cls.domain.master
+ cls.replicas = get_resources(cls.domain.replicas, 'replicas',
cls.num_replicas)
- cls.clients = get_resources(domain.clients, 'clients',
+ cls.clients = get_resources(cls.domain.clients, 'clients',
cls.num_clients)
cls.ad_domains = get_resources(config.ad_domains, 'AD domains',
cls.num_ad_domains)
+ # Check that we have all required extra hosts at our disposal
+ available_extra_roles = [role for domain in cls.get_domains()
+ for role in domain.extra_roles]
+ missing_extra_roles = list(set(cls.required_extra_roles) -
+ set(available_extra_roles))
+
+ if missing_extra_roles:
+ raise nose.SkipTest("Not all required extra hosts available, "
+ "missing: %s, available: %s"
+ % (missing_extra_roles,
+ available_extra_roles))
+
for host in cls.get_all_hosts():
host.add_log_collector(cls.collect_log)
cls.prepare_host(host)
@@ -75,8 +87,22 @@ class IntegrationTest(object):
raise
@classmethod
+ def host_by_role(cls, role):
+ for domain in cls.get_domains():
+ try:
+ return domain.host_by_role(role)
+ except LookupError:
+ pass
+ raise LookupError(role)
+
+ @classmethod
def get_all_hosts(cls):
- return [cls.master] + cls.replicas + cls.clients
+ return ([cls.master] + cls.replicas + cls.clients +
+ map(cls.host_by_role, cls.required_extra_roles))
+
+ @classmethod
+ def get_domains(cls):
+ return [cls.domain] + cls.ad_domains
@classmethod
def prepare_host(cls, host):
@@ -103,6 +129,7 @@ class IntegrationTest(object):
del cls.replicas
del cls.clients
del cls.ad_domains
+ del cls.domain
@classmethod
def uninstall(cls):