iilyak 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_r113720536
##########
File path: src/mem3/src/mem3_shards.erl
##########
@@ -726,4 +726,50 @@ 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)),
+ ChangesPid = (get_state(Pid))#st.changes_pid,
+ ?assert(is_process_alive(ChangesPid)),
+ true = test_util:stop_sync_throw(ChangesPid, shutdown, wait_timeout),
+ ?assertNot(is_process_alive(ChangesPid)),
+ ok
+ end).
+
+
+get_state(Pid) ->
Review comment:
Consider adding `mem3_shards:get_changes_pid` which does
`gen_server:call(Pid, get_changes_pid)`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services