mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#31620: test: Remove --noshutdown flag, Tidy startup failures
faf2f2c654
test: Avoid redundant stop and error spam on shutdown (MarcoFalke)fae3bf6b87
test: Avoid redundant stop and error spam on startup failure (MarcoFalke)fa0dc09b90
test: Remove --noshutdown flag (MarcoFalke)fad441fba0
test: Treat leftover process as error (MarcoFalke) Pull request description: The `--noshutdown` flag is brittle, confusing, and redundant: * Someone wanting to inspect the state after a test failure will likely also want to debug the state on the python side, so the option is redundant with `--pdbonfailure`. If there was a use case to replicate `--pdbonfailure` without starting pdb, a dedicated flag could be added for that use case. * It is brittle to use the flag for a passing test, because it will disable checks in the test. For example, on shutdown LSan will perform a leak check, and the test framework will check that the node did not crash, and it will check that the node did not print errors to stderr. Fix all issues by removing it. Also, tidy up startup error messages to be less confusing as a result. ACKs for top commit: hodlinator: re-ACKfaf2f2c654
pablomartin4btc: re tACKfaf2f2c654
Tree-SHA512: 46d7ae59c7be88b93f1f9e0b6be21af0fc101e646512e2c5e725682cb18bfec8aa010e0ebe89ce9ffe239e5caac0da5f81cc97b79e738d26ca5fa31930e8e4e3
This commit is contained in:
commit
f34c580bd8
2 changed files with 10 additions and 20 deletions
|
@ -171,8 +171,6 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
||||
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
|
||||
help="Leave bitcoinds and test.* datadir on exit or error")
|
||||
parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true",
|
||||
help="Don't stop bitcoinds after the test execution")
|
||||
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../cache"),
|
||||
help="Directory for caching pregenerated datadirs (default: %(default)s)")
|
||||
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs (must not exist)")
|
||||
|
@ -325,18 +323,15 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
|
||||
self.log.debug('Closing down network thread')
|
||||
self.network_thread.close()
|
||||
if not self.options.noshutdown:
|
||||
if self.success == TestStatus.FAILED:
|
||||
self.log.info("Not stopping nodes as test failed. The dangling processes will be cleaned up later.")
|
||||
else:
|
||||
self.log.info("Stopping nodes")
|
||||
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")
|
||||
|
||||
should_clean_up = (
|
||||
not self.options.nocleanup and
|
||||
not self.options.noshutdown and
|
||||
self.success != TestStatus.FAILED and
|
||||
not self.options.perf
|
||||
)
|
||||
|
@ -584,15 +579,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
if extra_args is None:
|
||||
extra_args = [None] * self.num_nodes
|
||||
assert_equal(len(extra_args), self.num_nodes)
|
||||
try:
|
||||
for i, node in enumerate(self.nodes):
|
||||
node.start(extra_args[i], *args, **kwargs)
|
||||
for node in self.nodes:
|
||||
node.wait_for_rpc_connection()
|
||||
except Exception:
|
||||
# If one node failed to start, stop the others
|
||||
self.stop_nodes()
|
||||
raise
|
||||
for i, node in enumerate(self.nodes):
|
||||
node.start(extra_args[i], *args, **kwargs)
|
||||
for node in self.nodes:
|
||||
node.wait_for_rpc_connection()
|
||||
|
||||
if self.options.coveragedir is not None:
|
||||
for node in self.nodes:
|
||||
|
|
|
@ -20,6 +20,7 @@ import time
|
|||
import urllib.parse
|
||||
import collections
|
||||
import shlex
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from .authproxy import (
|
||||
|
@ -158,7 +159,6 @@ 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
|
||||
# Cache perf subprocesses here by their data output filename.
|
||||
self.perf_subprocesses = {}
|
||||
|
||||
|
@ -200,11 +200,11 @@ class TestNode():
|
|||
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:
|
||||
if self.process:
|
||||
# Should only happen on test failure
|
||||
# Avoid using logger, as that may have already been shutdown when
|
||||
# this destructor is called.
|
||||
print(self._node_msg("Cleaning up leftover process"))
|
||||
print(self._node_msg("Cleaning up leftover process"), file=sys.stderr)
|
||||
self.process.kill()
|
||||
|
||||
def __getattr__(self, name):
|
||||
|
|
Loading…
Add table
Reference in a new issue