From a63eeaaec6dfa939faa2958354aa41da46a07cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Tue, 22 Sep 2020 14:50:43 +0200 Subject: [PATCH] ipatests: add check_if_sssd_is_online MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split wait_for_sssd_domain_status_online so that we can easily check that SSSD considers the IPA domain online with check_if_sssd_is_online. Related: https://pagure.io/freeipa/issue/8510 Signed-off-by: François Cami Reviewed-By: Florence Blanc-Renaud --- ipatests/pytest_ipa/integration/tasks.py | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 0690e7f6c..2c151879d 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2315,6 +2315,23 @@ def wait_for_certmonger_status(host, status, request_id, timeout=120): return state +def check_if_sssd_is_online(host): + """Check whether SSSD considers the IPA domain online. + + Analyse sssctl domain-status 's output to see if SSSD considers + the IPA domain of the host online. + + Could be extended for Trust domains as well. + """ + pattern = re.compile(r'Online status: (?P.*)\n') + result = host.run_command( + [paths.SSSCTL, "domain-status", host.domain.name, "-o"] + ) + match = pattern.search(result.stdout_text) + state = match.group('state') + return state == 'Online' + + def wait_for_sssd_domain_status_online(host, timeout=120): """Wait up to timeout (in seconds) for sssd domain status to become Online @@ -2325,14 +2342,8 @@ def wait_for_sssd_domain_status_online(host, timeout=120): as SSSD may need a while before it reconnects and switches from Offline mode to Online. """ - pattern = re.compile(r'Online status: (?P.*)\n') for _i in range(0, timeout, 5): - result = host.run_command( - [paths.SSSCTL, "domain-status", host.domain.name, "-o"] - ) - match = pattern.search(result.stdout_text) - state = match.group('state') - if state == 'Online': + if check_if_sssd_is_online(host): break time.sleep(5) else: