Merge pull request #10849 from zhongwencool/licence-conf-update
feat: support emqx_conf:update([license],Conf)
This commit is contained in:
commit
e6049df724
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_license, [
|
||||
{description, "EMQX License"},
|
||||
{vsn, "5.0.10"},
|
||||
{vsn, "5.0.11"},
|
||||
{modules, []},
|
||||
{registered, [emqx_license_sup]},
|
||||
{applications, [kernel, stdlib, emqx_ctl]},
|
||||
|
|
|
@ -122,9 +122,9 @@ do_update({key, Content}, Conf) when is_binary(Content); is_list(Content) ->
|
|||
{error, Reason} ->
|
||||
erlang:throw(Reason)
|
||||
end;
|
||||
%% We don't do extra action when update license's watermark.
|
||||
do_update(_Other, Conf) ->
|
||||
Conf.
|
||||
do_update(NewConf, _PrevConf) ->
|
||||
#{<<"key">> := NewKey} = NewConf,
|
||||
do_update({key, NewKey}, NewConf).
|
||||
|
||||
check_max_clients_exceeded(MaxClients) ->
|
||||
emqx_license_resources:connection_count() > MaxClients * 1.1.
|
||||
|
|
|
@ -24,10 +24,15 @@ end_per_suite(_) ->
|
|||
ok.
|
||||
|
||||
init_per_testcase(_Case, Config) ->
|
||||
ok = persistent_term:put(
|
||||
emqx_license_test_pubkey,
|
||||
emqx_license_test_lib:public_key_pem()
|
||||
),
|
||||
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
|
||||
Config.
|
||||
|
||||
end_per_testcase(_Case, _Config) ->
|
||||
persistent_term:erase(emqx_license_test_pubkey),
|
||||
ok.
|
||||
|
||||
set_special_configs(emqx_license) ->
|
||||
|
@ -53,3 +58,25 @@ t_update(_Config) ->
|
|||
_ = emqx_license_cli:license(["update", LicenseValue]),
|
||||
_ = emqx_license_cli:license(["reload"]),
|
||||
_ = emqx_license_cli:license(["update", "Invalid License Value"]).
|
||||
|
||||
t_conf_update(_Config) ->
|
||||
LicenseKey = emqx_license_test_lib:make_license(#{max_connections => "123"}),
|
||||
Conf = #{
|
||||
<<"connection_high_watermark">> => <<"50%">>,
|
||||
<<"connection_low_watermark">> => <<"45%">>,
|
||||
<<"key">> => LicenseKey
|
||||
},
|
||||
?assertMatch({ok, _}, emqx:update_config([license], Conf)),
|
||||
?assertEqual(
|
||||
#{
|
||||
connection_high_watermark => 0.5,
|
||||
connection_low_watermark => 0.45,
|
||||
key => LicenseKey
|
||||
},
|
||||
emqx:get_config([license])
|
||||
),
|
||||
?assertMatch(
|
||||
#{max_connections := 123},
|
||||
maps:from_list(emqx_license_checker:dump())
|
||||
),
|
||||
ok.
|
||||
|
|
Loading…
Reference in New Issue