Skip to content

Commit

Permalink
qa: Remove race between connecting and shutdown on separate connections
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Jan 16, 2019
1 parent cf0c67b commit 4412a59
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/functional/feature_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""Test bitcoind shutdown."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, get_rpc_proxy
from test_framework.util import assert_equal, get_rpc_proxy, wait_until
from threading import Thread

def test_long_call(node):
Expand All @@ -20,8 +20,14 @@ def set_test_params(self):

def run_test(self):
node = get_rpc_proxy(self.nodes[0].url, 1, timeout=600, coveragedir=self.nodes[0].coverage_dir)
# Force connection establishment by executing a dummy command.
node.getblockcount()
Thread(target=test_long_call, args=(node,)).start()
# wait 1 second to ensure event loop waits for current connections to close
# Wait until the server is executing the above `waitfornewblock`.
wait_until(lambda: len(self.nodes[0].getrpcinfo()['active_commands']) == 2)
# Wait 1 second after requesting shutdown but not before the `stop` call
# finishes. This is to ensure event loop waits for current connections
# to close.
self.stop_node(0, wait=1000)

if __name__ == '__main__':
Expand Down

0 comments on commit 4412a59

Please sign in to comment.