Skip to content

Commit f34c580

Browse files
committed
Merge bitcoin#31620: test: Remove --noshutdown flag, Tidy startup failures
faf2f2c test: Avoid redundant stop and error spam on shutdown (MarcoFalke) fae3bf6 test: Avoid redundant stop and error spam on startup failure (MarcoFalke) fa0dc09 test: Remove --noshutdown flag (MarcoFalke) fad441f 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-ACK faf2f2c pablomartin4btc: re tACK faf2f2c Tree-SHA512: 46d7ae59c7be88b93f1f9e0b6be21af0fc101e646512e2c5e725682cb18bfec8aa010e0ebe89ce9ffe239e5caac0da5f81cc97b79e738d26ca5fa31930e8e4e3
2 parents b086964 + faf2f2c commit f34c580

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

test/functional/test_framework/test_framework.py

+7-17
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ def parse_args(self, test_file):
171171
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
172172
parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
173173
help="Leave bitcoinds and test.* datadir on exit or error")
174-
parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true",
175-
help="Don't stop bitcoinds after the test execution")
176174
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../cache"),
177175
help="Directory for caching pregenerated datadirs (default: %(default)s)")
178176
parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs (must not exist)")
@@ -325,18 +323,15 @@ def shutdown(self):
325323

326324
self.log.debug('Closing down network thread')
327325
self.network_thread.close()
328-
if not self.options.noshutdown:
326+
if self.success == TestStatus.FAILED:
327+
self.log.info("Not stopping nodes as test failed. The dangling processes will be cleaned up later.")
328+
else:
329329
self.log.info("Stopping nodes")
330330
if self.nodes:
331331
self.stop_nodes()
332-
else:
333-
for node in self.nodes:
334-
node.cleanup_on_exit = False
335-
self.log.info("Note: bitcoinds were not stopped and may still be running")
336332

337333
should_clean_up = (
338334
not self.options.nocleanup and
339-
not self.options.noshutdown and
340335
self.success != TestStatus.FAILED and
341336
not self.options.perf
342337
)
@@ -584,15 +579,10 @@ def start_nodes(self, extra_args=None, *args, **kwargs):
584579
if extra_args is None:
585580
extra_args = [None] * self.num_nodes
586581
assert_equal(len(extra_args), self.num_nodes)
587-
try:
588-
for i, node in enumerate(self.nodes):
589-
node.start(extra_args[i], *args, **kwargs)
590-
for node in self.nodes:
591-
node.wait_for_rpc_connection()
592-
except Exception:
593-
# If one node failed to start, stop the others
594-
self.stop_nodes()
595-
raise
582+
for i, node in enumerate(self.nodes):
583+
node.start(extra_args[i], *args, **kwargs)
584+
for node in self.nodes:
585+
node.wait_for_rpc_connection()
596586

597587
if self.options.coveragedir is not None:
598588
for node in self.nodes:

test/functional/test_framework/test_node.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import urllib.parse
2121
import collections
2222
import shlex
23+
import sys
2324
from pathlib import Path
2425

2526
from .authproxy import (
@@ -158,7 +159,6 @@ def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor,
158159
self.rpc = None
159160
self.url = None
160161
self.log = logging.getLogger('TestFramework.node%d' % i)
161-
self.cleanup_on_exit = True # Whether to kill the node when this object goes away
162162
# Cache perf subprocesses here by their data output filename.
163163
self.perf_subprocesses = {}
164164

@@ -200,11 +200,11 @@ def _raise_assertion_error(self, msg: str):
200200
def __del__(self):
201201
# Ensure that we don't leave any bitcoind processes lying around after
202202
# the test ends
203-
if self.process and self.cleanup_on_exit:
203+
if self.process:
204204
# Should only happen on test failure
205205
# Avoid using logger, as that may have already been shutdown when
206206
# this destructor is called.
207-
print(self._node_msg("Cleaning up leftover process"))
207+
print(self._node_msg("Cleaning up leftover process"), file=sys.stderr)
208208
self.process.kill()
209209

210210
def __getattr__(self, name):

0 commit comments

Comments
 (0)