Copied yz_rt:http functions into yokozuna_rt, and replaced direct calls to ibrowse in the yz_* tests to use this function. Added the test result status to the "Test Run Complete" notice in riak_test.

This commit is contained in:
Fred Dushin 2016-05-27 15:35:39 -04:00
parent 61a37d5381
commit 4e80028a9d
5 changed files with 41 additions and 13 deletions

View File

@ -21,3 +21,5 @@
-type schema_name() :: string().
-type raw_schema() :: binary().
-type bucket() :: bucket() | {bucket(), bucket()}.
-define(IBROWSE_TIMEOUT, 60000).

View File

@ -61,7 +61,7 @@ confirm(TestModule, Outdir, TestMetaData, HarnessArgs) ->
{fail, all_prereqs_not_present}
end,
lager:notice("~s Test Run Complete", [TestModule]),
lager:notice("~s Test Run Complete ~p", [TestModule, Status]),
{ok, Logs} = stop_lager_backend(),
Log = unicode:characters_to_binary(Logs),

View File

@ -44,16 +44,22 @@
wait_for_schema/2,
wait_for_schema/3,
write_data/5,
write_data/6]).
write_data/6,
http/4,
http/5,
http/6]).
-type host() :: string().
-type portnum() :: integer().
-type count() :: non_neg_integer().
-type json_string() :: atom | string() | binary().
-type search_type() :: solr | yokozuna.
-type method() :: get | post | head | options | put | delete | trace |
mkcol | propfind | proppatch | lock | unlock | move | copy.
-type response() :: {ok, string(), [{string(), string()}], string()|binary()} |
{error, term()}.
-define(FMT(S, Args), lists:flatten(io_lib:format(S, Args))).
-define(IBROWSE_TIMEOUT, 60000).
-define(SOFTCOMMIT, 1000).
-spec host_entries(rt:conn_info()) -> [{host(), portnum()}].
@ -233,6 +239,7 @@ remove_index_dirs(Nodes, IndexName, Services) ->
[rt:stop(ANode) || ANode <- Nodes],
[rt:del_dir(binary_to_list(IndexDir)) || IndexDir <- IndexDirs],
[start_and_wait(ANode, Services) || ANode <- Nodes],
wait_for_index(Nodes, IndexName),
ok.
start_and_wait(Node, WaitForServices) ->
@ -472,3 +479,22 @@ get_yz_conn_info(Node) ->
{ok, SolrPort} = rpc:call(Node, application, get_env, [yokozuna, solr_port]),
%% Currently Yokozuna hardcodes listener to all interfaces
{"127.0.0.1", SolrPort}.
-spec http(method(), string(), list(), binary()|[]) -> response().
http(Method, URL, Headers, Body) ->
Opts = [],
ibrowse:send_req(URL, Headers, Method, Body, Opts, ?IBROWSE_TIMEOUT).
-spec http(method(), string(), list(), binary()|[], list()|timeout())
-> response().
http(Method, URL, Headers, Body, Opts) when is_list(Opts) ->
ibrowse:send_req(URL, Headers, Method, Body, Opts, ?IBROWSE_TIMEOUT);
http(Method, URL, Headers, Body, Timeout) when is_integer(Timeout) ->
Opts = [],
ibrowse:send_req(URL, Headers, Method, Body, Opts, Timeout).
-spec http(method(), string(), list(), binary()|[], list(), timeout())
-> response().
http(Method, URL, Headers, Body, Opts, Timeout) when
is_list(Opts) andalso is_integer(Timeout) ->
ibrowse:send_req(URL, Headers, Method, Body, Opts, Timeout).

View File

@ -311,8 +311,8 @@ test_extractor_with_aae_expire(Cluster, Index, Bucket, Packet) ->
mochiweb_util:quote_plus(Key)),
CT = ?EXTRACTOR_CT,
{ok, "204", _, _} = ibrowse:send_req(
URL, [{"Content-Type", CT}], put, Packet),
{ok, "204", _, _} = yokozuna_rt:http(
put, URL, [{"Content-Type", CT}], Packet),
yokozuna_rt:commit(Cluster, Index),
@ -332,13 +332,13 @@ test_extractor_with_aae_expire(Cluster, Index, Bucket, Packet) ->
yokozuna_rt:override_schema(APid, Cluster, Index, ?SCHEMANAME,
?TEST_SCHEMA_UPGRADE),
{ok, "200", RHeaders, _} = ibrowse:send_req(URL, [{"Content-Type", CT}], get,
{ok, "200", RHeaders, _} = yokozuna_rt:http(get, URL, [{"Content-Type", CT}],
[], []),
VC = proplists:get_value("X-Riak-Vclock", RHeaders),
{ok, "204", _, _} = ibrowse:send_req(
URL, [{"Content-Type", CT}, {"X-Riak-Vclock", VC}],
put, Packet),
{ok, "204", _, _} = yokozuna_rt:http(
put, URL, [{"Content-Type", CT}, {"X-Riak-Vclock", VC}],
Packet),
yokozuna_rt:commit(Cluster, Index),
yokozuna_rt:search_expect(ANode, Index, <<"method">>,

View File

@ -135,7 +135,7 @@ search_url(Host, Port, Index) ->
verify_count(Url, ExpectedCount) ->
AreUp =
fun() ->
{ok, "200", _, DBody} = ibrowse:send_req(Url, [], get, []),
{ok, "200", _, DBody} = yokozuna_rt:http(get, Url, [], [], "", 60000),
FoundCount = get_count(DBody),
lager:info("FoundCount: ~b, ExpectedCount: ~b",
[FoundCount, ExpectedCount]),
@ -149,7 +149,7 @@ get_count(Resp) ->
kvc:path([<<"response">>, <<"numFound">>], Struct).
get_keys_count(BucketURL) ->
{ok, "200", _, RBody} = ibrowse:send_req(BucketURL, [], get, []),
{ok, "200", _, RBody} = yokozuna_rt:http(get, BucketURL, [], []),
Struct = mochijson2:decode(RBody),
length(kvc:path([<<"keys">>], Struct)).
@ -158,8 +158,8 @@ check_counts(Pid, InitKeyCount, BucketURL) ->
Pid, ?INDEX, <<"*:*">>),
Resp#search_results.num_found
end || _ <- lists:seq(1,?TESTCYCLE)],
HTTPCounts = [begin {ok, "200", _, RBody} = ibrowse:send_req(
BucketURL, [], get, []),
HTTPCounts = [begin {ok, "200", _, RBody} = yokozuna_rt:http(
get, BucketURL, [], []),
Struct = mochijson2:decode(RBody),
length(kvc:path([<<"keys">>], Struct))
end || _ <- lists:seq(1,?TESTCYCLE)],