Skip to content

Commit

Permalink
More integration tests for maintenance mode
Browse files Browse the repository at this point in the history
References rabbitmq#2321
  • Loading branch information
michaelklishin committed Jul 14, 2020
1 parent f1e11b8 commit e06ab7c
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion test/maintenance_mode_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ groups() ->
[
{cluster_size_3, [], [
maintenance_mode_status,
listener_suspension_status
listener_suspension_status,
client_connection_closure,
queue_leadership_transition
]}
].

Expand Down Expand Up @@ -124,6 +126,7 @@ maintenance_mode_status(Config) ->

ok.


listener_suspension_status(Config) ->
Nodes = [A | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
ct:pal("Picked node ~s for maintenance tests...", [A]),
Expand Down Expand Up @@ -154,3 +157,48 @@ listener_suspension_status(Config) ->
rabbit_ct_client_helpers:close_connection(Conn3),

ok.


client_connection_closure(Config) ->
[A | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
ct:pal("Picked node ~s for maintenance tests...", [A]),

rabbit_ct_helpers:await_condition(
fun () -> not rabbit_ct_broker_helpers:is_being_drained_local_read(Config, A) end, 10000),

Conn1 = rabbit_ct_client_helpers:open_connection(Config, A),
?assert(is_pid(Conn1)),
?assertEqual(1, length(rabbit_ct_broker_helpers:rpc(Config, A, rabbit_networking, local_connections, []))),

rabbit_ct_broker_helpers:drain_node(Config, A),
?assertEqual(0, length(rabbit_ct_broker_helpers:rpc(Config, A, rabbit_networking, local_connections, []))),

rabbit_ct_broker_helpers:revive_node(Config, A).


queue_leadership_transition(Config) ->
[A | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
ct:pal("Picked node ~s for maintenance tests...", [A]),

rabbit_ct_helpers:await_condition(
fun () -> not rabbit_ct_broker_helpers:is_being_drained_local_read(Config, A) end, 10000),

PolicyPattern = <<"^cq.mirrored">>,
rabbit_ct_broker_helpers:set_ha_policy(Config, A, PolicyPattern, <<"all">>),

Conn = rabbit_ct_client_helpers:open_connection(Config, A),
{ok, Ch} = amqp_connection:open_channel(Conn),
QName = <<"cq.mirrored.1">>,
amqp_channel:call(Ch, #'queue.declare'{queue = QName, durable = true}),

?assertEqual(1, length(rabbit_ct_broker_helpers:rpc(Config, A, rabbit_amqqueue, list_local, [<<"/">>]))),

rabbit_ct_broker_helpers:drain_node(Config, A),
rabbit_ct_helpers:await_condition(
fun () -> rabbit_ct_broker_helpers:is_being_drained_local_read(Config, A) end, 10000),

?assertEqual(0, length(rabbit_ct_broker_helpers:rpc(Config, A, rabbit_amqqueue, list_local, [<<"/">>]))),

rabbit_ct_broker_helpers:revive_node(Config, A),
%% rabbit_ct_broker_helpers:set_ha_policy/4 uses pattern for policy name
rabbit_ct_broker_helpers:clear_policy(Config, A, PolicyPattern).

0 comments on commit e06ab7c

Please sign in to comment.