diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2011-10-15 12:07:42 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2011-10-15 12:07:42 +0100 |
commit | 6afd557d6abc7a284f210e598ac2dbb3bd7089b9 (patch) | |
tree | a0dd2cdae2cb8f4d7ed5f8472c86461535f07462 | |
parent | a94e4de87e32f7f85160a5e04e2d7092decafeb2 (diff) | |
download | rabbitmq-server-6afd557d6abc7a284f210e598ac2dbb3bd7089b9.tar.gz |
get coverage of timer-based sync/confirm
-rw-r--r-- | src/rabbit_tests.erl | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index f6d8e0cc..f9fb7591 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -1931,6 +1931,8 @@ test_msg_store() -> false = msg_store_contains(false, MsgIds, MSCState), %% test confirm logic passed = test_msg_store_confirms([hd(MsgIds)], Cap, MSCState), + %% check we don't contain any of the msgs we're about to publish + false = msg_store_contains(false, MsgIds, MSCState), %% publish the first half ok = msg_store_write(MsgIds1stHalf, MSCState), %% sync on the first half @@ -2044,8 +2046,6 @@ test_msg_store() -> restart_msg_store_empty(), passed. -%% We want to test that writes that get eliminated due to removes still -%% get confirmed. Removes themselves do not. test_msg_store_confirms(MsgIds, Cap, MSCState) -> %% write -> confirmed ok = msg_store_write(MsgIds, MSCState), @@ -2071,8 +2071,37 @@ test_msg_store_confirms(MsgIds, Cap, MSCState) -> ok = msg_store_write(MsgIds, MSCState), ok = msg_store_remove(MsgIds, MSCState), ok = on_disk_await(Cap, MsgIds), + %% confirmation on timer-based sync + passed = test_msg_store_confirm_timer(), + passed. + +test_msg_store_confirm_timer() -> + Ref = rabbit_guid:guid(), + MsgId = msg_id_bin(1), + Self = self(), + MSCState = rabbit_msg_store:client_init( + ?PERSISTENT_MSG_STORE, Ref, + fun (MsgIds, _ActionTaken) -> + case gb_sets:is_member(MsgId, MsgIds) of + true -> Self ! on_disk; + false -> ok + end + end, undefined), + ok = msg_store_write([MsgId], MSCState), + ok = msg_store_keep_busy_until_confirm([msg_id_bin(2)], MSCState), + ok = msg_store_remove([MsgId], MSCState), + ok = rabbit_msg_store:client_delete_and_terminate(MSCState), passed. +msg_store_keep_busy_until_confirm(MsgIds, MSCState) -> + receive + on_disk -> ok + after 0 -> + ok = msg_store_write(MsgIds, MSCState), + ok = msg_store_remove(MsgIds, MSCState), + msg_store_keep_busy_until_confirm(MsgIds, MSCState) + end. + test_msg_store_client_delete_and_terminate() -> restart_msg_store_empty(), MsgIds = [msg_id_bin(M) || M <- lists:seq(1, 10)], |