aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_traffic_SUITE.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-10-09 23:37:21 +0200
committerAnders Svensson <[email protected]>2011-10-10 11:27:07 +0200
commitbc099fc49937477d96f930237fc58d388a0d43ef (patch)
treedd2ba4d336fedd4e839339b173fef7da272f0bc9 /lib/diameter/test/diameter_traffic_SUITE.erl
parent7de6f57074245a51faf1379629fe2000ae1037e5 (diff)
downloadotp-bc099fc49937477d96f930237fc58d388a0d43ef.tar.gz
otp-bc099fc49937477d96f930237fc58d388a0d43ef.tar.bz2
otp-bc099fc49937477d96f930237fc58d388a0d43ef.zip
Use util to simplify connection establishment in suites
Diffstat (limited to 'lib/diameter/test/diameter_traffic_SUITE.erl')
-rw-r--r--lib/diameter/test/diameter_traffic_SUITE.erl33
1 files changed, 3 insertions, 30 deletions
diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl
index d85539edce..6704f24532 100644
--- a/lib/diameter/test/diameter_traffic_SUITE.erl
+++ b/lib/diameter/test/diameter_traffic_SUITE.erl
@@ -127,19 +127,6 @@
{module, ?MODULE},
{answer_errors, callback}]}]).
-%% Config for diameter:add_transport/2. In the listening case, listen
-%% on a free port that we then lookup using the implementation detail
-%% that diameter_tcp registers the port with diameter_reg.
--define(CONNECT(PortNr),
- {connect, [{transport_module, diameter_tcp},
- {transport_config, [{raddr, ?ADDR},
- {rport, PortNr},
- {ip, ?ADDR},
- {port, 0}]}]}).
--define(LISTEN,
- {listen, [{transport_module, diameter_tcp},
- {transport_config, [{ip, ?ADDR}, {port, 0}]}]}).
-
-define(SUCCESS,
?'DIAMETER_BASE_RESULT-CODE_DIAMETER_SUCCESS').
-define(COMMAND_UNSUPPORTED,
@@ -264,27 +251,13 @@ start_services(_Config) ->
ok = diameter:start_service(?CLIENT, ?SERVICE(?CLIENT)).
add_transports(Config) ->
- {ok, LRef} = diameter:add_transport(?SERVER, ?LISTEN),
- true = diameter:subscribe(?CLIENT),
- [PortNr] = ?util:lport(tcp, LRef, 20),
- {ok, CRef} = diameter:add_transport(?CLIENT, ?CONNECT(PortNr)),
- {up, CRef, _Peer, _Cfg, #diameter_packet{}}
- = receive #diameter_event{service = ?CLIENT, info = I} -> I
- after 2000 -> false
- end,
- true = diameter:unsubscribe(?CLIENT),
+ LRef = ?util:listen(?SERVER, tcp),
+ CRef = ?util:connect(?CLIENT, tcp, LRef),
?util:write_priv(Config, "transport", {LRef, CRef}).
-%% Remove the client transport and expect the server transport to
-%% go down.
remove_transports(Config) ->
{LRef, CRef} = ?util:read_priv(Config, "transport"),
- true = diameter:subscribe(?SERVER),
- ok = diameter:remove_transport(?CLIENT, CRef),
- {down, LRef, _, _}
- = receive #diameter_event{service = ?SERVER, info = I} -> I
- after 2000 -> false
- end.
+ ?util:disconnect(?CLIENT, CRef, ?SERVER, LRef).
stop_services(_Config) ->
ok = diameter:stop_service(?CLIENT),