You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/25 17:45:10 UTC

[couchdb] 07/41: Speedup eunit: fabric_doc_open_revs

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

davisp pushed a commit to branch speedup-test-suite
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 5405d03b74359fe8ff1c94a563db9be6070fcce5
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Dec 19 12:18:00 2019 -0600

    Speedup eunit: fabric_doc_open_revs
    
    Moving the meck configuration into setup and resetting in foreach makes
    tests quite a bit faster.
---
 src/fabric/src/fabric_doc_open_revs.erl | 90 ++++++++++++++++++++-------------
 1 file changed, 54 insertions(+), 36 deletions(-)

diff --git a/src/fabric/src/fabric_doc_open_revs.erl b/src/fabric/src/fabric_doc_open_revs.erl
index 8ac3f30..3d7b9dc 100644
--- a/src/fabric/src/fabric_doc_open_revs.erl
+++ b/src/fabric/src/fabric_doc_open_revs.erl
@@ -317,7 +317,7 @@ collapse_duplicate_revs_int([Reply | Rest]) ->
 -include_lib("eunit/include/eunit.hrl").
 
 
-setup() ->
+setup_all() ->
     config:start_link([]),
     meck:new([fabric, couch_stats, couch_log]),
     meck:new(fabric_util, [passthrough]),
@@ -328,11 +328,24 @@ setup() ->
 
 
 
-teardown(_) ->
-    (catch meck:unload([fabric, couch_stats, couch_log, fabric_util])),
+teardown_all(_) ->
+    meck:unload(),
     config:stop().
 
 
+setup() ->
+    meck:reset([
+        couch_log,
+        couch_stats,
+        fabric,
+        fabric_util
+    ]).
+
+
+teardown(_) ->
+    ok.
+
+
 state0(Revs, Latest) ->
     #state{
         worker_count = 3,
@@ -361,39 +374,44 @@ baz1() -> {ok, #doc{revs = {1, [<<"baz">>]}}}.
 
 open_doc_revs_test_() ->
     {
-        foreach,
-        fun setup/0,
-        fun teardown/1,
-        [
-            check_empty_response_not_quorum(),
-            check_basic_response(),
-            check_finish_quorum(),
-            check_finish_quorum_newer(),
-            check_no_quorum_on_second(),
-            check_done_on_third(),
-            check_specific_revs_first_msg(),
-            check_revs_done_on_agreement(),
-            check_latest_true(),
-            check_ancestor_counted_in_quorum(),
-            check_not_found_counts_for_descendant(),
-            check_worker_error_skipped(),
-            check_quorum_only_counts_valid_responses(),
-            check_empty_list_when_no_workers_reply(),
-            check_node_rev_stored(),
-            check_node_rev_store_head_only(),
-            check_node_rev_store_multiple(),
-            check_node_rev_dont_store_errors(),
-            check_node_rev_store_non_errors(),
-            check_node_rev_store_concatenate(),
-            check_node_rev_store_concantenate_multiple(),
-            check_node_rev_unmodified_on_down_or_exit(),
-            check_not_found_replies_are_removed_when_doc_found(),
-            check_not_found_returned_when_one_of_docs_not_found(),
-            check_not_found_returned_when_doc_not_found(),
-            check_longer_rev_list_returned(),
-            check_longer_rev_list_not_combined(),
-            check_not_found_removed_and_longer_rev_list()
-        ]
+        setup,
+        fun setup_all/0,
+        fun teardown_all/1,
+        {
+            foreach,
+            fun setup/0,
+            fun teardown/1,
+            [
+                check_empty_response_not_quorum(),
+                check_basic_response(),
+                check_finish_quorum(),
+                check_finish_quorum_newer(),
+                check_no_quorum_on_second(),
+                check_done_on_third(),
+                check_specific_revs_first_msg(),
+                check_revs_done_on_agreement(),
+                check_latest_true(),
+                check_ancestor_counted_in_quorum(),
+                check_not_found_counts_for_descendant(),
+                check_worker_error_skipped(),
+                check_quorum_only_counts_valid_responses(),
+                check_empty_list_when_no_workers_reply(),
+                check_node_rev_stored(),
+                check_node_rev_store_head_only(),
+                check_node_rev_store_multiple(),
+                check_node_rev_dont_store_errors(),
+                check_node_rev_store_non_errors(),
+                check_node_rev_store_concatenate(),
+                check_node_rev_store_concantenate_multiple(),
+                check_node_rev_unmodified_on_down_or_exit(),
+                check_not_found_replies_are_removed_when_doc_found(),
+                check_not_found_returned_when_one_of_docs_not_found(),
+                check_not_found_returned_when_doc_not_found(),
+                check_longer_rev_list_returned(),
+                check_longer_rev_list_not_combined(),
+                check_not_found_removed_and_longer_rev_list()
+            ]
+        }
     }.