Skip to content

Commit

Permalink
Prefer unlinking in test rather than test only start.
Browse files Browse the repository at this point in the history
The more similar the code used in test is to production, the better.
If the test needs to survive killing the manager, unlink can be used.
  • Loading branch information
lordnull committed Feb 28, 2014
1 parent e50efe1 commit 3a45117
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/riak_core_bg_manager.erl
Expand Up @@ -103,9 +103,7 @@
get_token/2,
get_token/3,
token_info/0,
token_info/1,
%% Testing
start/0
token_info/1
]).

%% reporting
Expand Down Expand Up @@ -139,11 +137,6 @@ start_link() ->
_ = maybe_create_ets(),
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).

%% Test entry point to start stand-alone server
start() ->
_ = maybe_create_ets(),
gen_server:start({local, ?SERVER}, ?MODULE, [], []).

%% @doc Global kill switch - causes all locks/tokens to be given out freely without limits.
%% Nothing will be tracked or recorded.
-spec bypass(boolean()) -> ok.
Expand Down
4 changes: 3 additions & 1 deletion test/bg_manager_tests.erl
Expand Up @@ -146,12 +146,14 @@ verify_token_rates() ->
%% doesn't take down our test too.
start_bg_mgr() ->
%% setup with history window to 1 seconds
?BG_MGR:start(),
{ok, Pid} = ?BG_MGR:start_link(),
unlink(Pid),
timer:sleep(100).

kill_bg_mgr() ->
Pid = erlang:whereis(?BG_MGR),
?assertNot(Pid == undefined),
unlink(Pid),
erlang:exit(Pid, kill).

crash_and_restart_token_manager() ->
Expand Down

0 comments on commit 3a45117

Please sign in to comment.