fix: ct failed
This commit is contained in:
parent
26a57a00bb
commit
6c9b959651
|
@ -306,15 +306,21 @@ put_raw(KeyPath, Config) ->
|
||||||
%%============================================================================
|
%%============================================================================
|
||||||
init_load(SchemaMod) ->
|
init_load(SchemaMod) ->
|
||||||
ConfFiles = application:get_env(emqx, config_files, []),
|
ConfFiles = application:get_env(emqx, config_files, []),
|
||||||
init_load(SchemaMod, ConfFiles).
|
init_load(SchemaMod, ConfFiles, #{raw_with_default => true}).
|
||||||
|
|
||||||
|
init_load(SchemaMod, Opts) when is_map(Opts) ->
|
||||||
|
ConfFiles = application:get_env(emqx, config_files, []),
|
||||||
|
init_load(SchemaMod, ConfFiles, Opts);
|
||||||
|
init_load(SchemaMod, ConfFiles) ->
|
||||||
|
init_load(SchemaMod, ConfFiles, #{raw_with_default => false}).
|
||||||
|
|
||||||
%% @doc Initial load of the given config files.
|
%% @doc Initial load of the given config files.
|
||||||
%% NOTE: The order of the files is significant, configs from files ordered
|
%% NOTE: The order of the files is significant, configs from files ordered
|
||||||
%% in the rear of the list overrides prior values.
|
%% in the rear of the list overrides prior values.
|
||||||
-spec init_load(module(), [string()] | binary() | hocon:config()) -> ok.
|
-spec init_load(module(), [string()] | binary() | hocon:config()) -> ok.
|
||||||
init_load(SchemaMod, Conf) when is_list(Conf) orelse is_binary(Conf) ->
|
init_load(SchemaMod, Conf, Opts) when is_list(Conf) orelse is_binary(Conf) ->
|
||||||
init_load(SchemaMod, parse_hocon(Conf));
|
init_load(SchemaMod, parse_hocon(Conf), Opts);
|
||||||
init_load(SchemaMod, RawConf) when is_map(RawConf) ->
|
init_load(SchemaMod, RawConf, Opts) when is_map(RawConf) ->
|
||||||
ok = save_schema_mod_and_names(SchemaMod),
|
ok = save_schema_mod_and_names(SchemaMod),
|
||||||
%% Merge environment variable overrides on top
|
%% Merge environment variable overrides on top
|
||||||
RawConfWithEnvs = merge_envs(SchemaMod, RawConf),
|
RawConfWithEnvs = merge_envs(SchemaMod, RawConf),
|
||||||
|
@ -323,13 +329,13 @@ init_load(SchemaMod, RawConf) when is_map(RawConf) ->
|
||||||
Overrides = hocon:deep_merge(ClusterOverrides, LocalOverrides),
|
Overrides = hocon:deep_merge(ClusterOverrides, LocalOverrides),
|
||||||
RawConfWithOverrides = hocon:deep_merge(RawConfWithEnvs, Overrides),
|
RawConfWithOverrides = hocon:deep_merge(RawConfWithEnvs, Overrides),
|
||||||
RootNames = get_root_names(),
|
RootNames = get_root_names(),
|
||||||
RawConfAll = raw_conf_with_default(SchemaMod, RootNames, RawConfWithOverrides),
|
RawConfAll = raw_conf_with_default(SchemaMod, RootNames, RawConfWithOverrides, Opts),
|
||||||
%% check configs against the schema
|
%% check configs against the schema
|
||||||
{_AppEnvs, CheckedConf} = check_config(SchemaMod, RawConfAll, #{}),
|
{_AppEnvs, CheckedConf} = check_config(SchemaMod, RawConfAll, #{}),
|
||||||
ok = save_to_config_map(CheckedConf, RawConfAll).
|
ok = save_to_config_map(CheckedConf, RawConfAll).
|
||||||
|
|
||||||
%% keep the raw and non-raw conf has the same keys to make update raw conf easier.
|
%% keep the raw and non-raw conf has the same keys to make update raw conf easier.
|
||||||
raw_conf_with_default(SchemaMod, RootNames, RawConf) ->
|
raw_conf_with_default(SchemaMod, RootNames, RawConf, #{raw_with_default := true}) ->
|
||||||
Fun = fun(Name, Acc) ->
|
Fun = fun(Name, Acc) ->
|
||||||
case maps:is_key(Name, RawConf) of
|
case maps:is_key(Name, RawConf) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -344,7 +350,9 @@ raw_conf_with_default(SchemaMod, RootNames, RawConf) ->
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
RawDefault = lists:foldl(Fun, #{}, RootNames),
|
RawDefault = lists:foldl(Fun, #{}, RootNames),
|
||||||
maps:merge(RawConf, fill_defaults(SchemaMod, RawDefault, #{})).
|
maps:merge(RawConf, fill_defaults(SchemaMod, RawDefault, #{}));
|
||||||
|
raw_conf_with_default(_SchemaMod, _RootNames, RawConf, _Opts) ->
|
||||||
|
RawConf.
|
||||||
|
|
||||||
schema_default(Schema) ->
|
schema_default(Schema) ->
|
||||||
case hocon_schema:field_schema(Schema, type) of
|
case hocon_schema:field_schema(Schema, type) of
|
||||||
|
|
|
@ -99,19 +99,7 @@ init([]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
ok = ekka:monitor(membership),
|
ok = ekka:monitor(membership),
|
||||||
_ = mria:wait_for_tables([?ROUTING_NODE]),
|
_ = mria:wait_for_tables([?ROUTING_NODE]),
|
||||||
%{ok, _} = mnesia:subscribe({table, ?ROUTING_NODE, simple}),
|
{ok, _} = mnesia:subscribe({table, ?ROUTING_NODE, simple}),
|
||||||
%% Temporary fix for debugging:
|
|
||||||
WhereToRead = ets:lookup(mnesia_gvar, {?ROUTING_NODE, where_to_read}),
|
|
||||||
case mnesia:subscribe({table, ?ROUTING_NODE, simple}) of
|
|
||||||
{ok, _} ->
|
|
||||||
ok;
|
|
||||||
Err ->
|
|
||||||
error(#{
|
|
||||||
failed_to_subscribe => Err,
|
|
||||||
where_to_read => WhereToRead,
|
|
||||||
status => mria_rlog:status()
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
Nodes = lists:foldl(
|
Nodes = lists:foldl(
|
||||||
fun(Node, Acc) ->
|
fun(Node, Acc) ->
|
||||||
case ekka:is_member(Node) of
|
case ekka:is_member(Node) of
|
||||||
|
|
|
@ -118,7 +118,7 @@ roots(high) ->
|
||||||
)},
|
)},
|
||||||
{"zones",
|
{"zones",
|
||||||
sc(
|
sc(
|
||||||
map("my_zone_name", ref("zone")),
|
map("name", ref("zone")),
|
||||||
#{desc => ?DESC(zones)}
|
#{desc => ?DESC(zones)}
|
||||||
)},
|
)},
|
||||||
{"mqtt",
|
{"mqtt",
|
||||||
|
@ -703,7 +703,7 @@ fields("conn_congestion") ->
|
||||||
sc(
|
sc(
|
||||||
boolean(),
|
boolean(),
|
||||||
#{
|
#{
|
||||||
default => false,
|
default => true,
|
||||||
desc => ?DESC(conn_congestion_enable_alarm)
|
desc => ?DESC(conn_congestion_enable_alarm)
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
|
@ -744,7 +744,7 @@ fields("listeners") ->
|
||||||
[
|
[
|
||||||
{"tcp",
|
{"tcp",
|
||||||
sc(
|
sc(
|
||||||
map(default, ref("mqtt_tcp_listener")),
|
map(name, ref("mqtt_tcp_listener")),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC(fields_listeners_tcp),
|
desc => ?DESC(fields_listeners_tcp),
|
||||||
required => {false, recursively}
|
required => {false, recursively}
|
||||||
|
@ -752,7 +752,7 @@ fields("listeners") ->
|
||||||
)},
|
)},
|
||||||
{"ssl",
|
{"ssl",
|
||||||
sc(
|
sc(
|
||||||
map(default, ref("mqtt_ssl_listener")),
|
map(name, ref("mqtt_ssl_listener")),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC(fields_listeners_ssl),
|
desc => ?DESC(fields_listeners_ssl),
|
||||||
required => {false, recursively}
|
required => {false, recursively}
|
||||||
|
@ -760,7 +760,7 @@ fields("listeners") ->
|
||||||
)},
|
)},
|
||||||
{"ws",
|
{"ws",
|
||||||
sc(
|
sc(
|
||||||
map(default, ref("mqtt_ws_listener")),
|
map(name, ref("mqtt_ws_listener")),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC(fields_listeners_ws),
|
desc => ?DESC(fields_listeners_ws),
|
||||||
required => {false, recursively}
|
required => {false, recursively}
|
||||||
|
@ -768,7 +768,7 @@ fields("listeners") ->
|
||||||
)},
|
)},
|
||||||
{"wss",
|
{"wss",
|
||||||
sc(
|
sc(
|
||||||
map(default, ref("mqtt_wss_listener")),
|
map(name, ref("mqtt_wss_listener")),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC(fields_listeners_wss),
|
desc => ?DESC(fields_listeners_wss),
|
||||||
required => {false, recursively}
|
required => {false, recursively}
|
||||||
|
@ -776,7 +776,7 @@ fields("listeners") ->
|
||||||
)},
|
)},
|
||||||
{"quic",
|
{"quic",
|
||||||
sc(
|
sc(
|
||||||
map(default, ref("mqtt_quic_listener")),
|
map(name, ref("mqtt_quic_listener")),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC(fields_listeners_quic),
|
desc => ?DESC(fields_listeners_quic),
|
||||||
required => {false, recursively}
|
required => {false, recursively}
|
||||||
|
|
|
@ -104,23 +104,6 @@ init_per_testcase(Case, Config) ->
|
||||||
end_per_testcase(Case, Config) ->
|
end_per_testcase(Case, Config) ->
|
||||||
?MODULE:Case({'end', Config}).
|
?MODULE:Case({'end', Config}).
|
||||||
|
|
||||||
set_special_configs(emqx) ->
|
|
||||||
Quic = #{
|
|
||||||
enabled => true,
|
|
||||||
bind => {{0, 0, 0, 0}, 14567},
|
|
||||||
acceptors => 16,
|
|
||||||
max_connections => 1024000,
|
|
||||||
keyfile => "etc/certs/key.pem",
|
|
||||||
certfile => "etc/certs/cert.pem",
|
|
||||||
mountpoint => <<"">>,
|
|
||||||
zone => default,
|
|
||||||
idle_timeout => 15000
|
|
||||||
},
|
|
||||||
emqx_config:put_listener_conf(quic, default, [], Quic),
|
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% PubSub Test
|
%% PubSub Test
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -435,10 +418,7 @@ t_connected_client_count_persistent(Config) when is_list(Config) ->
|
||||||
{clientid, ClientID}
|
{clientid, ClientID}
|
||||||
| Config
|
| Config
|
||||||
]),
|
]),
|
||||||
{{ok, _}, {ok, [_]}} = wait_for_events(
|
|
||||||
fun() -> emqtt:ConnFun(ConnPid2) end,
|
|
||||||
[emqx_cm_connected_client_count_inc]
|
|
||||||
),
|
|
||||||
{{ok, _}, {ok, [_, _]}} = wait_for_events(
|
{{ok, _}, {ok, [_, _]}} = wait_for_events(
|
||||||
fun() -> emqtt:ConnFun(ConnPid2) end,
|
fun() -> emqtt:ConnFun(ConnPid2) end,
|
||||||
[
|
[
|
||||||
|
|
|
@ -467,7 +467,8 @@ copy_certs(_, _) ->
|
||||||
|
|
||||||
load_config(SchemaModule, Config) ->
|
load_config(SchemaModule, Config) ->
|
||||||
ok = emqx_config:delete_override_conf_files(),
|
ok = emqx_config:delete_override_conf_files(),
|
||||||
ok = emqx_config:init_load(SchemaModule, Config).
|
ok = emqx_config:init_load(SchemaModule, Config),
|
||||||
|
ok.
|
||||||
|
|
||||||
-spec is_tcp_server_available(
|
-spec is_tcp_server_available(
|
||||||
Host :: inet:socket_address() | inet:hostname(),
|
Host :: inet:socket_address() | inet:hostname(),
|
||||||
|
|
|
@ -60,10 +60,20 @@ get_override_config_file() ->
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%% ------------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-ifdef(TEST).
|
||||||
|
init_load() ->
|
||||||
|
emqx_config:init_load(emqx_conf:schema_module(), #{raw_with_default => false}).
|
||||||
|
|
||||||
|
-else.
|
||||||
|
|
||||||
|
init_load() ->
|
||||||
|
emqx_config:init_load(emqx_conf:schema_module(), #{raw_with_default => true}).
|
||||||
|
-endif.
|
||||||
|
|
||||||
init_conf() ->
|
init_conf() ->
|
||||||
{ok, TnxId} = copy_override_conf_from_core_node(),
|
{ok, TnxId} = copy_override_conf_from_core_node(),
|
||||||
emqx_app:set_init_tnx_id(TnxId),
|
emqx_app:set_init_tnx_id(TnxId),
|
||||||
emqx_config:init_load(emqx_conf:schema_module()),
|
init_load(),
|
||||||
emqx_app:set_init_config_load_done().
|
emqx_app:set_init_config_load_done().
|
||||||
|
|
||||||
cluster_nodes() ->
|
cluster_nodes() ->
|
||||||
|
|
|
@ -178,6 +178,7 @@ t_dashboard(_Config) ->
|
||||||
|
|
||||||
{ok, Dashboard1} = get_config("dashboard"),
|
{ok, Dashboard1} = get_config("dashboard"),
|
||||||
?assertNotEqual(Dashboard, Dashboard1),
|
?assertNotEqual(Dashboard, Dashboard1),
|
||||||
|
timer:sleep(1000),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
get_config(Name) ->
|
get_config(Name) ->
|
||||||
|
|
Loading…
Reference in New Issue