Browse Source

Log imminent kills from havoc suite

juhlig 6 years ago
parent
commit
3a8986a63f
1 changed files with 11 additions and 6 deletions
  1. 11 6
      test/havoc_SUITE.erl

+ 11 - 6
test/havoc_SUITE.erl

@@ -29,14 +29,12 @@ init_per_suite(Config) ->
 	ok = application:start(havoc),
 	ok = application:start(havoc),
 	%% Comment to hide progress reports in the terminal.
 	%% Comment to hide progress reports in the terminal.
 	application:set_env(kernel, logger_sasl_compatible, true),
 	application:set_env(kernel, logger_sasl_compatible, true),
-	ok = application:start(sasl),
 	%% Enable logging of progress reports.
 	%% Enable logging of progress reports.
 	%% They will only be available in the HTML reports by default.
 	%% They will only be available in the HTML reports by default.
 	ok = logger:set_primary_config(level, info),
 	ok = logger:set_primary_config(level, info),
 	Config.
 	Config.
 
 
 end_per_suite(_) ->
 end_per_suite(_) ->
-	ok = application:stop(sasl),
 	ok = application:stop(havoc),
 	ok = application:stop(havoc),
 	ok = application:stop(ranch).
 	ok = application:stop(ranch).
 
 
@@ -50,17 +48,24 @@ havoc_tcp(_) ->
 	{ok, _} = ranch:start_listener(Name,
 	{ok, _} = ranch:start_listener(Name,
 		ranch_tcp, #{},
 		ranch_tcp, #{},
 		echo_protocol, []),
 		echo_protocol, []),
-	Port = ranch:get_port(Name),
+	Port1 = ranch:get_port(Name),
 	%% Establish a hundred connections.
 	%% Establish a hundred connections.
 	_ = [begin
 	_ = [begin
-		{ok, Socket} = gen_tcp:connect("localhost", Port, [{active, false}]),
+		{ok, Socket} = gen_tcp:connect("localhost", Port1, [{active, false}]),
 		Socket
 		Socket
 	end || _ <- lists:seq(1, 100)],
 	end || _ <- lists:seq(1, 100)],
 	%% Run Havoc.
 	%% Run Havoc.
-	havoc:on([{applications, [ranch]}]),
+	LogFun = fun
+		(Pid) when is_pid(Pid) ->
+			logger:info("~p~n", [erlang:process_info(Pid)]);
+		(Port) when is_port(Port) ->
+			logger:info("~p~n", [erlang:port_info(Port)])
+	end,
+	havoc:on([{applications, [ranch]}, {prekill_callback, LogFun}]),
 	timer:sleep(60000),
 	timer:sleep(60000),
 	havoc:off(),
 	havoc:off(),
 	timer:sleep(1000),
 	timer:sleep(1000),
 	%% Confirm we can still connect.
 	%% Confirm we can still connect.
-	{ok, _} = gen_tcp:connect("localhost", Port, [{active, false}]),
+	Port2 = ranch:get_port(Name),
+	{ok, _} = gen_tcp:connect("localhost", Port2, [{active, false}]),
 	ok = ranch:stop_listener(Name).
 	ok = ranch:stop_listener(Name).