-
Couldn't load subscription status.
- Fork 241
Ensure all test networks are within _with_ statements #7393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Ensure all test networks are within _with_ statements #7393
Conversation
There was a problem hiding this 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 addresses potential resource cleanup issues in end-to-end tests by ensuring all test networks are properly managed within Python context managers (with statements). This prevents scenarios where networks might not be stopped properly, leading to processes continuing to write to ledger directories and causing test failures.
Key changes:
- Converted all standalone
infra.network.Network()instantiations to usewith infra.network.network()context managers - Added unique label suffixes to prevent directory aliasing between networks in the same test
- Fixed deep copy usage to ensure proper argument isolation between networks
Looking at https://github.com/microsoft/CCF/actions/runs/18711838663/job/53362454045 it claims that the ledger directory already existed.
Afaict this can only happen if either:
Of these the most likely is that some node was not properly killed at the end of a test, and one possible way would be if a network was started and not stopped.
In e2e_operations.py we have a couple of networks that get started within a test, and potentially are not closed.
(the one which is glaring is the run_recovery_unsealing_corrupt)
If we instead encapsulate all of these networks via the with keywork in python, then when they go out of scope they are always stopped (and there is logging of stacktraces etc).
This PR does so for all networks in e2e_operations.py
There are some other similar ones in - lts compatibility, but these seem less likely to be obviously correct.
I've also taken the opportunity to ensure that at the very least for these networks that they are not alising over the same directory.