aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-04-17 13:36:51 +0200
committerLoïc Hoguin <[email protected]>2011-04-17 13:36:51 +0200
commit734f57aa8a79a942767d0707a053dbee6caa1290 (patch)
tree86077f46863882872a8a35de384331e0673c67e0
parent8f818d79dfe22af8a4a557c1e8676463224b9c22 (diff)
downloadcowboy-734f57aa8a79a942767d0707a053dbee6caa1290.tar.gz
cowboy-734f57aa8a79a942767d0707a053dbee6caa1290.tar.bz2
cowboy-734f57aa8a79a942767d0707a053dbee6caa1290.zip
ct: Throw garbage at the server then check if it's still up.
Basically: cat /dev/urandom | nc host port Only run this test if cat and nc are available.
-rw-r--r--test/http_SUITE.erl23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index da43536..6807f78 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -18,7 +18,7 @@
-export([all/0, groups/0, init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2]). %% ct.
--export([headers_dupe/1, pipeline/1, raw/1]). %% http.
+-export([headers_dupe/1, nc_rand/1, pipeline/1, raw/1]). %% http.
-export([http_200/1, http_404/1, websocket/1]). %% http and https.
%% ct.
@@ -28,7 +28,7 @@ all() ->
groups() ->
BaseTests = [http_200, http_404],
- [{http, [], [headers_dupe, pipeline, raw, websocket] ++ BaseTests},
+ [{http, [], [headers_dupe, nc_rand, pipeline, raw, websocket] ++ BaseTests},
{https, [], BaseTests}].
init_per_suite(Config) ->
@@ -100,6 +100,25 @@ headers_dupe(Config) ->
nomatch = binary:match(Data, <<"Connection: keep-alive">>),
ok = gen_tcp:close(Socket).
+nc_rand(Config) ->
+ Cat = os:find_executable("cat"),
+ Nc = os:find_executable("nc"),
+ case {Cat, Nc} of
+ {false, _} ->
+ {skip, {notfound, cat}};
+ {_, false} ->
+ {skip, {notfound, nc}};
+ _Good ->
+ %% Throw garbage at the server then check if it's still up.
+ {port, Port} = lists:keyfind(port, 1, Config),
+ [nc_rand_run(Port) || _N <- lists:seq(1, 100)],
+ Packet = "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n",
+ {Packet, 200} = raw_req(Packet, Config)
+ end.
+
+nc_rand_run(Port) ->
+ os:cmd("cat /dev/urandom | nc localhost " ++ integer_to_list(Port)).
+
pipeline(Config) ->
{port, Port} = lists:keyfind(port, 1, Config),
{ok, Socket} = gen_tcp:connect("localhost", Port,