Test that ha-promote-on-failure takes precedence over ha-promote-on-shutdown

This commit is contained in:
Daniil Fedotov 2018-04-18 18:02:51 +01:00
parent 0c6a4dc64b
commit ae7bf1ffa4
1 changed files with 16 additions and 2 deletions

View File

@ -321,23 +321,28 @@ promote_on_failure(Config) ->
durable = true}),
ok.
promote_on_shutdown(Config) ->
[A, B] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.promote">>,
<<"all">>, [{<<"ha-promote-on-shutdown">>, <<"always">>}]),
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.nopromote">>,
<<"all">>),
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"^ha.nopromoteonfailure">>,
<<"all">>, [{<<"ha-promote-on-failure">>, <<"when-synced">>},
{<<"ha-promote-on-shutdown">>, <<"always">>}]),
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
[begin
amqp_channel:call(ACh, #'queue.declare'{queue = Q,
durable = true}),
rabbit_ct_client_helpers:publish(ACh, Q, 10)
end || Q <- [<<"ha.promote.test">>, <<"ha.nopromote.test">>]],
end || Q <- [<<"ha.promote.test">>,
<<"ha.nopromote.test">>,
<<"ha.nopromoteonfailure.test">>]],
ok = rabbit_ct_broker_helpers:restart_node(Config, B),
ok = rabbit_ct_broker_helpers:stop_node(Config, A),
BCh = rabbit_ct_client_helpers:open_channel(Config, B),
BCh1 = rabbit_ct_client_helpers:open_channel(Config, B),
#'queue.declare_ok'{message_count = 0} =
amqp_channel:call(
BCh, #'queue.declare'{queue = <<"ha.promote.test">>,
@ -347,12 +352,21 @@ promote_on_shutdown(Config) ->
amqp_channel:call(
BCh, #'queue.declare'{queue = <<"ha.nopromote.test">>,
durable = true})),
?assertExit(
{{shutdown, {server_initiated_close, 404, _}}, _},
amqp_channel:call(
BCh1, #'queue.declare'{queue = <<"ha.nopromoteonfailure.test">>,
durable = true})),
ok = rabbit_ct_broker_helpers:start_node(Config, A),
ACh2 = rabbit_ct_client_helpers:open_channel(Config, A),
#'queue.declare_ok'{message_count = 10} =
amqp_channel:call(
ACh2, #'queue.declare'{queue = <<"ha.nopromote.test">>,
durable = true}),
#'queue.declare_ok'{message_count = 10} =
amqp_channel:call(
ACh2, #'queue.declare'{queue = <<"ha.nopromoteonfailure.test">>,
durable = true}),
ok.
nodes_policy_should_pick_master_from_its_params(Config) ->