Refactor retry loop awaiting for image status
Change-Id: If102370ccadaccf9ee9b3309eb273c183a7f13ea
This commit is contained in:
parent
154583a392
commit
5678f3e210
ranger_tempest_plugin/tests/api
@ -36,6 +36,7 @@ class BaseOrmTest(test.BaseTestCase):
|
|||||||
identity_url = CONF.identity.uri_v3 or ""
|
identity_url = CONF.identity.uri_v3 or ""
|
||||||
identity_url = identity_url.strip('/v3')
|
identity_url = identity_url.strip('/v3')
|
||||||
build_timeout = 120
|
build_timeout = 120
|
||||||
|
image_build_timeout = 300
|
||||||
build_interval = 10
|
build_interval = 10
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -115,21 +115,26 @@ class ImsBaseOrmTest(base.BaseOrmTest):
|
|||||||
_, body = cls.client.get_image(image_id)
|
_, body = cls.client.get_image(image_id)
|
||||||
image_status = body["image"]["status"]
|
image_status = body["image"]["status"]
|
||||||
start = int(time.time())
|
start = int(time.time())
|
||||||
while image_status != status:
|
while True:
|
||||||
time.sleep(cls.build_interval)
|
time.sleep(cls.build_interval)
|
||||||
_, body = cls.client.get_image(image_id)
|
_, body = cls.client.get_image(image_id)
|
||||||
image_status = body["image"]["status"]
|
image_status = body["image"]["status"]
|
||||||
|
|
||||||
|
if image_status == status:
|
||||||
|
break
|
||||||
|
|
||||||
if image_status == 'Error':
|
if image_status == 'Error':
|
||||||
message = ('Image %s failed to reach %s status'
|
message = ('Image %s failed to reach %s status'
|
||||||
' and is in ERROR status on orm' %
|
' and is in ERROR status on orm' %
|
||||||
(image_id, status))
|
(image_id, status))
|
||||||
raise exceptions.TempestException(message)
|
raise exceptions.TempestException(message)
|
||||||
if int(time.time()) - start >= cls.build_timeout:
|
|
||||||
|
if int(time.time()) - start >= cls.image_build_timeout:
|
||||||
message = ('Image %s failed to reach %s'
|
message = ('Image %s failed to reach %s'
|
||||||
' status within ''the required time (%s s)'
|
' status within ''the required time (%s s)'
|
||||||
' on orm and is in %s status.'
|
' on orm and is in %s status.'
|
||||||
% (image_id, status,
|
% (image_id, status,
|
||||||
cls.build_timeout,
|
cls.image_build_timeout,
|
||||||
image_status))
|
image_status))
|
||||||
raise exceptions.TimeoutException(message)
|
raise exceptions.TimeoutException(message)
|
||||||
|
|
||||||
@ -178,10 +183,10 @@ class ImsBaseOrmTest(base.BaseOrmTest):
|
|||||||
start = int(time.time())
|
start = int(time.time())
|
||||||
while True:
|
while True:
|
||||||
time.sleep(cls.build_interval)
|
time.sleep(cls.build_interval)
|
||||||
if int(time.time()) - start >= cls.build_timeout:
|
if int(time.time()) - start >= cls.image_build_timeout:
|
||||||
message = ('Image %s failed to be deleted'
|
message = ('Image %s failed to be deleted'
|
||||||
' within the required time (%s s)'
|
' within the required time (%s s)'
|
||||||
% (image_id, cls.build_timeout))
|
% (image_id, cls.image_build_timeout))
|
||||||
raise exceptions.TimeoutException(message)
|
raise exceptions.TimeoutException(message)
|
||||||
|
|
||||||
not_found = True
|
not_found = True
|
||||||
@ -215,11 +220,12 @@ class ImsBaseOrmTest(base.BaseOrmTest):
|
|||||||
('Image %s failed to get deleted '
|
('Image %s failed to get deleted '
|
||||||
'and is in error status') % image_id
|
'and is in error status') % image_id
|
||||||
raise exceptions.TempestException(message)
|
raise exceptions.TempestException(message)
|
||||||
if int(time.time()) - start >= cls.build_timeout:
|
if int(time.time()) - start >= cls.image_build_timeout:
|
||||||
message = ('Image %s failed to get deleted within '
|
message = ('Image %s failed to get deleted within '
|
||||||
'the required time (%s s) on orm '
|
'the required time (%s s) on orm '
|
||||||
'and is in %s status.'
|
'and is in %s status.'
|
||||||
% (image_id, cls.build_timeout, image_status))
|
% (image_id, cls.image_build_timeout,
|
||||||
|
image_status))
|
||||||
raise exceptions.TimeoutException(message)
|
raise exceptions.TimeoutException(message)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user