From 149b98e5721351a53c28c19e4c892f965af01511 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Wed, 2 Oct 2013 14:25:03 -0700 Subject: [PATCH] rest-api.py: test that ceph-rest-api is up and servicing requests Wait for the daemon to actually be ready before continuing with other tasks. Loop 12 times, waiting 5s, before deciding something's wrong. Fixes: #6243 Signed-off-by: Dan Mick --- teuthology/task/rest-api.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/teuthology/task/rest-api.py b/teuthology/task/rest-api.py index 4028f4773c..c7ba628b52 100644 --- a/teuthology/task/rest-api.py +++ b/teuthology/task/rest-api.py @@ -1,5 +1,6 @@ import logging import contextlib +import time from teuthology import misc as teuthology from teuthology import contextutil @@ -33,6 +34,24 @@ def run_rest_api_daemon(ctx, api_clients): stdin=run.PIPE, wait=False, ) + for i in range(1, 12): + log.info('testing for ceph-rest-api try {0}'.format(i)) + run_cmd = [ + 'wget', + '-O', + '/dev/null', + '-q', + 'http://localhost:5000/api/v0.1/status' + ] + proc = rems.run( + args=run_cmd, + check_status=False + ) + if proc.exitstatus == 0: + break + time.sleep(5) + if proc.exitstatus != 0: + raise RuntimeError('Cannot contact ceph-rest-api') try: yield -- 2.39.5