diff options
author | Loïc Hoguin <[email protected]> | 2019-07-22 16:17:10 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-07-22 16:17:10 +0200 |
commit | 516933f9dd2722329b3886c495d5242308958fe1 (patch) | |
tree | 60b16423184a4db405a65266c326b7944ce42256 /test/gun_SUITE.erl | |
parent | 265ece680c53f77d1685434d0636216c94021497 (diff) | |
download | gun-516933f9dd2722329b3886c495d5242308958fe1.tar.gz gun-516933f9dd2722329b3886c495d5242308958fe1.tar.bz2 gun-516933f9dd2722329b3886c495d5242308958fe1.zip |
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.
Diffstat (limited to 'test/gun_SUITE.erl')
-rw-r--r-- | test/gun_SUITE.erl | 30 |
1 files changed, 21 insertions, 9 deletions
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}]), |