test(conf): simplify confsync test suite
This commit is contained in:
parent
ae79516fd2
commit
6ea9d2a6d9
|
@ -74,10 +74,7 @@ t_copy_new_data_dir(Config) ->
|
||||||
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
||||||
ok = rpc:call(First, application, start, [emqx_conf]),
|
ok = rpc:call(First, application, start, [emqx_conf]),
|
||||||
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
||||||
|
ok = assert_data_copy_done(Nodes, File)
|
||||||
assert_data_copy_done(Nodes, File),
|
|
||||||
stop_cluster(Nodes),
|
|
||||||
ok
|
|
||||||
after
|
after
|
||||||
stop_cluster(Nodes)
|
stop_cluster(Nodes)
|
||||||
end.
|
end.
|
||||||
|
@ -101,10 +98,7 @@ t_copy_deprecated_data_dir(Config) ->
|
||||||
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
{[ok, ok, ok], []} = rpc:multicall(Nodes, ?MODULE, set_data_dir_env, []),
|
||||||
ok = rpc:call(First, application, start, [emqx_conf]),
|
ok = rpc:call(First, application, start, [emqx_conf]),
|
||||||
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
||||||
|
ok = assert_data_copy_done(Nodes, File)
|
||||||
assert_data_copy_done(Nodes, File),
|
|
||||||
stop_cluster(Nodes),
|
|
||||||
ok
|
|
||||||
after
|
after
|
||||||
stop_cluster(Nodes)
|
stop_cluster(Nodes)
|
||||||
end.
|
end.
|
||||||
|
@ -133,9 +127,7 @@ t_no_copy_from_newer_version_node(Config) ->
|
||||||
]),
|
]),
|
||||||
ok = rpc:call(First, application, start, [emqx_conf]),
|
ok = rpc:call(First, application, start, [emqx_conf]),
|
||||||
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
{[ok, ok], []} = rpc:multicall(Rest, application, start, [emqx_conf]),
|
||||||
ok = assert_no_cluster_conf_copied(Rest, File),
|
ok = assert_no_cluster_conf_copied(Rest, File)
|
||||||
stop_cluster(Nodes),
|
|
||||||
ok
|
|
||||||
after
|
after
|
||||||
stop_cluster(Nodes)
|
stop_cluster(Nodes)
|
||||||
end.
|
end.
|
||||||
|
@ -155,26 +147,30 @@ create_data_dir(File) ->
|
||||||
|
|
||||||
set_data_dir_env() ->
|
set_data_dir_env() ->
|
||||||
NodeDataDir = emqx:data_dir(),
|
NodeDataDir = emqx:data_dir(),
|
||||||
NodeStr = atom_to_list(node()),
|
NodeConfigDir = filename:join(NodeDataDir, "configs"),
|
||||||
%% will create certs and authz dir
|
%% will create certs and authz dir
|
||||||
ok = filelib:ensure_dir(NodeDataDir ++ "/configs/"),
|
ok = filelib:ensure_path(NodeConfigDir),
|
||||||
{ok, [ConfigFile]} = application:get_env(emqx, config_files),
|
ConfigFile = filename:join(NodeConfigDir, "emqx.conf"),
|
||||||
NewConfigFile = ConfigFile ++ "." ++ NodeStr,
|
ok = append_format(ConfigFile, "node.config_files = [~p]~n", [ConfigFile]),
|
||||||
ok = filelib:ensure_dir(NewConfigFile),
|
ok = append_format(ConfigFile, "node.data_dir = ~p~n", [NodeDataDir]),
|
||||||
{ok, _} = file:copy(ConfigFile, NewConfigFile),
|
application:set_env(emqx, config_files, [ConfigFile]),
|
||||||
Bin = iolist_to_binary(io_lib:format("node.config_files = [~p]~n", [NewConfigFile])),
|
|
||||||
ok = file:write_file(NewConfigFile, Bin, [append]),
|
|
||||||
DataDir = iolist_to_binary(io_lib:format("node.data_dir = ~p~n", [NodeDataDir])),
|
|
||||||
ok = file:write_file(NewConfigFile, DataDir, [append]),
|
|
||||||
application:set_env(emqx, config_files, [NewConfigFile]),
|
|
||||||
%% application:set_env(emqx, data_dir, Node),
|
%% application:set_env(emqx, data_dir, Node),
|
||||||
%% We set env both cluster.hocon and cluster-override.conf, but only one will be used
|
%% We set env both cluster.hocon and cluster-override.conf, but only one will be used
|
||||||
application:set_env(emqx, cluster_hocon_file, NodeDataDir ++ "/configs/cluster.hocon"),
|
|
||||||
application:set_env(
|
application:set_env(
|
||||||
emqx, cluster_override_conf_file, NodeDataDir ++ "/configs/cluster-override.conf"
|
emqx,
|
||||||
|
cluster_hocon_file,
|
||||||
|
filename:join([NodeDataDir, "configs", "cluster.hocon"])
|
||||||
|
),
|
||||||
|
application:set_env(
|
||||||
|
emqx,
|
||||||
|
cluster_override_conf_file,
|
||||||
|
filename:join([NodeDataDir, "configs", "cluster-override.conf"])
|
||||||
),
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
append_format(Filename, Fmt, Args) ->
|
||||||
|
ok = file:write_file(Filename, io_lib:format(Fmt, Args), [append]).
|
||||||
|
|
||||||
assert_data_copy_done([_First | Rest], File) ->
|
assert_data_copy_done([_First | Rest], File) ->
|
||||||
FirstDataDir = filename:dirname(filename:dirname(File)),
|
FirstDataDir = filename:dirname(filename:dirname(File)),
|
||||||
{ok, FakeCertFile} = file:read_file(FirstDataDir ++ "/certs/fake-cert"),
|
{ok, FakeCertFile} = file:read_file(FirstDataDir ++ "/certs/fake-cert"),
|
||||||
|
|
Loading…
Reference in New Issue