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

View File

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

View File

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

View File

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

View File

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