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/06 17:26:45 UTC
[couchdb] branch master updated: Remove some sleeps from change
feed test.
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 3b23d21 Remove some sleeps from change feed test.
3b23d21 is described below
commit 3b23d218c98c2a8d64991460e35f3956d5f35bc6
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Jul 6 14:47:13 2017 +0000
Remove some sleeps from change feed test.
Couldn't remove all sleeps as they are also used to
assert that nothing happened in a period of time or
to track generalized progress over a period of time
(the heartbeat test).
Issue #630
---
src/couch/test/couch_changes_tests.erl | 37 ++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/src/couch/test/couch_changes_tests.erl b/src/couch/test/couch_changes_tests.erl
index 3c0e5f6..d0fae1a 100644
--- a/src/couch/test/couch_changes_tests.erl
+++ b/src/couch/test/couch_changes_tests.erl
@@ -281,7 +281,9 @@ should_filter_continuous_feed_by_specific_doc_ids({DbName, Revs}) ->
},
DocIds = [<<"doc3">>, <<"doc4">>, <<"doc9999">>],
Req = {json_req, {[{<<"doc_ids">>, DocIds}]}},
+ reset_row_notifications(),
Consumer = spawn_consumer(DbName, ChangesArgs, Req),
+ ?assertEqual(ok, wait_row_notifications(2)),
ok = pause(Consumer),
Rows = get_rows(Consumer),
@@ -310,8 +312,9 @@ should_filter_continuous_feed_by_specific_doc_ids({DbName, Revs}) ->
{ok, _} = save_doc(Db, {[{<<"_id">>, <<"doc12">>}]}),
{ok, Rev3_3} = save_doc(Db, {[{<<"_id">>, <<"doc3">>},
{<<"_rev">>, Rev3_2}]}),
+ reset_row_notifications(),
ok = unpause(Consumer),
- timer:sleep(100),
+ ?assertEqual(ok, wait_row_notifications(2)),
ok = pause(Consumer),
NewRows = get_rows(Consumer),
@@ -325,8 +328,9 @@ should_filter_continuous_feed_by_specific_doc_ids({DbName, Revs}) ->
clear_rows(Consumer),
{ok, _Rev3_4} = save_doc(Db, {[{<<"_id">>, <<"doc3">>},
{<<"_rev">>, Rev3_3}]}),
+ reset_row_notifications(),
ok = unpause(Consumer),
- timer:sleep(100),
+ ?assertEqual(ok, wait_row_notifications(1)),
ok = pause(Consumer),
FinalRows = get_rows(Consumer),
@@ -426,7 +430,9 @@ should_select_with_continuous({DbName, Revs}) ->
GteDoc8 = {[{<<"$gte">>, <<"doc8">>}]},
Selector = {[{<<"_id">>, GteDoc8}]},
Req = {json_req, {[{<<"selector">>, Selector}]}},
+ reset_row_notifications(),
Consumer = spawn_consumer(DbName, ChArgs, Req),
+ ?assertEqual(ok, wait_row_notifications(1)),
ok = pause(Consumer),
Rows = get_rows(Consumer),
?assertMatch(
@@ -445,8 +451,9 @@ should_select_with_continuous({DbName, Revs}) ->
{<<"_rev">>, Rev8}]}),
{ok, _} = save_doc(Db, {[{<<"_id">>, <<"doc4">>},
{<<"_rev">>, Rev4}]}),
+ reset_row_notifications(),
ok = unpause(Consumer),
- timer:sleep(100),
+ ?assertEqual(ok, wait_row_notifications(1)),
ok = pause(Consumer),
NewRows = get_rows(Consumer),
?assertMatch(
@@ -837,6 +844,27 @@ wait_finished({_, ConsumerRef}) ->
]})
end.
+
+reset_row_notifications() ->
+ receive
+ row ->
+ reset_row_notifications()
+ after 0 ->
+ ok
+ end.
+
+
+wait_row_notifications(N) ->
+ receive
+ row when N == 1 ->
+ ok;
+ row when N > 1 ->
+ wait_row_notifications(N - 1)
+ after ?TIMEOUT ->
+ timeout
+ end.
+
+
spawn_consumer(DbName, ChangesArgs0, Req) ->
Parent = self(),
spawn_monitor(fun() ->
@@ -847,6 +875,7 @@ spawn_consumer(DbName, ChangesArgs0, Req) ->
Seq = couch_util:get_value(<<"seq">>, Change),
Del = couch_util:get_value(<<"deleted">>, Change, false),
Doc = couch_util:get_value(doc, Change, nil),
+ Parent ! row,
[#row{id = Id, seq = Seq, deleted = Del, doc = Doc} | Acc];
({stop, LastSeq}, _, Acc) ->
Parent ! {consumer_finished, lists:reverse(Acc), LastSeq},
@@ -861,7 +890,7 @@ spawn_consumer(DbName, ChangesArgs0, Req) ->
ChangesArgs = case (ChangesArgs0#changes_args.timeout =:= undefined)
andalso (ChangesArgs0#changes_args.heartbeat =:= undefined) of
true ->
- ChangesArgs0#changes_args{timeout = 10, heartbeat = 10};
+ ChangesArgs0#changes_args{timeout = 1000, heartbeat = 100};
false ->
ChangesArgs0
end,
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].