HomePhabricator

[electrum] fix flaky tear-down in functional tests

Description

[electrum] fix flaky tear-down in functional tests

Summary:
When the daemon stop command in called in the fulcrum_service's tear-down, it returns before all the the threads are terminated. In particular the wallet files still need to be saved before the daemon process exits. This causes a race condition when the test fixture deletes the data directory while WalletStorage._write creates a tmp file then deletes it. See https://github.com/python/cpython/pull/14064 for a description of how shutil.rmtree ends up raising a FileNotFoundError.

This issue will go away in Python 3.13 when shutil.rmtree no longer fails because it failed to delete an already deleted file. In the meantime ignore these failures.

I first tried a different approach: wait for the daemon process to actually terminate before deleting the data. However detecting the correct deamon process is not trivial, and if done wrong could cause more flakiness.

Test Plan: pytest electrumabc/tests/regtest

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D15989

Details

Provenance
PiRKAuthored on Apr 16 2024, 10:37
PiRKPushed on Apr 16 2024, 13:47
Reviewer
Restricted Project
Differential Revision
D15989: [electrum] fix flaky tear-down in functional tests
Parents
rABCc0fceec5bf0b: [Cashtab] Patch use of legacy const missed in rebase
Branches
Unknown
Tags
Unknown