From d2b749c175dc5b93715273591e2873ea27436126 Mon Sep 17 00:00:00 2001 From: PranjalManhgaye Date: Sat, 20 Jun 2026 09:32:10 +0530 Subject: [PATCH 1/2] Add per-component build_timeout for system test Docker builds Fixes #840. Components can set build_timeout in components.yaml; each test uses the max across its participants. DuMuX builds get 1800s by default. --- changelog-entries/840.md | 1 + tools/tests/README.md | 6 ++++-- tools/tests/components.yaml | 1 + tools/tests/metadata_parser/metdata.py | 15 +++++++++++---- tools/tests/systemtests/Systemtest.py | 24 +++++++++++++++++++++++- 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 changelog-entries/840.md diff --git a/changelog-entries/840.md b/changelog-entries/840.md new file mode 100644 index 000000000..b857d6474 --- /dev/null +++ b/changelog-entries/840.md @@ -0,0 +1 @@ +- Add optional per-component `build_timeout` in `components.yaml` for the system test Docker build step ([#840](https://github.com/precice/tutorials/issues/840)). diff --git a/tools/tests/README.md b/tools/tests/README.md index 620b76164..253813183 100644 --- a/tools/tests/README.md +++ b/tools/tests/README.md @@ -329,8 +329,10 @@ This template defines: ### Timeouts -A `GLOBAL_TIMEOUT` is used for all operations. Its default value is 600s (5min), it is set in the beginning of [`Systemtests.py`](https://github.com/precice/tutorials/blob/develop/tools/tests/systemtests/Systemtest.py), and it can be overridden via the `PRECICE_SYSTEMTESTS_TIMEOUT` environment variable. +Build and run/compare use separate timeouts. -Tests can define a different `timeout` in their `tests.yaml` entry, which applies to the running and results comparison steps. +**Build:** Each component in `components.yaml` may define `build_timeout` (seconds). For a test, the build step uses the maximum `build_timeout` among its components; components without `build_timeout` use `DEFAULT_BUILD_TIMEOUT` (600s by default, same as `GLOBAL_TIMEOUT`). Override the default via `PRECICE_SYSTEMTESTS_BUILD_TIMEOUT`. + +**Run and compare:** `GLOBAL_TIMEOUT` defaults to 600s and can be overridden via `PRECICE_SYSTEMTESTS_TIMEOUT`. Tests can define a different `timeout` in their `tests.yaml` entry, which applies to the running and results comparison steps only. diff --git a/tools/tests/components.yaml b/tools/tests/components.yaml index c7a4de2b0..13a2f8206 100644 --- a/tools/tests/components.yaml +++ b/tools/tests/components.yaml @@ -50,6 +50,7 @@ dealii-adapter: dumux-adapter: template: component-templates/dumux-adapter.yaml + build_timeout: 1800 build_arguments: PLATFORM: default: "ubuntu_2404" diff --git a/tools/tests/metadata_parser/metdata.py b/tools/tests/metadata_parser/metdata.py index 1c9b98d55..e8151b81b 100644 --- a/tools/tests/metadata_parser/metdata.py +++ b/tools/tests/metadata_parser/metdata.py @@ -97,6 +97,7 @@ class Component: name: str template: str parameters: BuildArguments + build_timeout: Optional[int] = None def __eq__(self, other): if isinstance(other, Component): @@ -130,11 +131,17 @@ def from_yaml(cls, path): with open(path, 'r') as f: data = yaml.safe_load(f) for component_name in data: - parameters = BuildArguments.from_components_yaml( - data[component_name]) - template = data[component_name]["template"] + component_data = data[component_name] + parameters = BuildArguments.from_components_yaml(component_data) + template = component_data["template"] + build_timeout = component_data.get("build_timeout", None) + if build_timeout is not None: + if not isinstance(build_timeout, int) or build_timeout <= 0: + raise ValueError( + f"build_timeout must be a positive integer for component " + f"'{component_name}', got {build_timeout!r}") components.append( - Component(component_name, template, parameters)) + Component(component_name, template, parameters, build_timeout)) return cls(components) diff --git a/tools/tests/systemtests/Systemtest.py b/tools/tests/systemtests/Systemtest.py index 932b6b944..a44f4286f 100644 --- a/tools/tests/systemtests/Systemtest.py +++ b/tools/tests/systemtests/Systemtest.py @@ -21,6 +21,8 @@ GLOBAL_TIMEOUT = int(os.environ.get("PRECICE_SYSTEMTESTS_TIMEOUT", 600)) +DEFAULT_BUILD_TIMEOUT = int( + os.environ.get("PRECICE_SYSTEMTESTS_BUILD_TIMEOUT", GLOBAL_TIMEOUT)) SHORT_TIMEOUT = 10 DIFF_RESULTS_DIR = "diff-results" @@ -236,6 +238,24 @@ def __hash__(self) -> int: def __post_init__(self): self.__init_args_to_use() self.env = {} + self.build_timeout = self._resolve_build_timeout() + + def _resolve_build_timeout(self) -> int: + """ + Use the maximum build_timeout of the distinct components in this test. + Components without build_timeout use DEFAULT_BUILD_TIMEOUT. + """ + timeouts = [] + seen_components = set() + for case in self.case_combination.cases: + if case.component.name in seen_components: + continue + seen_components.add(case.component.name) + if case.component.build_timeout is not None: + timeouts.append(case.component.build_timeout) + else: + timeouts.append(DEFAULT_BUILD_TIMEOUT) + return max(timeouts) if timeouts else DEFAULT_BUILD_TIMEOUT def __init_args_to_use(self): """ @@ -714,6 +734,8 @@ def _build_docker(self): Builds the docker image """ logging.debug(f"Building docker image for {self}") + logging.info( + f"Using build timeout {self.build_timeout}s for {self}") time_start = time.perf_counter() docker_compose_content = self.__get_docker_compose_file() with open(self.system_test_dir / "docker-compose.tutorial.yaml", 'w') as file: @@ -729,7 +751,7 @@ def _build_docker(self): 'build', ], "build", - GLOBAL_TIMEOUT, + self.build_timeout, ) elapsed_time = time.perf_counter() - time_start return DockerComposeResult(exit_code, stdout_data, stderr_data, self, elapsed_time) From 5323fe44bda0ce262a856b9de955fc7bec9e01a6 Mon Sep 17 00:00:00 2001 From: Pranjal Date: Sat, 20 Jun 2026 09:46:08 +0530 Subject: [PATCH 2/2] Update and rename 840.md to 848.md --- changelog-entries/840.md | 1 - changelog-entries/848.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 changelog-entries/840.md create mode 100644 changelog-entries/848.md diff --git a/changelog-entries/840.md b/changelog-entries/840.md deleted file mode 100644 index b857d6474..000000000 --- a/changelog-entries/840.md +++ /dev/null @@ -1 +0,0 @@ -- Add optional per-component `build_timeout` in `components.yaml` for the system test Docker build step ([#840](https://github.com/precice/tutorials/issues/840)). diff --git a/changelog-entries/848.md b/changelog-entries/848.md new file mode 100644 index 000000000..b112c8235 --- /dev/null +++ b/changelog-entries/848.md @@ -0,0 +1 @@ +- Add optional per-component `build_timeout` in `components.yaml` for the system test Docker build step ([#848](https://github.com/precice/tutorials/pull/848)).