Skip to content

Commit 51e92a0

Browse files
systemtests: add configurable timeout per test case (closes #371)
1 parent 1f54fc5 commit 51e92a0

5 files changed

Lines changed: 17 additions & 5 deletions

File tree

changelog-entries/371.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add optional `timeout` field to `tests.yaml` entries, allowing per-test timeout configuration. Defaults to 600s for backward compatibility. Applies to the solver run and fieldcompare phases.

tools/tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,11 @@ test_suites:
331331
- fluid-openfoam
332332
- solid-fenics
333333
reference_result: ./flow-over-heated-plate/reference-results/fluid-openfoam_solid-fenics.tar.gz
334+
timeout: 3600
334335
```
335336
337+
The optional `timeout` field (in seconds, default: 600) sets the maximum time allowed for the solver run and fieldcompare phases. Use this for long-running tutorials such as `heat-exchanger` or `turek-hron-fsi3`.
338+
336339
This defines two test suites, namely `openfoam_adapter_pr` and `openfoam_adapter_release`. Each of them defines which case combinations of which tutorials to run.
337340
338341
### Generate Reference Results

tools/tests/metadata_parser/metdata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def from_cases_tuple(cls, cases: Tuple[Case], tutorial: Tutorial):
279279
class ReferenceResult:
280280
path: Path
281281
case_combination: CaseCombination
282+
timeout: int = 600
282283

283284
def __repr__(self) -> str:
284285
return f"{self.path.as_posix()}"

tools/tests/systemtests/Systemtest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020

2121

22-
GLOBAL_TIMEOUT = 600
22+
BUILD_TIMEOUT = 600
2323
SHORT_TIMEOUT = 10
2424

2525

@@ -394,7 +394,7 @@ def _run_field_compare(self):
394394
cwd=self.system_test_dir)
395395

396396
try:
397-
stdout, stderr = process.communicate(timeout=GLOBAL_TIMEOUT)
397+
stdout, stderr = process.communicate(timeout=self.reference_result.timeout)
398398
except KeyboardInterrupt as k:
399399
process.kill()
400400
raise KeyboardInterrupt from k
@@ -439,7 +439,7 @@ def _build_docker(self):
439439
cwd=self.system_test_dir)
440440

441441
try:
442-
stdout, stderr = process.communicate(timeout=GLOBAL_TIMEOUT)
442+
stdout, stderr = process.communicate(timeout=BUILD_TIMEOUT)
443443
except KeyboardInterrupt as k:
444444
process.kill()
445445
# process.send_signal(9)
@@ -483,7 +483,7 @@ def _run_tutorial(self):
483483
cwd=self.system_test_dir)
484484

485485
try:
486-
stdout, stderr = process.communicate(timeout=GLOBAL_TIMEOUT)
486+
stdout, stderr = process.communicate(timeout=self.reference_result.timeout)
487487
except KeyboardInterrupt as k:
488488
process.kill()
489489
# process.send_signal(9)

tools/tests/systemtests/TestSuite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ def from_yaml(cls, path, parsed_tutorials: Tutorials):
6363
tutorial_case['case_combination'], tutorial)
6464
if case_combination_requested in all_case_combinations:
6565
case_combinations_of_tutorial[tutorial].append(case_combination_requested)
66+
timeout_raw = tutorial_case.get('timeout', 600)
67+
if isinstance(timeout_raw, str):
68+
timeout = int(timeout_raw.rstrip('s'))
69+
else:
70+
timeout = int(timeout_raw)
71+
if timeout <= 0:
72+
raise ValueError(f"timeout must be a positive integer, got {timeout}")
6673
reference_results_of_tutorial[tutorial].append(ReferenceResult(
67-
tutorial_case['reference_result'], case_combination_requested))
74+
tutorial_case['reference_result'], case_combination_requested, timeout))
6875
else:
6976
raise Exception(
7077
f"Could not find the following cases {tutorial_case['case-combination']} in the current metadata of tutorial {tutorial.name}")

0 commit comments

Comments
 (0)