summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-03-14 23:48:35 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2011-03-14 23:48:35 +0000
commit6d7121d192dd59108c58574b63db04ec8a34c345 (patch)
treedc9f51adddd711037748095c43610d8a82e5ea81
parent3b6abf573736adc7e205ffbc5d8ab5f3c6206ac7 (diff)
downloadrabbitmq-server-6d7121d192dd59108c58574b63db04ec8a34c345.tar.gz
Ensure we hit both branches of fhc:filter_pending
-rw-r--r--src/rabbit_tests.erl24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index d5956c4c..87c905d7 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1628,10 +1628,12 @@ test_file_handle_cache() ->
ok = file_handle_cache:set_limit(5), %% 1 or 2 sockets, 2 msg_stores
TmpDir = filename:join(rabbit_mnesia:dir(), "tmp"),
ok = filelib:ensure_dir(filename:join(TmpDir, "nothing")),
- Src = filename:join(TmpDir, "file1"),
- Dst = filename:join(TmpDir, "file2"),
+ Src1 = filename:join(TmpDir, "file1"),
+ Dst1 = filename:join(TmpDir, "file2"),
+ Src2 = filename:join(TmpDir, "file3"),
+ Dst2 = filename:join(TmpDir, "file4"),
Content = <<"foo">>,
- CopyFun = fun () ->
+ CopyFun = fun (Src, Dst) ->
ok = file:write_file(Src, Content),
{ok, SrcHdl} = file_handle_cache:open(Src, [read], []),
{ok, DstHdl} = file_handle_cache:open(Dst, [write], []),
@@ -1648,18 +1650,22 @@ test_file_handle_cache() ->
%% This will block and never return, so we
%% exercise the fhc tidying up the pending
%% queue on the death of a process.
- ok = CopyFun()
+ ok = CopyFun(Src1, Dst1)
end),
- ok = CopyFun(),
- ok = file_handle_cache:set_limit(3),
+ ok = CopyFun(Src1, Dst1),
+ ok = file_handle_cache:set_limit(2),
Pid ! {next, self()},
receive {next, Pid} -> ok end,
+ timer:sleep(100),
+ Pid1 = spawn(fun () -> CopyFun(Src2, Dst2) end),
+ timer:sleep(100),
erlang:monitor(process, Pid),
- timer:sleep(500),
+ erlang:monitor(process, Pid1),
exit(Pid, kill),
+ exit(Pid1, kill),
receive {'DOWN', _MRef, process, Pid, _Reason} -> ok end,
- file:delete(Src),
- file:delete(Dst),
+ receive {'DOWN', _MRef1, process, Pid1, _Reason1} -> ok end,
+ [file:delete(File) || File <- [Src1, Dst1, Src2, Dst2]],
ok = file_handle_cache:set_limit(Limit),
passed.