diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-01-31 11:10:50 +1300 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-01-31 11:10:56 +1300 |
commit | 1d1f8bbf57118e01904448108a104e20f50d2544 (patch) | |
tree | 5d08094ad92d581eba31f7702500b8ca936fe97b /test | |
parent | 3b69310beb172b2b56fbfc38c45898a1b627ac54 (diff) | |
parent | b951b0973cfd4e0db4607a00d434a04afb0d6199 (diff) |
Merge #16115: On bitcoind startup, write config args to debug.log
b951b0973cfd4e0db4607a00d434a04afb0d6199 on startup, write config options to debug.log (Larry Ruane)
Pull request description:
When a developer is examining `debug.log` after something goes wrong, it's often useful to know the exact options the failing instance of `bitcoind` was started with. Sometimes the `debug.log` file is all that's available for the analysis. This PR logs the `bitcoin.conf` entries and command-line arguments to `debug.log` on startup.
ACKs for top commit:
MarcoFalke:
ACK b951b0973cfd4e0db4607a00d434a04afb0d6199 🐪
jonatack:
ACK b951b0973c reviewed diff, re-code review, built, ran tests, launched bitcoind and reviewed debug log output, verified value of `str` debug log in the added unit test.
Tree-SHA512: bbca4fb3d49f99261758302bde0b8b67300ccc72e7380b01f1f66a146ae8a008a045df0ca5ca9664caff034d0ee38ea7ef38a50f38374525608c07ba52790358
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/feature_config_args.py | 30 | ||||
-rwxr-xr-x | test/functional/test_framework/test_node.py | 7 |
2 files changed, 36 insertions, 1 deletions
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index 003a74184b..1bc62f660d 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -83,10 +83,40 @@ class ConfArgsTest(BitcoinTestFramework): self.start_node(0, extra_args=['-noconnect=0']) self.stop_node(0) + def test_args_log(self): + self.log.info('Test config args logging') + with self.nodes[0].assert_debug_log( + expected_msgs=[ + 'Command-line arg: addnode="some.node"', + 'Command-line arg: rpcauth=****', + 'Command-line arg: rpcbind=****', + 'Command-line arg: rpcpassword=****', + 'Command-line arg: rpcuser=****', + 'Command-line arg: torpassword=****', + 'Config file arg: regtest="1"', + 'Config file arg: [regtest] server="1"', + ], + unexpected_msgs=[ + 'alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0', + '127.1.1.1', + 'secret-rpcuser', + 'secret-torpassword', + ]): + self.start_node(0, extra_args=[ + '-addnode=some.node', + '-rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0', + '-rpcbind=127.1.1.1', + '-rpcpassword=', + '-rpcuser=secret-rpcuser', + '-torpassword=secret-torpassword', + ]) + self.stop_node(0) + def run_test(self): self.stop_node(0) self.test_log_buffer() + self.test_args_log() self.test_config_file_parser() diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index e5c77ae5fa..0742dbe617 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -298,7 +298,9 @@ class TestNode(): wait_until(self.is_node_stopped, timeout=timeout) @contextlib.contextmanager - def assert_debug_log(self, expected_msgs, timeout=2): + def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2): + if unexpected_msgs is None: + unexpected_msgs = [] time_end = time.time() + timeout debug_log = os.path.join(self.datadir, self.chain, 'debug.log') with open(debug_log, encoding='utf-8') as dl: @@ -313,6 +315,9 @@ class TestNode(): dl.seek(prev_size) log = dl.read() print_log = " - " + "\n - ".join(log.splitlines()) + for unexpected_msg in unexpected_msgs: + if re.search(re.escape(unexpected_msg), log, flags=re.MULTILINE): + self._raise_assertion_error('Unexpected message "{}" partially matches log:\n\n{}\n\n'.format(unexpected_msg, print_log)) for expected_msg in expected_msgs: if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None: found = False |