Page MenuHomePhabricator

[backport#18691] test: add wait_for_cookie_credentials() to framework for rpcwait tests
AbandonedPublic

Authored by majcosta on Jan 25 2021, 22:56.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Summary

92fe537cf704dfb4ae830c8c8b382f08c4893e65 test: fix intermittent race condition in interface_bitcoin_cli.py (Jon Atack)
c648e636b2f230db5f1d1137088685f74ae42454 test: add wait_for_cookie_credentials() to test framework (Jon Atack)

Pull request description:

This PR adds a `wait_for_cookie_credentials()` method to the test framework and calls it before the `-rpcwait` tests, to avoid an intermittent race condition on the CI run with Valgrind where the cookie file isn't written yet when the CLI call with `-rpcwait` arrives to `get_auth_cookie()`.

To reproduce/test, build with
```diff
diff --git a/src/httprpc.cpp b/src/httprpc.cpp
index 60c4d06f12..3dd06c4758 100644
--- a/src/httprpc.cpp
+++ b/src/httprpc.cpp
@@ -291,6 +291,7 @@ static bool InitRPCAuthentication()
 bool StartHTTPRPC()
 {
     LogPrint(BCLog::RPC, "Starting HTTP RPC server\n");
+    UninterruptibleSleep(std::chrono::seconds{11});
     if (!InitRPCAuthentication())
```
then run the test normally and with valgrind
```
test/functional/interface_bitcoin_cli.py -l debug
valgrind test/functional/interface_bitcoin_cli.py -l debug
```
Thanks to Marco Falke for all the help. Closes #18684.

Backport of Core PR18691

Test Plan
ninja all check-functional

Diff Detail

Event Timeline

Tail of the build log:

wallet_importmulti.py started
p2p_unrequested_blocks.py passed, Duration: 3 s
wallet_keypool.py started
rpc_createmultisig.py passed, Duration: 3 s
wallet_listsinceblock.py started
rpc_scantxoutset.py passed, Duration: 3 s
wallet_reorgsrestore.py started
wallet_importmulti.py passed, Duration: 3 s
wallet_resendwallettransactions.py started
wallet_avoidreuse.py passed, Duration: 4 s
wallet_txn_clone.py --mineblock started
wallet_keypool.py passed, Duration: 3 s
wallet_txn_doublespend.py --mineblock started
wallet_reorgsrestore.py passed, Duration: 3 s
abc-cmdline.py started
wallet_listsinceblock.py passed, Duration: 5 s
abc-finalize-block.py started
wallet_txn_clone.py --mineblock passed, Duration: 3 s
abc-invalid-chains.py started
wallet_txn_doublespend.py --mineblock passed, Duration: 3 s
abc-mempool-coherence-on-activations.py started
abc-finalize-block.py passed, Duration: 1 s
abc-minimaldata.py started
abc-cmdline.py passed, Duration: 2 s
abc-replay-protection.py started
abc-invalid-chains.py passed, Duration: 2 s
abc-schnorr.py started
abc-mempool-coherence-on-activations.py passed, Duration: 2 s
abc-schnorrmultisig.py started
abc-minimaldata.py passed, Duration: 2 s
abc-segwit-recovery.py started
abc-replay-protection.py passed, Duration: 2 s
feature_includeconf.py started
abc-schnorr.py passed, Duration: 2 s
feature_reindex.py started
abc-segwit-recovery.py passed, Duration: 2 s
mempool_accept.py started
abc-schnorrmultisig.py passed, Duration: 2 s
mining_basic.py started
feature_includeconf.py passed, Duration: 2 s
p2p_blocksonly.py started
mempool_accept.py passed, Duration: 2 s
p2p_disconnect_ban.py started
mining_basic.py passed, Duration: 2 s
p2p_dos_header_tree.py started
feature_reindex.py passed, Duration: 2 s
p2p_filter.py started
wallet_resendwallettransactions.py passed, Duration: 11 s
rpc_bind.py --ipv4 started
p2p_disconnect_ban.py passed, Duration: 2 s
rpc_bind.py --ipv6 started
p2p_dos_header_tree.py passed, Duration: 2 s
rpc_getchaintips.py started
p2p_filter.py passed, Duration: 2 s
rpc_setban.py started
rpc_bind.py --ipv4 passed, Duration: 2 s
rpc_txoutproof.py started
rpc_bind.py --ipv6 passed, Duration: 2 s
wallet_createwallet.py started
Build build-diff timed out after 1200.0s

We can take yours, it has additional code style improvements. I chose not to change the quotes to single quotes in my backport, which lead the linter not to fix those lines.
I would just put the comments on their own lines in the new function in test_node.py

PiRK requested changes to this revision.Jan 26 2021, 07:32
PiRK added inline comments.
test/functional/test_framework/test_node.py
364

comments on their own line

This revision now requires changes to proceed.Jan 26 2021, 07:32

already done, abandoning