mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 16:45:29 +00:00
Refactored download/1 out of client_verify_java
This commit is contained in:
parent
37b6047f90
commit
730b39113c
16
src/rt.erl
16
src/rt.erl
@ -53,6 +53,7 @@
|
|||||||
deploy_nodes/1,
|
deploy_nodes/1,
|
||||||
deploy_nodes/2,
|
deploy_nodes/2,
|
||||||
down/2,
|
down/2,
|
||||||
|
download/1,
|
||||||
enable_search_hook/2,
|
enable_search_hook/2,
|
||||||
get_deps/0,
|
get_deps/0,
|
||||||
get_os_env/1,
|
get_os_env/1,
|
||||||
@ -108,6 +109,7 @@
|
|||||||
teardown/0,
|
teardown/0,
|
||||||
update_app_config/2,
|
update_app_config/2,
|
||||||
upgrade/2,
|
upgrade/2,
|
||||||
|
url_to_filename/1,
|
||||||
versions/0,
|
versions/0,
|
||||||
wait_for_cluster_service/2,
|
wait_for_cluster_service/2,
|
||||||
wait_for_cmd/1,
|
wait_for_cmd/1,
|
||||||
@ -182,6 +184,20 @@ which(Command) ->
|
|||||||
true
|
true
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
download(Url) ->
|
||||||
|
lager:info("Downloading ~s", [Url]),
|
||||||
|
Filename = url_to_filename(Url),
|
||||||
|
case filelib:is_file(filename:join(rt:config(rt_scratch_dir), Filename)) of
|
||||||
|
true ->
|
||||||
|
lager:info("Got it ~p", [Filename]),
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
lager:info("Getting it ~p", [Filename]),
|
||||||
|
rt:stream_cmd("curl -O -L " ++ Url, [{cd, rt:config(rt_scratch_dir)}])
|
||||||
|
end.
|
||||||
|
|
||||||
|
url_to_filename(Url) ->
|
||||||
|
lists:last(string:tokens(Url, "/")).
|
||||||
%% @doc like rt:which, but asserts on failure
|
%% @doc like rt:which, but asserts on failure
|
||||||
assert_which(Command) ->
|
assert_which(Command) ->
|
||||||
?assert(rt:which(Command)).
|
?assert(rt:which(Command)).
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
|
|
||||||
%% Change when a new release comes out.
|
%% Change when a new release comes out.
|
||||||
-define(JAVA_FAT_BE_URL, rt:config(java.fat_be_url)).
|
-define(JAVA_FAT_BE_URL, rt:config(java.fat_be_url)).
|
||||||
-define(JAVA_FAT_FILENAME, lists:last(string:tokens(?JAVA_FAT_BE_URL, "/"))).
|
|
||||||
-define(JAVA_TESTS_URL, rt:config(java.tests_url)).
|
-define(JAVA_TESTS_URL, rt:config(java.tests_url)).
|
||||||
-define(JAVA_TESTS_FILENAME, lists:last(string:tokens(?JAVA_TESTS_URL, "/"))).
|
|
||||||
|
|
||||||
-prereq("java").
|
-prereq("java").
|
||||||
-prereq("curl").
|
-prereq("curl").
|
||||||
@ -30,16 +28,19 @@ confirm() ->
|
|||||||
|
|
||||||
prereqs() ->
|
prereqs() ->
|
||||||
%% Does you have the java client available?
|
%% Does you have the java client available?
|
||||||
you_got_jars(?JAVA_FAT_BE_URL, ?JAVA_FAT_FILENAME),
|
rt:download(?JAVA_FAT_BE_URL),
|
||||||
you_got_jars(?JAVA_TESTS_URL, ?JAVA_TESTS_FILENAME),
|
rt:download(?JAVA_TESTS_URL),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
java_unit_tests(HTTP_Host, HTTP_Port, _PB_Host, PB_Port) ->
|
java_unit_tests(HTTP_Host, HTTP_Port, _PB_Host, PB_Port) ->
|
||||||
lager:info("Run the Java unit tests from somewhere on the local machine."),
|
lager:info("Run the Java unit tests from somewhere on the local machine."),
|
||||||
|
|
||||||
%% run the following:
|
%% run the following:
|
||||||
Cmd = io_lib:format("java -Dcom.basho.riak.host=~s -Dcom.basho.riak.http.port=~p -Dcom.basho.riak.pbc.port=~p -cp ~s:~s org.junit.runner.JUnitCore com.basho.riak.client.AllTests",
|
Cmd = io_lib:format(
|
||||||
[HTTP_Host, HTTP_Port, PB_Port, rt:config(rt_scratch_dir) ++ "/" ++ ?JAVA_FAT_FILENAME, rt:config(rt_scratch_dir) ++ "/" ++ ?JAVA_TESTS_FILENAME]),
|
"java -Dcom.basho.riak.host=~s -Dcom.basho.riak.http.port=~p -Dcom.basho.riak.pbc.port=~p -cp ~s:~s org.junit.runner.JUnitCore com.basho.riak.client.AllTests",
|
||||||
|
[HTTP_Host, HTTP_Port, PB_Port,
|
||||||
|
rt:config(rt_scratch_dir) ++ "/" ++ rt:url_to_filename(?JAVA_FAT_BE_URL),
|
||||||
|
rt:config(rt_scratch_dir) ++ "/" ++ rt:url_to_filename(?JAVA_TESTS_URL)]),
|
||||||
lager:info("Cmd: ~s", [Cmd]),
|
lager:info("Cmd: ~s", [Cmd]),
|
||||||
|
|
||||||
{ExitCode, JavaLog} = rt:stream_cmd(Cmd, [{cd, rt:config(rt_scratch_dir)}]),
|
{ExitCode, JavaLog} = rt:stream_cmd(Cmd, [{cd, rt:config(rt_scratch_dir)}]),
|
||||||
@ -47,15 +48,3 @@ java_unit_tests(HTTP_Host, HTTP_Port, _PB_Host, PB_Port) ->
|
|||||||
lager:info(JavaLog),
|
lager:info(JavaLog),
|
||||||
?assertNot(rt:str(JavaLog, "FAILURES!!!")),
|
?assertNot(rt:str(JavaLog, "FAILURES!!!")),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
you_got_jars(Url, Filename) ->
|
|
||||||
case file:read_file_info(Filename) of
|
|
||||||
{ok, _} ->
|
|
||||||
lager:info("Got it ~p", [Filename]),
|
|
||||||
ok;
|
|
||||||
{error, _} ->
|
|
||||||
lager:info("Getting it ~p", [Filename]),
|
|
||||||
rt:stream_cmd("curl -O -L " ++ Url, [{cd, rt:config(rt_scratch_dir)}]);
|
|
||||||
_ -> meh
|
|
||||||
end.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user