aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjuhlig <[email protected]>2019-07-15 10:50:08 +0200
committerLoïc Hoguin <[email protected]>2019-07-16 15:51:23 +0200
commit1a929ead1268aa948c68d52e0b2f6ff88b299929 (patch)
tree2f77d674052c781956415d26a17ca010fff29d0d
parent3f2c087856b55c3ce00991e847ed98057a6e88cd (diff)
downloadranch-1a929ead1268aa948c68d52e0b2f6ff88b299929.tar.gz
ranch-1a929ead1268aa948c68d52e0b2f6ff88b299929.tar.bz2
ranch-1a929ead1268aa948c68d52e0b2f6ff88b299929.zip
Run havoc on embedded listeners
-rw-r--r--test/havoc_SUITE.erl24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/havoc_SUITE.erl b/test/havoc_SUITE.erl
index 86d2a1c..db8969f 100644
--- a/test/havoc_SUITE.erl
+++ b/test/havoc_SUITE.erl
@@ -82,6 +82,30 @@ havoc_ssl(_) ->
ok = do_connect(1, ranch_ssl, ranch:get_port(Name), 1000),
ok = ranch:stop_listener(Name).
+havoc_embedded(_) ->
+ doc("Start an embedded TCP listener, establish a hundred connections, "
+ "run havoc, confirm we can still connect."),
+ %% Start embedded listener.
+ Name = name(),
+ {ok, SupPid} = embedded_sup:start_link(),
+ {ok, _} = embedded_sup:start_listener(SupPid, Name,
+ ranch_tcp, #{}, echo_protocol, []),
+ %% Establish a hundred connections.
+ ok = do_connect(100, ranch_tcp, ranch:get_port(Name), 1000),
+ %% Set restart frequency of ranch_sup and embedded_sup.
+ do_set_sup_frequencies([ranch_sup, SupPid], 999999, 1),
+ %% Run havoc.
+ havoc:on([{avg_wait, 100}, {deviation, 0}, {applications, [ranch]},
+ {supervisors, [SupPid]}, supervisor, {prekill_callback, fun do_log/1}]),
+ timer:sleep(10000),
+ havoc:off(),
+ timer:sleep(1000),
+ %% Confirm we can still connect.
+ ok = do_connect(1, ranch_tcp, ranch:get_port(Name), 1000),
+ ok = embedded_sup:stop_listener(SupPid, Name),
+ embedded_sup:stop(SupPid),
+ ok.
+
do_set_sup_frequencies(Sups, Intensity, Period) ->
StateFun = fun (S) -> setelement(7, setelement(6, S, Intensity), Period) end,
_ = [sys:replace_state(Sup, StateFun) || Sup <- Sups],