mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
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 <myusuf@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
ec73de969f
commit
6739d8722c
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user