Commit cdd35a12 authored by Vincent Pelletier's avatar Vincent Pelletier

caucase.test: Recalibrate tests delays to pass on a low-end machine.

Reference machine: Raspberry Pi 1 B+.
caucased can take around 40s to start (CA generation, ...).
parent 44a29702
Pipeline #10147 failed with stage
in 0 seconds
......@@ -130,7 +130,7 @@ def canConnect(address): # pragma: no cover
sock.close()
return True
def retry(callback, try_count=200, try_delay=0.1): # pragma: no cover
def retry(callback, try_count=10, try_delay=0.1): # pragma: no cover
"""
Poll <callback> every <try_delay> for <try_count> times or until it returns
a true value.
......@@ -627,7 +627,7 @@ class CaucaseTest(unittest.TestCase):
server = self._server
self._server_until.action = ON_EVENT_RAISE
self._server_event.set()
server.join(2)
server.join(60)
if server.is_alive(): # pragma: no cover
raise ValueError('%r does not wish to die' % (server, ))
......@@ -1492,7 +1492,7 @@ class CaucaseTest(unittest.TestCase):
# it knew it all along.
with open(self._client_user_ca_crt, 'wb') as client_user_ca_crt_file:
client_user_ca_crt_file.write(new_cau_crt_pem)
self._startServer()
self._startServer(timeout=20)
new_user_key = self._createAndApproveCertificate(
user_key_path,
'user',
......@@ -1551,7 +1551,7 @@ class CaucaseTest(unittest.TestCase):
# If server certificate is deleted, it gets re-created, even it CAS
# reached its certificate auto-approval limit.
os.unlink(self._server_key)
self._startServer()
self._startServer(timeout=20)
if not retry(lambda: os.path.exists(self._server_key)): # pragma: no cover
raise AssertionError('%r was not recreated within 1 second' % (
self._server_key,
......@@ -1600,7 +1600,7 @@ class CaucaseTest(unittest.TestCase):
with open(self._server_key, 'rb') as server_key_file:
return server_key_file.read()
reference_server_key = readServerKey()
self._startServer()
self._startServer(timeout=20)
if not retry(
lambda: readServerKey() != reference_server_key,
): # pragma: no cover
......@@ -2306,7 +2306,7 @@ class CaucaseTest(unittest.TestCase):
table_prefix='cau',
).dumpIterator())
self._startServer(('--backup-directory', self._server_backup_path))
backup_path_list = retry(lambda: glob.glob(backup_glob))
backup_path_list = retry(lambda: glob.glob(backup_glob), try_count=200)
if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file not created after 1 second')
backup_path, = backup_path_list
......@@ -2440,7 +2440,7 @@ class CaucaseTest(unittest.TestCase):
for backup_path in glob.glob(backup_glob):
os.unlink(backup_path)
self._startServer(('--backup-directory', self._server_backup_path))
backup_path_list = retry(lambda: glob.glob(backup_glob))
backup_path_list = retry(lambda: glob.glob(backup_glob), try_count=200)
if not backup_path_list: # pragma: no cover
raise AssertionError('Backup file not created after 1 second')
backup_path, = glob.glob(backup_glob)
......@@ -2909,7 +2909,7 @@ class CaucaseTest(unittest.TestCase):
self._server_until.action = ON_EVENT_EXPIRE
self._server_event.set()
# Wait for it to be back to sleep.
self._server_until.wait()
self._server_until.wait(timeout=20)
# Verify renewal happened.
after = ssl.get_server_certificate(address)
self.assertNotEqual(before, after)
......@@ -2928,7 +2928,7 @@ class CaucaseTest(unittest.TestCase):
netloc += ':%s' % port
self._server_netloc = netloc
self._caucase_url = 'http://' + netloc
self._startServer()
self._startServer(timeout=60)
user_key_path = self._createFirstUser()
service_key = self._createAndApproveCertificate(
user_key_path,
......@@ -3114,7 +3114,7 @@ class CaucaseShellTest(unittest.TestCase):
'Process %r exited with status %s, dumping output:\n%s' % (
command,
status,
stdout,
stdout.decode('ascii'),
)
)
......
......@@ -1159,10 +1159,10 @@ EOF
caucased_pid="$!"
# shellcheck disable=SC2064
trap "kill \"$caucased_pid\"; wait; rm -rf \"$tmp_dir\"" EXIT
# wait for up to about 10 seconds for caucased to start listening (initial
# wait for up to about 60 seconds for caucased to start listening (initial
# certificate generation.
echo 'Waiting for caucased to be ready...'
for _ in $(seq 100); do
for _ in $(seq 600); do
_curlInsecure "http://$netloc" > /dev/null
status=$?
test $status -eq 0 && break
......
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