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 @@ ...@@ -26,6 +26,7 @@
############################################################################## ##############################################################################
import os import os
import time
from six.moves.urllib.parse import urljoin from six.moves.urllib.parse import urljoin
import requests import requests
...@@ -68,6 +69,7 @@ class TestRepman(SlapOSInstanceTestCase): ...@@ -68,6 +69,7 @@ class TestRepman(SlapOSInstanceTestCase):
) )
self.assertEqual(resp.status_code, requests.codes.ok) self.assertEqual(resp.status_code, requests.codes.ok)
for i in range(20):
resp = requests.get( resp = requests.get(
urljoin(self.url, '/api/clusters'), urljoin(self.url, '/api/clusters'),
params={ params={
...@@ -78,6 +80,10 @@ class TestRepman(SlapOSInstanceTestCase): ...@@ -78,6 +80,10 @@ class TestRepman(SlapOSInstanceTestCase):
) )
self.assertEqual(resp.status_code, requests.codes.ok) self.assertEqual(resp.status_code, requests.codes.ok)
cluster, = resp.json() cluster, = resp.json()
if cluster['isProvision'] and cluster['isFailable'] and not cluster['isDown']:
break
time.sleep(i)
self.assertTrue(cluster['isProvision']) self.assertTrue(cluster['isProvision'])
self.assertTrue(cluster['isFailable']) self.assertTrue(cluster['isFailable'])
self.assertFalse(cluster['isDown']) 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