Commit e4673d8a authored by John L. Villalovos's avatar John L. Villalovos Committed by Nejc Habjan
Browse files

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.
parent 2dda9dc1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
import logging
import subprocess
import textwrap
import time
@@ -24,12 +25,22 @@ data = {

@pytest.fixture(scope="module")
def job_with_artifacts(gitlab_runner, project):
    start_time = time.time()

    project.files.create(data)

    jobs = None
    while not jobs:
        time.sleep(0.5)
        jobs = project.jobs.list(scope="success")
        if time.time() - start_time < 60:
            continue
        logging.error("job never succeeded")
        for job in project.jobs.list():
            job = project.jobs.get(job.id)
            logging.info(f"{job.status} job: {job.pformat()}")
            logging.info(f"job log:\n{job.trace()}\n")
        pytest.fail("Fixture 'job_with_artifact' failed")

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