aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-21 21:03:06 +0100
committerLoïc Hoguin <[email protected]>2017-10-21 21:03:06 +0100
commitdebaecd49ae3efab4c319f3ec67677c82fe9e9a5 (patch)
treebbe70e44dfc333ea8be4cb0e71d27d39466093fd
parent76f4db863e230638f0c9b018c5bd3586799cd7ba (diff)
downloadcowboy-debaecd49ae3efab4c319f3ec67677c82fe9e9a5.tar.gz
cowboy-debaecd49ae3efab4c319f3ec67677c82fe9e9a5.tar.bz2
cowboy-debaecd49ae3efab4c319f3ec67677c82fe9e9a5.zip
Add a test for stream_reply metrics
-rw-r--r--test/metrics_SUITE.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/metrics_SUITE.erl b/test/metrics_SUITE.erl
index 33b60bd..9ccb1d1 100644
--- a/test/metrics_SUITE.erl
+++ b/test/metrics_SUITE.erl
@@ -68,7 +68,8 @@ init_routes(_) -> [
{"localhost", [
{"/", hello_h, []},
{"/default", default_h, []},
- {"/full/:key", echo_h, []}
+ {"/full/:key", echo_h, []},
+ {"/resp/:key[/:arg]", resp_h, []}
]}
].
@@ -87,9 +88,12 @@ do_metrics_callback() ->
hello_world(Config) ->
doc("Confirm metrics are correct for a normal GET request."),
+ do_get("/", Config).
+
+do_get(Path, Config) ->
%% Perform a GET request.
ConnPid = gun_open(Config),
- Ref = gun:get(ConnPid, "/", [
+ Ref = gun:get(ConnPid, Path, [
{<<"accept-encoding">>, <<"gzip">>},
{<<"x-test-pid">>, pid_to_list(self())}
]),
@@ -119,7 +123,9 @@ hello_world(Config) ->
resp_headers := ExpectedRespHeaders,
resp_body_length := RespBodyLen
} = Metrics,
- ExpectedRespHeaders = maps:from_list(RespHeaders),
+ %% The transfer-encoding header is hidden from stream handlers.
+ ExpectedRespHeaders = maps:remove(<<"transfer-encoding">>,
+ maps:from_list(RespHeaders)),
true = byte_size(RespBody) > 0,
true = RespBodyLen > 0,
%% The request process executed normally.
@@ -300,3 +306,8 @@ do_early_error(Config) ->
after 1000 ->
error(timeout)
end.
+
+%% This test is identical to normal GET except for the handler.
+stream_reply(Config) ->
+ doc("Confirm metrics are correct for long polling."),
+ do_get("/resp/stream_reply2/200", Config).