aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-02-07 12:05:32 +0100
committerMicael Karlberg <[email protected]>2019-02-22 19:45:52 +0100
commit8aa6b2ca02b6f08fd66178209317fa5ac658a88a (patch)
tree41e4ff9b2d944e630e12ca680fb6208b25ede50e
parente4156fe240367b4ccad36277ff05d97ac0cb2a32 (diff)
downloadotp-8aa6b2ca02b6f08fd66178209317fa5ac658a88a.tar.gz
otp-8aa6b2ca02b6f08fd66178209317fa5ac658a88a.tar.bz2
otp-8aa6b2ca02b6f08fd66178209317fa5ac658a88a.zip
[socket|test] Some improvements to (esock) ttest
Add a quiet mode for ttest which is used when running in a (terminal) shell. Moved the esock-ttest script(s) into their own directory. Minor improvements to the (client) result printout. Also fixed copyright (end) dates. OTP-14831
-rw-r--r--erts/emulator/test/esock_ttest/.gitignore0
-rwxr-xr-xerts/emulator/test/esock_ttest/esock-ttest (renamed from erts/emulator/test/esock-ttest)8
-rwxr-xr-xerts/emulator/test/esock_ttest/esock-ttest-client72
-rwxr-xr-xerts/emulator/test/esock_ttest/esock-ttest-server-gen32
-rwxr-xr-xerts/emulator/test/esock_ttest/esock-ttest-server-sock32
-rw-r--r--erts/emulator/test/socket_test_ttest_lib.erl4
-rw-r--r--erts/emulator/test/socket_test_ttest_tcp_client.erl103
-rw-r--r--erts/emulator/test/socket_test_ttest_tcp_client_gen.erl13
-rw-r--r--erts/emulator/test/socket_test_ttest_tcp_client_socket.erl13
9 files changed, 219 insertions, 58 deletions
diff --git a/erts/emulator/test/esock_ttest/.gitignore b/erts/emulator/test/esock_ttest/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/erts/emulator/test/esock_ttest/.gitignore
diff --git a/erts/emulator/test/esock-ttest b/erts/emulator/test/esock_ttest/esock-ttest
index 418b19eec1..f0d363ab30 100755
--- a/erts/emulator/test/esock-ttest
+++ b/erts/emulator/test/esock_ttest/esock-ttest
@@ -3,7 +3,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -289,7 +289,8 @@ exec(#{role := client,
msg_id := MsgID,
max_outstanding := MaxOutstanding,
runtime := RunTime}) ->
- case socket_test_ttest_tcp_client_gen:start(Active,
+ case socket_test_ttest_tcp_client_gen:start(true,
+ Active,
Addr, Port,
MsgID, MaxOutstanding,
RunTime) of
@@ -311,7 +312,8 @@ exec(#{role := client,
msg_id := MsgID,
max_outstanding := MaxOutstanding,
runtime := RunTime}) ->
- case socket_test_ttest_tcp_client_socket:start(Method,
+ case socket_test_ttest_tcp_client_socket:start(true,
+ Method,
Active,
Addr, Port,
MsgID, MaxOutstanding,
diff --git a/erts/emulator/test/esock_ttest/esock-ttest-client b/erts/emulator/test/esock_ttest/esock-ttest-client
new file mode 100755
index 0000000000..1ab56f2d44
--- /dev/null
+++ b/erts/emulator/test/esock_ttest/esock-ttest-client
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2019-2019. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# %CopyrightEnd%
+#
+
+EMU=$ERL_TOP/erts/emulator
+EMU_TEST=$EMU/test
+ESOCK_TTEST=$EMU_TEST/esock_ttest
+
+RUNTIME=30
+
+MSGID=$1
+SERVER_ADDR=$2
+SERVER_PORT=$3
+
+# ---------------------------------------------------------------------------
+
+ITERATIONS="\
+ gen false $MSGID
+ gen true $MSGID
+ gen once $MSGID
+ sock false $MSGID
+ sock true $MSGID
+ sock once $MSGID"
+
+# gen false 2
+# gen true 2
+# gen once 2
+# sock false 2
+# sock true 2
+# sock once 2
+# gen false 3
+# gen true 3
+# gen once 3
+# sock false 3
+# sock true 3
+# sock once 3
+#
+
+# ---------------------------------------------------------------------------
+
+echo "$ITERATIONS" |
+ while read TRANSPORT ACTIVE MSG_ID; do
+
+ echo ""
+ echo "=========== transport = $TRANSPORT, active = $ACTIVE, msg-id = $MSG_ID ==========="
+ # The /dev/null at the end is necessary because erlang "does things" with stdin
+ # and this case would cause the 'while read' to "fail" so that we only would
+ # loop one time
+ $ESOCK_TTEST/esock-ttest --client --transport $TRANSPORT --active $ACTIVE --msg-id $MSG_ID --scon $SERVER_ADDR:$SERVER_PORT --runtime $RUNTIME </dev/null
+ echo ""
+
+ done
+
+
diff --git a/erts/emulator/test/esock_ttest/esock-ttest-server-gen b/erts/emulator/test/esock_ttest/esock-ttest-server-gen
new file mode 100755
index 0000000000..c29184772e
--- /dev/null
+++ b/erts/emulator/test/esock_ttest/esock-ttest-server-gen
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2019-2019. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# %CopyrightEnd%
+#
+
+EMU=$ERL_TOP/erts/emulator
+EMU_TEST=$EMU/test
+ESOCK_TTEST=$EMU_TEST/esock_ttest
+
+if [ $# = 1 ]; then
+ ACTIVE="--active $1"
+fi
+
+$ESOCK_TTEST/esock-ttest --server --transport gen $ACTIVE
+
diff --git a/erts/emulator/test/esock_ttest/esock-ttest-server-sock b/erts/emulator/test/esock_ttest/esock-ttest-server-sock
new file mode 100755
index 0000000000..4ec0d335d9
--- /dev/null
+++ b/erts/emulator/test/esock_ttest/esock-ttest-server-sock
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2019-2019. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# %CopyrightEnd%
+#
+
+EMU=$ERL_TOP/erts/emulator
+EMU_TEST=$EMU/test
+ESOCK_TTEST=$EMU_TEST/esock_ttest
+
+if [ $# = 1 ]; then
+ ACTIVE="--active $1"
+fi
+
+$ESOCK_TTEST/esock-ttest --server --transport sock $ACTIVE
+
diff --git a/erts/emulator/test/socket_test_ttest_lib.erl b/erts/emulator/test/socket_test_ttest_lib.erl
index 71679bc6d6..7fc13df46a 100644
--- a/erts/emulator/test/socket_test_ttest_lib.erl
+++ b/erts/emulator/test/socket_test_ttest_lib.erl
@@ -56,8 +56,10 @@ format_timestamp({_N1, _N2, N3} = TS) ->
%% Time is always in number os ms (milli seconds)
%% At some point, we should convert this to a more readable format...
+format_time(T) when (T < 1000) ->
+ format("~w ms", [T]);
format_time(T) ->
- format("~p", [T]).
+ format("~w sec (~w ms)", [T div 1000, T]).
formated_process_stats(Pid) ->
diff --git a/erts/emulator/test/socket_test_ttest_tcp_client.erl b/erts/emulator/test/socket_test_ttest_tcp_client.erl
index bf34a8c2ab..5efa3fe491 100644
--- a/erts/emulator/test/socket_test_ttest_tcp_client.erl
+++ b/erts/emulator/test/socket_test_ttest_tcp_client.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -45,13 +45,13 @@
start_monitor/6, start_monitor/7, start_monitor/9,
%% These are for starting in a shell when run "manually"
- start/4, start/5, start/7,
+ start/4, start/5, start/7, start/8,
stop/1
]).
%% Internal exports
-export([
- do_start/9
+ do_start/10
]).
-include_lib("kernel/include/inet.hrl").
@@ -96,17 +96,8 @@ start_monitor(Node, Notify, Transport, Active, Addr, Port, 3 = MsgID) ->
start_monitor(Node, Notify, Transport, Active, Addr, Port,
MsgID, MaxOutstanding, RunTime)
when (Node =/= node()) ->
- %% ?I("start_monitor -> entry with"
- %% "~n Node: ~p"
- %% "~n Transport: ~p"
- %% "~n Active: ~p"
- %% "~n Addr: ~p"
- %% "~n Port: ~p"
- %% "~n MsgID: ~p"
- %% "~n MaxOutstanding: ~p"
- %% "~n RunTime: ~p",
- %% [Node, Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime]),
- Args = [self(), Notify,
+ Args = [false,
+ self(), Notify,
Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime],
case rpc:call(Node, ?MODULE, do_start, Args) of
{badrpc, _} = Reason ->
@@ -119,7 +110,8 @@ start_monitor(Node, Notify, Transport, Active, Addr, Port,
end;
start_monitor(_, Notify, Transport, Active, Addr, Port,
MsgID, MaxOutstanding, RunTime) ->
- case do_start(self(), Notify,
+ case do_start(false,
+ self(), Notify,
Transport, Active, Addr, Port,
MsgID, MaxOutstanding, RunTime) of
{ok, Pid} ->
@@ -134,22 +126,31 @@ start(Transport, Active, Addr, Port) ->
start(Transport, Active, Addr, Port, ?MSG_ID_DEFAULT).
start(Transport, Active, Addr, Port, 1 = MsgID) ->
- start(Transport, Active, Addr, Port, MsgID,
+ start(false,
+ Transport, Active, Addr, Port, MsgID,
?MAX_OUTSTANDING_DEFAULT_1, ?RUNTIME_DEFAULT);
start(Transport, Active, Addr, Port, 2 = MsgID) ->
- start(Transport, Active, Addr, Port, MsgID,
+ start(false,
+ Transport, Active, Addr, Port, MsgID,
?MAX_OUTSTANDING_DEFAULT_2, ?RUNTIME_DEFAULT);
start(Transport, Active, Addr, Port, 3 = MsgID) ->
- start(Transport, Active, Addr, Port, MsgID,
+ start(false,
+ Transport, Active, Addr, Port, MsgID,
?MAX_OUTSTANDING_DEFAULT_3, ?RUNTIME_DEFAULT).
start(Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
+ start(false,
+ Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime).
+
+start(Quiet, Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
Notify = fun(R) -> present_results(R) end,
- do_start(self(), Notify,
+ do_start(Quiet,
+ self(), Notify,
Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime).
--spec do_start(Parent,
+-spec do_start(Quiet,
+ Parent,
Notify,
Transport,
Active,
@@ -158,6 +159,7 @@ start(Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
MsgID,
MaxOutstanding,
RunTime) -> {ok, Pid} | {error, Reason} when
+ Quiet :: pid(),
Parent :: pid(),
Notify :: function(),
Transport :: atom() | tuple(),
@@ -170,9 +172,11 @@ start(Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
Pid :: pid(),
Reason :: term().
-do_start(Parent, Notify,
+do_start(Quiet,
+ Parent, Notify,
Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime)
- when is_pid(Parent) andalso
+ when is_boolean(Quiet) andalso
+ is_pid(Parent) andalso
is_function(Notify) andalso
(is_atom(Transport) orelse is_tuple(Transport)) andalso
(is_boolean(Active) orelse (Active =:= once)) andalso
@@ -181,19 +185,10 @@ do_start(Parent, Notify,
(is_integer(MsgID) andalso (MsgID >= 1) andalso (MsgID =< 3)) andalso
(is_integer(MaxOutstanding) andalso (MaxOutstanding > 0)) andalso
(is_integer(RunTime) andalso (RunTime > 0)) ->
- %% ?I("do_start -> entry with"
- %% "~n Parent: ~p"
- %% "~n Transport: ~p"
- %% "~n Active: ~p"
- %% "~n Addr: ~p"
- %% "~n Port: ~p"
- %% "~n MsgID: ~p"
- %% "~n MaxOutstanding: ~p"
- %% "~n RunTime: ~p",
- %% [Parent, Transport, Active, Addr, Port, MsgID, MaxOutstanding, RunTime]),
Starter = self(),
Init = fun() -> put(sname, "client"),
- init(Starter,
+ init(Quiet,
+ Starter,
Parent,
Notify,
Transport, Active, Addr, Port,
@@ -219,27 +214,36 @@ stop(Pid) when is_pid(Pid) ->
%% ==========================================================================
-init(Starter,
+init(Quiet,
+ Starter,
Parent, Notify,
Transport, Active, Addr, Port,
MsgID, MaxOutstanding, RunTime) ->
- ?I("init with"
- "~n Transport: ~p"
- "~n Active: ~p"
- "~n Addr: ~s"
- "~n Port: ~p"
- "~n Msg ID: ~p (=> 16 + ~w bytes)"
- "~n Max Outstanding: ~p"
- "~n (Suggested) Run Time: ~p ms",
- [Transport, Active, inet:ntoa(Addr), Port,
- MsgID, size(which_msg_data(MsgID)), MaxOutstanding, RunTime]),
+ if
+ not Quiet ->
+ ?I("init with"
+ "~n Transport: ~p"
+ "~n Active: ~p"
+ "~n Addr: ~s"
+ "~n Port: ~p"
+ "~n Msg ID: ~p (=> 16 + ~w bytes)"
+ "~n Max Outstanding: ~p"
+ "~n (Suggested) Run Time: ~p ms",
+ [Transport, Active, inet:ntoa(Addr), Port,
+ MsgID, size(which_msg_data(MsgID)), MaxOutstanding, RunTime]);
+ true ->
+ ok
+ end,
{Mod, Connect} = process_transport(Transport),
case Connect(Addr, Port) of
{ok, Sock} ->
- ?I("connected"),
+ if not Quiet -> ?I("connected");
+ true -> ok
+ end,
Starter ! {?MODULE, self(), ok},
initial_activation(Mod, Sock, Active),
- Results = loop(#{slogan => run,
+ Results = loop(#{quiet => Quiet,
+ slogan => run,
runtime => RunTime,
start => ?T(),
parent => Parent,
@@ -559,10 +563,13 @@ process_acc_data(_ID, _Data) ->
ok.
-handle_message(#{parent := Parent, sock := Sock, scnt := SCnt} = State) ->
+handle_message(#{quiet := Quiet,
+ parent := Parent, sock := Sock, scnt := SCnt} = State) ->
receive
{timeout, _TRef, stop} ->
- ?I("STOP"),
+ if not Quiet -> ?I("STOP");
+ true -> ok
+ end,
%% This will have the effect that no more requests are sent...
State#{num => SCnt, stop_started => ?T()};
diff --git a/erts/emulator/test/socket_test_ttest_tcp_client_gen.erl b/erts/emulator/test/socket_test_ttest_tcp_client_gen.erl
index 33eebfb10f..0ec2e908d7 100644
--- a/erts/emulator/test/socket_test_ttest_tcp_client_gen.erl
+++ b/erts/emulator/test/socket_test_ttest_tcp_client_gen.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
-module(socket_test_ttest_tcp_client_gen).
-export([
- start/3, start/4, start/6,
+ start/3, start/4, start/6, start/7,
stop/1
]).
@@ -34,7 +34,14 @@ start(Active, Addr, Port, MsgID) ->
socket_test_ttest_tcp_client:start(?TRANSPORT_MOD, Active, Addr, Port, MsgID).
start(Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
- socket_test_ttest_tcp_client:start(?TRANSPORT_MOD,
+ socket_test_ttest_tcp_client:start(false,
+ ?TRANSPORT_MOD,
+ Active, Addr, Port,
+ MsgID, MaxOutstanding, RunTime).
+
+start(Quiet, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
+ socket_test_ttest_tcp_client:start(Quiet,
+ ?TRANSPORT_MOD,
Active, Addr, Port,
MsgID, MaxOutstanding, RunTime).
diff --git a/erts/emulator/test/socket_test_ttest_tcp_client_socket.erl b/erts/emulator/test/socket_test_ttest_tcp_client_socket.erl
index c0a3302ecd..acf2556793 100644
--- a/erts/emulator/test/socket_test_ttest_tcp_client_socket.erl
+++ b/erts/emulator/test/socket_test_ttest_tcp_client_socket.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2018-2018. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2019. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
-module(socket_test_ttest_tcp_client_socket).
-export([
- start/4, start/5, start/7,
+ start/4, start/5, start/7, start/8,
stop/1
]).
@@ -36,7 +36,14 @@ start(Method, Active, Addr, Port, MsgID) ->
Active, Addr, Port, MsgID).
start(Method, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
- socket_test_ttest_tcp_client:start(?MOD(Method),
+ socket_test_ttest_tcp_client:start(false,
+ ?MOD(Method),
+ Active, Addr, Port,
+ MsgID, MaxOutstanding, RunTime).
+
+start(Quiet, Method, Active, Addr, Port, MsgID, MaxOutstanding, RunTime) ->
+ socket_test_ttest_tcp_client:start(Quiet,
+ ?MOD(Method),
Active, Addr, Port,
MsgID, MaxOutstanding, RunTime).