diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 8c4dd9553..3102e47a3 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -47,6 +47,7 @@ from cryptography import x509 from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.backends import default_backend +from datetime import datetime, timedelta from ipapython import certdb from ipapython import ipautil @@ -2587,6 +2588,26 @@ def get_healthcheck_version(host): return healthcheck_version +def wait_for_ipa_to_start(host, timeout=60): + """Wait up to timeout seconds for ipa to start on a given host. + + If DS is restarted, and SSSD must be online, please consider using + wait_for_sssd_domain_status_online(host) in the test after calling + this method. + """ + interval = 1 + end_time = datetime.now() + timedelta(seconds=timeout) + for _i in range(0, timeout, interval): + if datetime.now() > end_time: + raise RuntimeError("Request timed out") + time.sleep(interval) + result = host.run_command( + [paths.IPACTL, "status"], raiseonerr=False + ) + if result.returncode == 0: + break + + def run_ssh_cmd( from_host=None, to_host=None, username=None, cmd=None, auth_method=None, password=None, private_key_path=None,