You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/06/15 01:12:23 UTC
[couchdb] branch main updated: Clean up fabric_bench_test databases
This is an automated email from the ASF dual-hosted git repository.
jaydoane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new bca3ab09f Clean up fabric_bench_test databases
bca3ab09f is described below
commit bca3ab09f07c6bc0ebb71cee483f88823f6dd7d7
Author: Jay Doane <ja...@apache.org>
AuthorDate: Wed Jun 14 17:13:22 2023 -0700
Clean up fabric_bench_test databases
In some cases, it's possible for databases created in previous test
runs to cause test failures like this:
fabric_bench_test:97: -with/1-fun-0- (t_db_deletion_ignores_other_dbs)...*failed*
in function fabric_bench_test:t_db_deletion_ignores_other_dbs/1 (test/eunit/fabric_bench_test.erl, line 76)
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 531)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 356)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 514)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 456)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 346)
in call from eunit_proc:run_group/2 (eunit_proc.erl, line 570)
**error:{badmatch,{error,file_exists}}
output:<<"">>
This deletes databases created by the tests, and also preemptively
deletes databases that might exist from previous test failures that
were unable to clean up after themselves.
---
src/fabric/test/eunit/fabric_bench_test.erl | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/fabric/test/eunit/fabric_bench_test.erl b/src/fabric/test/eunit/fabric_bench_test.erl
index 95d0dc41c..afdd03db1 100644
--- a/src/fabric/test/eunit/fabric_bench_test.erl
+++ b/src/fabric/test/eunit/fabric_bench_test.erl
@@ -64,9 +64,11 @@ t_newer_db_deletion_doesnt_work(_Ctx) ->
Db = <<"fabricbenchdb-", Suffix/binary>>,
ok = fabric:create_db(Db, [{q, 1}, {n, 1}]),
fabric_bench:delete_old_dbs(),
- ?assertEqual({ok, 0}, fabric:get_doc_count(Db)).
+ ?assertEqual({ok, 0}, fabric:get_doc_count(Db)),
+ ok = fabric:delete_db(Db).
t_db_deletion_ignores_other_dbs(_Ctx) ->
+ ok = delete_prefixed_dbs(<<"fabricbenchdb">>),
Db1 = <<"fabricbenchdb-">>,
Db2 = <<"fabricbenchdb">>,
Db3 = <<"fabricbenchdb-xyz">>,
@@ -76,4 +78,14 @@ t_db_deletion_ignores_other_dbs(_Ctx) ->
fabric_bench:delete_old_dbs(),
?assertEqual({ok, 0}, fabric:get_doc_count(Db1)),
?assertEqual({ok, 0}, fabric:get_doc_count(Db2)),
- ?assertEqual({ok, 0}, fabric:get_doc_count(Db3)).
+ ?assertEqual({ok, 0}, fabric:get_doc_count(Db3)),
+ ok = delete_prefixed_dbs(<<"fabricbenchdb">>).
+
+delete_prefixed_dbs(Prefix) ->
+ {ok, Prefixed} = fabric:all_dbs(Prefix),
+ lists:foreach(
+ fun(Name) ->
+ ok = fabric:delete_db(Name)
+ end,
+ Prefixed
+ ).