From 5cb57ba153b9febfca17f90166791e104262615e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 21 Dec 2018 12:16:44 +0100 Subject: [socket-nif|test] Buffer set and adjusted traffic ping-pong iterations Handle (rcv and snd) buffer set failure. The number of iterations (message exchanges) that the traffic ping-cases has been adjusted down (by a factor of 10). Also, improve skip'ing. OTP-14831 --- erts/emulator/test/socket_SUITE.erl | 54 ++++++++++++++++++++++------ erts/emulator/test/socket_test_evaluator.erl | 14 ++++++-- 2 files changed, 56 insertions(+), 12 deletions(-) (limited to 'erts') diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index f77eb5502c..3adda52e1e 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -18,7 +18,14 @@ %% %CopyrightEnd% %% +%% Run the entire test suite: %% ts:run(emulator, socket_SUITE, [batch]). +%% +%% Run a specific group: +%% ts:run(emulator, socket_SUITE, {group, foo}, [batch]). +%% +%% Run a specific test case: +%% ts:run(emulator, socket_SUITE, foo, [batch]). -module(socket_SUITE). @@ -433,9 +440,9 @@ -define(TPP_MEDIUM, lists:flatten(lists:duplicate(1024, ?TPP_SMALL))). -define(TPP_LARGE, lists:flatten(lists:duplicate(1024, ?TPP_MEDIUM))). --define(TPP_SMALL_NUM, 100000). --define(TPP_MEDIUM_NUM, 100000). --define(TPP_LARGE_NUM, 1000). +-define(TPP_SMALL_NUM, 10000). +-define(TPP_MEDIUM_NUM, 1000). +-define(TPP_LARGE_NUM, 100). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2736,6 +2743,7 @@ api_to_connect_tcp(InitState) -> end}, #{desc => "create node", cmd => fun(#{host := Host} = State) -> + ?SEV_IPRINT("try create node on ~p", [Host]), case start_node(Host, client) of {ok, Node} -> ?SEV_IPRINT("client node ~p started", @@ -9475,14 +9483,34 @@ traffic_ping_pong_sendmsg_and_recvmsg_tcp(InitState) -> traffic_ping_pong_send_and_receive_tcp(#{msg := Msg} = InitState) -> Fun = fun(Sock) -> {ok, RcvSz} = socket:getopt(Sock, socket, rcvbuf), + ?SEV_IPRINT("RcvBuf is ~p (needs atleast ~p)", + [RcvSz, 16+size(Msg)]), if (RcvSz < size(Msg)) -> - ok = socket:setopt(Sock, socket, rcvbuf, 1024+size(Msg)); + case socket:setopt(Sock, + socket, rcvbuf, 1024+size(Msg)) of + ok -> + ok; + {error, enobufs} -> + skip({failed_change, rcvbuf}); + {error, Reason1} -> + ?FAIL({rcvbuf, Reason1}) + end; true -> ok end, {ok, SndSz} = socket:getopt(Sock, socket, sndbuf), + ?SEV_IPRINT("SndBuf is ~p (needs atleast ~p)", + [SndSz, 16+size(Msg)]), if (SndSz < size(Msg)) -> - ok = socket:setopt(Sock, socket, sndbuf, 1024+size(Msg)); + case socket:setopt(Sock, + socket, sndbuf, 1024+size(Msg)) of + ok -> + ok; + {error, enobufs} -> + skip({failed_change, sndbuf}); + {error, Reason2} -> + ?FAIL({sndbuf, Reason2}) + end; true -> ok end, @@ -9924,7 +9952,7 @@ traffic_ping_pong_send_and_receive_tcp2(InitState) -> Result2 = erlang:delete_element(1, Result), {ok, State#{server_result => Result2}}; {ok, BadResult} -> - ?SEV_EPRINT("bad sever result: " + ?SEV_EPRINT("bad server result: " "~n ~p", [BadResult]), {error, {invalid_server_result, BadResult}}; {error, _} = ERROR -> @@ -10166,10 +10194,10 @@ tpp_tcp_client_await_continue(Parent, Slogan) -> ?SEV_IPRINT("await continue (~p)", [Slogan]), case ?SEV_AWAIT_CONTINUE(Parent, parent, Slogan) of ok -> - %% ?SEV_IPRINT("continue (~p): ok", [Slogan]), + ?SEV_IPRINT("continue (~p): ok", [Slogan]), ok; {ok, Data} -> - %% ?SEV_IPRINT("continue (~p): ok with data", [Slogan]), + ?SEV_IPRINT("continue (~p): ok with data", [Slogan]), Data; {error, Reason} -> ?SEV_EPRINT("continue (~p): error" @@ -16526,7 +16554,11 @@ sock_close(Sock) -> local_host() -> try net_adm:localhost() of Host when is_list(Host) -> - list_to_atom(Host) + %% Convert to shortname if long + case string:tokens(Host, [$.]) of + [H|_] -> + list_to_atom(H) + end catch C:E:S -> erlang:raise(C, E, S) @@ -16546,7 +16578,9 @@ which_local_addr(Domain) -> which_addr(_Domain, []) -> ?FAIL(no_address); -which_addr(Domain, [{Name, IFO}|_IFL]) when (Name =/= "lo") -> +which_addr(Domain, [{"lo" ++ _, _}|IFL]) -> + which_addr(Domain, IFL); +which_addr(Domain, [{_Name, IFO}|_IFL]) -> which_addr2(Domain, IFO); which_addr(Domain, [_|IFL]) -> which_addr(Domain, IFL). diff --git a/erts/emulator/test/socket_test_evaluator.erl b/erts/emulator/test/socket_test_evaluator.erl index deea7e5d36..fe6a6ff70a 100644 --- a/erts/emulator/test/socket_test_evaluator.erl +++ b/erts/emulator/test/socket_test_evaluator.erl @@ -130,6 +130,10 @@ loop(ID, [#{desc := Desc, "~n Reason: ~p", [ID, Reason]), exit({command_failed, ID, Reason, State}) catch + throw:{skip, R} = E:_ -> + eprint("command ~w skip: " + "~n Skip Reason: ~p", [ID, R]), + exit(E); C:E:S -> eprint("command ~w crashed: " "~n Class: ~p" @@ -150,6 +154,8 @@ await_finish(Evs) -> await_finish([], []) -> ok; await_finish([], Fails) -> + ?SEV_EPRINT("Fails: " + "~n ~p", [Fails]), Fails; await_finish(Evs, Fails) -> receive @@ -443,8 +449,12 @@ await(ExpPid, Name, Announcement, Slogan, OtherPids) ok; {Announcement, Pid, Slogan, Extra} when (Pid =:= ExpPid) -> {ok, Extra}; + {'DOWN', _, process, Pid, {skip, SkipReason}} when (Pid =:= ExpPid) -> + iprint("Unexpected SKIP from ~w (~p): " + "~n ~p", [Name, Pid, SkipReason]), + ?LIB:skip({Name, SkipReason}); {'DOWN', _, process, Pid, Reason} when (Pid =:= ExpPid) -> - eprint("Unexpected DOWN regarding ~w ~p: " + eprint("Unexpected DOWN from ~w (~p): " "~n ~p", [Name, Pid, Reason]), {error, {unexpected_exit, Name}}; {'DOWN', _, process, OtherPid, Reason} -> @@ -476,7 +486,7 @@ pi(Pid, Item) -> check_down(Pid, DownReason, Pids) -> case lists:keymember(Pid, 1, Pids) of {value, {_, Name}} -> - eprint("Unexpected DOWN regarding ~w ~p: " + eprint("Unexpected DOWN from ~w (~p): " "~n ~p", [Name, Pid, DownReason]), {error, {unexpected_exit, Name}}; false -> -- cgit v1.2.3