diff options
author | Loïc Hoguin <[email protected]> | 2019-10-04 11:57:29 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-10-04 11:57:29 +0200 |
commit | 1a9e62ae2a3b4e39c10c87b5841b460ed81124a9 (patch) | |
tree | 85551da1e89de0ffd4bfb3c4cd683c3b1d228276 /test/metrics_SUITE.erl | |
parent | 28aee1f2720da122f83758b141c503f7bff18ffb (diff) | |
download | cowboy-1a9e62ae2a3b4e39c10c87b5841b460ed81124a9.tar.gz cowboy-1a9e62ae2a3b4e39c10c87b5841b460ed81124a9.tar.bz2 cowboy-1a9e62ae2a3b4e39c10c87b5841b460ed81124a9.zip |
Improve some early_error tests
Diffstat (limited to 'test/metrics_SUITE.erl')
-rw-r--r-- | test/metrics_SUITE.erl | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/test/metrics_SUITE.erl b/test/metrics_SUITE.erl index 971dd16..32f6c43 100644 --- a/test/metrics_SUITE.erl +++ b/test/metrics_SUITE.erl @@ -290,21 +290,20 @@ no_resp_body(Config) -> end. early_error(Config) -> - case config(protocol, Config) of - http -> do_early_error(Config); - http2 -> doc("The callback early_error/5 is not currently used for HTTP/2.") - end. - -do_early_error(Config) -> doc("Confirm metrics are correct for an early_error response."), %% Perform a malformed GET request. ConnPid = gun_open(Config), - Ref = gun:get(ConnPid, "/", [ + %% We must use different solutions to hit early_error with a stream_error + %% reason in both protocols. + {Method, Headers, Status, Error} = case config(protocol, Config) of + http -> {<<"GET">>, [{<<"host">>, <<"host:port">>}], 400, protocol_error}; + http2 -> {<<"TRACE">>, [], 501, no_error} + end, + Ref = gun:request(ConnPid, Method, "/", [ {<<"accept-encoding">>, <<"gzip">>}, - {<<"host">>, <<"host:port">>}, {<<"x-test-pid">>, pid_to_list(self())} - ]), - {response, fin, 400, RespHeaders} = gun:await(ConnPid, Ref), + |Headers], <<>>), + {response, fin, Status, RespHeaders} = gun:await(ConnPid, Ref), gun:close(ConnPid), %% Receive the metrics and validate them. receive @@ -314,9 +313,9 @@ do_early_error(Config) -> ref := _, pid := From, streamid := 1, - reason := {stream_error, protocol_error, _}, + reason := {stream_error, Error, _}, partial_req := #{}, - resp_status := 400, + resp_status := Status, resp_headers := ExpectedRespHeaders, early_error_time := _, resp_body_length := 0 @@ -331,7 +330,7 @@ do_early_error(Config) -> early_error_request_line(Config) -> case config(protocol, Config) of http -> do_early_error_request_line(Config); - http2 -> doc("The callback early_error/5 is not currently used for HTTP/2.") + http2 -> doc("There are no request lines in HTTP/2.") end. do_early_error_request_line(Config) -> |