From ce5a511349841547b752e88aa4f4a400dde46ec0 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 28 Dec 2018 17:14:27 +0100 Subject: [PATCH] Speed up stopping of nodes in tests by splitting up stop and wait (#2587) Especially speed up MN based tests which currently spend multiple seconds waiting for nodes to stop. --- qa/rpc-tests/test_framework/util.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index e6d2045676481..48f58ddafebe0 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -407,18 +407,25 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None def log_filename(dirname, n_node, logname): return os.path.join(dirname, "node"+str(n_node), "regtest", logname) -def stop_node(node, i): +def wait_node(i): + return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT) + assert_equal(return_code, 0) + del bitcoind_processes[i] + +def stop_node(node, i, wait=True): try: node.stop() except http.client.CannotSendRequest as e: print("WARN: Unable to stop node: " + repr(e)) - return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT) - assert_equal(return_code, 0) - del bitcoind_processes[i] + if wait: + wait_node(i) -def stop_nodes(nodes): +def stop_nodes(nodes, fast=True): for i, node in enumerate(nodes): - stop_node(node, i) + stop_node(node, i, not fast) + if fast: + for i, node in enumerate(nodes): + wait_node(i) assert not bitcoind_processes.values() # All connections must be gone now def set_node_times(nodes, t):