From 51521e1f9d247d9ab3cc2f25fa896126668cc64a Mon Sep 17 00:00:00 2001 From: Helen Koike Date: Fri, 29 Sep 2023 23:31:30 -0300 Subject: [PATCH] ci/ci_run_n_monitor: limit repetitions on --stress --stress options now receives the number of repetitions or -1 to behave as before. Signed-off-by: Helen Koike Part-of: --- bin/ci/ci_run_n_monitor.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 8940733c41b..32b5a506c99 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -79,7 +79,7 @@ def monitor_pipeline( target_job: str, dependencies, force_manual: bool, - stress: bool, + stress: int, ) -> tuple[Optional[int], Optional[int]]: """Monitors pipeline and delegate canceling jobs""" statuses: dict[str, str] = defaultdict(str) @@ -97,8 +97,12 @@ def monitor_pipeline( target_id = job.id if stress and job.status in ["success", "failed"]: - stress_status_counter[job.name][job.status] += 1 - enable_job(project, job, "retry", force_manual) + if ( + stress < 0 + or sum(stress_status_counter[job.name].values()) < stress + ): + enable_job(project, job, "retry", force_manual) + stress_status_counter[job.name][job.status] += 1 else: enable_job(project, job, "target", force_manual) @@ -120,15 +124,20 @@ def monitor_pipeline( cancel_jobs(project, to_cancel) if stress: + enough = True for job_name, status in stress_status_counter.items(): print( f"{job_name}\tsucc: {status['success']}; " f"fail: {status['failed']}; " - f"total: {sum(status.values())}", + f"total: {sum(status.values())} of {stress}", flush=False, ) - pretty_wait(REFRESH_WAIT_JOBS) - continue + if stress < 0 or sum(status.values()) < stress: + enough = False + + if not enough: + pretty_wait(REFRESH_WAIT_JOBS) + continue print("---------------------------------", flush=False) @@ -239,7 +248,12 @@ def parse_args() -> None: parser.add_argument( "--force-manual", action="store_true", help="Force jobs marked as manual" ) - parser.add_argument("--stress", action="store_true", help="Stresstest job(s)") + parser.add_argument( + "--stress", + default=0, + type=int, + help="Stresstest job(s). Number or repetitions or -1 for infinite.", + ) parser.add_argument( "--project", default="mesa",