commit 5678f3e210070cabd47ad47186400fd0a8128a2a Author: Chi Lo Date: Fri Oct 2 11:41:07 2020 -0700 Refactor retry loop awaiting for image status Change-Id: If102370ccadaccf9ee9b3309eb273c183a7f13ea diff --git a/ranger_tempest_plugin/tests/api/base.py b/ranger_tempest_plugin/tests/api/base.py index f7da4ee..0f81b85 100755 --- a/ranger_tempest_plugin/tests/api/base.py +++ b/ranger_tempest_plugin/tests/api/base.py @@ -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 diff --git a/ranger_tempest_plugin/tests/api/ims_base.py b/ranger_tempest_plugin/tests/api/ims_base.py index 71d9fc5..39c1640 100755 --- a/ranger_tempest_plugin/tests/api/ims_base.py +++ b/ranger_tempest_plugin/tests/api/ims_base.py @@ -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