diff options
author | Jay Doane <jaydoane@apache.org> | 2022-07-25 15:05:45 -0700 |
---|---|---|
committer | Jay Doane <jay.s.doane@gmail.com> | 2022-08-20 15:38:34 -0700 |
commit | baef83f6ba6b9b3dc45c8c653b7b829c3345e0c7 (patch) | |
tree | 2a54ec6fa176c5b8a755eda1a3b82b519c13158a | |
parent | 7a53ffcceea2a7990438277b7a0520c8dcb38ec6 (diff) | |
download | couchdb-baef83f6ba6b9b3dc45c8c653b7b829c3345e0c7.tar.gz |
Address race in cpse_incref_decref test
Occasionally, this test fails with the following stack trace:
cpse_gather: make_test_fun (cpse_incref_decref)...*failed*
in function cpse_test_ref_counting:'-cpse_incref_decref/1-fun-0-'/2 (src/cpse_test_ref_counting.erl, line 44)
in call from cpse_test_ref_counting:cpse_incref_decref/1 (src/cpse_test_ref_counting.erl, line 44)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 522)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 347)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 505)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 447)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 337)
**error:{assert,[{module,cpse_test_ref_counting},
{line,44},
{expression,"lists : member ( Pid , Pids1 )"},
{expected,true},
{value,false}]}
output:<<"">>
Wrap the former assertion in a `test_util:wait` call to account for
the apparent race between client readiness and
`couch_db_engine:monitored_by/1`.
-rw-r--r-- | src/couch_pse_tests/src/cpse_test_ref_counting.erl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/couch_pse_tests/src/cpse_test_ref_counting.erl b/src/couch_pse_tests/src/cpse_test_ref_counting.erl index a0123d1ca..e56321080 100644 --- a/src/couch_pse_tests/src/cpse_test_ref_counting.erl +++ b/src/couch_pse_tests/src/cpse_test_ref_counting.erl @@ -40,8 +40,15 @@ cpse_incref_decref({Db, _}) -> {Pid, _} = Client = start_client(Db), wait_client(Client), - Pids1 = couch_db_engine:monitored_by(Db), - ?assert(lists:member(Pid, Pids1)), + test_util:wait( + fun() -> + MonitoredPids1 = couch_db_engine:monitored_by(Db), + case lists:member(Pid, MonitoredPids1) of + true -> ok; + false -> wait + end + end + ), close_client(Client), |