test: test cluster.links reloaded

This commit is contained in:
zhongwencool 2024-07-10 10:50:36 +08:00
parent 937fb153c2
commit 3c832db13d
2 changed files with 14 additions and 8 deletions

View File

@ -57,13 +57,16 @@ mk_clusters(NameA, NameB, PortA, PortB, ConfA, ConfB, Config) ->
{NodesA, NodesB}. {NodesA, NodesB}.
t_config_update_cli('init', Config0) -> t_config_update_cli('init', Config0) ->
Config = Config1 =
[ [
{update_from, cli},
{name_prefix, ?FUNCTION_NAME} {name_prefix, ?FUNCTION_NAME}
| lists:keydelete(update_from, 1, Config0) | Config0
], ],
t_config_update('init', Config); Config2 = t_config_update('init', Config1),
[
{update_from, cli}
| lists:keydelete(update_from, 1, Config2)
];
t_config_update_cli('end', Config) -> t_config_update_cli('end', Config) ->
t_config_update('end', Config). t_config_update('end', Config).
@ -683,8 +686,8 @@ validate_update_cli_failed(Node, Config) ->
), ),
ConfFile = prepare_conf_file(?FUNCTION_NAME, ConfBin, Config), ConfFile = prepare_conf_file(?FUNCTION_NAME, ConfBin, Config),
?assertMatch( ?assertMatch(
{error, <<"Cannot update read-only key 'cluster.autoheal'.">>}, {error, <<"Cannot update read-only key 'cluster.autoclean'.">>},
erpc:call(Node, emqx_cluster_cli, conf, [["load", ConfFile]]) erpc:call(Node, emqx_conf_cli, conf, [["load", ConfFile]])
) )
end. end.
@ -700,7 +703,10 @@ update_links_from_api(Node, Links, _Config) ->
update_links_from_cli(Node, Links, Config) -> update_links_from_cli(Node, Links, Config) ->
ConfBin = hocon_pp:do(#{<<"cluster">> => #{<<"links">> => Links}}, #{}), ConfBin = hocon_pp:do(#{<<"cluster">> => #{<<"links">> => Links}}, #{}),
ConfFile = prepare_conf_file(?FUNCTION_NAME, ConfBin, Config), ConfFile = prepare_conf_file(?FUNCTION_NAME, ConfBin, Config),
erpc:call(Node, emqx_cluster_cli, conf, [["load", ConfFile]]). case erpc:call(Node, emqx_conf_cli, conf, [["load", ConfFile]]) of
ok -> {ok, Links};
Error -> Error
end.
prepare_conf_file(Name, Content, CTConfig) -> prepare_conf_file(Name, Content, CTConfig) ->
Filename = tc_conf_file(Name, CTConfig), Filename = tc_conf_file(Name, CTConfig),

View File

@ -309,7 +309,7 @@ t_configs_key(_Config) ->
}, },
ReadOnlyBin = iolist_to_binary(hocon_pp:do(ReadOnlyConf, #{})), ReadOnlyBin = iolist_to_binary(hocon_pp:do(ReadOnlyConf, #{})),
{error, ReadOnlyError} = update_configs_with_binary(ReadOnlyBin), {error, ReadOnlyError} = update_configs_with_binary(ReadOnlyBin),
?assertEqual(<<"{\"errors\":\"Cannot update read-only key 'cluster'.\"}">>, ReadOnlyError), ?assertMatch(<<"{\"errors\":\"Cannot update read-only key 'cluster", _/binary>>, ReadOnlyError),
?assertMatch({ok, <<>>}, update_configs_with_binary(ReadOnlyBin, _IgnoreReadonly = true)), ?assertMatch({ok, <<>>}, update_configs_with_binary(ReadOnlyBin, _IgnoreReadonly = true)),
ok. ok.