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 00:14:07 UTC

[couchdb] branch fabric-bench-test-db-cleanup created (now 85973de25)

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a change to branch fabric-bench-test-db-cleanup
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at 85973de25 Clean up fabric_bench_test databases

This branch includes the following new commits:

     new 85973de25 Clean up fabric_bench_test databases

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Clean up fabric_bench_test databases

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch fabric-bench-test-db-cleanup
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 85973de2593c594aa8e8741c588cd5eed45e9876
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
+    ).