aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Uhlig <[email protected]>2022-01-13 10:57:03 +0100
committerLoïc Hoguin <[email protected]>2022-04-28 18:02:20 +0200
commit6d752383bec3d8c543aea0220b5a8cb28dab7852 (patch)
tree1f465254ba82a41a4285214daaccfa7409fe9164
parentfa6c24a65e0e1482ce52dd1f0e08a39ad85b6c82 (diff)
downloadranch-6d752383bec3d8c543aea0220b5a8cb28dab7852.tar.gz
ranch-6d752383bec3d8c543aea0220b5a8cb28dab7852.tar.bz2
ranch-6d752383bec3d8c543aea0220b5a8cb28dab7852.zip
Fix upgrade suite for 2.1
-rw-r--r--src/ranch_conns_sup.erl19
-rw-r--r--test/upgrade_SUITE.erl48
2 files changed, 12 insertions, 55 deletions
diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl
index 649f856..6e6de00 100644
--- a/src/ranch_conns_sup.erl
+++ b/src/ranch_conns_sup.erl
@@ -471,25 +471,6 @@ system_terminate(Reason, _, _, {State, _, NbChildren, _}) ->
terminate(State, Reason, NbChildren).
-spec system_code_change(any(), _, _, _) -> {ok, any()}.
-system_code_change({#state{parent=Parent, ref=Ref, conn_type=ConnType,
- shutdown=Shutdown, transport=Transport, protocol=Protocol,
- opts=Opts, handshake_timeout=HandshakeTimeout,
- max_conns=MaxConns, logger=Logger}, CurConns, NbChildren,
- Sleepers}, _, {down, _}, _) ->
- {ok, {{state, Parent, Ref, ConnType, Shutdown, Transport, Protocol,
- Opts, HandshakeTimeout, MaxConns, Logger}, CurConns, NbChildren,
- Sleepers}};
-system_code_change({{state, Parent, Ref, ConnType, Shutdown, Transport, Protocol,
- Opts, HandshakeTimeout, MaxConns, Logger}, CurConns, NbChildren,
- Sleepers}, _, _, _) ->
- Self = self(),
- [Id] = [Id || {Id, Pid} <- ranch_server:get_connections_sups(Ref), Pid=:=Self],
- StatsCounters = ranch_server:get_stats_counters(Ref),
- {ok, {#state{parent=Parent, ref=Ref, id=Id, conn_type=ConnType, shutdown=Shutdown,
- transport=Transport, protocol=Protocol, opts=Opts,
- handshake_timeout=HandshakeTimeout, max_conns=MaxConns,
- stats_counters_ref=StatsCounters,
- logger=Logger}, CurConns, NbChildren, Sleepers}};
system_code_change(Misc, _, _, _) ->
{ok, Misc}.
diff --git a/test/upgrade_SUITE.erl b/test/upgrade_SUITE.erl
index 8e14bcc..0e3b757 100644
--- a/test/upgrade_SUITE.erl
+++ b/test/upgrade_SUITE.erl
@@ -193,57 +193,33 @@ upgrade_ranch_one_conn(_) ->
do_upgrade_ranch_one_conn() ->
Example = tcp_echo,
- ExampleStr = atom_to_list(Example),
+% ExampleStr = atom_to_list(Example),
Port = 5555,
- {_, Rel, _} = do_get_paths(Example),
+% {_, Rel, _} = do_get_paths(Example),
try
%% Copy the example.
do_copy(Example),
%% Build and start the example release using the previous Ranch version.
CommitOrTag = do_use_ranch_previous(Example),
do_compile_and_start(Example),
- %% Ensure that the metrics key is not present in the ranch:info output.
- "false\n" = do_exec_log(Rel ++ " eval "
- "'maps:is_key(metrics, ranch:info(" ++ ExampleStr ++ "))'"),
%% Establish a connection and check that it works.
- {ok, S} = gen_tcp:connect("localhost", Port, [{active, false}, binary]),
- ok = gen_tcp:send(S, "Hello!"),
- {ok, <<"Hello!">>} = gen_tcp:recv(S, 0, 1000),
+ {ok, S1} = gen_tcp:connect("localhost", Port, [{active, false}, binary]),
+ ok = gen_tcp:send(S1, "Hello!"),
+ {ok, <<"Hello!">>} = gen_tcp:recv(S1, 0, 1000),
%% Update Ranch to master then build a release upgrade.
do_build_relup(Example, CommitOrTag),
%% Perform the upgrade, then check that our connection is still up.
do_upgrade(Example),
- %% Ensure that the mextrics key is present in the ranch:info output.
- "true\n" = do_exec_log(Rel ++ " eval "
- "'maps:is_key(metrics, ranch:info(" ++ ExampleStr ++ "))'"),
- ok = gen_tcp:send(S, "Hello!"),
- {ok, <<"Hello!">>} = gen_tcp:recv(S, 0, 1000),
- %% Ensure that no accepts have been counted yet.
- "0\n" = do_exec_log(Rel ++ " eval "
- "'lists:sum([N || {{conns_sup, _, accept}, N} <- "
- "maps:to_list(maps:get(metrics, ranch:info(" ++ ExampleStr ++ ")))])'"),
+ ok = gen_tcp:send(S1, "Hello!"),
+ {ok, <<"Hello!">>} = gen_tcp:recv(S1, 0, 1000),
%% Check that new connections are still accepted.
{ok, S2} = gen_tcp:connect("localhost", Port, [{active, false}, binary]),
- %% Ensure that the accept has been counted.
- "1\n" = do_exec_log(Rel ++ " eval "
- "'lists:sum([N || {{conns_sup, _, accept}, N} <- "
- "maps:to_list(maps:get(metrics, ranch:info(" ++ ExampleStr ++ ")))])'"),
- %% Ensure that no terminates have been counted yet.
- "0\n" = do_exec_log(Rel ++ " eval "
- "'lists:sum([N || {{conns_sup, _, terminate}, N} <- "
- "maps:to_list(maps:get(metrics, ranch:info(" ++ ExampleStr ++ ")))])'"),
- %% Close the socket, ensure that the termination has been counted.
- ok = gen_tcp:close(S2),
- "1\n" = do_exec_log(Rel ++ " eval "
- "'lists:sum([N || {{conns_sup, _, terminate}, N} <- "
- "maps:to_list(maps:get(metrics, ranch:info(" ++ ExampleStr ++ ")))])'"),
- %% Perform the downgrade, then check that our connection is still up.
+ %% Perform the downgrade, then check that our connections are still up.
do_downgrade(Example),
- %% Ensure that the mextrics key is not present any more.
- "false\n" = do_exec_log(Rel ++ " eval "
- "'maps:is_key(metrics, ranch:info(" ++ ExampleStr ++ "))'"),
- ok = gen_tcp:send(S, "Hello!"),
- {ok, <<"Hello!">>} = gen_tcp:recv(S, 0, 1000),
+ ok = gen_tcp:send(S1, "Hello!"),
+ {ok, <<"Hello!">>} = gen_tcp:recv(S1, 0, 1000),
+ ok = gen_tcp:send(S2, "Hello!"),
+ {ok, <<"Hello!">>} = gen_tcp:recv(S2, 0, 1000),
%% Check that new connections are still accepted.
{ok, _} = gen_tcp:connect("localhost", Port, [{active, false}, binary]),
ok