Commit 6d8b7375 authored by Jérome Perrin's avatar Jérome Perrin

software/erp5/test: tolerate errors in TestPublishedURLIsReachableMixin

Sometimes during the first request to zope mariadb is not started yet and we
have an Site Error. In this case retry several times until we have a sucessful
response.
parent 4ce28efb
Pipeline #11188 failed with stage
in 0 seconds
...@@ -47,20 +47,17 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -47,20 +47,17 @@ class TestPublishedURLIsReachableMixin(object):
# What happens is that instanciation just create the services, but does not # What happens is that instanciation just create the services, but does not
# wait for ERP5 to be initialized. When this test run ERP5 instance is # wait for ERP5 to be initialized. When this test run ERP5 instance is
# instanciated, but zope is still busy creating the site and haproxy replies # instanciated, but zope is still busy creating the site and haproxy replies
# with 503 Service Unavailable, sometimes the first request is 404, so we # with 503 Service Unavailable when zope is not started yet, with 404 when
# retry in a loop. # erp5 site is not created, with 500 when mysql is not yet reachable, so we
# If we can move the "create site" in slapos node instance, then this retry loop # retry in a loop until we get a succesful response.
# would not be necessary.
for i in range(1, 60): for i in range(1, 60):
r = requests.get(url, verify=False) # XXX can we get CA from caucase already ? r = requests.get(url, verify=False) # XXX can we get CA from caucase already ?
if r.status_code in (requests.codes.service_unavailable, if r.status_code != requests.codes.ok:
requests.codes.not_found):
delay = i * 2 delay = i * 2
self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay) self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay)
time.sleep(delay) time.sleep(delay)
continue continue
if r.status_code != requests.codes.ok: r.raise_for_status()
r.raise_for_status()
break break
self.assertIn("ERP5", r.text) self.assertIn("ERP5", r.text)
......
...@@ -47,20 +47,17 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -47,20 +47,17 @@ class TestPublishedURLIsReachableMixin(object):
# What happens is that instanciation just create the services, but does not # What happens is that instanciation just create the services, but does not
# wait for ERP5 to be initialized. When this test run ERP5 instance is # wait for ERP5 to be initialized. When this test run ERP5 instance is
# instanciated, but zope is still busy creating the site and haproxy replies # instanciated, but zope is still busy creating the site and haproxy replies
# with 503 Service Unavailable, sometimes the first request is 404, so we # with 503 Service Unavailable when zope is not started yet, with 404 when
# retry in a loop. # erp5 site is not created, with 500 when mysql is not yet reachable, so we
# If we can move the "create site" in slapos node instance, then this retry loop # retry in a loop until we get a succesful response.
# would not be necessary.
for i in range(1, 60): for i in range(1, 60):
r = requests.get(url, verify=False) # XXX can we get CA from caucase already ? r = requests.get(url, verify=False) # XXX can we get CA from caucase already ?
if r.status_code in (requests.codes.service_unavailable, if r.status_code != requests.codes.ok:
requests.codes.not_found):
delay = i * 2 delay = i * 2
self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay) self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay)
time.sleep(delay) time.sleep(delay)
continue continue
if r.status_code != requests.codes.ok: r.raise_for_status()
r.raise_for_status()
break break
self.assertIn("ERP5", r.text) self.assertIn("ERP5", r.text)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment