Skip to content

Commit 0c6a4dc

Browse files
committed
Test for ha-promote-on-failure policy key
1 parent 5f06ff4 commit 0c6a4dc

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/dynamic_ha_SUITE.erl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ groups() ->
5959
vhost_deletion,
6060
force_delete_if_no_master,
6161
promote_on_shutdown,
62+
promote_on_failure,
6263
slave_recovers_after_vhost_failure,
6364
slave_recovers_after_vhost_down_an_up,
6465
master_migrates_on_vhost_down,
@@ -287,6 +288,40 @@ force_delete_if_no_master(Config) ->
287288
amqp_channel:call(BCh3, #'queue.delete'{queue = <<"ha.nopromote.test2">>}),
288289
ok.
289290

291+
promote_on_failure(Config) ->
292+
[A, B] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
293+
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.promote">>,
294+
<<"all">>, [{<<"ha-promote-on-failure">>, <<"always">>}]),
295+
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.nopromote">>,
296+
<<"all">>, [{<<"ha-promote-on-failure">>, <<"when-synced">>}]),
297+
298+
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
299+
[begin
300+
amqp_channel:call(ACh, #'queue.declare'{queue = Q,
301+
durable = true}),
302+
rabbit_ct_client_helpers:publish(ACh, Q, 10)
303+
end || Q <- [<<"ha.promote.test">>, <<"ha.nopromote.test">>]],
304+
ok = rabbit_ct_broker_helpers:restart_node(Config, B),
305+
ok = rabbit_ct_broker_helpers:kill_node(Config, A),
306+
BCh = rabbit_ct_client_helpers:open_channel(Config, B),
307+
#'queue.declare_ok'{message_count = 0} =
308+
amqp_channel:call(
309+
BCh, #'queue.declare'{queue = <<"ha.promote.test">>,
310+
durable = true}),
311+
?assertExit(
312+
{{shutdown, {server_initiated_close, 404, _}}, _},
313+
amqp_channel:call(
314+
BCh, #'queue.declare'{queue = <<"ha.nopromote.test">>,
315+
durable = true})),
316+
ok = rabbit_ct_broker_helpers:start_node(Config, A),
317+
ACh2 = rabbit_ct_client_helpers:open_channel(Config, A),
318+
#'queue.declare_ok'{message_count = 10} =
319+
amqp_channel:call(
320+
ACh2, #'queue.declare'{queue = <<"ha.nopromote.test">>,
321+
durable = true}),
322+
ok.
323+
324+
290325
promote_on_shutdown(Config) ->
291326
[A, B] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
292327
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.promote">>,

0 commit comments

Comments
 (0)