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