This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch fix-flaky-fabric-bench-test in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ca9eb115de54267a4373e8c975c5f438a87aff72 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Wed Oct 4 17:30:41 2023 -0400 Fix flaky fabric_bench test Rapidly creating and deleting a db in the this test triggers a race condition. A potential culprit might be the gen_server cast in https://github.com/apache/couchdb/blob/main/src/mem3/src/mem3_util.erl#L176. To fix the flakiness use the newer `opts_for_db/1` function with a test wait function. This way we may also avoid inadvertently re-creating the shard file due to the `create_if_missing` option from `get_doc_count/1`. --- src/fabric/test/eunit/fabric_bench_test.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fabric/test/eunit/fabric_bench_test.erl b/src/fabric/test/eunit/fabric_bench_test.erl index afdd03db1..0c9e85372 100644 --- a/src/fabric/test/eunit/fabric_bench_test.erl +++ b/src/fabric/test/eunit/fabric_bench_test.erl @@ -56,7 +56,17 @@ t_old_db_deletion_works(_Ctx) -> Db = <<"fabricbenchdb-", Suffix/binary>>, ok = fabric:create_db(Db, [{q, 1}, {n, 1}]), fabric_bench:delete_old_dbs(), - ?assertError(database_does_not_exist, fabric:get_doc_count(Db)). + % Quick db creation and deletion is racy so + % we have to wait until the db is gone before proceeding. + WaitFun = fun() -> + try mem3_shards:opts_for_db(Db) of + _ -> wait + catch + error:database_does_not_exist -> + ok + end + end, + test_util:wait(WaitFun, 1000). t_newer_db_deletion_doesnt_work(_Ctx) -> SevenHoursAgoUsec = os:system_time(microsecond) - (7 * 60 * 60 * 1000000),
