test(ft): inject configs through hocon subsystem

So that relevant parts of config would be initialized with defaults.
This commit is contained in:
Andrew Mayorov 2023-03-15 13:57:42 +03:00 committed by Ilya Averyanov
parent e1dc48fa2b
commit 0c821cd3bd
5 changed files with 15 additions and 29 deletions

View File

@ -58,9 +58,8 @@ end_per_suite(_Config) ->
set_special_configs(Config) ->
fun
(emqx_ft) ->
ok = emqx_config:put([file_transfer, storage], #{
type => local, root => emqx_ft_test_helpers:ft_root(Config, node())
});
Root = emqx_ft_test_helpers:ft_root(Config, node()),
emqx_ft_test_helpers:load_config(#{storage => #{type => local, root => Root}});
(_) ->
ok
end.
@ -109,10 +108,8 @@ mk_cluster_specs(Config) ->
{conf, [{[listeners, Proto, default, enabled], false} || Proto <- [ssl, ws, wss]]},
{env_handler, fun
(emqx_ft) ->
ok = emqx_config:put([file_transfer, storage], #{
type => local,
root => emqx_ft_test_helpers:ft_root(Config, node())
});
Root = emqx_ft_test_helpers:ft_root(Config, node()),
emqx_ft_test_helpers:load_config(#{storage => #{type => local, root => Root}});
(_) ->
ok
end}

View File

@ -41,9 +41,8 @@ end_per_suite(_Config) ->
set_special_configs(Config) ->
fun
(emqx_ft) ->
ok = emqx_config:put([file_transfer, storage], #{
type => local, root => emqx_ft_test_helpers:ft_root(Config, node())
});
Root = emqx_ft_test_helpers:ft_root(Config, node()),
emqx_ft_test_helpers:load_config(#{storage => #{type => local, root => Root}});
(_) ->
ok
end.

View File

@ -48,9 +48,8 @@ end_per_suite(_Config) ->
set_special_configs(Config) ->
fun
(emqx_ft) ->
ok = emqx_config:put([file_transfer, storage], #{
type => local, root => emqx_ft_test_helpers:ft_root(Config, node())
});
Root = emqx_ft_test_helpers:ft_root(Config, node()),
emqx_ft_test_helpers:load_config(#{storage => #{type => local, root => Root}});
(_) ->
ok
end.

View File

@ -40,19 +40,9 @@ init_per_testcase(TC, Config) ->
ok = emqx_common_test_helpers:start_app(
emqx_ft,
fun(emqx_ft) ->
emqx_common_test_helpers:load_config(
emqx_ft_schema,
iolist_to_binary([
"file_transfer {"
" storage = {"
" type = \"local\","
" root = \"",
mk_root(TC, Config),
"\""
" }"
"}"
])
)
emqx_ft_test_helpers:load_config(#{
storage => #{type => local, root => mk_root(TC, Config)}
})
end
),
Config.

View File

@ -30,9 +30,7 @@ start_additional_node(Config, Name) ->
{configure_gen_rpc, true},
{env_handler, fun
(emqx_ft) ->
ok = emqx_config:put([file_transfer, storage], #{
type => local, root => ft_root(Config, node())
});
load_config(#{storage => #{type => local, root => ft_root(Config, node())}});
(_) ->
ok
end}
@ -45,6 +43,9 @@ stop_additional_node(Node) ->
ok = emqx_common_test_helpers:stop_slave(Node),
ok.
load_config(Config) ->
emqx_common_test_helpers:load_config(emqx_ft_schema, #{file_transfer => Config}).
tcp_port(Node) ->
{_, Port} = rpc:call(Node, emqx_config, get, [[listeners, tcp, default, bind]]),
Port.