Commits

Anonymous committed 2966c63

test riak:local_client and riak:client_connect

Comments (0)

Files changed (2)

 -export([get_app_env/1,get_app_env/2]).
 -export([client_connect/3,client_connect/4,local_client/0]).
 
+-include_lib("eunit/include/eunit.hrl").
+
 %% @spec start([ConfigPath :: list()]) -> ok
 %% @doc Start the riak server.
 %%      ConfigPath specifies the location of the riak configuration file.
 	    ok
     end.
 	
+local_client_test() ->
+    Node = node(),
+    {ok, {riak_client, Node, _ClientId}} = riak:local_client().
+
+remote_client_test() ->
+    application:set_env(riak, doorbell_port, 9002),   
+    application:set_env(riak, riak_cookie, remote_client_test),
+    riak_doorbell:start_link(),
+    {ok, {riak_client, _, _}} = riak:client_connect("127.0.0.1", 9002, 
+                                                    remote_client_test),
+    riak_doorbell:stop().

src/riak_doorbell.erl

 -export([start_link/0]).
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
 	 terminate/2, code_change/3]).
--export([ring/2,knock/3]).
+-export([ring/2,knock/3, stop/0]).
 
 -include_lib("eunit/include/eunit.hrl").
 	 
     gen_udp:close(SendSock),
     Res.
 
+stop() -> gen_server:cast(?MODULE, stop).
+    
 % @private
 init([Port]) ->
     Opts = [{active, true},
 handle_info(_Info, State) -> {noreply, State}.
 
 %% @private
-handle_cast(_Request, State) -> {noreply,State}.
+handle_cast(stop, State) -> {stop, normal,State}.
 
 %% @private
 handle_call(_Request, _From, State) -> {reply, no_call, State}.
             ok
     after 1000 ->
             throw(knock_test_timeout)
-    end.
+    end,
+    riak_doorbell:stop().