Skip to content

Commit

Permalink
Test GM crash when group is deleted while processing a DOWN message
Browse files Browse the repository at this point in the history
  • Loading branch information
dcorbacho committed Aug 19, 2016
1 parent 89a4e14 commit 6fc561f
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test/gm_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ all() ->
confirmed_broadcast,
member_death,
receive_in_order,
unexpected_msg
unexpected_msg,
down_in_members_change
].

init_per_suite(Config) ->
Expand Down Expand Up @@ -123,6 +124,41 @@ unexpected_msg(_Config) ->
passed
end).

down_in_members_change(_Config) ->
%% Setup
ok = gm:create_tables(),
{ok, Pid} = gm:start_link(?MODULE, ?MODULE, self(),
fun rabbit_misc:execute_mnesia_transaction/1),
passed = receive_joined(Pid, [Pid], timeout_joining_gm_group_1),
{ok, Pid2} = gm:start_link(?MODULE, ?MODULE, self(),
fun rabbit_misc:execute_mnesia_transaction/1),
passed = receive_joined(Pid2, [Pid, Pid2], timeout_joining_gm_group_2),
passed = receive_birth(Pid, Pid2, timeout_waiting_for_birth_2),

%% Test. Simulate that the gm group is deleted (forget_group) while
%% processing the 'DOWN' message from the neighbour
process_flag(trap_exit, true),
ok = meck:new(mnesia, [passthrough]),
ok = meck:expect(mnesia, read, fun({gm_group, ?MODULE}) ->
[];
(Key) ->
meck:passthrough([Key])
end),
gm:leave(Pid2),
Passed = receive
{'EXIT', Pid, normal} ->
passed;
{'EXIT', Pid, _} ->
crashed
after 15000 ->
timeout
end,
%% Cleanup
meck:unload(mnesia),
process_flag(trap_exit, false),
passed = Passed.


do_broadcast(Fun) ->
with_two_members(broadcast_fun(Fun)).

Expand Down

0 comments on commit 6fc561f

Please sign in to comment.