ENH: Auto-cleanup BigIO test outputs and enforce serial execution#6013
Conversation
20a6907 to
002e08a
Compare
Design Alternatives: BigIO Test Output CleanupChosen approach: CTest fixture cleanup (CMake-side)A new CMake function
For Alternative considered: in-test C++ self-cleanupAll 4 test source files follow the same pattern: write a large image, read it back, compare pixels, return Why this was rejected:
Serial execution requirementAll BigIO tests now set The |
|
| Filename | Overview |
|---|---|
| CMake/ITKModuleTest.cmake | Adds ITK_REMOVE_BIGIO_FILES_ON_SUCCESS option and itk_add_bigio_test_cleanup() function; the function's CTest fixture semantics are documented incorrectly — cleanup runs unconditionally, not only on success, and filtered reruns won't auto-trigger cleanup |
| Modules/IO/ImageBase/test/CMakeLists.txt | Consolidates per-test RESOURCE_LOCK properties into a single set_tests_properties block, adds RUN_SERIAL and BigIO/RUNS_LONG labels, and registers cleanup hooks for three LargeImage tests |
| Modules/IO/Meta/test/CMakeLists.txt | Adds RUN_SERIAL to existing set_tests_properties block replacing old appended set_property calls, and registers cleanup hooks for all four LargeMetaImage tests |
| Modules/IO/TIFF/test/CMakeLists.txt | Same RUN_SERIAL consolidation pattern as IO/Meta; removes four separate set_property APPEND RUN_SERIAL blocks and registers TIFF cleanup hooks |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["ctest selects BigIO test\ne.g. itkLargeMetaImageWriteReadTest1"] --> B{"Full run or\nfiltered run?"}
B -- "Full run\n(no -R filter)" --> C["Both main test AND _cleanup\ntest are in the set"]
B -- "Filtered run\n(-R LargeMetaImage)" --> D["Only main test matches\nNo FIXTURES_REQUIRED present"]
C --> E["CTest fixture ordering:\nSETUP runs before CLEANUP"]
D --> F["_cleanup test NOT auto-added\nCleanup silently skipped"]
E --> G{"Main test result?"}
G -- "PASS" --> H["_cleanup runs\ncmake -E rm -f files"]
G -- "FAIL" --> I["_cleanup STILL runs\n(CMake docs: cleanup is unconditional)\nFiles deleted despite failure"]
H --> J["Disk space reclaimed ✓"]
I --> K["Disk space reclaimed\nbut debug files lost\n(contradicts PR design intent)"]
Reviews (1): Last reviewed commit: "ENH: Auto-cleanup BigIO test outputs and..." | Re-trigger Greptile
002e08a to
519bb41
Compare
blowekamp
left a comment
There was a problem hiding this comment.
Please separate the change in properties from the addition of the clean up step. The current concept and behavior of the RESOURCE_LOCK may have been missed. If there is a test in here that is missing this lock, then it could be added in this PR.
I think these ctest properties are a blocker for converting tests to the google test framework. I don't know of any work around for that.
This looks like a nice usage of this ctest fixture feature. However I think "itk_add_bigio_test_cleanup" may be too specific, and it could be generalized to "itk_add_file_test_cleanup" to just delete listed files
519bb41 to
5f4d4dd
Compare
|
Thanks @blowekamp — all three concerns addressed, branch force-pushed:
|
dzenanz
left a comment
There was a problem hiding this comment.
A very welcome feature. I have a bunch of local builds, some of which are big due to temporary test outputs. Some inline requests.
Consolidate scattered set_tests_properties / set_property calls for BigIO large-image tests into unified blocks per test group. ImageBase: merge three separate RESOURCE_LOCK MEMORY_SIZE blocks into one set_tests_properties covering all three tests; add BigIO/RUNS_LONG labels for CTest filtering. TIFF: consolidate four separate set_property(... APPEND ... RUN_SERIAL) calls (one per test) into the existing set_tests_properties blocks. No behavioral change — RUN_SERIAL was already set for all four tests. Meta: consolidate test4's separate set_property(... RUN_SERIAL) into its set_tests_properties block. No behavioral change for test4. Tests 1-3 retain MEMORY_SIZE-only serialization (no RUN_SERIAL added because the MEMORY_SIZE resource lock already serializes memory- intensive tests while permitting non-memory tests to run concurrently, which matters for nightly valgrind/coverage builds).
Add itk_add_file_test_cleanup() to ITKModuleTest.cmake. The function uses CTest FIXTURES_SETUP/FIXTURES_CLEANUP to register a companion <test_name>_cleanup test that removes specified output files after the main test completes. Controlled by the ITK_REMOVE_TEST_FILES_ON_SUCCESS option (default ON). When OFF, no cleanup test is registered and files are retained for manual debugging. For .mhd output files the companion .raw/.zraw sidecar is automatically included in the removal list. Apply to all BigIO large-image tests in IO/ImageBase, IO/Meta, and IO/TIFF where multi-gigabyte outputs would otherwise accumulate and exhaust disk space on CI runners and local builds. The function name was chosen to be IO-format-agnostic (suggested by blowekamp during review of an earlier draft).
5f4d4dd to
eca08ff
Compare
|
FYI: Failing test for mac is fixed in #6015 |
80b191f
into
InsightSoftwareConsortium:main
Summary
ITK_REMOVE_BIGIO_FILES_ON_SUCCESS(advanced CMake option, default ON) that automatically removes multi-gigabyte BigIO test output files after successful completionRUN_SERIALon all BigIO tests to prevent concurrent disk exhaustionitk_add_bigio_test_cleanup()using CTest fixturesMotivation
The 11 BigIO write-read tests produce up to 47 GB of temporary files:
On CI runners (GitHub Actions ubuntu-22.04: 146 GB total, ~89 GB free after build), running these tests without cleanup risks disk exhaustion. PR #6011 addressed this with post-build
.o/.acleanup, but the root cause is that BigIO outputs accumulate across test runs.How it works
CTest fixture semantics:
FIXTURES_SETUP— it runs and produces output filescmake -E rm -f) isFIXTURES_CLEANUP— it runs only after SETUP passes.mhdfiles, companion.raw/.zrawdata files are also removedITK_REMOVE_BIGIO_FILES_ON_SUCCESS=OFFto always retain filesDesign alternatives considered
An in-test C++ self-cleanup approach was evaluated and rejected. See
Documentation/docs/design/BigIO_test_cleanup_design.mdfor the full rationale (multiple exit paths, format-dependent companion files, reader lifetime, separation of concerns, no runtime configurability).Affected modules
IO/Meta: LargeMetaImageWriteReadTest 1–4IO/TIFF: LargeTIFFImageWriteReadTest 1–4IO/ImageBase: LargeImageWriteReadTest 2D/3D, WriteConvertReadTest plan
ITK_REMOVE_BIGIO_FILES_ON_SUCCESS=ON(default): BigIO output files are removed after passing testsITK_REMOVE_BIGIO_FILES_ON_SUCCESS=OFF: BigIO output files are retainedRUN_SERIALprevents concurrent BigIO tests inctest -jN🤖 Generated with Claude Code