From c98c045affe053ba37e062e2754f32dcd65a0b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 21 Nov 2022 17:53:29 +0100 Subject: Don't infinite loop gun_pool on bad configuration We leave the pool in a degraded state if the configuration given is invalid and a lookup/connect can't be made. --- test/pool_SUITE.erl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/pool_SUITE.erl b/test/pool_SUITE.erl index 7643368..3105aa6 100644 --- a/test/pool_SUITE.erl +++ b/test/pool_SUITE.erl @@ -376,8 +376,25 @@ reconnect_h2(Config) -> %% @todo reconnect_ws stop_pool(Config) -> - doc("Confirm the pool can be used for HTTP/1.1 connections."), + doc("Confirm the pool can be stopped."), Port = config(port, Config), {ok, ManagerPid} = gun_pool:start_pool("localhost", Port, #{scope => ?FUNCTION_NAME}), gun_pool:await_up(ManagerPid), gun_pool:stop_pool("localhost", Port, #{scope => ?FUNCTION_NAME}). + +degraded_configuration_error(Config) -> + doc("Confirm the pool ends up in a degraded state " + "when connection is impossible because of bad configuration."), + Port = config(port, Config), + %% We attempt to connect to an unreachable IP. + {ok, ManagerPid} = gun_pool:start_pool({20, 20, 20, 1}, Port, #{ + conn_opts => #{tcp_opts => [{ip, {127, 0, 0, 1}}]}, + scope => ?FUNCTION_NAME, + size => 1 + }), + %% Wait for the lookup/connect to fail. + timer:sleep(500), + {degraded, #{conns := Conns}} = gun_pool:info(ManagerPid), + true = Conns =:= #{}, + %% We can stop the pool even if degraded. + gun_pool:stop_pool({20, 20, 20, 1}, Port, #{scope => ?FUNCTION_NAME}). -- cgit v1.2.3