diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-05-10 10:31:01 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-05-10 10:31:05 -0400 |
commit | f3e747ee775f243202ef10249e8041ea4fdeac82 (patch) | |
tree | 976fe126373dca312daba6275486a154e30f24f8 /test/functional | |
parent | 196c5a947a071f7c9c5b211f0a47787a7d540ecb (diff) | |
parent | 09c6699900da962c5e35eb82e358240a4099838f (diff) |
Merge #13201: [qa] Handle disconnect_node race
09c6699900 [qa] Handle disconnect_node race (Suhas Daftuar)
Pull request description:
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.
Tree-SHA512: 3078cea0006fcb507c812004a777c505eb1e9dda7c6df12dbbe72395a73ff6f6760f597b6492054f5487b34534417ddef5fbad30553c135c288c4b7cfce79223
Diffstat (limited to 'test/functional')
-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 c7710cc89e..e016148f70 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -352,7 +352,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) |