[tests] Fix intermittent rpc_net.py failure. #12804

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:rpc_net_py_fix changing 1 files +21 −13
  1. jnewbery commented at 9:18 pm on March 27, 2018: member

    rpc_net.py would intermittently fail on Travis, probably due to assuming that two consecutive RPC calls were atomic. Fix this by trying the test up to three times and only failing if all three attempts fail.

    EDIT: PR updated to:

    rpc_net.py would intermittently fail on Travis, probably due to assuming that two consecutive RPC calls were atomic. Fix this by only testing that amounts are bounded above and below rather than equal.

    fixes #11778

  2. fanquake added the label Tests on Mar 27, 2018
  3. [tests] Fix intermittent rpc_net.py failure.
    rpc_net.py would intermittently fail on Travis, probably
    due to assuming that two consecutive RPC calls were atomic.
    Fix this by only testing that amounts are bounded above and
    below rather than equal.
    5a67c0524e
  4. in test/functional/rpc_net.py:39 in b7e2619eea outdated
    43-        assert_equal(sum([peer['bytessent'] for peer in peer_info]),
    44-                     net_totals['totalbytessent'])
    45+        # Check that getnettotals totalbytesrecv and totalbytessent
    46+        # are consistent with getpeerinfo. Since the RPC calls are
    47+        # not atomic, this may fail. Try up to 3 times.
    48+        for i in range(3):
    


    conscott commented at 11:54 am on March 28, 2018:

    Does it make sense to add a time.sleep() before getpeerinfo() so that the two calls might have a better chance of being in sync?

    I am also curious if you have been able to reproduce locally; I have not. I assume this changes the likelihood of failure significantly lower, but I am curious if in the case where the first try fails, might the second also be likely to fail for whatever reason.

  5. jnewbery force-pushed on Mar 28, 2018
  6. jnewbery commented at 7:40 pm on March 28, 2018: member

    ok. I’ve thought about this some more, and changed the approach. Rather than trying three times and hoping that there’ll be equality at some point, I’m now calling getnettotals before and after getpeerinfo and asserting that the info returned by getpeerinfo is bounded above and below by the totals in getnettotals. I’ve also changed some equality tests below to inequality tests, for the same reason - that there may be unexpected network traffic between the two calls.

    We can’t guarantee that there won’t be network traffic between two separate RPC calls, so we shouldn’t be testing for that.

  7. meshcollider commented at 9:13 pm on March 28, 2018: contributor
    I like the second approach much better than the 3 attempts, utACK https://github.com/bitcoin/bitcoin/pull/12804/commits/5a67c0524e5dc98d0e387f189545bc99863916d4
  8. laanwj commented at 8:42 pm on March 29, 2018: member
    utACK 5a67c05
  9. MarcoFalke commented at 3:55 pm on March 30, 2018: member
    utACK 5a67c0524e5dc98d0e387f189545bc99863916d4
  10. MarcoFalke merged this on Mar 30, 2018
  11. MarcoFalke closed this on Mar 30, 2018

  12. MarcoFalke referenced this in commit 243c9bb79a on Mar 30, 2018
  13. promag commented at 3:59 pm on March 30, 2018: member

    PR description invalid?

    utACK 5a67c05.

  14. MarcoFalke commented at 4:02 pm on March 30, 2018: member
    Oops, missed that. But can’t change now that it is merged. :(
  15. promag commented at 4:16 pm on March 30, 2018: member
    Could still copy commit message to PR description so it’s correct for future reference.
  16. MarcoFalke referenced this in commit 24e17356c3 on Apr 20, 2018
  17. MarcoFalke referenced this in commit 4bdb0ce517 on Apr 20, 2018
  18. HashUnlimited referenced this in commit 035982740a on May 13, 2018
  19. ccebrecos referenced this in commit c90aab4d0c on Sep 14, 2018
  20. jnewbery commented at 8:47 pm on January 7, 2019: member

    Could still copy commit message to PR description so it’s correct for future reference.

    Sorry - missed this entirely. PR description now fixed.

  21. jnewbery deleted the branch on Jan 7, 2019
  22. codablock referenced this in commit cf632029b9 on Oct 22, 2019
  23. barrystyle referenced this in commit 66f64a20eb on Jan 22, 2020
  24. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me