diff --git a/test/registry_tests.py b/test/registry_tests.py index 15cb54e7b..cc61947d0 100644 --- a/test/registry_tests.py +++ b/test/registry_tests.py @@ -314,6 +314,9 @@ class BaseRegistryMixin(object): response = self.session.request(method, self.get_server_url() + url, headers=headers, data=data, auth=auth_tuple, params=params) + if expected_code is None: + return response + if response.status_code != expected_code: print response.text @@ -1503,10 +1506,20 @@ class ACIConversionTests(RegistryTestCaseMixin, V1RegistryPushMixin, LiveServerT return tar, response.content def get_converted_signature(self): - # Give time for the signature to be written before continuing. - time.sleep(2) - response = self.conduct('GET', '/c1/aci/localhost:5000/devtable/newrepo/latest/aci.asc/linux/amd64/', auth='sig') - return response.content + counter = 0 + + # Give time for the signature to be written before continuing. As we don't exactly know when + # this is (based on CPU conditions when the test is being run), we try a backoff and sleep + # approach. + while counter < 5: + response = self.conduct('GET', '/c1/aci/localhost:5000/devtable/newrepo/latest/aci.asc/linux/amd64/', auth='sig', expected_code=None) + if response.status_code == 202 or response.status_code == 404: + counter += 1 + time.sleep(counter * 2) + else: + return response.content + + self.fail('Signature was never created') def _verify_signature(self, signature, converted): sig_bytes = StringIO(signature)