diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2018-04-06 10:53:35 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2018-04-08 10:47:31 -0400 |
commit | e36a0c08529bccc695ec71a7ec1df89367cc1628 (patch) | |
tree | 7b33d7c1aac9c7d4c1efc4e1f52d02c1e013e12d /test/functional/test_framework | |
parent | 1d540046fe47eb7b6062c55ebebd801ece96231c (diff) |
[qa] Ensure bitcoind processes are cleaned up when tests end
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/test_framework.py | 2 | ||||
-rwxr-xr-x | test/functional/test_framework/test_node.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index d427f62856..1a71796e91 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -148,6 +148,8 @@ class BitcoinTestFramework(): if self.nodes: self.stop_nodes() else: + for node in self.nodes: + node.cleanup_on_exit = False self.log.info("Note: bitcoinds were not stopped and may still be running") if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED: diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 291ac3ee46..b3c2fc0a09 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -81,9 +81,20 @@ class TestNode(): self.rpc = None self.url = None self.log = logging.getLogger('TestFramework.node%d' % i) + self.cleanup_on_exit = True # Whether to kill the node when this object goes away self.p2ps = [] + def __del__(self): + # Ensure that we don't leave any bitcoind processes lying around after + # the test ends + if self.process and self.cleanup_on_exit: + # Should only happen on test failure + # Avoid using logger, as that may have already been shutdown when + # this destructor is called. + print("Cleaning up leftover process") + self.process.kill() + def __getattr__(self, name): """Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" if self.use_cli: |