add build-job-matrix.py --timeout-multiplier (#15526)
* add build-job-matrix.py --timeout-multiplier * add test for build-job-matrix.py --timeout-multiplier
This commit is contained in:
parent
ba3ac20c55
commit
2e4943ef80
|
@ -74,6 +74,7 @@ arg_parser.add_argument("--per", type=str, choices=["directory", "file"], requir
|
|||
arg_parser.add_argument("--verbose", "-v", action="store_true")
|
||||
arg_parser.add_argument("--only", action="append", default=[])
|
||||
arg_parser.add_argument("--duplicates", type=int, default=1)
|
||||
arg_parser.add_argument("--timeout-multiplier", type=float, default=1)
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
if args.verbose:
|
||||
|
@ -110,7 +111,7 @@ for path in test_paths:
|
|||
for_matrix = {
|
||||
"check_resource_usage": conf["check_resource_usage"],
|
||||
"enable_pytest_monitor": "-p monitor" if conf["check_resource_usage"] else "",
|
||||
"job_timeout": conf["job_timeout"],
|
||||
"job_timeout": round(conf["job_timeout"] * args.timeout_multiplier),
|
||||
"pytest_parallel_args": pytest_parallel_args,
|
||||
"checkout_blocks_and_plots": conf["checkout_blocks_and_plots"],
|
||||
"install_timelord": conf["install_timelord"],
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Dict, List
|
||||
|
||||
import tests
|
||||
|
||||
build_job_matrix_path = pathlib.Path(tests.__file__).with_name("build-job-matrix.py")
|
||||
|
||||
|
||||
def run(args: List[str]) -> str:
|
||||
completed_process = subprocess.run(
|
||||
[sys.executable, build_job_matrix_path, *args],
|
||||
check=True,
|
||||
encoding="utf-8",
|
||||
stdout=subprocess.PIPE,
|
||||
)
|
||||
return completed_process.stdout
|
||||
|
||||
|
||||
def test() -> None:
|
||||
timeouts: Dict[int, Dict[str, int]] = {}
|
||||
|
||||
multipliers = [1, 2, 3]
|
||||
|
||||
for multiplier in multipliers:
|
||||
timeouts[multiplier] = {}
|
||||
output = run(args=["--per", "directory", "--timeout-multiplier", str(multiplier)])
|
||||
matrix = json.loads(output)
|
||||
for entry in matrix:
|
||||
timeouts[multiplier][entry["name"]] = entry["job_timeout"]
|
||||
|
||||
reference = timeouts[1]
|
||||
|
||||
for multiplier in multipliers:
|
||||
if multiplier == 1:
|
||||
continue
|
||||
|
||||
adjusted_reference = {key: value * multiplier for key, value in reference.items()}
|
||||
assert timeouts[multiplier] == adjusted_reference
|
Loading…
Reference in New Issue