From 2d6e72c2cbc9eaf49bed4e80d02cb32fe9810d06 Mon Sep 17 00:00:00 2001 From: Sergi Blanch Torne Date: Tue, 28 May 2024 14:48:05 +0200 Subject: [PATCH] ci: continue stress run'n'monitor When the tool is used to stress test a pipeline, if there are jobs already ran, use their information like it does when the stress flag is not set. This provides consistency between the behavior when stress argument is not set, to when it is set. When it is not set, it uses the information about jobs that are already done. When it is set, it has to use the information about the already ran jobs. Also, it saves resources by triggering the minimum required. Signed-off-by: Sergi Blanch Torne Reviewed-by: Guilherme Gallo Part-of: --- bin/ci/ci_run_n_monitor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 3a6af463d87..e8dd6c85fac 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -107,6 +107,13 @@ def monitor_pipeline( stress_status_counter = defaultdict(lambda: defaultdict(int)) target_id = None + # Pre-populate the stress status counter for already completed target jobs. + if stress: + # When stress test, it is necessary to collect this information before start. + for job in pipeline.jobs.list(all=True, include_retried=True): + if target_jobs_regex.fullmatch(job.name) and job.status in ["success", "failed"]: + stress_status_counter[job.name][job.status] += 1 + while True: deps_failed = [] to_cancel = [] @@ -309,7 +316,9 @@ def parse_args() -> None: "--stress", default=0, type=int, - help="Stresstest job(s). Number or repetitions or -1 for infinite.", + help="Stresstest job(s). Specify the number of times to rerun the selected jobs, " + "or use -1 for indefinite. Defaults to 0. If jobs have already been executed, " + "this will ensure the total run count respects the specified number.", ) parser.add_argument( "--project",