From 5a102fe8fef8471039a02d82067295f9a388b8b5 Mon Sep 17 00:00:00 2001 From: Chandan Kumar Date: Mon, 16 Jul 2018 21:50:57 +0530 Subject: [PATCH] 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 --- config_tempest/services/object_storage.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/config_tempest/services/object_storage.py b/config_tempest/services/object_storage.py index db7df383..809dfe65 100644 --- a/config_tempest/services/object_storage.py +++ b/config_tempest/services/object_storage.py @@ -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