mirror of
https://github.com/ceph/ceph
synced 2025-03-19 17:06:24 +00:00
qa/tests: retry the api call after making the request
based on the pointer from Bill in https://tracker.ceph.com/issues/62972#note-75 Fixes: https://tracker.ceph.com/issues/62972 Signed-off-by: Nizamudeen A <nia@redhat.com>
This commit is contained in:
parent
3cdf529835
commit
1588712b55
@ -336,9 +336,20 @@ class DashboardTestCase(MgrTestCase):
|
||||
raise ex
|
||||
|
||||
@classmethod
|
||||
def _get(cls, url, params=None, version=DEFAULT_API_VERSION, set_cookies=False, headers=None):
|
||||
return cls._request(url, 'GET', params=params, version=version,
|
||||
set_cookies=set_cookies, headers=headers)
|
||||
def _get(cls, url, params=None, version=DEFAULT_API_VERSION, set_cookies=False, headers=None,
|
||||
retries=0, wait_func=None):
|
||||
while retries >= 0:
|
||||
try:
|
||||
return cls._request(url, 'GET', params=params, version=version,
|
||||
set_cookies=set_cookies, headers=headers)
|
||||
except requests.RequestException as e:
|
||||
if retries == 0:
|
||||
raise e from None
|
||||
|
||||
log.info("Retrying the GET req. Total retries left is... %s", retries)
|
||||
if wait_func:
|
||||
wait_func()
|
||||
retries -= 1
|
||||
|
||||
@classmethod
|
||||
def _view_cache_get(cls, url, retries=5):
|
||||
@ -510,9 +521,11 @@ class DashboardTestCase(MgrTestCase):
|
||||
self.assertEqual(body['detail'], detail)
|
||||
|
||||
@classmethod
|
||||
def _ceph_cmd(cls, cmd):
|
||||
def _ceph_cmd(cls, cmd, wait=0):
|
||||
res = cls.mgr_cluster.mon_manager.raw_cluster_cmd(*cmd)
|
||||
log.debug("command result: %s", res)
|
||||
if wait:
|
||||
time.sleep(wait)
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
|
@ -39,9 +39,13 @@ class MgrModuleTestCase(DashboardTestCase):
|
||||
class MgrModuleTest(MgrModuleTestCase):
|
||||
|
||||
def test_list_disabled_module(self):
|
||||
self._ceph_cmd(['mgr', 'module', 'disable', 'iostat'])
|
||||
self.wait_until_rest_api_accessible()
|
||||
data = self._get('/api/mgr/module')
|
||||
self._ceph_cmd(['mgr', 'module', 'disable', 'iostat'], wait=3)
|
||||
data = self._get(
|
||||
'/api/mgr/module',
|
||||
retries=1,
|
||||
wait_func=lambda: # pylint: disable=unnecessary-lambda
|
||||
self.wait_until_rest_api_accessible()
|
||||
)
|
||||
self.assertStatus(200)
|
||||
self.assertSchema(
|
||||
data,
|
||||
@ -57,9 +61,13 @@ class MgrModuleTest(MgrModuleTestCase):
|
||||
self.assertFalse(module_info['enabled'])
|
||||
|
||||
def test_list_enabled_module(self):
|
||||
self._ceph_cmd(['mgr', 'module', 'enable', 'iostat'])
|
||||
self.wait_until_rest_api_accessible()
|
||||
data = self._get('/api/mgr/module')
|
||||
self._ceph_cmd(['mgr', 'module', 'enable', 'iostat'], wait=3)
|
||||
data = self._get(
|
||||
'/api/mgr/module',
|
||||
retries=1,
|
||||
wait_func=lambda: # pylint: disable=unnecessary-lambda
|
||||
self.wait_until_rest_api_accessible()
|
||||
)
|
||||
self.assertStatus(200)
|
||||
self.assertSchema(
|
||||
data,
|
||||
|
Loading…
Reference in New Issue
Block a user