Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion test/hackney_conn_http3_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ cleanup(_) ->
%% HTTP/3 Connection Tests
%%====================================================================

%% Live external-server tests (cloudflare over HTTP/3) are opt-in: they depend on
%% the network and intermittently crash the quic h3 library, which destabilizes
%% CI. Set HACKNEY_LIVE_TESTS to run them; the HTTP/3 e2e CT suites
%% (make http3-e2e-test) cover live testing otherwise. parse_headers_test_ below
%% is a pure unit test and stays enabled.
maybe_live(GenFun) ->
case os:getenv("HACKNEY_LIVE_TESTS") of
false -> [];
_ -> GenFun()
end.

%% Test HTTP/3 connection via hackney_conn
http3_conn_test_() ->
http3_conn_test_() -> maybe_live(fun http3_conn_live/0).
http3_conn_live() ->
{
"HTTP/3 connection tests via hackney_conn",
{
Expand Down
25 changes: 20 additions & 5 deletions test/hackney_h3_integration_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,18 @@ get_location(Headers) ->
%% TLS Verification Tests
%%====================================================================

tls_test_() ->
%% Live external-server tests (cloudflare/httpbin over HTTP/3) are opt-in: they
%% depend on the network and intermittently crash the quic h3 library, which
%% destabilizes CI. Set HACKNEY_LIVE_TESTS to run them; the HTTP/3 e2e CT suites
%% (make http3-e2e-test) cover live testing otherwise.
maybe_live(GenFun) ->
case os:getenv("HACKNEY_LIVE_TESTS") of
false -> [];
_ -> GenFun()
end.

tls_test_() -> maybe_live(fun tls_live/0).
tls_live() ->
{
"HTTP/3 TLS verification tests",
{
Expand Down Expand Up @@ -186,7 +197,8 @@ test_connect_with_verify() ->
%% Redirect Tests
%%====================================================================

redirect_test_() ->
redirect_test_() -> maybe_live(fun redirect_live/0).
redirect_live() ->
{
"HTTP/3 redirect handling tests",
{
Expand Down Expand Up @@ -252,7 +264,8 @@ test_redirect_path() ->
%% HTTP Methods Tests
%%====================================================================

methods_test_() ->
methods_test_() -> maybe_live(fun methods_live/0).
methods_live() ->
{
"HTTP/3 method tests",
{
Expand Down Expand Up @@ -344,7 +357,8 @@ test_multiple_requests() ->
%% High-level API Tests
%%====================================================================

high_level_api_test_() ->
high_level_api_test_() -> maybe_live(fun high_level_api_live/0).
high_level_api_live() ->
{
"HTTP/3 high-level API tests",
{
Expand Down Expand Up @@ -391,7 +405,8 @@ test_h3_connect_api() ->
%% Error Handling Tests
%%====================================================================

error_handling_test_() ->
error_handling_test_() -> maybe_live(fun error_handling_live/0).
error_handling_live() ->
{
"HTTP/3 error handling tests",
{
Expand Down
19 changes: 16 additions & 3 deletions test/hackney_http3_integration_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ cleanup(_) ->
%% HTTP/3 Integration Tests
%%====================================================================

http3_integration_test_() ->
%% Live external-server tests (cloudflare/httpbin over HTTP/3) are opt-in: they
%% depend on the network and intermittently crash the quic h3 library, which
%% destabilizes CI. Set HACKNEY_LIVE_TESTS to run them; the HTTP/3 e2e CT suites
%% (make http3-e2e-test) cover live testing otherwise.
maybe_live(GenFun) ->
case os:getenv("HACKNEY_LIVE_TESTS") of
false -> [];
_ -> GenFun()
end.

http3_integration_test_() -> maybe_live(fun http3_integration_live/0).
http3_integration_live() ->
{
"HTTP/3 hackney API integration tests",
{
Expand Down Expand Up @@ -109,7 +120,8 @@ test_altsvc_enables_h3() ->
%% Protocol Selection Tests
%%====================================================================

protocol_selection_test_() ->
protocol_selection_test_() -> maybe_live(fun protocol_selection_live/0).
protocol_selection_live() ->
{
"Protocol selection tests",
{
Expand Down Expand Up @@ -158,7 +170,8 @@ test_blocked_fallback() ->
%% hackney:get with HTTP/3 Tests
%%====================================================================

http3_get_test_() ->
http3_get_test_() -> maybe_live(fun http3_get_live/0).
http3_get_live() ->
{
"HTTP/3 hackney:get tests",
{
Expand Down
19 changes: 16 additions & 3 deletions test/hackney_http3_streaming_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ cleanup(_) ->
%% HTTP/3 Async Streaming Tests
%%====================================================================

h3_async_streaming_test_() ->
%% Live external-server tests (cloudflare over HTTP/3) are opt-in: they depend on
%% the network and intermittently crash the quic h3 library, which destabilizes
%% CI. Set HACKNEY_LIVE_TESTS to run them; the HTTP/3 e2e CT suites
%% (make http3-e2e-test) cover live testing otherwise.
maybe_live(GenFun) ->
case os:getenv("HACKNEY_LIVE_TESTS") of
false -> [];
_ -> GenFun()
end.

h3_async_streaming_test_() -> maybe_live(fun h3_async_streaming_live/0).
h3_async_streaming_live() ->
{
"HTTP/3 async streaming tests",
{
Expand All @@ -50,7 +61,8 @@ h3_async_streaming_test_() ->
%% HTTP/3 Pull-based Streaming Tests (stream_body)
%%====================================================================

h3_stream_body_test_() ->
h3_stream_body_test_() -> maybe_live(fun h3_stream_body_live/0).
h3_stream_body_live() ->
{
"HTTP/3 stream_body tests",
{
Expand Down Expand Up @@ -137,7 +149,8 @@ read_all_chunks(ConnPid, Acc) ->
%% HTTP/3 Body Sending Tests (streaming uploads)
%%====================================================================

h3_send_body_test_() ->
h3_send_body_test_() -> maybe_live(fun h3_send_body_live/0).
h3_send_body_live() ->
{
"HTTP/3 send_body tests",
{
Expand Down
15 changes: 11 additions & 4 deletions test/hackney_pool_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,17 @@ test_checkout_timeout() ->
URL = <<"http://localhost:8123/pool">>,
Headers = [],
hackney_pool:start_pool(pool_test_timeout, [{pool_size, 1}]),
Opts = [{max_body, 2048}, {pool, pool_test_timeout}, {max_per_host, 1},
{connect_timeout, 1000}, {checkout_timeout, 100}],
{ok, Ref} = hackney:request(post, URL, Headers, stream, Opts),
{error, Error} = hackney:request(post, URL, Headers, stream, Opts),
BaseOpts = [{max_body, 2048}, {pool, pool_test_timeout}, {max_per_host, 1},
{connect_timeout, 1000}],
%% The first request must acquire the single per-host slot; give it a
%% generous checkout_timeout so it is not itself raced by a slow connect or
%% transient load-regulation contention on the shared localhost:8123 host
%% (only the second request, which must wait for that slot, uses the tight
%% timeout we are actually asserting on).
{ok, Ref} = hackney:request(post, URL, Headers, stream,
[{checkout_timeout, 5000} | BaseOpts]),
{error, Error} = hackney:request(post, URL, Headers, stream,
[{checkout_timeout, 100} | BaseOpts]),
hackney:close(Ref),
?assertEqual(checkout_timeout, Error),
hackney_pool:stop_pool(pool_test_timeout).
Expand Down
Loading