From 6739d8722c4a3e84cdcf1e058c6fd15317ac0ca4 Mon Sep 17 00:00:00 2001 From: Mohammad Rizwan Yusuf Date: Mar 11 2020 19:48:42 +0000 Subject: Move wait_for_request() method to tasks.py Moved the method so that it can be used by other modules too Signed-off-by: Mohammad Rizwan Yusuf Reviewed-By: Rob Crittenden --- diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index c56d623..6d1ffb5 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -142,6 +142,7 @@ def check_arguments_are(slice, instanceof): return wrapped return wrapper + def prepare_reverse_zone(host, ip): zone = get_reverse_zone_default(ip) result = host.run_command(["ipa", @@ -151,6 +152,7 @@ def prepare_reverse_zone(host, ip): logger.warning("%s", result.stderr_text) return zone, result.returncode + def prepare_host(host): if isinstance(host, Host): env_filename = os.path.join(host.config.test_dir, 'env.sh') @@ -240,6 +242,7 @@ def host_service_active(host, service): return res.returncode == 0 + def fix_apache_semaphores(master): systemd_available = master.transport.file_exists(paths.SYSTEMCTL) @@ -330,6 +333,7 @@ def enable_ds_audit_log(host, enabled='on'): """.format(enabled=enabled)) ldapmodify_dm(host, logging_ldif) + def set_default_ttl_for_ipa_dns_zone(host, raiseonerr=True): args = [ 'ipa', 'dnszone-mod', host.domain.name, @@ -2107,3 +2111,22 @@ def uninstall_packages(host, pkgs): else: raise ValueError('install_packages: unknown platform %s' % platform) host.run_command(install_cmd + pkgs) + + +def wait_for_request(host, request_id, timeout=120): + for _i in range(0, timeout, 5): + result = host.run_command( + "getcert list -i %s | grep status: | awk '{ print $2 }'" % + request_id + ) + + state = result.stdout_text.strip() + print("certmonger request is in state %r", state) + if state in ('CA_REJECTED', 'CA_UNREACHABLE', 'CA_UNCONFIGURED', + 'NEED_GUIDANCE', 'NEED_CA', 'MONITORING'): + break + time.sleep(5) + else: + raise RuntimeError("request timed out") + + return state diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py index bb4a83c..c40603b 100644 --- a/ipatests/test_integration/test_installation.py +++ b/ipatests/test_integration/test_installation.py @@ -69,25 +69,6 @@ def server_install_setup(func): return wrapped -def wait_for_request(host, request_id, timeout=120): - for _i in range(0, timeout, 5): - result = host.run_command( - "getcert list -i %s | grep status: | awk '{ print $2 }'" % - request_id - ) - - state = result.stdout_text.strip() - print("certmonger request is in state %r", state) - if state in ('CA_REJECTED', 'CA_UNREACHABLE', 'CA_UNCONFIGURED', - 'NEED_GUIDANCE', 'NEED_CA', 'MONITORING'): - break - time.sleep(5) - else: - raise RuntimeError("request timed out") - - return state - - class InstallTestBase1(IntegrationTest): num_replicas = 3 @@ -353,14 +334,14 @@ class TestInstallCA(IntegrationTest): request_id = re.findall(r'\d+', result.stdout_text) # check if certificate is tracked by certmonger - status = wait_for_request(self.master, request_id[0], 300) + status = tasks.wait_for_request(self.master, request_id[0], 300) assert status == "MONITORING" # ensure if key and token are re-usable cmd_args = ['getcert', 'resubmit', '-i', request_id[0]] self.master.run_command(cmd_args) - status = wait_for_request(self.master, request_id[0], 300) + status = tasks.wait_for_request(self.master, request_id[0], 300) assert status == "MONITORING"