diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-22 13:43:42 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-22 13:43:42 +0100 |
commit | 53a4c70ccb385db9958ab5920c07d01aed031ac9 (patch) | |
tree | 2670beb1bbbc4f8ecb8d4684ad2b5fa1dcefbad8 | |
parent | 26dcf08d53529eda03709e4b2e075f7373859b5d (diff) | |
download | rabbitmq-server-53a4c70ccb385db9958ab5920c07d01aed031ac9.tar.gz |
add test
this fails on default (or, rather, bug23166, until that is merged)
-rw-r--r-- | src/rabbit_tests.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 3c90fefa..bffc6729 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -56,6 +56,7 @@ test_content_prop_roundtrip(Datum, Binary) -> all_tests() -> application:set_env(rabbit, file_handles_high_watermark, 10, infinity), ok = file_handle_cache:set_limit(10), + passed = test_file_handle_cache(), passed = test_backing_queue(), passed = test_priority_queue(), passed = test_bpqueue(), @@ -1416,6 +1417,25 @@ extra_arg_hook(Hookname, Handler, Args, Extra1, Extra2) -> test_supervisor_delayed_restart() -> test_sup:test_supervisor_delayed_restart(). +test_file_handle_cache() -> + %% test copying when there is just one spare handle + Limit = file_handle_cache:get_limit(), + ok = file_handle_cache:set_limit(4), %% 2 reserved, 1 in use, 1 spare + TmpDir = rabbit_mnesia:dir() ++ "/tmp/", + ok = filelib:ensure_dir(TmpDir), + Src = TmpDir ++ "file1", + Dst = TmpDir ++ "file2", + Content = <<"foo">>, + ok = file:write_file(Src, Content), + {ok, SrcHdl} = file_handle_cache:open(Src, [read], []), + {ok, DstHdl} = file_handle_cache:open(Dst, [write], []), + Size = size(Content), + {ok, Size} = file_handle_cache:copy(SrcHdl, DstHdl, Size), + ok = file_handle_cache:delete(SrcHdl), + file_handle_cache:delete(DstHdl), + ok = file_handle_cache:set_limit(Limit), + passed. + test_backing_queue() -> case application:get_env(rabbit, backing_queue_module) of {ok, rabbit_variable_queue} -> |