Commit 4ef735c6 authored by Jérome Perrin's avatar Jérome Perrin

software/repman: retry requests to prevent flaky test

Test was sometimes failing with:

======================================================================
FAIL: test_http_get (test.TestRepman)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "slapos-repository/software/repman/test/test.py", line 81, in test_http_get
    self.assertTrue(cluster['isProvision'])
AssertionError: False is not true

It can take a little time before everything is ready and we don't have a
promise for this, because it's really application level.
parent 926d2097
Pipeline #16872 failed with stage
......@@ -26,6 +26,7 @@
##############################################################################
import os
import time
from six.moves.urllib.parse import urljoin
import requests
......@@ -68,16 +69,21 @@ class TestRepman(SlapOSInstanceTestCase):
)
self.assertEqual(resp.status_code, requests.codes.ok)
resp = requests.get(
urljoin(self.url, '/api/clusters'),
params={
'query': '{"method":"GET","isArray":false}',
},
headers=headers,
verify=False,
)
self.assertEqual(resp.status_code, requests.codes.ok)
cluster, = resp.json()
for i in range(20):
resp = requests.get(
urljoin(self.url, '/api/clusters'),
params={
'query': '{"method":"GET","isArray":false}',
},
headers=headers,
verify=False,
)
self.assertEqual(resp.status_code, requests.codes.ok)
cluster, = resp.json()
if cluster['isProvision'] and cluster['isFailable'] and not cluster['isDown']:
break
time.sleep(i)
self.assertTrue(cluster['isProvision'])
self.assertTrue(cluster['isFailable'])
self.assertFalse(cluster['isDown'])
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