fix(ct): adapt cluster setup helper to replicant nodes
Before this change, trying to start cluster consisting of cores + replicants resulted in error joining replicant node to the cluster.
This commit is contained in:
parent
52354bf58a
commit
acd6e5635b
|
@ -652,10 +652,13 @@ ensure_quic_listener(Name, UdpPort, ExtraSettings) ->
|
|||
%% Extras app starting handler. It is the second arg passed to emqx_common_test_helpers:start_apps/2
|
||||
env_handler => fun((AppName :: atom()) -> term()),
|
||||
%% Application env preset before calling `emqx_common_test_helpers:start_apps/2`
|
||||
env => {AppName :: atom(), Key :: atom(), Val :: term()},
|
||||
env => [{AppName :: atom(), Key :: atom(), Val :: term()}],
|
||||
%% Whether to execute `emqx_config:init_load(SchemaMod)`
|
||||
%% default: true
|
||||
load_schema => boolean(),
|
||||
%% Which node in the cluster to join to.
|
||||
%% default: first core node
|
||||
join_to => node(),
|
||||
%% If we want to exercise the scenario where a node joins an
|
||||
%% existing cluster where there has already been some
|
||||
%% configuration changes (via cluster rpc), then we need to enable
|
||||
|
@ -690,28 +693,38 @@ emqx_cluster(Specs0, CommonOpts) ->
|
|||
]),
|
||||
%% Set the default node of the cluster:
|
||||
CoreNodes = [node_name(Name) || {{core, Name, _}, _} <- Specs],
|
||||
JoinTo0 =
|
||||
JoinTo =
|
||||
case CoreNodes of
|
||||
[First | _] -> First;
|
||||
_ -> undefined
|
||||
end,
|
||||
JoinTo =
|
||||
case maps:find(join_to, CommonOpts) of
|
||||
{ok, true} -> JoinTo0;
|
||||
{ok, JT} -> JT;
|
||||
error -> JoinTo0
|
||||
end,
|
||||
[
|
||||
{Name,
|
||||
merge_opts(Opts, #{
|
||||
base_port => base_port(Number),
|
||||
NodeOpts = fun(Number) ->
|
||||
#{
|
||||
base_port => base_port(Number),
|
||||
env => [
|
||||
{mria, core_nodes, CoreNodes},
|
||||
{gen_rpc, client_config_per_node, {internal, GenRpcPorts}}
|
||||
]
|
||||
}
|
||||
end,
|
||||
RoleOpts = fun
|
||||
(core) ->
|
||||
#{
|
||||
join_to => JoinTo,
|
||||
env => [
|
||||
{mria, core_nodes, CoreNodes},
|
||||
{mria, node_role, Role},
|
||||
{gen_rpc, client_config_per_node, {internal, GenRpcPorts}}
|
||||
{mria, node_role, core}
|
||||
]
|
||||
})}
|
||||
};
|
||||
(replicant) ->
|
||||
#{
|
||||
env => [
|
||||
{mria, node_role, replicant},
|
||||
{ekka, cluster_discovery, {static, [{seeds, CoreNodes}]}}
|
||||
]
|
||||
}
|
||||
end,
|
||||
[
|
||||
{Name, merge_opts(merge_opts(NodeOpts(Number), RoleOpts(Role)), Opts)}
|
||||
|| {{Role, Name, Opts}, Number} <- Specs
|
||||
].
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ mk_cluster_specs(Config, Opts) ->
|
|||
{core, emqx_bridge_api_SUITE1, #{}},
|
||||
{core, emqx_bridge_api_SUITE2, #{}}
|
||||
],
|
||||
CommonOpts = #{
|
||||
CommonOpts = Opts#{
|
||||
env => [{emqx, boot_modules, [broker]}],
|
||||
apps => [],
|
||||
% NOTE
|
||||
|
@ -157,7 +157,6 @@ mk_cluster_specs(Config, Opts) ->
|
|||
load_apps => ?SUITE_APPS ++ [emqx_dashboard],
|
||||
env_handler => fun load_suite_config/1,
|
||||
load_schema => false,
|
||||
join_to => maps:get(join_to, Opts, true),
|
||||
priv_data_dir => ?config(priv_dir, Config)
|
||||
},
|
||||
emqx_common_test_helpers:emqx_cluster(Specs, CommonOpts).
|
||||
|
|
|
@ -247,7 +247,6 @@ cluster(Specs, Config) ->
|
|||
{env, Env},
|
||||
{apps, [emqx_conf]},
|
||||
{load_schema, false},
|
||||
{join_to, true},
|
||||
{priv_data_dir, PrivDataDir},
|
||||
{env_handler, fun
|
||||
(emqx) ->
|
||||
|
|
|
@ -284,7 +284,6 @@ cluster(Specs) ->
|
|||
{env, Env},
|
||||
{apps, [emqx_conf]},
|
||||
{load_schema, false},
|
||||
{join_to, true},
|
||||
{env_handler, fun
|
||||
(emqx) ->
|
||||
application:set_env(emqx, boot_modules, []),
|
||||
|
|
|
@ -159,7 +159,6 @@ cluster(Specs) ->
|
|||
{env, Env},
|
||||
{apps, [emqx_conf, emqx_management]},
|
||||
{load_schema, false},
|
||||
{join_to, true},
|
||||
{env_handler, fun
|
||||
(emqx) ->
|
||||
application:set_env(emqx, boot_modules, []),
|
||||
|
|
|
@ -444,7 +444,6 @@ cluster(Config) ->
|
|||
env => [{mria, db_backend, rlog}],
|
||||
load_schema => true,
|
||||
start_autocluster => true,
|
||||
join_to => true,
|
||||
listener_ports => [],
|
||||
conf => [{[dashboard, listeners, http, bind], 0}],
|
||||
env_handler =>
|
||||
|
|
Loading…
Reference in New Issue