You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2017/07/18 19:27:20 UTC

[couchdb] branch master updated: Remove get_details replicator job gen_server call

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

vatamane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new c8bf463  Remove get_details replicator job gen_server call
c8bf463 is described below

commit c8bf463139adc53187626f34d3ac4ffbc9352ca8
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Jul 18 14:54:55 2017 -0400

    Remove get_details replicator job gen_server call
    
    This was used from a test only and it wasn't reliable. Because of replicator
    job delays initialization the `State` would be either #rep_state{} or #rep. If
    replication job hasn't finished initializing, then state would be #rep{} and a
    call like get_details which matches the state with #rep_state{] would fail with
    the batmatch error.
    
    As seen in issue #686
    
    So remove `get_details` call and let the test rely on task polling as all other
    tests do.
---
 src/couch_replicator/src/couch_replicator_scheduler_job.erl  |  3 ---
 src/couch_replicator/test/couch_replicator_compact_tests.erl | 10 ----------
 2 files changed, 13 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator_scheduler_job.erl b/src/couch_replicator/src/couch_replicator_scheduler_job.erl
index 66bfdbf..88abe7c 100644
--- a/src/couch_replicator/src/couch_replicator_scheduler_job.erl
+++ b/src/couch_replicator/src/couch_replicator_scheduler_job.erl
@@ -215,9 +215,6 @@ do_init(#rep{options = Options, id = {BaseId, Ext}, user_ctx=UserCtx} = Rep) ->
     }.
 
 
-handle_call(get_details, _From, #rep_state{rep_details = Rep} = State) ->
-    {reply, {ok, Rep}, State};
-
 handle_call({add_stats, Stats}, From, State) ->
     gen_server:reply(From, ok),
     NewStats = couch_replicator_utils:sum_stats(State#rep_state.stats, Stats),
diff --git a/src/couch_replicator/test/couch_replicator_compact_tests.erl b/src/couch_replicator/test/couch_replicator_compact_tests.erl
index 1a79465..28f46e4 100644
--- a/src/couch_replicator/test/couch_replicator_compact_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_compact_tests.erl
@@ -112,7 +112,6 @@ check_active_tasks(RepPid, {BaseId, Ext} = RepId, Src, Tgt) ->
     end,
     FullRepId = ?l2b(BaseId ++ Ext),
     Pid = ?l2b(pid_to_list(RepPid)),
-    ok = wait_for_replicator(RepId),
     RepTasks = wait_for_task_status(),
     ?assertNotEqual(timeout, RepTasks),
     [RepTask] = RepTasks,
@@ -131,20 +130,11 @@ check_active_tasks(RepPid, {BaseId, Ext} = RepId, Src, Tgt) ->
     Pending = couch_util:get_value(changes_pending, RepTask),
     ?assert(is_integer(Pending)).
 
-rep_details(RepId) ->
-    gen_server:call(get_pid(RepId), get_details).
-
 replication_tasks() ->
     lists:filter(fun(P) ->
         couch_util:get_value(type, P) =:= replication
     end, couch_task_status:all()).
 
-wait_for_replicator(RepId) ->
-    %% since replicator started asynchronously
-    %% we need to wait when it would be in couch_task_status
-    %% we query replicator:details to ensure that do_init happen
-    ?assertMatch({ok, _}, rep_details(RepId)),
-    ok.
 
 wait_for_task_status() ->
     test_util:wait(fun() ->

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].