riak_test/tests/client_java_verify.erl

53 lines
1.9 KiB
Erlang

-module(client_java_verify).
-behavior(riak_test).
-export([confirm/0]).
-include_lib("eunit/include/eunit.hrl").
%% Change when a new release comes out.
-define(JAVA_FAT_BE_URL, rt_config:get(java.fat_be_url)).
-define(JAVA_TESTS_URL, rt_config:get(java.tests_url)).
-prereq("java").
-prereq("curl").
confirm() ->
lager:info("+P ~p", [erlang:system_info(process_limit)]),
prereqs(),
Nodes = rt:deploy_nodes(1),
[Node1] = Nodes,
?assertEqual(ok, rt:wait_until_nodes_ready([Node1])),
rpc:call(Node1, application, set_env, [erlang_js, script_timeout, 10000]),
[{Node1, ConnectionInfo}] = rt:connection_info([Node1]),
{HTTP_Host, HTTP_Port} = orddict:fetch(http, ConnectionInfo),
{PB_Host, PB_Port} = orddict:fetch(pb, ConnectionInfo),
lager:info("Connection Info: http: ~p:~p pb: ~p:~p", [HTTP_Host, HTTP_Port, PB_Host, PB_Port]),
java_unit_tests(HTTP_Host, HTTP_Port, PB_Host, PB_Port),
pass.
prereqs() ->
%% Does you have the java client available?
rt_local:download(?JAVA_FAT_BE_URL),
rt_local:download(?JAVA_TESTS_URL),
ok.
java_unit_tests(HTTP_Host, HTTP_Port, _PB_Host, PB_Port) ->
lager:info("Run the Java unit tests from somewhere on the local machine."),
%% 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",
[HTTP_Host, HTTP_Port, PB_Port,
rt_config:get(rt_scratch_dir) ++ "/" ++ rt_local:url_to_filename(?JAVA_FAT_BE_URL),
rt_config:get(rt_scratch_dir) ++ "/" ++ rt_local:url_to_filename(?JAVA_TESTS_URL)]),
lager:info("Cmd: ~s", [Cmd]),
{ExitCode, JavaLog} = rt_local:stream_cmd(Cmd, [{cd, rt_config:get(rt_scratch_dir)}]),
?assertEqual(0, ExitCode),
lager:info(JavaLog),
?assertNot(rt:str(JavaLog, "FAILURES!!!")),
ok.