Permalink
Browse files

Wait for riak_api to startup and shutdown so that the listener can ac…

…tually bind.
  • Loading branch information...
1 parent c9e0bf2 commit 00e1c0a1785a907114bb6639a89396c1151bb752 @seancribbs seancribbs committed Jul 16, 2012
Showing with 12 additions and 0 deletions.
  1. +1 −0 rebar.config
  2. +11 −0 test/pb_service_test.erl
View
@@ -1,5 +1,6 @@
{cover_enabled, true}.
{erl_opts, [warnings_as_errors, {parse_transform, lager_transform}]}.
+{eunit_opts, [verbose]}.
{deps, [
{lager, ".*", {git, "git://github.com/basho/lager.git", "master"}},
{riak_pb, ".*", {git, "git://github.com/basho/riak_pb.git", "master"}},
@@ -86,13 +86,15 @@ setup() ->
riak_api_pb_service:register(?MODULE, ?MSGMIN, ?MSGMAX),
[ application:start(A) || A <- Deps ],
+ riak_core:wait_for_application(riak_api),
{OldServices, OldHost, OldPort, Deps}.
cleanup({S, H, P, Deps}) ->
[ application:stop(A) || A <- lists:reverse(Deps), not is_otp_base_app(A) ],
application:set_env(riak_api, services, S),
application:set_env(riak_api, pb_ip, H),
application:set_env(riak_api, pb_port, P),
+ wait_for_application_shutdown(riak_api),
ok.
request(Code, Payload) when is_binary(Payload), is_integer(Code) ->
@@ -164,6 +166,15 @@ late_registration_test_() ->
}.
+wait_for_application_shutdown(App) ->
+ case lists:keymember(App, 1, application:which_applications()) of
+ true ->
+ timer:sleep(250),
+ wait_for_application_shutdown(App);
+ false ->
+ ok
+ end.
+
%% The following three functions build a list of dependent
%% applications. They will not handle circular or mutually-dependent
%% applications.

0 comments on commit 00e1c0a

Please sign in to comment.