Repository: couchdb-couch Updated Branches: refs/heads/2365-fix-failed-multipart-process-leak [created] fd7f88895
[squash] Add a test for COUCHDB-2365 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/8f9bd3e6 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/8f9bd3e6 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/8f9bd3e6 Branch: refs/heads/2365-fix-failed-multipart-process-leak Commit: 8f9bd3e6c762b58a2d7d3bdc06131a606d904783 Parents: 46cb6a4 Author: Mike Wallace <[email protected]> Authored: Tue Oct 7 23:45:11 2014 +0100 Committer: Mike Wallace <[email protected]> Committed: Wed Oct 8 10:01:44 2014 +0100 ---------------------------------------------------------------------- test/couch_stream_tests.erl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/8f9bd3e6/test/couch_stream_tests.erl ---------------------------------------------------------------------- diff --git a/test/couch_stream_tests.erl b/test/couch_stream_tests.erl index 3e84ca0..e12e714 100644 --- a/test/couch_stream_tests.erl +++ b/test/couch_stream_tests.erl @@ -38,7 +38,8 @@ stream_test_() -> fun should_return_stream_size_on_close/1, fun should_return_valid_pointers/1, fun should_recall_last_pointer_position/1, - fun should_stream_more_with_4K_chunk_size/1 + fun should_stream_more_with_4K_chunk_size/1, + fun should_stop_on_normal_exit_of_stream_opener/1 ] } }. @@ -94,6 +95,21 @@ should_stream_more_with_4K_chunk_size({Fd, _}) -> ?_assertMatch({[{0, 4100}, {4106, 1020}], 5120, _, _, _}, couch_stream:close(Stream)). +should_stop_on_normal_exit_of_stream_opener({Fd, _}) -> + RunnerPid = self(), + OpenerPid = spawn( + fun() -> + {ok, StreamPid} = couch_stream:open(Fd), + RunnerPid ! {pid, StreamPid} + end), + StreamPid = receive + {pid, StreamPid0} -> StreamPid0 + end, + % Confirm the validity of the test by verifying the stream opener has died + ?_assertNot(is_process_alive(OpenerPid)), + % Verify the stream itself has also died + ?_assertNot(is_process_alive(StreamPid)). + read_all(Fd, PosList) -> Data = couch_stream:foldl(Fd, PosList, fun(Bin, Acc) -> [Bin, Acc] end, []),
