Skip to content

Commit

Permalink
Merge bitcoin#20683: test: Fix restart node race
Browse files Browse the repository at this point in the history
fab46b3 test: Fix restart node race (MarcoFalke)

Pull request description:

  It is not allowed to start a node before it has been fully stopped. Otherwise it could lead to intermittent issues due to access issues (e.g. cookie file https://cirrus-ci.com/task/6409665024098304?command=ci#L4793)

  Fix that by waiting for the node to fully stop.

ACKs for top commit:
  laanwj:
    code review ACK fab46b3

Tree-SHA512: 7605cac0573a7b04f05ff110d0131e8940d87f7baf6d698505ed16b363d4d15b1e552c5ffd1a187c8fe5639f7e265c3122734c85283275746e46bd789614fd21
  • Loading branch information
laanwj authored and PastaPastaPasta committed Aug 8, 2023
1 parent 04a0baa commit a365ed0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,12 @@ def start_nodes(self, extra_args=None, *args, **kwargs):
def stop_node(self, i, expected_stderr='', wait=0):
"""Stop a dashd test node"""
self.nodes[i].stop_node(expected_stderr=expected_stderr, wait=wait)
self.nodes[i].wait_until_stopped()

def stop_nodes(self, expected_stderr='', wait=0):
"""Stop multiple dashd test nodes"""
for node in self.nodes:
# Issue RPC to stop nodes
node.stop_node(expected_stderr=expected_stderr, wait=wait)
node.stop_node(expected_stderr=expected_stderr, wait=wait, wait_until_stopped=False)

for node in self.nodes:
# Wait for nodes to stop
Expand Down
5 changes: 4 additions & 1 deletion test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def get_wallet_rpc(self, wallet_name):
def version_is_at_least(self, ver):
return self.version is None or self.version >= ver

def stop_node(self, expected_stderr='', wait=0):
def stop_node(self, expected_stderr='', *, wait=0, wait_until_stopped=True):
"""Stop the node."""
if not self.running:
return
Expand All @@ -344,6 +344,9 @@ def stop_node(self, expected_stderr='', wait=0):

del self.p2ps[:]

if wait_until_stopped:
self.wait_until_stopped()

def is_node_stopped(self):
"""Checks whether the node has stopped.
Expand Down

0 comments on commit a365ed0

Please sign in to comment.