Skip to content

Commit 065c8b2

Browse files
systemtests: archive fieldcompare diff files on failure
1 parent 1f54fc5 commit 065c8b2

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

changelog-entries/742.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Archive fieldcompare diff files to `diff-results/` on failure so they are included in the CI artifact and can be downloaded for inspection.

tools/tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ In this case, building and running seems to work out, but the tests fail because
105105

106106
The easiest way to debug a systemtest run is first to have a look at the output written into the action on GitHub.
107107
If this does not provide enough hints, the next step is to download the generated `system_tests_run_<run_id>_<run_attempt>` artifact. Note that by default this will only be generated if the systemtests fail.
108-
Inside the archive, a test-specific subfolder like `flow-over-heated-plate_fluid-openfoam-solid-fenics_2023-11-19-211723` contains two log files: a `stderr.log` and `stdout.log`. This can be a starting point for a further investigation.
108+
Inside the archive, a test-specific subfolder like `flow-over-heated-plate_fluid-openfoam-solid-fenics_2023-11-19-211723` contains two log files: a `stderr.log` and `stdout.log`. This can be a starting point for a further investigation. If fieldcompare detected differences, any diff VTK files (e.g. `diff_*.vtu`) are copied into a `diff-results/` subfolder in the same directory — open these in ParaView to see exactly where results diverge from the reference.
109109

110110
## Adding new tests
111111

tools/tests/systemtests/Systemtest.py

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

2121

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

2525

@@ -513,6 +513,31 @@ def __write_logs(self, stdout_data: List[str], stderr_data: List[str]):
513513
with open(self.system_test_dir / "stderr.log", 'w') as stderr_file:
514514
stderr_file.write("\n".join(stderr_data))
515515

516+
def __archive_diff_files(self):
517+
"""
518+
Copies any diff VTK files produced by fieldcompare into a dedicated
519+
diff-results/ folder inside the system test directory so they are
520+
included in the CI artifact and can be downloaded for inspection.
521+
"""
522+
precice_exports = self.system_test_dir / PRECICE_REL_OUTPUT_DIR
523+
diff_dest = self.system_test_dir / "diff-results"
524+
if not precice_exports.exists():
525+
logging.debug("No precice-exports directory found, skipping diff file archiving")
526+
return
527+
diff_files = (list(precice_exports.rglob("*diff*.vtu")) +
528+
list(precice_exports.rglob("*diff*.vtk")) +
529+
list(precice_exports.rglob("*diff*.vtp")))
530+
if not diff_files:
531+
logging.debug("No diff files found in precice-exports, skipping archiving")
532+
return
533+
diff_dest.mkdir(exist_ok=True)
534+
for diff_file in diff_files:
535+
dest_file = diff_dest / diff_file.name
536+
shutil.copy2(diff_file, dest_file)
537+
logging.info(f"Archived diff file: {diff_file.name} -> {diff_dest}")
538+
logging.info(f"Archived {len(diff_files)} diff file(s) to {diff_dest}")
539+
540+
516541
def __prepare_for_run(self, run_directory: Path):
517542
"""
518543
Prepares the run_directory with folders and datastructures needed for every systemtest execution
@@ -566,6 +591,7 @@ def run(self, run_directory: Path):
566591
std_out.extend(fieldcompare_result.stdout_data)
567592
std_err.extend(fieldcompare_result.stderr_data)
568593
if fieldcompare_result.exit_code != 0:
594+
self.__archive_diff_files()
569595
self.__write_logs(std_out, std_err)
570596
logging.critical(f"Fieldcompare returned non zero exit code, therefore {self} failed")
571597
return SystemtestResult(

0 commit comments

Comments
 (0)