aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-12-14 14:30:29 +0100
committerSiri Hansen <[email protected]>2019-01-16 09:59:24 +0100
commit72c625bc20a1510a01e7eaa5978f903b45e3e88e (patch)
tree26e1aeb4a5e39b1147cac6b79e3693a0303ce99c /lib/kernel
parent6211cead7be6f0871cfcccccdfc00dbeb466bcf2 (diff)
downloadotp-72c625bc20a1510a01e7eaa5978f903b45e3e88e.tar.gz
otp-72c625bc20a1510a01e7eaa5978f903b45e3e88e.tar.bz2
otp-72c625bc20a1510a01e7eaa5978f903b45e3e88e.zip
[logger] Add test for restart of logger proxy
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/test/logger_proxy_SUITE.erl57
1 files changed, 56 insertions, 1 deletions
diff --git a/lib/kernel/test/logger_proxy_SUITE.erl b/lib/kernel/test/logger_proxy_SUITE.erl
index 2a76eec0fd..ea3733dae7 100644
--- a/lib/kernel/test/logger_proxy_SUITE.erl
+++ b/lib/kernel/test/logger_proxy_SUITE.erl
@@ -73,7 +73,9 @@ all() ->
emulator,
remote,
remote_emulator,
- config].
+ config,
+ restart_after,
+ terminate].
%%%-----------------------------------------------------------------
%%% Test cases
@@ -173,9 +175,62 @@ config(_Config) ->
config(cleanup,_Config) ->
ok.
+restart_after(Config) ->
+ Restart = 3000,
+ ok = logger:update_proxy_config(#{overload_kill_enable => true,
+ overload_kill_qlen => 10,
+ overload_kill_restart_after => Restart}),
+ Proxy = whereis(logger_proxy),
+ Proxy = erlang:system_info(system_logger),
+ Ref = erlang:monitor(process,Proxy),
+ spawn(fun() ->
+ [logger_proxy ! {log,debug,
+ [{test_case,?FUNCTION_NAME},
+ {line,?LINE}],
+ L2=?LOC} || _ <- lists:seq(1,100)]
+ end),
+ receive
+ {'DOWN',Ref,_,_,_Reason} ->
+ undefined = erlang:system_info(system_logger),
+ timer:sleep(Restart),
+ poll_restarted(10)
+ after 5000 ->
+ ct:fail(proxy_not_terminated)
+ end,
+ ok.
+
+%% Test that system_logger flag is set to logger process if
+%% logger_proxy terminates for other reason than overloaded.
+terminate(Config) ->
+ Logger = whereis(logger),
+ Proxy = whereis(logger_proxy),
+ Proxy = erlang:system_info(system_logger),
+ Ref = erlang:monitor(process,Proxy),
+ ok = logger_olp:stop(Proxy),
+ receive
+ {'DOWN',Ref,_,_,_Reason} ->
+ Logger = erlang:system_info(system_logger),
+ logger_proxy:restart(),
+ poll_restarted(10)
+ after 5000 ->
+ ct:fail(proxy_not_terminated)
+ end,
+ ok.
+
%%%-----------------------------------------------------------------
%%% Internal functions
+poll_restarted(0) ->
+ ct:fail(proxy_not_restarted);
+poll_restarted(N) ->
+ timer:sleep(1000),
+ case whereis(logger_proxy) of
+ undefined ->
+ poll_restarted(N-1);
+ Pid ->
+ ok
+ end.
+
%% Logger handler callback
log(#{meta:=Meta},#{config:=Pid}) ->
Pid ! {logged,Meta}.