Skip to content

Commit

Permalink
fixed global registration, migrated collector to gen_server
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperthunk committed Aug 4, 2010
1 parent b4188cc commit 7791b56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/libtest/collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 12 additions & 15 deletions test/libtest_collector_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down

0 comments on commit 7791b56

Please sign in to comment.