diff --git a/apps/emqx/test/emqx_config_handler_SUITE.erl b/apps/emqx/test/emqx_config_handler_SUITE.erl index f04b8256c..194198571 100644 --- a/apps/emqx/test/emqx_config_handler_SUITE.erl +++ b/apps/emqx/test/emqx_config_handler_SUITE.erl @@ -174,7 +174,7 @@ t_sub_key_update_remove(_Config) -> %% remove ?assertEqual( - {ok, #{post_config_update => #{emqx_config_handler_SUITE => ok}}}, + {ok, #{post_config_update => #{?MODULE => ok}}}, emqx:remove_config(KeyPath) ), ?assertError( @@ -184,18 +184,6 @@ t_sub_key_update_remove(_Config) -> ?assertEqual(false, lists:member(<<"cpu_check_interval">>, OSKey)), ?assert(length(OSKey) > 0), - ?assertEqual( - {ok, #{ - config => 60000, - post_config_update => #{?MODULE => ok}, - raw_config => <<"60s">> - }}, - emqx:reset_config(KeyPath, Opts) - ), - OSKey1 = maps:keys(emqx:get_raw_config([sysmon, os])), - ?assertEqual(true, lists:member(<<"cpu_check_interval">>, OSKey1)), - ?assert(length(OSKey1) > 1), - ok = emqx_config_handler:remove_handler(KeyPath), ok = emqx_config_handler:remove_handler(KeyPath2), ok. @@ -292,44 +280,6 @@ t_get_raw_cluster_override_conf(_Config) -> ?assertEqual(OldInfo, NewInfo), ok. -t_save_config_failed(_Config) -> - ok. - -t_update_sub(_Config) -> - PathKey = [sysmon], - Opts = #{rawconf_with_defaults => true}, - ok = emqx_config_handler:add_handler(PathKey, ?MODULE), - %% update sub key - #{<<"os">> := OS1} = emqx:get_raw_config(PathKey), - {ok, Res} = emqx:update_config(PathKey ++ [os, cpu_check_interval], <<"120s">>, Opts), - ?assertEqual( - #{ - config => 120000, - post_config_update => #{}, - raw_config => <<"120s">> - }, - Res - ), - ?assertMatch(#{os := #{cpu_check_interval := 120000}}, emqx:get_config(PathKey)), - #{<<"os">> := OS2} = emqx:get_raw_config(PathKey), - ?assertEqual(lists:sort(maps:keys(OS1)), lists:sort(maps:keys(OS2))), - - %% update sub key - SubKey = PathKey ++ [os, cpu_high_watermark], - ?assertEqual( - {ok, #{ - config => 0.81, - post_config_update => #{}, - raw_config => <<"81%">> - }}, - emqx:update_config(SubKey, "81%", Opts) - ), - ?assertEqual(0.81, emqx:get_config(SubKey)), - ?assertEqual("81%", emqx:get_raw_config(SubKey)), - - ok = emqx_config_handler:remove_handler(PathKey), - ok. - pre_config_update([sysmon], UpdateReq, _RawConf) -> {ok, UpdateReq}; pre_config_update([sysmon, os], UpdateReq, _RawConf) -> diff --git a/apps/emqx_ft/test/emqx_ft_storage_exporter_s3_SUITE.erl b/apps/emqx_ft/test/emqx_ft_storage_exporter_s3_SUITE.erl index e717fe262..9e6050f36 100644 --- a/apps/emqx_ft/test/emqx_ft_storage_exporter_s3_SUITE.erl +++ b/apps/emqx_ft/test/emqx_ft_storage_exporter_s3_SUITE.erl @@ -110,9 +110,13 @@ t_upload_error(Config) -> Name = "cool_name", Data = <<"data"/utf8>>, - {ok, _} = emqx_conf:update( - [file_transfer, storage, local, exporter, s3, bucket], <<"invalid-bucket">>, #{} + Conf = emqx_conf:get_raw([file_transfer], #{}), + Conf1 = emqx_utils_maps:deep_put( + [<<"storage">>, <<"local">>, <<"exporter">>, <<"s3">>, <<"bucket">>], + Conf, + <<"invalid-bucket">> ), + {ok, _} = emqx_conf:update([file_transfer], Conf1, #{}), ?assertEqual( {error, unspecified_error}, diff --git a/apps/emqx_rule_engine/src/emqx_rule_engine.erl b/apps/emqx_rule_engine/src/emqx_rule_engine.erl index 02e3a60ac..096a33341 100644 --- a/apps/emqx_rule_engine/src/emqx_rule_engine.erl +++ b/apps/emqx_rule_engine/src/emqx_rule_engine.erl @@ -255,11 +255,11 @@ ensure_action_removed(RuleId, ActionName) -> case emqx:get_raw_config([rule_engine, rules, RuleId], not_found) of not_found -> ok; - #{<<"actions">> := Acts} -> + #{<<"actions">> := Acts} = Conf -> NewActs = [AName || AName <- Acts, FilterFunc(AName, ActionName)], {ok, _} = emqx_conf:update( - emqx_rule_engine:config_key_path() ++ [RuleId, actions], - NewActs, + emqx_rule_engine:config_key_path() ++ [RuleId], + Conf#{<<"actions">> => NewActs}, #{override_to => cluster} ), ok @@ -380,7 +380,7 @@ init([]) -> {write_concurrency, true}, {read_concurrency, true} ]), - ok = emqx_config_handler:add_handler( + ok = emqx_conf:add_handler( [rule_engine, jq_implementation_module], emqx_rule_engine_schema ),