aboutsummaryrefslogtreecommitdiffstats
path: root/test/ws_handler_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-10-10 11:33:35 +0200
committerLoïc Hoguin <[email protected]>2019-10-10 11:33:35 +0200
commitd52e84bdd97b93d7d9cea827de57bd4a0edea9a8 (patch)
tree48958da1fc3bd2b2e3666fc9ee2b545099116d47 /test/ws_handler_SUITE.erl
parentcc54c207e35f3ab7a2dfc105eef39fe7d3bf1633 (diff)
downloadcowboy-d52e84bdd97b93d7d9cea827de57bd4a0edea9a8.tar.gz
cowboy-d52e84bdd97b93d7d9cea827de57bd4a0edea9a8.tar.bz2
cowboy-d52e84bdd97b93d7d9cea827de57bd4a0edea9a8.zip
Add shutdown_reason Websocket command
This allows changing the normal exit reason of Websocket processes, providing a way to signal other processes of why the exit occurred.
Diffstat (limited to 'test/ws_handler_SUITE.erl')
-rw-r--r--test/ws_handler_SUITE.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/ws_handler_SUITE.erl b/test/ws_handler_SUITE.erl
index 67d50d2..872b152 100644
--- a/test/ws_handler_SUITE.erl
+++ b/test/ws_handler_SUITE.erl
@@ -52,7 +52,8 @@ init_dispatch(Name) ->
{"/info", ws_info_commands_h, RunOrHibernate},
{"/active", ws_active_commands_h, RunOrHibernate},
{"/deflate", ws_deflate_commands_h, RunOrHibernate},
- {"/set_options", ws_set_options_commands_h, RunOrHibernate}
+ {"/set_options", ws_set_options_commands_h, RunOrHibernate},
+ {"/shutdown_reason", ws_shutdown_reason_commands_h, RunOrHibernate}
]}]).
%% Support functions for testing using Gun.
@@ -286,3 +287,21 @@ websocket_set_options_idle_timeout(Config) ->
after 2000 ->
error(timeout)
end.
+
+websocket_shutdown_reason(Config) ->
+ doc("The command {shutdown_reason, any()} can be used to "
+ "change the shutdown reason of a Websocket connection."),
+ ConnPid = gun_open(Config),
+ StreamRef = gun:ws_upgrade(ConnPid, "/shutdown_reason", [
+ {<<"x-test-pid">>, pid_to_list(self())}
+ ]),
+ {upgrade, [<<"websocket">>], _} = gun:await(ConnPid, StreamRef),
+ WsPid = receive {ws_pid, P} -> P after 1000 -> error(timeout) end,
+ MRef = monitor(process, WsPid),
+ WsPid ! {self(), {?MODULE, ?FUNCTION_NAME}},
+ receive
+ {'DOWN', MRef, process, WsPid, {shutdown, {?MODULE, ?FUNCTION_NAME}}} ->
+ ok
+ after 1000 ->
+ error(timeout)
+ end.