diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2018-05-09 13:14:21 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2018-05-09 13:20:14 -0400 |
commit | 09c6699900da962c5e35eb82e358240a4099838f (patch) | |
tree | f290d8c32a5061975d67e88ee8e1501a053ce775 | |
parent | 08c1caf863656e8c4302f0ff392772f0055760e5 (diff) |
[qa] Handle disconnect_node race
Several tests call disconnect_nodes() on each node-pair in rapid
succession, resulting in a race condition if a node disconnects a peer
in-between the calculation of the nodeid's to disconnect and the
invocation of the disconnectnode rpc call. Handle this.
-rw-r--r-- | test/functional/test_framework/util.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 540727dc85..93588b9669 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -351,7 +351,14 @@ def set_node_times(nodes, t): def disconnect_nodes(from_connection, node_num): for peer_id in [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']]: - from_connection.disconnectnode(nodeid=peer_id) + try: + from_connection.disconnectnode(nodeid=peer_id) + except JSONRPCException as e: + # If this node is disconnected between calculating the peer id + # and issuing the disconnect, don't worry about it. + # This avoids a race condition if we're mass-disconnecting peers. + if e.error['code'] != -29: # RPC_CLIENT_NODE_NOT_CONNECTED + raise # wait to disconnect wait_until(lambda: [peer['id'] for peer in from_connection.getpeerinfo() if "testnode%d" % node_num in peer['subver']] == [], timeout=5) |