couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vatam...@apache.org
Subject [couchdb] 02/02: Test changes_listener dies on mem3_shards shutdown
Date Wed, 10 May 2017 16:16:16 GMT
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

commit 3691c2edbc6603963b1b5ad1bf97dfb69886c4a6
Author: Jay Doane <jay.s.doane@gmail.com>
AuthorDate: Sun May 7 22:56:38 2017 -0700

    Test changes_listener dies on mem3_shards shutdown
    
    This adds a test to ensure that the changes_listener process exits when
    the mem3_shards process is shut down.
    
    COUCHDB-3398
---
 src/mem3/src/mem3_shards.erl | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/mem3/src/mem3_shards.erl b/src/mem3/src/mem3_shards.erl
index a419e45..8d9cfb9 100644
--- a/src/mem3/src/mem3_shards.erl
+++ b/src/mem3/src/mem3_shards.erl
@@ -732,4 +732,45 @@ 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),
+    ok = application:start(config),
+    {ok, Pid} = ?MODULE:start_link(),
+    true = erlang:unlink(Pid),
+    Pid.
+
+
+teardown_changes(Pid) ->
+    true = exit(Pid, shutdown),
+    ok = application:stop(config),
+    meck:unload().
+
+
+should_kill_changes_listener_on_shutdown(Pid) ->
+    ?_test(begin
+        ?assert(is_process_alive(Pid)),
+        {ok, ChangesPid} = get_changes_pid(),
+        ?assert(is_process_alive(ChangesPid)),
+        true = test_util:stop_sync_throw(
+            ChangesPid, fun() -> exit(Pid, shutdown) end, wait_timeout),
+        ?assertNot(is_process_alive(ChangesPid)),
+        ok
+    end).
+
+
 -endif.

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

Mime
View raw message