Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit564ab74

Browse files
test: attempt to make functional test startup more reliable
The functional tests have been erratic. Current theory is that we arestarting the tests before the GitLab container is fully up andrunning. * Add checking of the Health Check[1] endpoints. * Add a 20 second delay after we believe it is up and running. * Increase timeout from 300 to 400 seconds[1]https://docs.gitlab.com/ee/user/admin_area/monitoring/health_check.html
1 parent4b798fc commit564ab74

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

‎tests/functional/conftest.py‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
fromsubprocessimportcheck_output
77

88
importpytest
9+
importrequests
910

1011
importgitlab
1112
importgitlab.base
1213
fromtests.functionalimporthelpers
1314

15+
SLEEP_TIME=20
16+
1417

1518
@pytest.fixture(scope="session")
1619
deffixture_dir(test_dir):
@@ -129,15 +132,30 @@ def check_is_alive():
129132
Return a healthcheck function fixture for the GitLab container spinup.
130133
"""
131134

132-
def_check(container:str,start_time:float)->bool:
135+
def_check(
136+
*,container:str,start_time:float,docker_ip:str,docker_port:int
137+
)->bool:
133138
setup_time=time.perf_counter()-start_time
134139
minutes,seconds=int(setup_time/60),int(setup_time%60)
135140
logging.info(
136141
f"Checking if GitLab container is up. "
137142
f"Have been checking for{minutes} minute(s),{seconds} seconds ..."
138143
)
139144
logs= ["docker","logs",container]
140-
return"gitlab Reconfigured!"incheck_output(logs).decode()
145+
if"gitlab Reconfigured!"notincheck_output(logs).decode():
146+
returnFalse
147+
logging.info("GitLab has finished reconfiguring.")
148+
gitlab_url=f"http://{docker_ip}:{docker_port}"
149+
forcheckin ("health","readiness","liveness"):
150+
url=f"{gitlab_url}/-/{check}"
151+
logging.info(f"Checking{check!r} endpoint at:{url}")
152+
result=requests.get(url)
153+
ifresult.status_code!=200:
154+
logging.info(f"{check!r} check did not return 200:{result}")
155+
returnFalse
156+
logging.info(f"Sleeping for{SLEEP_TIME}")
157+
time.sleep(SLEEP_TIME)
158+
returnTrue
141159

142160
return_check
143161

@@ -174,9 +192,14 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
174192
start_time=time.perf_counter()
175193
logging.info("Waiting for GitLab container to become ready.")
176194
docker_services.wait_until_responsive(
177-
timeout=300,
195+
timeout=400,
178196
pause=10,
179-
check=lambda:check_is_alive("gitlab-test",start_time=start_time),
197+
check=lambda:check_is_alive(
198+
container="gitlab-test",
199+
start_time=start_time,
200+
docker_ip=docker_ip,
201+
docker_port=port,
202+
),
180203
)
181204
setup_time=time.perf_counter()-start_time
182205
minutes,seconds=int(setup_time/60),int(setup_time%60)
@@ -208,6 +231,7 @@ def gl(gitlab_config):
208231
logging.info("Instantiating python-gitlab gitlab.Gitlab instance")
209232
instance=gitlab.Gitlab.from_config("local", [gitlab_config])
210233

234+
logging.info("Reset GitLab")
211235
reset_gitlab(instance)
212236

213237
returninstance

‎tests/functional/fixtures/docker-compose.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
grafana['enable'] =false
3333
letsencrypt['enable'] =false
3434
gitlab_rails['initial_license_file'] = '/python-gitlab-ci.gitlab-license'
35+
gitlab_rails['monitoring_whitelist'] = ['0.0.0.0/0']
3536
entrypoint:
3637
-/bin/sh
3738
--c

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp