mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Add a test for stream_reply metrics
This commit is contained in:
parent
76f4db863e
commit
debaecd49a
1 changed files with 14 additions and 3 deletions
|
@ -68,7 +68,8 @@ init_routes(_) -> [
|
||||||
{"localhost", [
|
{"localhost", [
|
||||||
{"/", hello_h, []},
|
{"/", hello_h, []},
|
||||||
{"/default", default_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) ->
|
hello_world(Config) ->
|
||||||
doc("Confirm metrics are correct for a normal GET request."),
|
doc("Confirm metrics are correct for a normal GET request."),
|
||||||
|
do_get("/", Config).
|
||||||
|
|
||||||
|
do_get(Path, Config) ->
|
||||||
%% Perform a GET request.
|
%% Perform a GET request.
|
||||||
ConnPid = gun_open(Config),
|
ConnPid = gun_open(Config),
|
||||||
Ref = gun:get(ConnPid, "/", [
|
Ref = gun:get(ConnPid, Path, [
|
||||||
{<<"accept-encoding">>, <<"gzip">>},
|
{<<"accept-encoding">>, <<"gzip">>},
|
||||||
{<<"x-test-pid">>, pid_to_list(self())}
|
{<<"x-test-pid">>, pid_to_list(self())}
|
||||||
]),
|
]),
|
||||||
|
@ -119,7 +123,9 @@ hello_world(Config) ->
|
||||||
resp_headers := ExpectedRespHeaders,
|
resp_headers := ExpectedRespHeaders,
|
||||||
resp_body_length := RespBodyLen
|
resp_body_length := RespBodyLen
|
||||||
} = Metrics,
|
} = 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 = byte_size(RespBody) > 0,
|
||||||
true = RespBodyLen > 0,
|
true = RespBodyLen > 0,
|
||||||
%% The request process executed normally.
|
%% The request process executed normally.
|
||||||
|
@ -300,3 +306,8 @@ do_early_error(Config) ->
|
||||||
after 1000 ->
|
after 1000 ->
|
||||||
error(timeout)
|
error(timeout)
|
||||||
end.
|
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).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue