Skip to content

Commit 6b4f009

Browse files
systemtests: archive fieldcompare diff files on failure
1 parent 1f54fc5 commit 6b4f009

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

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: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import os
2020

2121

22-
GLOBAL_TIMEOUT = 600
22+
GLOBAL_TIMEOUT = 900
23+
DIFF_RESULTS_DIR = "diff-results"
2324
SHORT_TIMEOUT = 10
2425

2526

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

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

0 commit comments

Comments
 (0)