Skip to content

Commit

Permalink
Filter out non replicator tasks in test case
Browse files Browse the repository at this point in the history
Previously the test relied in the assumption that there are no
couch_tasks are running concurrently. This commit fixes that assumption
by filtering out all non replication related tasks from the output of
couch_task_status:all().
  • Loading branch information
iilyak committed May 19, 2017
1 parent 1fa3f58 commit 27f5067
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/couch_replicator/test/couch_replicator_compact_tests.erl
Expand Up @@ -113,7 +113,7 @@ check_active_tasks(RepPid, {BaseId, Ext} = RepId, Src, Tgt) ->
FullRepId = ?l2b(BaseId ++ Ext),
Pid = ?l2b(pid_to_list(RepPid)),
ok = wait_for_replicator(RepId),
[RepTask] = couch_task_status:all(),
[RepTask] = replication_tasks(),
?assertEqual(Pid, couch_util:get_value(pid, RepTask)),
?assertEqual(FullRepId, couch_util:get_value(replication_id, RepTask)),
?assertEqual(true, couch_util:get_value(continuous, RepTask)),
Expand All @@ -129,10 +129,14 @@ 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
Expand Down

0 comments on commit 27f5067

Please sign in to comment.