Permalink
Browse files

fixed global registration, migrated collector to gen_server

  • Loading branch information...
1 parent b4188cc commit 7791b56d7c89f9696fd5aed1df8a80cafdd7675c @hyperthunk committed Aug 4, 2010
Showing with 14 additions and 17 deletions.
  1. +2 −2 src/libtest/collector.erl
  2. +12 −15 test/libtest_collector_SUITE.erl
@@ -81,13 +81,13 @@ start_link() ->
%% @doc Starts the server with the supplied configuration.
%%
start_link(Options) ->
- gen_server:start_link({global, ?COLLECTOR}, ?MODULE, Options, gen_server_options(Options)).
+ gen_server:start({global, ?COLLECTOR}, ?MODULE, Options, gen_server_options(Options)).
stop() ->
%%?PDEBUG("sending kill signal to collector at ~p", [global:safe_whereis_name(?COLLECTOR)]),
%%global:send(?COLLECTOR, {internal, {kill, self()}}),
%%?WAIT_FOR_MESSAGE({ok, shutting_down})
- gen_server:call(?COLLECTOR, stop).
+ gen_server:call({global, ?COLLECTOR}, stop).
%%init_it(Parent, Options) ->
%% case catch( global:register_name(?COLLECTOR, self()) ) of
@@ -40,33 +40,30 @@ all() -> ?CT_REGISTER_TESTS(?MODULE).
init_per_suite(Config) ->
%%?PDEBUG("starting ~p~n", [?GEN_SERVER]),
{ok, Server} = ?COLLECTOR:start_link(),
- ?PDEBUG("collector startup: ~p~n", [Server]),
- ?PDEBUG("collector registered against ~p", [global:whereis_name(?COLLECTOR)]),
- ?PDEBUG("in init - is server alive? ~p~n", [erlang:is_process_alive(Server)]),
- [{server, Server}|Config].
- %%Pid = spawn(?MODULE, loop, []),
- %%{ok, Slave} = slave:start(net_adm:localhost(), ?MODULE),
+ ?PDEBUG("in init - collector ~p has started...~n", [Server]),
+ ?PDEBUG("in init - collector globally registered against ~p", [global:whereis_name(?COLLECTOR)]),
+ ?PDEBUG("in init - is server ~p alive? ~p~n", [Server, erlang:is_process_alive(Server)]),
+ {ok, Slave} = slave:start(net_adm:localhost(), ?MODULE),
+ [{slave, Slave}|[{server, Server}|Config]].
+ %%Pid = spawn(?MODULE, loop, []),
%%global:register_name(?COLLECTOR, Pid),
%%?PDEBUG("collector registered against ~p", [global:whereis_name(?COLLECTOR)]),
%%global:sync(),
%%rpc:call(Slave, global, sync, []),
%%[{slave, Slave}|Config].
-end_per_suite(Config) ->
+end_per_suite(_Config) ->
%%?PDEBUG("stopping [~p]~n", [catch( ?COLLECTOR:stop() )]),
%%Slave = ?config(slave, Config),
%%slave:stop(Slave),
ok.
collector_is_singleton_process(Config) ->
- Server = ?config(server, Config),
- ?PDEBUG("in test - collector registered against ~p~n", [global:whereis_name(?COLLECTOR)]),
- ?PDEBUG("in test - is server alive? ~p~n", [erlang:is_process_alive(Server)]),
- ?PDEBUG("server ~p status: ~p~n", [Server, gen_server:call(?COLLECTOR, whassup)]),
- %% erlang:is_process_alive(Server)]),
-
- %%Slave = ?config(slave, Config),
- {ok, Slave} = slave:start(net_adm:localhost(), ?MODULE),
+ %%?PDEBUG("in test - collector globally registered against ~p~n", [global:whereis_name(?COLLECTOR)]),
+ %%?PDEBUG("in test - is server ~p alive? ~p~n", [Server, erlang:is_process_alive(Server)]),
+ %%?PDEBUG("server ~p status: ~p~n", [Server, gen_server:call({global, ?COLLECTOR}, whassup)]),
+ Slave = ?config(slave, Config),
+ rpc:call(Slave, global, sync, []),
Location = global:whereis_name(?COLLECTOR),
RemoteLocation = rpc:call(Slave, global, whereis_name, [?COLLECTOR]),
?PDEBUG("comparing ~p to ~p...~n", [RemoteLocation, Location]),

0 comments on commit 7791b56

Please sign in to comment.