Page MenuHomePhabricator

Fix randomly failing scheduler_tests test
ClosedPublic

Authored by Fabien on Feb 27 2023, 14:48.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC22b5f24f5d16: Fix randomly failing scheduler_tests test
Summary
The root cause is that the original test author was misusing threads and/or synchronization primitives. There is no guarantee that the first main thread runs before the last scheduled task. As such, sometimes, the last task runs and writes "42" into the `counter` before the `BOOST_CHECK_EQUAL(counter, 0)` line gets a chance to be evaluated in the main thread.

Port of bchn#1189.

Test Plan
ninja all check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Feb 27 2023, 14:48

Failed tests logs:

====== Bitcoin ABC functional tests: abc_p2p_avalanche_proof_voting.py ======

------- Stdout: -------
2023-02-27T14:55:10.612000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_145423/abc_p2p_avalanche_proof_voting_10
2023-02-27T14:55:12.970000Z TestFramework (INFO): Trigger polling from the node...
2023-02-27T14:55:13.176000Z TestFramework (INFO): Check we poll for valid proof
2023-02-27T14:55:13.686000Z TestFramework (INFO): Check we don't poll for subsequent proofs if the cooldown is not elapsed, proof not the favorite
2023-02-27T14:55:13.688000Z TestFramework (INFO): Check we don't poll for subsequent proofs if the cooldown is not elapsed, proof is the favorite
2023-02-27T14:55:13.689000Z TestFramework (INFO): Check we poll for conflicting proof if the proof is not the favorite
2023-02-27T14:55:13.886000Z TestFramework (INFO): Check we poll for conflicting proof if the proof is the favorite
2023-02-27T14:55:14.103000Z TestFramework (INFO): Check we don't poll for proofs that get rejected
2023-02-27T14:55:14.104000Z TestFramework (INFO): Check we don't poll for invalid proofs and get banned
2023-02-27T14:55:20.092000Z TestFramework (INFO): Test proof acceptance
2023-02-27T14:55:25.910000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
            self.wait_until(lambda: self.can_find_proof_in_poll(
                proofid, response=AvalancheProofVoteResponse.ACTIVE), timeout=5)
'''
2023-02-27T14:55:25.910000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_p2p_avalanche_proof_voting.py", line 118, in run_test
    self.update_tests(node)
  File "/work/test/functional/abc_p2p_avalanche_proof_voting.py", line 217, in update_tests
    self.wait_until(lambda: accept_proof(proofid_seq30))
  File "/work/test/functional/test_framework/test_framework.py", line 705, in wait_until
    return wait_until_helper(test_function, timeout=timeout,
  File "/work/test/functional/test_framework/util.py", line 273, in wait_until_helper
    if predicate():
  File "/work/test/functional/abc_p2p_avalanche_proof_voting.py", line 217, in <lambda>
    self.wait_until(lambda: accept_proof(proofid_seq30))
  File "/work/test/functional/abc_p2p_avalanche_proof_voting.py", line 207, in accept_proof
    self.wait_until(lambda: self.can_find_proof_in_poll(
  File "/work/test/functional/test_framework/test_framework.py", line 705, in wait_until
    return wait_until_helper(test_function, timeout=timeout,
  File "/work/test/functional/test_framework/util.py", line 285, in wait_until_helper
    raise AssertionError(
AssertionError: Predicate ''''
            self.wait_until(lambda: self.can_find_proof_in_poll(
                proofid, response=AvalancheProofVoteResponse.ACTIVE), timeout=5)
''' not true after 5.0 seconds
2023-02-27T14:55:25.960000Z TestFramework (INFO): Stopping nodes
2023-02-27T14:55:28.265000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_145423/abc_p2p_avalanche_proof_voting_10
2023-02-27T14:55:28.265000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_145423/abc_p2p_avalanche_proof_voting_10/test_framework.log
2023-02-27T14:55:28.265000Z TestFramework (ERROR): 
2023-02-27T14:55:28.265000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_145423/abc_p2p_avalanche_proof_voting_10' to consolidate all logs
2023-02-27T14:55:28.266000Z TestFramework (ERROR): 
2023-02-27T14:55:28.266000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-02-27T14:55:28.266000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-02-27T14:55:28.266000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_p2p_avalanche_proof_voting.py

This revision is now accepted and ready to land.Feb 27 2023, 16:15
This revision was landed with ongoing or failed builds.Feb 27 2023, 16:16
This revision was automatically updated to reflect the committed changes.