Merge #14958: qa: Remove race between connecting and shutdown on separate connections
4412a59bfe
qa: Remove race between connecting and shutdown on separate connections (João Barbosa)
Pull request description:
Fixes the error https://github.com/bitcoin/bitcoin/pull/14670#issuecomment-447255352 reported by @ken2812221.
There is a race between RPC stop and another concurrent call in the test framework. The connection must be established and the command `waitfornewblock` running before calling `stop`.
See also https://github.com/bitcoin/bitcoin/pull/14670#issuecomment-447304513.
Tree-SHA512: 77feb8628d3b9c025ec0cf83565d4d6680cad4fb182fc93a65df8b573f3e799ba4c44e06d9001dd8a375ca0b1ee17f10e66c3902b6256d0ae2acbc64539185d7
This commit is contained in:
commit
3ae3748ce1
1 changed files with 8 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
||||||
"""Test bitcoind shutdown."""
|
"""Test bitcoind shutdown."""
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
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
|
from threading import Thread
|
||||||
|
|
||||||
def test_long_call(node):
|
def test_long_call(node):
|
||||||
|
@ -20,8 +20,14 @@ class ShutdownTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
node = get_rpc_proxy(self.nodes[0].url, 1, timeout=600, coveragedir=self.nodes[0].coverage_dir)
|
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()
|
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)
|
self.stop_node(0, wait=1000)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue