summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2018-03-16 16:37:30 +0300
committerGitHub <noreply@github.com>2018-03-16 16:37:30 +0300
commit2ae6ba6578baaef95657d1b90470f848d464eeb7 (patch)
treef36b209186ea0bf66c1bbc45fa02b0c875d3265e /test
parente431a622cd1b018aa2f1eb83d6dba18fbd53b365 (diff)
parentfc8abae47427eb9ae4347177cc23dd9d4e10ba35 (diff)
downloadrabbitmq-server-git-2ae6ba6578baaef95657d1b90470f848d464eeb7.tar.gz
Merge pull request #1556 from rabbitmq/vhost-sup-race
Do not try to start a vhost supervisors on not fully booted nodes.
Diffstat (limited to 'test')
-rw-r--r--test/clustering_management_SUITE.erl26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/clustering_management_SUITE.erl b/test/clustering_management_SUITE.erl
index e04fff2182..e9f52de3c8 100644
--- a/test/clustering_management_SUITE.erl
+++ b/test/clustering_management_SUITE.erl
@@ -53,7 +53,8 @@ groups() ->
forget_offline_removes_things,
force_boot,
status_with_alarm,
- wait_fails_when_cluster_fails
+ wait_fails_when_cluster_fails,
+ concurrent_default_data_creation
]},
{cluster_size_4, [], [
forget_promotes_offline_slave
@@ -636,6 +637,29 @@ wait_fails_when_cluster_fails(Config) ->
{error, _, _} = rabbit_ct_broker_helpers:rabbitmqctl(Config, Rabbit,
["wait", RabbitPidFile]).
+concurrent_default_data_creation(Config) ->
+ [Rabbit, Hare] = rabbit_ct_broker_helpers:get_node_configs(Config,
+ nodename),
+ %% Run multiple times to detect a race.
+ %% This test simulates concurrent initialisation of several key node DB tables.
+ %% Since this is node-local state, in practice this can only
+ %% happen when a new cluster is formed and two nodes are booting
+ %% at roughly the same time (say, within a couple of ms from each other).
+ [concurrent_default_data_creation1(Rabbit, Hare) || _ <- lists:seq(1, 20)].
+
+concurrent_default_data_creation1(Rabbit, Hare) ->
+ %% Clear default data.
+ [{atomic, ok} = rpc:call(Rabbit, mnesia, clear_table, [Tab])
+ || Tab <- [rabbit_user, rabbit_user_permission, rabbit_vhost]],
+ %% Stop both nodes
+ [ok = rpc:call(Node, rabbit, stop, []) || Node <- [Rabbit, Hare]],
+ %% Start nodes in parallel
+ [spawn(fun() -> rpc:call(Node, rabbit, start, []) end)
+ || Node <- [Rabbit, Hare]],
+ %% Verify both nodes are started successfully
+ [ok = rpc:call(Node, rabbit, await_startup, [Node]) || Node <- [Rabbit, Hare]],
+ [{ok, _Pid} = rpc:call(Node, rabbit_vhost_sup_sup, get_vhost_sup, [<<"/">>]) || Node <- [Rabbit, Hare]].
+
%% ----------------------------------------------------------------------------
%% Internal utils
%% ----------------------------------------------------------------------------