Просмотр исходного кода

test(ft): inject configs through hocon subsystem

So that relevant parts of config would be initialized with defaults.
Andrew Mayorov 3 лет назад
Родитель
Сommit
0c821cd3bd

+ 4 - 7
apps/emqx_ft/test/emqx_ft_SUITE.erl

@@ -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}

+ 2 - 3
apps/emqx_ft/test/emqx_ft_api_SUITE.erl

@@ -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.

+ 2 - 3
apps/emqx_ft/test/emqx_ft_storage_fs_SUITE.erl

@@ -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.

+ 3 - 13
apps/emqx_ft/test/emqx_ft_storage_fs_gc_SUITE.erl

@@ -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.

+ 4 - 3
apps/emqx_ft/test/emqx_ft_test_helpers.erl

@@ -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.