make riak_kv_wterl_backend start the wterl app
This commit is contained in:
parent
ea3e73c0d7
commit
29acf9df7a
2 changed files with 43 additions and 47 deletions
|
@ -87,6 +87,17 @@ start(Partition, Config) ->
|
||||||
lager:error("Failed to create wterl dir: data_root is not set"),
|
lager:error("Failed to create wterl dir: data_root is not set"),
|
||||||
{error, data_root_unset};
|
{error, data_root_unset};
|
||||||
DataRoot ->
|
DataRoot ->
|
||||||
|
AppStart = case application:start(wterl) of
|
||||||
|
ok ->
|
||||||
|
ok;
|
||||||
|
{error, {already_started, _}} ->
|
||||||
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
lager:error("Failed to start wterl: ~p", [Reason]),
|
||||||
|
{error, Reason}
|
||||||
|
end,
|
||||||
|
case AppStart of
|
||||||
|
ok ->
|
||||||
ok = filelib:ensure_dir(filename:join(DataRoot, "x")),
|
ok = filelib:ensure_dir(filename:join(DataRoot, "x")),
|
||||||
case wterl_conn:open(DataRoot) of
|
case wterl_conn:open(DataRoot) of
|
||||||
{ok, ConnRef} ->
|
{ok, ConnRef} ->
|
||||||
|
@ -100,10 +111,13 @@ start(Partition, Config) ->
|
||||||
table=Table,
|
table=Table,
|
||||||
session=SRef,
|
session=SRef,
|
||||||
partition=Partition}};
|
partition=Partition}};
|
||||||
{error, Reason} ->
|
{error, ConnReason}=ConnError ->
|
||||||
lager:error("Failed to start wterl backend: ~p\n",
|
lager:error("Failed to start wterl backend: ~p\n",
|
||||||
[Reason]),
|
[ConnReason]),
|
||||||
{error, Reason}
|
ConnError
|
||||||
|
end;
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -425,35 +439,13 @@ fetch_status(Cursor, {ok, Stat}, Acc) ->
|
||||||
-ifdef(TEST).
|
-ifdef(TEST).
|
||||||
|
|
||||||
simple_test_() ->
|
simple_test_() ->
|
||||||
{spawn, [{setup, SF, CF, TF}]} = riak_kv_backend:standard_test(?MODULE, []),
|
|
||||||
{setup,
|
|
||||||
fun() ->
|
|
||||||
?assertCmd("rm -rf test/wterl-backend"),
|
?assertCmd("rm -rf test/wterl-backend"),
|
||||||
application:set_env(wterl, data_root, "test/wterl-backend"),
|
application:set_env(wterl, data_root, "test/wterl-backend"),
|
||||||
application:start(wterl),
|
riak_kv_backend:standard_test(?MODULE, []).
|
||||||
SF()
|
|
||||||
end,
|
|
||||||
fun(X) ->
|
|
||||||
CF(X),
|
|
||||||
application:stop(wterl)
|
|
||||||
end,
|
|
||||||
fun(X) -> TF(X) end}.
|
|
||||||
|
|
||||||
custom_config_test_() ->
|
custom_config_test_() ->
|
||||||
{spawn, [{setup, SF, CF, TF}]} = riak_kv_backend:standard_test(
|
|
||||||
?MODULE,
|
|
||||||
[{data_root, "test/wterl-backend"}]),
|
|
||||||
{setup,
|
|
||||||
fun() ->
|
|
||||||
?assertCmd("rm -rf test/wterl-backend"),
|
?assertCmd("rm -rf test/wterl-backend"),
|
||||||
application:set_env(wterl, data_root, ""),
|
application:set_env(wterl, data_root, ""),
|
||||||
application:start(wterl),
|
riak_kv_backend:standard_test(?MODULE, [{data_root, "test/wterl-backend"}]).
|
||||||
SF()
|
|
||||||
end,
|
|
||||||
fun(X) ->
|
|
||||||
CF(X),
|
|
||||||
application:stop(wterl)
|
|
||||||
end,
|
|
||||||
fun(X) -> TF(X) end}.
|
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
|
@ -170,8 +170,12 @@ simple_test_() ->
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertCmd("rm -rf " ++ ?DATADIR),
|
?assertCmd("rm -rf " ++ ?DATADIR),
|
||||||
?assertMatch(ok, filelib:ensure_dir(filename:join(?DATADIR, "x"))),
|
?assertMatch(ok, filelib:ensure_dir(filename:join(?DATADIR, "x"))),
|
||||||
{ok, Pid} = start_link(),
|
case start_link() of
|
||||||
|
{ok, Pid} ->
|
||||||
|
Pid;
|
||||||
|
{error, {already_started, Pid}} ->
|
||||||
Pid
|
Pid
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
fun(_) ->
|
fun(_) ->
|
||||||
stop()
|
stop()
|
||||||
|
|
Loading…
Reference in a new issue