Parcourir la source

test(emqx_common_test_helpers): keep EMQX ENV vars on a child node for its lifetime

Serge Tupchii il y a 2 ans
Parent
commit
33fa053b9b
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      apps/emqx/test/emqx_common_test_helpers.erl

+ 6 - 7
apps/emqx/test/emqx_common_test_helpers.erl

@@ -859,6 +859,12 @@ setup_node(Node, Opts) when is_map(Opts) ->
     %% Setting env before starting any applications
     %% Setting env before starting any applications
     set_envs(Node, Env),
     set_envs(Node, Env),
 
 
+    NodeDataDir = filename:join([
+        PrivDataDir,
+        node(),
+        integer_to_list(erlang:unique_integer())
+    ]),
+
     %% Here we start the apps
     %% Here we start the apps
     EnvHandlerForRpc =
     EnvHandlerForRpc =
         fun(App) ->
         fun(App) ->
@@ -870,17 +876,10 @@ setup_node(Node, Opts) when is_map(Opts) ->
                     %% to avoid sharing data between executions and/or
                     %% to avoid sharing data between executions and/or
                     %% nodes.  these variables might not be in the
                     %% nodes.  these variables might not be in the
                     %% config file (e.g.: emqx_enterprise_schema).
                     %% config file (e.g.: emqx_enterprise_schema).
-                    NodeDataDir = filename:join([
-                        PrivDataDir,
-                        node(),
-                        integer_to_list(erlang:unique_integer())
-                    ]),
                     Cookie = atom_to_list(erlang:get_cookie()),
                     Cookie = atom_to_list(erlang:get_cookie()),
                     os:putenv("EMQX_NODE__DATA_DIR", NodeDataDir),
                     os:putenv("EMQX_NODE__DATA_DIR", NodeDataDir),
                     os:putenv("EMQX_NODE__COOKIE", Cookie),
                     os:putenv("EMQX_NODE__COOKIE", Cookie),
                     emqx_config:init_load(SchemaMod),
                     emqx_config:init_load(SchemaMod),
-                    os:unsetenv("EMQX_NODE__DATA_DIR"),
-                    os:unsetenv("EMQX_NODE__COOKIE"),
                     application:set_env(emqx, init_config_load_done, true)
                     application:set_env(emqx, init_config_load_done, true)
                 end,
                 end,