Skip to content

Commit 871b246

Browse files
committed
more conservative waiting for gitlab to be ready
1 parent 561247a commit 871b246

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/infrastructure/gitlab.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import uuid
22
from tempfile import TemporaryDirectory
3+
from time import sleep
34
from urllib.parse import quote
45

56
import httpx
@@ -51,8 +52,16 @@ def ready(self):
5152
self.host_port = self.ports[f"{GITLAB_LISTEN_PORT}/tcp"][0]
5253
self.host_url = f"http://localhost:{self.host_port}"
5354

54-
response = httpx.get(self.host_url, follow_redirects=True)
55-
return response.status_code == 200
55+
# we want gitlab to return a 200 several times in a row.
56+
# especially in the github runners it can act flaky otherwise.
57+
for _ in range(3):
58+
response = httpx.get(self.host_url, follow_redirects=True)
59+
if response.status_code != 200:
60+
return False
61+
62+
sleep(5)
63+
64+
return True
5665

5766

5867
gitlab_container = container(
@@ -71,7 +80,7 @@ def ready(self):
7180
"{gitlab_logs_volume.name}": {"bind": "/var/log/gitlab", "mode": "rw"},
7281
},
7382
scope="session",
74-
timeout=5 * 30,
83+
timeout=5 * 60,
7584
wrapper_class=GitlabContainer,
7685
)
7786

0 commit comments

Comments
 (0)