diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-19 13:11:22 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-19 13:11:22 +0100 |
commit | 9c8a0bedf7df7665c0abb5c097e4397ad6879ad0 (patch) | |
tree | 214809d2739b232cfa3ce81ff273e5db7677295f | |
parent | d05e19a41857040b1d10435509501a6f49a30a77 (diff) | |
download | rabbitmq-server-9c8a0bedf7df7665c0abb5c097e4397ad6879ad0.tar.gz |
refactor: simplify msg_store tests
-rw-r--r-- | src/rabbit_tests.erl | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index c1d3885b..b506784e 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -1414,6 +1414,12 @@ msg_store_write(Guids, MSCState) -> rabbit_msg_store:write(?PERSISTENT_MSG_STORE, Guid, Guid, MSCStateN) end, {ok, MSCState}, Guids). +msg_store_remove(Ids) -> + lists:foldl(fun (Guid, ok) -> + rabbit_msg_store:remove(?PERSISTENT_MSG_STORE, + [guid_bin(Guid)]) + end, ok, Ids). + test_msg_store() -> stop_msg_store(), ok = start_msg_store_empty(), @@ -1528,22 +1534,13 @@ test_msg_store() -> MSCStateN end, rabbit_msg_store:client_init(?PERSISTENT_MSG_STORE, Ref), GuidsBig)), %% .., then 3s by 1... - ok = lists:foldl( - fun (Guid, ok) -> - rabbit_msg_store:remove(?PERSISTENT_MSG_STORE, [guid_bin(Guid)]) - end, ok, lists:seq(BigCount, 1, -3)), + ok = msg_store_remove(lists:seq(BigCount, 1, -3)), %% .., then remove 3s by 2, from the young end first. This hits %% GC (under 50% good data left, but no empty files. Must GC). - ok = lists:foldl( - fun (Guid, ok) -> - rabbit_msg_store:remove(?PERSISTENT_MSG_STORE, [guid_bin(Guid)]) - end, ok, lists:seq(BigCount-1, 1, -3)), + ok = msg_store_remove(lists:seq(BigCount-1, 1, -3)), %% .., then remove 3s by 3, from the young end first. This hits %% GC... - ok = lists:foldl( - fun (Guid, ok) -> - rabbit_msg_store:remove(?PERSISTENT_MSG_STORE, [guid_bin(Guid)]) - end, ok, lists:seq(BigCount-2, 1, -3)), + ok = msg_store_remove(lists:seq(BigCount-2, 1, -3)), %% ensure empty false = msg_store_contains(false, GuidsBig), %% restart empty |