summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorOleg Fayans <ofayans@redhat.com>2016-03-21 08:46:11 +0100
committerMartin Basti <mbasti@redhat.com>2016-03-23 12:46:23 +0100
commitd58cd04e8a618b0bf33d36099f782149c93dbd33 (patch)
treef7090a11d0648c111453fd4bb4b862df56eae5b0 /ipatests
parent5b32ffcd1ac4bda9c34545682cc30ec4e2ec7c3b (diff)
downloadfreeipa-d58cd04e8a618b0bf33d36099f782149c93dbd33.tar.gz
freeipa-d58cd04e8a618b0bf33d36099f782149c93dbd33.tar.xz
freeipa-d58cd04e8a618b0bf33d36099f782149c93dbd33.zip
rewrite a misprocessed teardown_method method as a custom decorator
teardown_method is a standard pytest method used to put any code to be executed after each test method is executed. While treated correctly by our integration tests, this method is misinterpreted by in-tree tests in the following way: in-tree tests try to execute it even if all the test methods are skipped due to test resources being not configured. This causes the tests, that otherwise would have been skipped, to fail https://fedorahosted.org/freeipa/ticket/5723 Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_integration/tasks.py22
-rw-r--r--ipatests/test_integration/test_replica_promotion.py17
2 files changed, 26 insertions, 13 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index c2129708b..f6390377d 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -1153,3 +1153,25 @@ def uninstall_replica(master, replica):
"-p", master.config.dirman_password,
replica.hostname], raiseonerr=False)
uninstall_master(replica)
+
+
+def replicas_cleanup(func):
+ """
+ replicas_cleanup decorator, applied to any test method in integration tests
+ uninstalls all replicas in the topology leaving only master
+ configured
+ """
+ def wrapped(*args):
+ func(*args)
+ for host in args[0].replicas:
+ uninstall_replica(args[0].master, host)
+ uninstall_client(host)
+ result = args[0].master.run_command(
+ ["ipa", "host-del", "--updatedns", host.hostname],
+ raiseonerr=False)
+ # Workaround for 5627
+ if "host not found" in result.stderr_text:
+ args[0].master.run_command(["ipa",
+ "host-del",
+ host.hostname], raiseonerr=False)
+ return wrapped
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
index c44cafb5f..c60b0964b 100644
--- a/ipatests/test_integration/test_replica_promotion.py
+++ b/ipatests/test_integration/test_replica_promotion.py
@@ -8,6 +8,7 @@ from ipatests.test_integration.test_caless import assert_error
from ipalib.constants import DOMAIN_LEVEL_0
from ipalib.constants import DOMAIN_LEVEL_1
from ipalib.constants import DOMAIN_SUFFIX_NAME
+from ipatests.test_integration.tasks import replicas_cleanup
class ReplicaPromotionBase(IntegrationTest):
@@ -16,19 +17,6 @@ class ReplicaPromotionBase(IntegrationTest):
def install(cls, mh):
tasks.install_master(cls.master, domain_level=cls.domain_level)
- def teardown_method(self, method):
- for host in self.replicas:
- tasks.uninstall_replica(self.master, host)
- tasks.uninstall_client(host)
- result = self.master.run_command(
- ["ipa", "host-del", "--updatedns", host.hostname],
- raiseonerr=False)
- # Workaround for 5627
- if "host not found" in result.stderr_text:
- self.master.run_command(["ipa",
- "host-del",
- host.hostname], raiseonerr=False)
-
def test_kra_install_master(self):
result1 = tasks.install_kra(self.master,
first_instance=True,
@@ -47,6 +35,7 @@ class TestReplicaPromotionLevel0(ReplicaPromotionBase):
num_replicas = 1
domain_level = DOMAIN_LEVEL_0
+ @replicas_cleanup
def test_promotion_disabled(self):
"""
Testcase:
@@ -64,6 +53,7 @@ class TestReplicaPromotionLevel0(ReplicaPromotionBase):
'You must provide a file generated by ipa-replica-prepare'
' to create a replica when the domain is at level 0', 1)
+ @replicas_cleanup
def test_backup_restore(self):
"""
TestCase:
@@ -172,6 +162,7 @@ class TestReplicaPromotionLevel1(ReplicaPromotionBase):
num_replicas = 1
domain_level = DOMAIN_LEVEL_1
+ @replicas_cleanup
def test_replica_prepare_disabled(self):
replica = self.replicas[0]
args = ['ipa-replica-prepare',