From 9ca5927b88ca93caacc1b724c9fe3e7ca3fc19c3 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Fri, 8 Jul 2022 10:31:47 +0800 Subject: [PATCH] fix: issue in test cases --- apps/emqx/src/emqx_config.erl | 5 ++-- apps/emqx/src/emqx_config_handler.erl | 25 +++---------------- .../emqx_authn_jwks_connector.erl | 2 +- .../test/emqx_authn_enable_flag_SUITE.erl | 19 +++++++------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/apps/emqx/src/emqx_config.erl b/apps/emqx/src/emqx_config.erl index dbc374e3e..3f89e2082 100644 --- a/apps/emqx/src/emqx_config.erl +++ b/apps/emqx/src/emqx_config.erl @@ -508,12 +508,11 @@ get_schema_mod(RootName) -> get_root_names() -> maps:get(names, persistent_term:get(?PERSIS_SCHEMA_MODS, #{names => []})). --spec save_configs(app_envs(), config(), raw_config(), raw_config(), update_opts()) -> - ok | {error, term()}. +-spec save_configs(app_envs(), config(), raw_config(), raw_config(), update_opts()) -> ok. save_configs(_AppEnvs, Conf, RawConf, OverrideConf, Opts) -> %% We first try to save to override.conf, because saving to files is more error prone %% than saving into memory. - save_to_override_conf(OverrideConf, Opts), + ok = save_to_override_conf(OverrideConf, Opts), %% We may need also support hot config update for the apps that use application envs. %% If that is the case uncomment the following line to update the configs to app env %save_to_app_env(_AppEnvs), diff --git a/apps/emqx/src/emqx_config_handler.erl b/apps/emqx/src/emqx_config_handler.erl index fe2b71e27..ad46c1ee3 100644 --- a/apps/emqx/src/emqx_config_handler.erl +++ b/apps/emqx/src/emqx_config_handler.erl @@ -278,22 +278,9 @@ check_and_save_configs( case do_post_config_update(ConfKeyPath, Handlers, OldConf, NewConf, AppEnvs, UpdateArgs, #{}) of {ok, Result0} -> remove_from_local_if_cluster_change(ConfKeyPath, Opts), - case - save_configs( - ConfKeyPath, - AppEnvs, - NewConf, - NewRawConf, - OverrideConf, - UpdateArgs, - Opts - ) - of - {ok, Result1} -> - {ok, Result1#{post_config_update => Result0}}; - Error -> - Error - end; + ok = emqx_config:save_configs(AppEnvs, NewConf, NewRawConf, OverrideConf, Opts), + Result1 = return_change_result(ConfKeyPath, UpdateArgs), + {ok, Result1#{post_config_update => Result0}}; Error -> Error end. @@ -432,12 +419,6 @@ call_post_config_update( ) -> {ok, Result}. -save_configs(ConfKeyPath, AppEnvs, CheckedConf, NewRawConf, OverrideConf, UpdateArgs, Opts) -> - case emqx_config:save_configs(AppEnvs, CheckedConf, NewRawConf, OverrideConf, Opts) of - ok -> {ok, return_change_result(ConfKeyPath, UpdateArgs)}; - {error, Reason} -> {error, {save_configs, Reason}} - end. - %% The default callback of config handlers %% the behaviour is overwriting the old config if: %% 1. the old config is undefined diff --git a/apps/emqx_authn/src/simple_authn/emqx_authn_jwks_connector.erl b/apps/emqx_authn/src/simple_authn/emqx_authn_jwks_connector.erl index add797f2e..8f98e2f1e 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_jwks_connector.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_jwks_connector.erl @@ -79,7 +79,7 @@ on_get_status(_InstId, #{pool_name := PoolName}) -> end end, case emqx_plugin_libs_pool:health_check_ecpool_workers(PoolName, Func) of - true -> connecting; + true -> connected; false -> disconnected end. diff --git a/apps/emqx_authn/test/emqx_authn_enable_flag_SUITE.erl b/apps/emqx_authn/test/emqx_authn_enable_flag_SUITE.erl index 1d10169ae..aa4ab6cf8 100644 --- a/apps/emqx_authn/test/emqx_authn_enable_flag_SUITE.erl +++ b/apps/emqx_authn/test/emqx_authn_enable_flag_SUITE.erl @@ -71,16 +71,17 @@ end_per_testcase(_Case, Config) -> Config. listener_mqtt_tcp_conf(Port, EnableAuthn) -> + PortS = integer_to_binary(Port), #{ - acceptors => 16, - zone => default, - access_rules => ["allow all"], - bind => {{0, 0, 0, 0}, Port}, - max_connections => 1024000, - mountpoint => <<>>, - proxy_protocol => false, - proxy_protocol_timeout => 3000, - enable_authn => EnableAuthn + <<"acceptors">> => 16, + <<"zone">> => <<"default">>, + <<"access_rules">> => ["allow all"], + <<"bind">> => <<"0.0.0.0:", PortS/binary>>, + <<"max_connections">> => 1024000, + <<"mountpoint">> => <<>>, + <<"proxy_protocol">> => false, + <<"proxy_protocol_timeout">> => 3000, + <<"enable_authn">> => EnableAuthn }. t_enable_authn(_Config) ->