Fix flaky tests
This commit is contained in:
parent
496bc59e39
commit
4747dea395
1 changed files with 17 additions and 4 deletions
|
@ -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,11 +1506,21 @@ 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')
|
||||
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)
|
||||
content_bytes = StringIO(converted)
|
||||
|
|
Reference in a new issue