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:14 UTC
[couchdb] 11/41: Speedup eunit: couch_replicator_doc_processor
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 d540999174bbfe2ef1d4b6936601e4a786b51bcb
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Dec 19 13:31:20 2019 -0600
Speedup eunit: couch_replicator_doc_processor
Another example of moving mocks around.
---
.../src/couch_replicator_doc_processor.erl | 68 ++++++++++++++--------
1 file changed, 45 insertions(+), 23 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_doc_processor.erl b/src/couch_replicator/src/couch_replicator_doc_processor.erl
index 29170ed..6778d53 100644
--- a/src/couch_replicator/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator/src/couch_replicator_doc_processor.erl
@@ -614,25 +614,30 @@ cluster_membership_foldl(#rdoc{id = {DbName, DocId} = Id, rid = RepId}, nil) ->
doc_processor_test_() ->
{
- foreach,
- fun setup/0,
- fun teardown/1,
- [
- t_bad_change(),
- t_regular_change(),
- t_change_with_doc_processor_crash(),
- t_change_with_existing_job(),
- t_deleted_change(),
- t_triggered_change(),
- t_completed_change(),
- t_active_replication_completed(),
- t_error_change(),
- t_failed_change(),
- t_change_for_different_node(),
- t_change_when_cluster_unstable(),
- t_ejson_docs(),
- t_cluster_membership_foldl()
- ]
+ setup,
+ fun setup_all/0,
+ fun teardown_all/1,
+ {
+ foreach,
+ fun setup/0,
+ fun teardown/1,
+ [
+ t_bad_change(),
+ t_regular_change(),
+ t_change_with_doc_processor_crash(),
+ t_change_with_existing_job(),
+ t_deleted_change(),
+ t_triggered_change(),
+ t_completed_change(),
+ t_active_replication_completed(),
+ t_error_change(),
+ t_failed_change(),
+ t_change_for_different_node(),
+ t_change_when_cluster_unstable(),
+ t_ejson_docs(),
+ t_cluster_membership_foldl()
+ ]
+ }
}.
@@ -829,7 +834,7 @@ get_worker_ref_test_() ->
% Test helper functions
-setup() ->
+setup_all() ->
meck:expect(couch_log, info, 2, ok),
meck:expect(couch_log, notice, 2, ok),
meck:expect(couch_log, warning, 2, ok),
@@ -845,15 +850,32 @@ setup() ->
end),
meck:expect(couch_replicator_scheduler, remove_job, 1, ok),
meck:expect(couch_replicator_docs, remove_state_fields, 2, ok),
- meck:expect(couch_replicator_docs, update_failed, 3, ok),
+ meck:expect(couch_replicator_docs, update_failed, 3, ok).
+
+
+teardown_all(_) ->
+ meck:unload().
+
+
+setup() ->
+ meck:reset([
+ config,
+ couch_log,
+ couch_replicator_clustering,
+ couch_replicator_doc_processor_worker,
+ couch_replicator_docs,
+ couch_replicator_scheduler
+ ]),
+ % Set this expectation back to the default for
+ % each test since some tests change it
+ meck:expect(couch_replicator_clustering, owner, 2, node()),
{ok, Pid} = start_link(),
unlink(Pid),
Pid.
teardown(Pid) ->
- exit(Pid, kill),
- meck:unload().
+ exit(Pid, kill).
removed_state_fields() ->