From 516933f9dd2722329b3886c495d5242308958fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 22 Jul 2019 16:17:10 +0200 Subject: Split domain lookup/connect/TLS handshake and add events This changes the way we connect to servers entirely. We now have three states when connecting (domain_lookup, connect and tls_handshake when applicable) and as a result three corresponding timeout options. Each state has a start/end event associated and the event data was tweaked to best match each event. Since the TLS handshake is separate, the transport_opts option was also split into two: tcp_opts and tls_opts. --- test/gun_SUITE.erl | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'test/gun_SUITE.erl') diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl index 6afaaf5..6a01cf6 100644 --- a/test/gun_SUITE.erl +++ b/test/gun_SUITE.erl @@ -54,18 +54,22 @@ atom_hostname(_) -> connect_timeout(_) -> doc("Ensure an integer value for connect_timeout is accepted."), - {ok, Pid} = gun:open("localhost", 12345, #{connect_timeout => 1000, retry => 0}), - Ref = monitor(process, Pid), - receive - {'DOWN', Ref, process, Pid, {shutdown, _}} -> - ok - after 5000 -> - error(timeout) - end. + do_timeout(connect_timeout, 1000). connect_timeout_infinity(_) -> doc("Ensure infinity for connect_timeout is accepted."), - {ok, Pid} = gun:open("localhost", 12345, #{connect_timeout => infinity, retry => 0}), + do_timeout(connect_timeout, infinity). + +domain_lookup_timeout(_) -> + doc("Ensure an integer value for domain_lookup_timeout is accepted."), + do_timeout(domain_lookup_timeout, 1000). + +domain_lookup_timeout_infinity(_) -> + doc("Ensure infinity for domain_lookup_timeout is accepted."), + do_timeout(domain_lookup_timeout, infinity). + +do_timeout(Opt, Timeout) -> + {ok, Pid} = gun:open("localhost", 12345, #{Opt => Timeout, retry => 0}), Ref = monitor(process, Pid), receive {'DOWN', Ref, process, Pid, {shutdown, _}} -> @@ -496,6 +500,14 @@ supervise_false(_) -> [] = [P || {_, P, _, _} <- supervisor:which_children(gun_sup), P =:= Pid], ok. +tls_handshake_timeout(_) -> + doc("Ensure an integer value for tls_handshake_timeout is accepted."), + do_timeout(tls_handshake_timeout, 1000). + +tls_handshake_timeout_infinity(_) -> + doc("Ensure infinity for tls_handshake_timeout is accepted."), + do_timeout(tls_handshake_timeout, infinity). + transform_header_name(_) -> doc("The transform_header_name option allows changing the case of header names."), {ok, ListenSocket} = gen_tcp:listen(0, [binary, {active, false}]), -- cgit v1.2.3