mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
committed by
Martin Basti
parent
5b32ffcd1a
commit
d58cd04e8a
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user