Merge pull request #10389 from zhongwencool/core-nodes-array
fix: emqx_schema: comma_separated_atoms() type cannot be configured as a list
This commit is contained in:
commit
37c0badb06
|
@ -29,7 +29,7 @@
|
|||
{esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.6"}}},
|
||||
{ekka, {git, "https://github.com/emqx/ekka", {tag, "0.14.6"}}},
|
||||
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}},
|
||||
{hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.39.1"}}},
|
||||
{hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.39.2"}}},
|
||||
{emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.2"}}},
|
||||
{pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}},
|
||||
{recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}},
|
||||
|
|
|
@ -135,7 +135,7 @@ fields("cluster") ->
|
|||
)},
|
||||
{"core_nodes",
|
||||
sc(
|
||||
emqx_schema:comma_separated_atoms(),
|
||||
node_array(),
|
||||
#{
|
||||
mapping => "mria.core_nodes",
|
||||
default => [],
|
||||
|
@ -203,7 +203,7 @@ fields(cluster_static) ->
|
|||
[
|
||||
{"seeds",
|
||||
sc(
|
||||
hoconsc:array(atom()),
|
||||
node_array(),
|
||||
#{
|
||||
default => [],
|
||||
desc => ?DESC(cluster_static_seeds),
|
||||
|
@ -1312,3 +1312,6 @@ validator_string_re(Val, RE, Error) ->
|
|||
catch
|
||||
_:_ -> {error, Error}
|
||||
end.
|
||||
|
||||
node_array() ->
|
||||
hoconsc:union([emqx_schema:comma_separated_atoms(), hoconsc:array(atom())]).
|
||||
|
|
|
@ -5,6 +5,46 @@
|
|||
-module(emqx_conf_schema_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
array_nodes_test() ->
|
||||
ExpectNodes = ['emqx1@127.0.0.1', 'emqx2@127.0.0.1'],
|
||||
BaseConf =
|
||||
""
|
||||
"\n"
|
||||
" node {\n"
|
||||
" name = \"emqx1@127.0.0.1\"\n"
|
||||
" cookie = \"emqxsecretcookie\"\n"
|
||||
" data_dir = \"data\"\n"
|
||||
" }\n"
|
||||
" cluster {\n"
|
||||
" name = emqxcl\n"
|
||||
" discovery_strategy = static\n"
|
||||
" static.seeds = ~p\n"
|
||||
" core_nodes = ~p\n"
|
||||
" }\n"
|
||||
" "
|
||||
"",
|
||||
lists:foreach(
|
||||
fun(Nodes) ->
|
||||
ConfFile = iolist_to_binary(io_lib:format(BaseConf, [Nodes, Nodes])),
|
||||
{ok, Conf} = hocon:binary(ConfFile, #{format => richmap}),
|
||||
ConfList = hocon_tconf:generate(emqx_conf_schema, Conf),
|
||||
ClusterDiscovery = proplists:get_value(
|
||||
cluster_discovery, proplists:get_value(ekka, ConfList)
|
||||
),
|
||||
?assertEqual(
|
||||
{static, [{seeds, ExpectNodes}]},
|
||||
ClusterDiscovery,
|
||||
Nodes
|
||||
),
|
||||
?assertEqual(
|
||||
ExpectNodes,
|
||||
proplists:get_value(core_nodes, proplists:get_value(mria, ConfList)),
|
||||
Nodes
|
||||
)
|
||||
end,
|
||||
[["emqx1@127.0.0.1", "emqx2@127.0.0.1"], "emqx1@127.0.0.1, emqx2@127.0.0.1"]
|
||||
),
|
||||
ok.
|
||||
|
||||
doc_gen_test() ->
|
||||
%% the json file too large to encode.
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Unify the config formats for `cluster.core_nodes` and `cluster.statics.seeds`.
|
||||
Now they both support formats in array `["emqx1@127.0.0.1", "emqx2@127.0.0.1"]` or semicolon-separated string `"emqx1@127.0.0.1,emqx2@127.0.0.1"`.
|
2
mix.exs
2
mix.exs
|
@ -72,7 +72,7 @@ defmodule EMQXUmbrella.MixProject do
|
|||
# in conflict by emqtt and hocon
|
||||
{:getopt, "1.0.2", override: true},
|
||||
{:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "1.0.7", override: true},
|
||||
{:hocon, github: "emqx/hocon", tag: "0.39.1", override: true},
|
||||
{:hocon, github: "emqx/hocon", tag: "0.39.2", override: true},
|
||||
{:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.5.2", override: true},
|
||||
{:esasl, github: "emqx/esasl", tag: "0.2.0"},
|
||||
{:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"},
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
, {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
|
||||
, {getopt, "1.0.2"}
|
||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.7"}}}
|
||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.39.1"}}}
|
||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.39.2"}}}
|
||||
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.5.2"}}}
|
||||
, {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}}
|
||||
, {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.2"}}}
|
||||
|
|
Loading…
Reference in New Issue