Skip to content

Commit 503cc9f

Browse files
committed
Test single slave restart after forget_cluster_nodes in offline mode
rabbitmq-server#1213 [#145084865]
1 parent 8cedd3f commit 503cc9f

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

test/dynamic_ha_SUITE.erl

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ groups() ->
6262
{cluster_size_3, [], [
6363
change_policy,
6464
rapid_change,
65-
nodes_policy_should_pick_master_from_its_params
65+
nodes_policy_should_pick_master_from_its_params,
66+
promote_slave_after_standalone_restart
6667
% FIXME: Re-enable those tests when the know issues are
6768
% fixed.
6869
% failing_random_policies,
@@ -319,6 +320,45 @@ failing_random_policies(Config) ->
319320
[all, undefined, {exactly, 2}, all, {exactly, 3}, {exactly, 3},
320321
undefined, {exactly, 3}, all])).
321322

323+
promote_slave_after_standalone_restart(Config) ->
324+
%% Tests that slaves can be brought up standalone after forgetting the rest
325+
%% of the cluster. Slave ordering should be irrelevant.
326+
%% https://github.com/rabbitmq/rabbitmq-server/issues/1213
327+
[A, B, C] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
328+
Ch = rabbit_ct_client_helpers:open_channel(Config, A),
329+
330+
rabbit_ct_broker_helpers:set_ha_policy(Config, A, ?POLICY, <<"all">>),
331+
amqp_channel:call(Ch, #'queue.declare'{queue = ?QNAME,
332+
durable = true}),
333+
334+
rabbit_ct_client_helpers:publish(Ch, ?QNAME, 15),
335+
rabbit_ct_client_helpers:close_channel(Ch),
336+
337+
timer:sleep(500),
338+
15 = proplists:get_value(messages, find_queue(?QNAME, A)),
339+
340+
rabbit_ct_broker_helpers:stop_node(Config, C),
341+
rabbit_ct_broker_helpers:stop_node(Config, B),
342+
rabbit_ct_broker_helpers:stop_node(Config, A),
343+
344+
%% Restart one slave
345+
forget_cluster_node(Config, B, C),
346+
forget_cluster_node(Config, B, A),
347+
348+
ok = rabbit_ct_broker_helpers:start_node(Config, B),
349+
15 = proplists:get_value(messages, find_queue(?QNAME, B)),
350+
ok = rabbit_ct_broker_helpers:stop_node(Config, B),
351+
352+
%% Restart the other
353+
forget_cluster_node(Config, C, B),
354+
forget_cluster_node(Config, C, A),
355+
356+
ok = rabbit_ct_broker_helpers:start_node(Config, C),
357+
15 = proplists:get_value(messages, find_queue(?QNAME, C)),
358+
ok = rabbit_ct_broker_helpers:stop_node(Config, C),
359+
360+
ok.
361+
322362
%%----------------------------------------------------------------------------
323363

324364
assert_slaves(RPCNode, QName, Exp) ->
@@ -528,3 +568,7 @@ apply_policy(Config, N, {exactly, Exactly}) ->
528568
rabbit_ct_broker_helpers:set_ha_policy(
529569
Config, N, ?POLICY, {<<"exactly">>, Exactly},
530570
[{<<"ha-sync-mode">>, <<"automatic">>}]).
571+
572+
forget_cluster_node(Config, Node, Removee) ->
573+
rabbit_ct_broker_helpers:rabbitmqctl(
574+
Config, Node, ["forget_cluster_node", "--offline", Removee]).

0 commit comments

Comments
 (0)