You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by gi...@git.apache.org on 2017/04/27 00:05:12 UTC

[GitHub] jaydoane commented on a change in pull request #492: Test changes_listener dies on mem3_shards shutdown

jaydoane commented on a change in pull request #492: Test changes_listener dies on mem3_shards shutdown
URL: https://github.com/apache/couchdb/pull/492#discussion_r113590571
 
 

 ##########
 File path: src/mem3/src/mem3_shards.erl
 ##########
 @@ -726,4 +726,54 @@ wait_writer_result(WRef) ->
 spawn_link_mock_writer(Db, Shards, Timeout) ->
     erlang:spawn_link(fun() -> shard_writer(Db, Shards, Timeout) end).
 
+
+
+mem3_shards_changes_test_() -> {
+    "Test mem3_shards changes listener", {
+        foreach,
+        fun setup_changes/0, fun teardown_changes/1,
+        [
+            fun should_kill_changes_listener_on_shutdown/1
+        ]
+    }
+}.
+
+
+setup_changes() ->
+    ok = meck:expect(mem3_util, ensure_exists, ['_'],
+        {ok, #db{name = <<"dbs">>, update_seq = 0}}),
+    ok = meck:expect(couch_db, close, ['_'], ok),
+    application:start(config),
+    {ok, Pid} = ?MODULE:start_link(),
+    erlang:unlink(Pid),
+    Pid.
+
+
+teardown_changes(Pid) ->
+    exit(Pid, shutdown),
+    application:stop(config),
+    meck:unload().
+
+
+should_kill_changes_listener_on_shutdown(Pid) ->
+    ?_test(begin
+        ?assert(is_process_alive(Pid)),
+        ChangesPid = (get_state(Pid))#st.changes_pid,
+        ?assert(is_process_alive(ChangesPid)),
+        Ref = erlang:monitor(process, ChangesPid),
 
 Review comment:
   Thanks @iilyak, that makes it much easier to understand!
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services