Skip to content

Commit dae553d

Browse files
Store reference iterations logs as separate tar member (Option A)
1 parent 6b7720f commit dae553d

3 files changed

Lines changed: 37 additions & 17 deletions

File tree

tools/tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ In addition, in the directories of the cases executed, you can find `system-test
9494
When the tests fail at the results comparison step, this typically means that there are numerical regressions (unless something wrong went undetected in a previous step). We use [fieldcompare](https://gitlab.com/dglaeser/fieldcompare) to compare all [preCICE exports](https://precice.org/configuration-export.html) to reference results generated from a previous run. Relevant files:
9595

9696
- `precice-exports/`: The coupling meshes of the test run.
97-
- `reference-results/`: The coupling meshes of the reference run, as stored on Git LFS, expanded into `reference-results-unpacked`. For implicit-coupling tests, the reference `.tar.gz` also contains an `iterations-logs/` directory with the reference `precice-*-iterations.log` files.
97+
- `reference-results/`: The coupling meshes of the reference run, as stored on Git LFS, expanded into `reference-results-unpacked`. For implicit-coupling tests, the reference `.tar.gz` also contains a separate `{case}.iterations-logs/` directory with the reference `precice-*-iterations.log` files.
9898
- `diff-results/`: Numerical difference of the results in the two directories (computed with `fieldcompare dir --diff precice-exports/ reference/`). These are only present on failed comparisons.
99-
- `iterations-logs/`: The `precice-*-iterations.log` files of the test run. Only present in implicit coupling tests and compared by SHA-256 hash against the copies unpacked from the reference `.tar.gz`.
99+
- `iterations-logs/`: The `precice-*-iterations.log` files of the test run. Only present in implicit coupling tests and compared by SHA-256 hash against the copies unpacked from `{case}.iterations-logs/` in the reference `.tar.gz`.
100100

101101
To reproduce the comparison locally, use the [same fieldcompare command](https://github.com/precice/tutorials/blob/develop/tools/tests/docker-compose.field_compare.template.yaml):
102102

tools/tests/generate_reference_results.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
from metadata_parser.metdata import Tutorials, ReferenceResult
33
from systemtests.TestSuite import TestSuites
44
from systemtests.SystemtestArguments import SystemtestArguments
5-
from systemtests.Systemtest import Systemtest, GLOBAL_TIMEOUT, ITERATIONS_LOGS_DIR
5+
from systemtests.Systemtest import (
6+
Systemtest,
7+
GLOBAL_TIMEOUT,
8+
ITERATIONS_LOGS_DIR,
9+
reference_iterations_logs_tar_arcname,
10+
)
611
from pathlib import Path
712
from typing import List
813
import shutil
@@ -24,19 +29,29 @@ def create_reference_tar_gz(
2429
output_filename: Path,
2530
iterations_logs: List[tuple[str, Path]],
2631
) -> None:
27-
"""Archive precice-exports and optional iterations logs into one reference tar."""
32+
"""Archive precice-exports and optional iterations logs as separate top-level tar members."""
2833
stem = output_filename.name.replace(".tar.gz", "")
29-
staging = system_test_dir / f".{stem}_reference_tar_staging"
30-
if staging.exists():
31-
shutil.rmtree(staging)
32-
shutil.copytree(exports_dir, staging)
33-
for rel, src in iterations_logs:
34-
dest = staging / ITERATIONS_LOGS_DIR / rel
35-
dest.parent.mkdir(parents=True, exist_ok=True)
36-
shutil.copy2(src, dest)
37-
with tarfile.open(output_filename, "w:gz") as tar:
38-
tar.add(staging, arcname=stem)
39-
shutil.rmtree(staging)
34+
exports_staging = system_test_dir / f".{stem}_reference_exports_staging"
35+
logs_staging = system_test_dir / f".{stem}_reference_logs_staging"
36+
for staging in (exports_staging, logs_staging):
37+
if staging.exists():
38+
shutil.rmtree(staging)
39+
shutil.copytree(exports_dir, exports_staging)
40+
try:
41+
with tarfile.open(output_filename, "w:gz") as tar:
42+
tar.add(exports_staging, arcname=stem)
43+
if iterations_logs:
44+
for rel, src in iterations_logs:
45+
dest = logs_staging / rel
46+
dest.parent.mkdir(parents=True, exist_ok=True)
47+
shutil.copy2(src, dest)
48+
tar.add(
49+
logs_staging,
50+
arcname=reference_iterations_logs_tar_arcname(stem),
51+
)
52+
finally:
53+
shutil.rmtree(exports_staging, ignore_errors=True)
54+
shutil.rmtree(logs_staging, ignore_errors=True)
4055

4156

4257
def get_machine_informations():

tools/tests/systemtests/Systemtest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
DIFF_RESULTS_DIR = "diff-results"
2828
ITERATIONS_LOGS_DIR = "iterations-logs"
2929

30+
31+
def reference_iterations_logs_tar_arcname(stem: str) -> str:
32+
"""Top-level tar member name for reference iterations logs (separate from VTU data)."""
33+
return f"{stem}.{ITERATIONS_LOGS_DIR}"
34+
35+
3036
STAGE_LOG_FILES = {
3137
"build": "system-tests-build.log",
3238
"run": "system-tests-run.log",
@@ -727,8 +733,7 @@ def _unpacked_reference_iterations_logs_dir(self) -> Path:
727733
return (
728734
self.system_test_dir
729735
/ PRECICE_REL_REFERENCE_DIR
730-
/ stem
731-
/ ITERATIONS_LOGS_DIR
736+
/ reference_iterations_logs_tar_arcname(stem)
732737
)
733738

734739
def _collect_iterations_logs(

0 commit comments

Comments
 (0)