8000 chore(test): prevent 'job_with_artifact' fixture running forever · python-gitlab/python-gitlab@e4673d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e4673d8

Browse files
JohnVillalovosnejch
authored andcommitted
chore(test): prevent 'job_with_artifact' fixture running forever
Previously the 'job_with_artifact' fixture could run forever. Now give it up to 60 seconds to complete before failing.
1 parent 2dda9dc commit e4673d8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/functional/cli/test_cli_artifacts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import subprocess
23
import textwrap
34
import time
@@ -24,12 +25,22 @@
2425

2526
@pytest.fixture(scope="module")
2627
def job_with_artifacts(gitlab_runner, project):
28+
start_time = time.time()
29+
2730
project.files.create(data)
2831

2932
jobs = None
3033
while not jobs:
3134
time.sleep(0.5)
3235
jobs = project.jobs.list(scope="success")
36+
if time.time() - start_time < 60:
37+
continue
38+
logging.error("job never succeeded")
39+
for job in project.jobs.list():
40+
job = project.jobs.get(job.id)
41+
logging.info(f"{job.status} job: {job.pformat()}")
42+
logging.info(f"job log:\n{job.trace()}\n")
43+
pytest.fail("Fixture 'job_with_artifact' failed")
3344

3445
return project.jobs.get(jobs[0].id)
3546

0 commit comments

Comments
 (0)
0