Skip to content

[test] Use anonymous inodes for temp DB files in snapshot and valset …#2146

Open
maxkozlovsky wants to merge 1 commit intomainfrom
max/fix-test-temp-file-cleanup
Open

[test] Use anonymous inodes for temp DB files in snapshot and valset …#2146
maxkozlovsky wants to merge 1 commit intomainfrom
max/fix-test-temp-file-cleanup

Conversation

@maxkozlovsky
Copy link
Contributor

…tests

Replace named temp files (mkstemp + manual cleanup) with anonymous inodes via make_temporary_inode(), referenced through /proc/self/fd/. Files are automatically reclaimed by the OS when the fd closes, even on crash or abort.

Also replace hardcoded /tmp/snapshot paths with mkdtemp-based TempDir RAII to avoid conflicts between concurrent test runs.

Copilot AI review requested due to automatic review settings March 18, 2026 13:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors test setup/teardown for on-disk DB snapshot/staking tests to use a temporary inode (via make_temporary_inode) and RAII helpers, reducing reliance on named temp files and manual cleanup.

Changes:

  • Replace mkstemp-based temp DB creation with an RAII TempDb that uses make_temporary_inode() and /proc/self/fd/<fd>.
  • Add RAII TempDir for snapshot directory lifecycle management in snapshot tests.
  • Adjust test fixtures to ensure correct destruction order when an FD must remain open.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
category/execution/monad/staking/test_read_valset.cpp Introduces TempDb RAII helper and switches staking valset tests to use an anonymous temporary inode-backed DB path.
category/execution/ethereum/test/test_db_snapshot.cpp Introduces TempDb/TempDir RAII helpers and updates snapshot tests to use them instead of manual temp paths and cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@maxkozlovsky maxkozlovsky force-pushed the max/fix-test-temp-file-cleanup branch from aebe5ce to e42c375 Compare March 18, 2026 13:57
…tests

Replace named temp files (mkstemp + manual cleanup) with anonymous inodes
via make_temporary_inode(), referenced through /proc/self/fd/<N>. Files are
automatically reclaimed by the OS when the fd closes, even on crash or abort.

Also replace hardcoded /tmp/snapshot paths with mkdtemp-based TempDir RAII
to avoid conflicts between concurrent test runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@maxkozlovsky maxkozlovsky force-pushed the max/fix-test-temp-file-cleanup branch from e42c375 to 5db2a32 Compare March 21, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants