aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/diameter/test')
-rw-r--r--lib/diameter/test/diameter_capx_SUITE.erl2
-rw-r--r--lib/diameter/test/diameter_examples_SUITE.erl6
-rw-r--r--lib/diameter/test/diameter_pool_SUITE.erl4
-rw-r--r--lib/diameter/test/diameter_traffic_SUITE.erl15
-rw-r--r--lib/diameter/test/diameter_transport_SUITE.erl44
-rw-r--r--lib/diameter/test/diameter_util.erl57
6 files changed, 51 insertions, 77 deletions
diff --git a/lib/diameter/test/diameter_capx_SUITE.erl b/lib/diameter/test/diameter_capx_SUITE.erl
index 0d535b6642..51b6c1d7f2 100644
--- a/lib/diameter/test/diameter_capx_SUITE.erl
+++ b/lib/diameter/test/diameter_capx_SUITE.erl
@@ -384,7 +384,7 @@ load_dict(N) ->
A3 = erl_anno:new(3),
A4 = erl_anno:new(4),
Forms = [{attribute, A1, module, Mod},
- {attribute, A2, compile, [export_all]},
+ {attribute, A2, export, [{id,0}]},
{function, A3, id, 0,
[{clause, A4, [], [], [{integer, A4, N}]}]}],
{ok, Mod, Bin, []} = compile:forms(Forms, [return]),
diff --git a/lib/diameter/test/diameter_examples_SUITE.erl b/lib/diameter/test/diameter_examples_SUITE.erl
index 680ce4f366..fad54d62b2 100644
--- a/lib/diameter/test/diameter_examples_SUITE.erl
+++ b/lib/diameter/test/diameter_examples_SUITE.erl
@@ -70,8 +70,6 @@
%% Transport protocols over which the example Diameter nodes are run.
-define(PROTS, [tcp, sctp]).
--define(ADDR, diameter_util:ip4()).
-
%% ===========================================================================
suite() ->
@@ -348,7 +346,7 @@ top(Dir, LibDir) ->
start({server, Prot}) ->
ok = diameter:start(),
ok = server:start(),
- {ok, Ref} = server:listen({Prot, ?ADDR, 3868}),
+ {ok, Ref} = server:listen(Prot),
[_] = ?util:lport(Prot, Ref),
ok;
@@ -356,7 +354,7 @@ start({client = Svc, Prot}) ->
ok = diameter:start(),
true = diameter:subscribe(Svc),
ok = client:start(),
- {ok, Ref} = client:connect({Prot, ?ADDR, ?ADDR, 3868}),
+ {ok, Ref} = client:connect(Prot),
receive #diameter_event{info = {up, Ref, _, _, _}} -> ok end;
start(Config) ->
diff --git a/lib/diameter/test/diameter_pool_SUITE.erl b/lib/diameter/test/diameter_pool_SUITE.erl
index eadb354a1d..97c16940ff 100644
--- a/lib/diameter/test/diameter_pool_SUITE.erl
+++ b/lib/diameter/test/diameter_pool_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2015. All Rights Reserved.
+%% Copyright Ericsson AB 2015-2017. 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.
@@ -115,7 +115,7 @@ connect(ClientProt, ServerProt) ->
%% 'up' events. (Although it's likely.)
sleep(),
{9,5} = count("server", LRef, accept), %% 5 connections + 4 accepting
- %% Ensure ther are still the expected number of accepting transports
+ %% Ensure there are still the expected number of accepting transports
%% after stopping the client service.
ok = diameter:stop_service("client"),
sleep(),
diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl
index 6b2f1a6ba8..84b41f14b7 100644
--- a/lib/diameter/test/diameter_traffic_SUITE.erl
+++ b/lib/diameter/test/diameter_traffic_SUITE.erl
@@ -92,7 +92,6 @@
send_multiple_filters_2/1,
send_multiple_filters_3/1,
send_anything/1,
- outstanding/1,
remove_transports/1,
empty/1,
stop_services/1,
@@ -203,8 +202,7 @@
{'Acct-Application-Id', [?DIAMETER_APP_ID_ACCOUNTING]},
{restrict_connections, false},
{string_decode, Decode},
- {incoming_maxlen, 1 bsl 21},
- {spawn_opt, [{min_heap_size, 5000}]}
+ {incoming_maxlen, 1 bsl 21}
| [{application, [{dictionary, D},
{module, ?MODULE},
{answer_errors, callback}]}
@@ -256,7 +254,7 @@ suite() ->
[{timetrap, {seconds, 10}}].
all() ->
- [start, result_codes, {group, traffic}, outstanding, empty, stop].
+ [start, result_codes, {group, traffic}, empty, stop].
groups() ->
[{P, [P], Ts} || Ts <- [tc(tc())], P <- [shuffle, parallel]]
@@ -466,8 +464,8 @@ add_transports(Config) ->
|| T == sctp andalso CS]],
[{capabilities_cb, fun capx/2},
{pool_size, 8},
- {spawn_opt, [{min_heap_size, 8096}]},
- {applications, apps(rfc3588)}]),
+ {applications, apps(rfc3588)}]
+ ++ [{spawn_opt, {erlang, spawn, []}} || CS]),
Cs = [?util:connect(CN,
[T, {sender, CS}],
LRef,
@@ -486,11 +484,6 @@ apps(D0) ->
D = dict0(D0),
[acct(D), D].
-%% Ensure there are no outstanding requests in request table.
-outstanding(_Config) ->
- [] = [T || T <- ets:tab2list(diameter_request),
- is_atom(element(1,T))].
-
remove_transports(Config) ->
#group{client_service = CN,
server_service = SN}
diff --git a/lib/diameter/test/diameter_transport_SUITE.erl b/lib/diameter/test/diameter_transport_SUITE.erl
index 14c748ad20..9d981d0a2b 100644
--- a/lib/diameter/test/diameter_transport_SUITE.erl
+++ b/lib/diameter/test/diameter_transport_SUITE.erl
@@ -56,10 +56,8 @@
-define(RECV(Pat, Ret), receive Pat -> Ret end).
-define(RECV(Pat), ?RECV(Pat, diameter_lib:now())).
-%% Address to open sockets on.
--define(ADDR(Prot), if sctp == Prot -> diameter_util:ip4();
- true -> {127,0,0,1}
- end).
+%% Sockets are opened on the loopback address.
+-define(ADDR, {127,0,0,1}).
%% diameter_tcp doesn't use anything but host_ip_address, and that
%% only is a local address isn't configured as at transport start.
@@ -351,14 +349,13 @@ rand_bytes(N) ->
%% start_connect/3
start_connect(Prot, PortNr, Ref) ->
- Addr = ?ADDR(Prot),
- {ok, TPid, [_]} = start_connect(Prot,
- {connect, Ref},
- ?SVC([]),
- [{raddr, Addr},
- {rport, PortNr},
- {ip, Addr},
- {port, 0}]),
+ {ok, TPid, [?ADDR]} = start_connect(Prot,
+ {connect, Ref},
+ ?SVC([]),
+ [{raddr, ?ADDR},
+ {rport, PortNr},
+ {ip, ?ADDR},
+ {port, 0}]),
?RECV(?TMSG({TPid, connected, _})),
TPid.
@@ -371,9 +368,9 @@ start_connect(tcp, T, Svc, Opts) ->
start_accept(Prot, Ref) ->
{Mod, Opts} = tmod(Prot),
- {ok, TPid, [_]} = Mod:start({accept, Ref},
- ?SVC([?ADDR(Prot)]),
- [{port, 0} | Opts]),
+ {ok, TPid, [?ADDR]} = Mod:start({accept, Ref},
+ ?SVC([?ADDR]),
+ [{port, 0} | Opts]),
?RECV(?TMSG({TPid, connected})),
TPid.
@@ -387,20 +384,19 @@ tmod(tcp) ->
%% gen_connect/2
gen_connect(sctp = P, PortNr) ->
- Addr = ?ADDR(P),
- {ok, Sock} = Ok = gen_sctp:open([{ip, Addr}, {port, 0} | ?SCTP_OPTS]),
- ok = gen_sctp:connect_init(Sock, Addr, PortNr, []),
+ {ok, Sock} = Ok = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]),
+ ok = gen_sctp:connect_init(Sock, ?ADDR, PortNr, []),
Ok = gen_accept(P, Sock);
-gen_connect(tcp = P, PortNr) ->
- gen_tcp:connect(?ADDR(P), PortNr, ?TCP_OPTS).
+gen_connect(tcp, PortNr) ->
+ gen_tcp:connect(?ADDR, PortNr, ?TCP_OPTS).
%% gen_listen/1
-gen_listen(sctp = P) ->
- {ok, Sock} = gen_sctp:open([{ip, ?ADDR(P)}, {port, 0} | ?SCTP_OPTS]),
+gen_listen(sctp) ->
+ {ok, Sock} = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]),
{gen_sctp:listen(Sock, true), Sock};
-gen_listen(tcp = P) ->
- gen_tcp:listen(0, [{ip, ?ADDR(P)} | ?TCP_OPTS]).
+gen_listen(tcp) ->
+ gen_tcp:listen(0, [{ip, ?ADDR} | ?TCP_OPTS]).
%% gen_accept/2
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index 7266d3678c..03f79096ac 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -32,8 +32,7 @@
foldl/3,
scramble/1,
unique_string/0,
- have_sctp/0,
- ip4/0]).
+ have_sctp/0]).
%% diameter-specific
-export([lport/2,
@@ -185,13 +184,19 @@ unique_string() ->
%% have_sctp/0
have_sctp() ->
+ have_sctp(erlang:system_info(system_architecture)).
+
+%% Don't run SCTP on platforms where it's either known to be flakey or
+%% isn't available.
+
+have_sctp("sparc-sun-solaris2.10") ->
+ false;
+
+have_sctp(_) ->
case gen_sctp:open() of
{ok, Sock} ->
- RC = gen_sctp:connect(Sock, ip4(), 3868, []),
gen_sctp:close(Sock),
- %% Connect has been seen to return eafnosupport on at least
- %% one SunOS 10 Sparc host, for reasons unknown.
- RC /= {error, eafnosupport};
+ true;
{error, E} when E == eprotonosupport;
E == esocktnosupport -> %% fail on any other reason
false
@@ -360,8 +365,7 @@ tmod(any) ->
opts([Prot | Opts], T) ->
tmo(T, lists:append([[{transport_module, M}, {transport_config, C ++ Opts}]
|| M <- tmod(Prot),
- C <- [buf(M,T) ++ [{ip, addr(M)}, {port, 0}]
- ++ remote(M,T)]]));
+ C <- [cfg(M,T) ++ cfg(M) ++ cfg(T)]]));
opts(Prot, T) ->
opts([Prot], T).
@@ -380,38 +384,21 @@ tmo([M, C | Opts]) ->
%% Listening SCTP socket need larger-than-default buffers to avoid
%% resends on some platforms (eg. SLES 11).
-buf(diameter_sctp, listen) ->
+cfg(diameter_sctp, listen) ->
[{recbuf, 1 bsl 16}, {sndbuf, 1 bsl 16}];
-buf(_, _) ->
+
+cfg(_, _) ->
[].
-addr(diameter_tcp) ->
- {127,0,0,1};
-addr(diameter_sctp) ->
- ip4().
+cfg(M)
+ when M == diameter_tcp;
+ M == diameter_sctp ->
+ [{ip, ?ADDR}, {port, 0}];
-remote(_, listen) ->
+cfg(listen) ->
[{accept, M} || M <- [{256,0,0,1}, ["256.0.0.1", ["^.+$"]]]];
-remote(Mod, PortNr) ->
- [{raddr, addr(Mod)}, {rport, PortNr}].
-
-%% Try to use something other than the loopback address where this
-%% address is known to be problematic for gen_sctp.
-ip4() ->
- try
- "sparc-sun-solaris2.10" = erlang:system_info(system_architecture),
- {ok, List} = inet:getifaddrs(),
- hd(lists:flatmap(fun ip4/1, List))
- catch
- error:_ ->
- ?ADDR
- end.
-
-ip4({_, Opts}) ->
- {flags, Flags} = lists:keyfind(flags, 1, Opts),
- [A || lists:member(up, Flags),
- not lists:member(loopback, Flags),
- {addr, {_,_,_,_} = A} <- Opts].
+cfg(PortNr) ->
+ [{raddr, ?ADDR}, {rport, PortNr}].
%% ---------------------------------------------------------------------------
%% info/0