Return False if healthcheck api failed

* https://review.openstack.org/#/c/568869/ adds support of using
  healthcheck api to check swift functionality, This commit adds
  what if healthcheck fails to discover it will give trackback it
  needs to be handled.

Change-Id: I5748eec8c15871f0c5f3f450a68d4d816fad6475
This commit is contained in:
Chandan Kumar 2018-07-16 21:50:57 +05:30 committed by Arx Cruz
parent 947946419c
commit 5a102fe8fe

View File

@ -57,6 +57,15 @@ class ObjectStorageService(Service):
LOG.info("Role %s already exists", key_value)
conf.set('object-storage', 'operator_role', 'admin')
def _check_health_check(self, path):
try:
self.client.accounts.skip_path()
resp, _ = self.client.accounts.get(path, {})
return resp['status'] == '200'
except Exception as e:
LOG.warning('Healthcheck API not discovered giving %s', e)
return False
def check_service_status(self, conf):
"""Use healthcheck api to check the service status
@ -74,12 +83,12 @@ class ObjectStorageService(Service):
return False
return True
except configparser.NoSectionError:
# discoverability wasn't set by python-tempestconf,
# let's discover it
# Turning http://.../v1/foobar into http://.../
self.client.accounts.skip_path()
resp, _ = self.client.accounts.get("healthcheck", {})
return resp['status'] == '200'
# On swift, healthcheck is under http://.../healthcheck, while in
# ceph is under http://.../swift/healthcheck, we check both cases
return_value = self._check_health_check('healthcheck')
if not return_value:
return_value = self._check_health_check('swift/healthcheck')
return return_value
def set_default_tempest_options(self, conf):
"""Set default values for swift