You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by bb...@apache.org on 2014/10/31 20:53:27 UTC

[12/41] couch-mrview commit: updated refs/heads/master to 28e51f3

add index update events notifications

Conflicts:
	src/couch_mrview_updater.erl


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/18b5f6ff
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/18b5f6ff
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/18b5f6ff

Branch: refs/heads/master
Commit: 18b5f6ff54683fca633cd1678522936a03598546
Parents: 7a65916
Author: benoitc <be...@apache.org>
Authored: Thu Jan 30 09:21:06 2014 +0100
Committer: Benjamin Bastian <be...@gmail.com>
Committed: Thu Oct 30 13:38:33 2014 -0700

----------------------------------------------------------------------
 src/couch_mrview_updater.erl |  3 +++
 test/09-index-events.t       | 46 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/18b5f6ff/src/couch_mrview_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_updater.erl b/src/couch_mrview_updater.erl
index 16645aa..7b24e42 100644
--- a/src/couch_mrview_updater.erl
+++ b/src/couch_mrview_updater.erl
@@ -194,6 +194,9 @@ write_results(Parent, State) ->
                 Parent ! {new_state, NewState};
             true ->
                 send_partial(NewState#mrst.partial_resp_pid, NewState),
+                % notifify the view update
+                couch_index_event:notify({index_update, {DbName, IdxName,
+                                                         couch_mrview_index}}),
                 write_results(Parent, NewState)
             end
     end.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/18b5f6ff/test/09-index-events.t
----------------------------------------------------------------------
diff --git a/test/09-index-events.t b/test/09-index-events.t
new file mode 100644
index 0000000..90654b8
--- /dev/null
+++ b/test/09-index-events.t
@@ -0,0 +1,46 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! -pa ./deps/*/ebin -pa ./apps/*/ebin -pa ./test/etap
+
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+main(_) ->
+    etap:plan(2),
+    case (catch test()) of
+        ok ->
+            etap:end_tests();
+        Other ->
+            etap:diag(io_lib:format("Test died abnormally: ~p", [Other])),
+            etap:bail(Other)
+    end,
+    timer:sleep(300),
+    ok.
+
+test() ->
+    test_util:start_couch(),
+    {ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, changes),
+    test_update_event(Db),
+    test_util:stop_couch(),
+    ok.
+
+test_update_event(Db) ->
+    {ok, Pid} = couch_index_event:start_link(self()),
+    etap:ok(is_pid(Pid), "event handler added"),
+    ok = couch_mrview:refresh(Db, <<"_design/bar">>),
+    Expect = {index_update, {<<"foo">>, <<"_design/bar">>,
+                             couch_mrview_index}},
+    receive
+        Event ->
+            etap:is(Event, Expect, "index update events OK")
+    end,
+    couch_index_event:stop(Pid).