changeset 26704:c366a982fcea

Merge #9824: qa: Check return code when stopping nodes fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
author Wladimir J. van der Laan <laanwj@gmail.com>
date Thu, 23 Feb 2017 10:40:44 +0100
parents 4d31d046decd 9b423b8f8d3f
children 48e57083107f
files
diffstat 3 files changed, 15 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/qa/rpc-tests/fundrawtransaction.py	Thu Feb 23 10:38:09 2017 +0100
+++ b/qa/rpc-tests/fundrawtransaction.py	Thu Feb 23 10:40:44 2017 +0100
@@ -469,7 +469,9 @@
         # locked wallet test
         self.nodes[1].encryptwallet("test")
         self.nodes.pop(1)
-        stop_nodes(self.nodes)
+        stop_node(self.nodes[0], 0)
+        stop_node(self.nodes[1], 2)
+        stop_node(self.nodes[2], 3)
 
         self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
         # This test is not meant to test fee estimation and we'd like
--- a/qa/rpc-tests/rpcbind_test.py	Thu Feb 23 10:38:09 2017 +0100
+++ b/qa/rpc-tests/rpcbind_test.py	Thu Feb 23 10:40:44 2017 +0100
@@ -35,11 +35,9 @@
             base_args += ['-rpcallowip=' + x for x in allow_ips]
         binds = ['-rpcbind='+addr for addr in addresses]
         self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
-        try:
-            pid = bitcoind_processes[0].pid
-            assert_equal(set(get_bind_addrs(pid)), set(expected))
-        finally:
-            stop_nodes(self.nodes)
+        pid = bitcoind_processes[0].pid
+        assert_equal(set(get_bind_addrs(pid)), set(expected))
+        stop_nodes(self.nodes)
 
     def run_allowip_test(self, allow_ips, rpchost, rpcport):
         '''
@@ -48,13 +46,10 @@
         '''
         base_args = ['-disablewallet', '-nolisten'] + ['-rpcallowip='+x for x in allow_ips]
         self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [base_args])
-        try:
-            # connect to node through non-loopback interface
-            node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
-            node.getnetworkinfo()
-        finally:
-            node = None # make sure connection will be garbage collected and closed
-            stop_nodes(self.nodes)
+        # connect to node through non-loopback interface
+        node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
+        node.getnetworkinfo()
+        stop_nodes(self.nodes)
 
     def run_test(self):
         # due to OS-specific network stats queries, this test works only on Linux
--- a/qa/rpc-tests/test_framework/util.py	Thu Feb 23 10:38:09 2017 +0100
+++ b/qa/rpc-tests/test_framework/util.py	Thu Feb 23 10:40:44 2017 +0100
@@ -375,28 +375,19 @@
         node.stop()
     except http.client.CannotSendRequest as e:
         print("WARN: Unable to stop node: " + repr(e))
-    bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
+    return_code = bitcoind_processes[i].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
+    assert_equal(return_code, 0)
     del bitcoind_processes[i]
 
 def stop_nodes(nodes):
-    for node in nodes:
-        try:
-            node.stop()
-        except http.client.CannotSendRequest as e:
-            print("WARN: Unable to stop node: " + repr(e))
-    del nodes[:] # Emptying array closes connections as a side effect
-    wait_bitcoinds()
+    for i, node in enumerate(nodes):
+        stop_node(node, i)
+    assert not bitcoind_processes.values() # All connections must be gone now
 
 def set_node_times(nodes, t):
     for node in nodes:
         node.setmocktime(t)
 
-def wait_bitcoinds():
-    # Wait for all bitcoinds to cleanly exit
-    for bitcoind in bitcoind_processes.values():
-        bitcoind.wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
-    bitcoind_processes.clear()
-
 def connect_nodes(from_connection, node_num):
     ip_port = "127.0.0.1:"+str(p2p_port(node_num))
     from_connection.addnode(ip_port, "onetry")