feat(olp): bump lc to 0.1.1
This commit is contained in:
parent
8d8969672b
commit
b0c27c74fd
|
@ -9,7 +9,7 @@
|
|||
%% This rebar.config is necessary because the app may be used as a
|
||||
%% `git_subdir` dependency in other projects.
|
||||
{deps,
|
||||
[ {lc, {git, "https://github.com/qzhuyan/lc.git", {tag, "0.1.0"}}}
|
||||
[ {lc, {git, "https://github.com/qzhuyan/lc.git", {tag, "0.1.1"}}}
|
||||
, {gproc, {git, "https://github.com/uwiger/gproc", {tag, "0.8.0"}}}
|
||||
, {typerefl, {git, "https://github.com/k32/typerefl", {tag, "0.8.5"}}}
|
||||
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
%%--------------------------------------------------------------------
|
||||
-module(emqx_olp).
|
||||
|
||||
-include_lib("lc/include/lc.hrl").
|
||||
|
||||
-export([ is_overloaded/0
|
||||
, backoff/1
|
||||
, backoff_gc/1
|
||||
|
@ -100,9 +102,16 @@ off() ->
|
|||
load_ctl:stop_runq_flagman(5000).
|
||||
|
||||
%% @doc turn on backgroud runq check.
|
||||
-spec on() -> {ok, pid()} | {error, running | restarting}.
|
||||
-spec on() -> {ok, pid()} | {error, running | restarting | disabled}.
|
||||
on() ->
|
||||
load_ctl:restart_runq_flagman().
|
||||
case load_ctl:restart_runq_flagman() of
|
||||
{error, disabled} ->
|
||||
OldCfg = load_ctl:get_config(),
|
||||
ok = load_ctl:put_config(OldCfg#{ ?RUNQ_MON_F0 => true }),
|
||||
load_ctl:restart_runq_flagman();
|
||||
Other ->
|
||||
Other
|
||||
end.
|
||||
|
||||
%%% Internals
|
||||
-spec do_check(Zone::atom(), cfg_key(), cnt_name()) -> boolean().
|
||||
|
|
|
@ -35,9 +35,18 @@ end_per_suite(_Config) ->
|
|||
|
||||
init_per_testcase(_, Config) ->
|
||||
emqx_olp:on(),
|
||||
ok = load_ctl:put_config(#{ ?RUNQ_MON_T1 => 200
|
||||
case wait_for(fun() -> lc_sup:whereis_runq_flagman() end, 10) of
|
||||
true -> ok;
|
||||
false ->
|
||||
ct:fail("runq_flagman is not up")
|
||||
end,
|
||||
ok = load_ctl:put_config(#{ ?RUNQ_MON_F0 => true
|
||||
, ?RUNQ_MON_F1 => 5
|
||||
, ?RUNQ_MON_F2 => 1
|
||||
, ?RUNQ_MON_T1 => 200
|
||||
, ?RUNQ_MON_T2 => 50
|
||||
, ?RUNQ_MON_C1 => 3
|
||||
, ?RUNQ_MON_C1 => 2
|
||||
, ?RUNQ_MON_F5 => -1
|
||||
}),
|
||||
Config.
|
||||
|
||||
|
@ -47,15 +56,16 @@ t_off_on(_Config) ->
|
|||
ok = emqx_olp:off(),
|
||||
?assert(not is_process_alive(Old)),
|
||||
{ok, Pid} = emqx_olp:on(),
|
||||
timer:sleep(1000),
|
||||
?assert(is_process_alive(Pid)).
|
||||
|
||||
%% Test that overload detection works
|
||||
t_is_overloaded(_Config) ->
|
||||
P = burst_runq(),
|
||||
timer:sleep(2000),
|
||||
timer:sleep(3000),
|
||||
?assert(emqx_olp:is_overloaded()),
|
||||
exit(P, kill),
|
||||
timer:sleep(2000),
|
||||
timer:sleep(3000),
|
||||
?assert(not emqx_olp:is_overloaded()).
|
||||
|
||||
%% Test that new conn is rejected when olp is enabled
|
||||
|
@ -95,3 +105,14 @@ worker_parent(N, {M, F, A}) ->
|
|||
busy_loop() ->
|
||||
erlang:yield(),
|
||||
busy_loop().
|
||||
|
||||
wait_for(_Fun, 0) ->
|
||||
false;
|
||||
wait_for(Fun, Retry) ->
|
||||
case is_pid(Fun()) of
|
||||
true ->
|
||||
true;
|
||||
false ->
|
||||
timer:sleep(10),
|
||||
wait_for(Fun, Retry - 1)
|
||||
end.
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
{post_hooks,[]}.
|
||||
|
||||
{deps,
|
||||
[ {lc, {git, "https://github.com/qzhuyan/lc.git", {tag, "0.1.0"}}}
|
||||
[ {lc, {git, "https://github.com/qzhuyan/lc.git", {tag, "0.1.1"}}}
|
||||
, {gpb, "4.11.2"} %% gpb only used to build, but not for release, pin it here to avoid fetching a wrong version due to rebar plugins scattered in all the deps
|
||||
, {typerefl, {git, "https://github.com/k32/typerefl", {tag, "0.8.5"}}}
|
||||
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.1.9"}}}
|
||||
|
|
Loading…
Reference in New Issue