|
|
@@ -59,14 +59,15 @@ t_copy_new_data_dir(_Config) ->
|
|
|
%% 1. Start all nodes
|
|
|
[First | Rest] = Nodes = start_cluster(Cluster),
|
|
|
try
|
|
|
+ File = "/configs/cluster.hocon",
|
|
|
assert_config_load_done(Nodes),
|
|
|
- rpc:call(First, ?MODULE, create_data_dir, []),
|
|
|
+ rpc:call(First, ?MODULE, create_data_dir, [File]),
|
|
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, application, stop, [emqx_conf]),
|
|
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
|
|
ok = rpc:call(First, application, start, [emqx_conf]),
|
|
|
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
|
|
|
|
|
- assert_data_copy_done(Nodes, "/configs/cluster.hocon"),
|
|
|
+ assert_data_copy_done(Nodes, File),
|
|
|
stop_cluster(Nodes),
|
|
|
ok
|
|
|
after
|
|
|
@@ -82,14 +83,15 @@ t_copy_deprecated_data_dir(_Config) ->
|
|
|
%% 1. Start all nodes
|
|
|
[First | Rest] = Nodes = start_cluster(Cluster),
|
|
|
try
|
|
|
+ File = "/configs/cluster-override.conf",
|
|
|
assert_config_load_done(Nodes),
|
|
|
- rpc:call(First, ?MODULE, create_deprecated_data_dir, []),
|
|
|
+ rpc:call(First, ?MODULE, create_data_dir, [File]),
|
|
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, application, stop, [emqx_conf]),
|
|
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
|
|
ok = rpc:call(First, application, start, [emqx_conf]),
|
|
|
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
|
|
|
|
|
- assert_data_copy_done(Nodes, "/configs/cluster-override.conf"),
|
|
|
+ assert_data_copy_done(Nodes, File),
|
|
|
stop_cluster(Nodes),
|
|
|
ok
|
|
|
after
|
|
|
@@ -100,7 +102,7 @@ t_copy_deprecated_data_dir(_Config) ->
|
|
|
%% Helper functions
|
|
|
%%------------------------------------------------------------------------------
|
|
|
|
|
|
-create_data_dir() ->
|
|
|
+create_data_dir(File) ->
|
|
|
Node = atom_to_list(node()),
|
|
|
ok = filelib:ensure_dir(Node ++ "/certs/"),
|
|
|
ok = filelib:ensure_dir(Node ++ "/authz/"),
|
|
|
@@ -108,17 +110,7 @@ create_data_dir() ->
|
|
|
ok = file:write_file(Node ++ "/certs/fake-cert", list_to_binary(Node)),
|
|
|
ok = file:write_file(Node ++ "/authz/fake-authz", list_to_binary(Node)),
|
|
|
Telemetry = <<"telemetry.enable = false">>,
|
|
|
- ok = file:write_file(Node ++ "/configs/cluster.hocon", Telemetry).
|
|
|
-
|
|
|
-create_deprecated_data_dir() ->
|
|
|
- Node = atom_to_list(node()),
|
|
|
- ok = filelib:ensure_dir(Node ++ "/certs/"),
|
|
|
- ok = filelib:ensure_dir(Node ++ "/authz/"),
|
|
|
- ok = filelib:ensure_dir(Node ++ "/configs/"),
|
|
|
- ok = file:write_file(Node ++ "/certs/fake-cert", list_to_binary(Node)),
|
|
|
- ok = file:write_file(Node ++ "/authz/fake-authz", list_to_binary(Node)),
|
|
|
- Telemetry = <<"telemetry.enable = false">>,
|
|
|
- ok = file:write_file(Node ++ "/configs/cluster-override.conf", Telemetry).
|
|
|
+ ok = file:write_file(Node ++ File, Telemetry).
|
|
|
|
|
|
set_data_dir_env() ->
|
|
|
Node = atom_to_list(node()),
|
|
|
@@ -134,7 +126,7 @@ set_data_dir_env() ->
|
|
|
application:set_env(emqx, config_files, [NewConfigFile]),
|
|
|
application:set_env(emqx, data_dir, Node),
|
|
|
%% We set env both cluster.hocon and cluster-override.conf, but only one will be used
|
|
|
- application:set_env(emqx, cluster_conf_file, Node ++ "/configs/cluster.hocon"),
|
|
|
+ application:set_env(emqx, cluster_hocon_file, Node ++ "/configs/cluster.hocon"),
|
|
|
application:set_env(emqx, cluster_override_conf_file, Node ++ "/configs/cluster-override.conf"),
|
|
|
ok.
|
|
|
|