diff --git a/tests/secondary_index_tests.erl b/tests/secondary_index_tests.erl index c3d10077b..ea640aafd 100644 --- a/tests/secondary_index_tests.erl +++ b/tests/secondary_index_tests.erl @@ -34,8 +34,13 @@ -define(KEYS(A,B,G1,G2), [int_to_key(N) || N <- lists:seq(A,B), G1, G2]). confirm() -> - Conf = [{riak_core, [{default_bucket_props, [{allow_mult, true}, - {dvv_enabled, true}]}]}], + Conf = + [{riak_core, + [{default_bucket_props, + [{allow_mult, true}, {dvv_enabled, true}]} + ]}, + {riak_kv, [{secondary_index_json, otp}] + }], Nodes = rt:build_cluster(3, Conf), ?assertEqual(ok, rt:wait_until_nodes_ready(Nodes)), diff --git a/tests/verify_2i_timeout.erl b/tests/verify_2i_timeout.erl index ba03d5ab1..55070e0be 100644 --- a/tests/verify_2i_timeout.erl +++ b/tests/verify_2i_timeout.erl @@ -27,6 +27,7 @@ -define(FOO, <<"foo">>). confirm() -> + KeyCount = 8000, inets:start(), Config = [{riak_kv, [{secondary_index_timeout, 1}]}], %% ludicrously short, should fail always Nodes = rt:build_cluster([{current, Config}, {current, Config}, {current, Config}]), @@ -36,9 +37,9 @@ confirm() -> Http = rt:http_url(hd(Nodes)), [put_an_object(PBPid, N) || N <- lists:seq(0, 500)], - [put_an_object(PBPid, int_to_key(N), N, ?FOO) || N <- lists:seq(501, 5000)], + [put_an_object(PBPid, int_to_key(N), N, ?FOO) || N <- lists:seq(501, KeyCount)], - ExpectedKeys = lists:sort([int_to_key(N) || N <- lists:seq(0, 5000)]), + ExpectedKeys = lists:sort([int_to_key(N) || N <- lists:seq(0, KeyCount)]), Query = {<<"$bucket">>, ?BUCKET}, %% Verifies that the app.config param was used ?assertEqual({error, timeout}, stream_pb(PBPid, Query, [])), @@ -53,7 +54,7 @@ confirm() -> lager:info("Query error with ErrCode ~p", [ErrCode]), - ?assertEqual(true, ErrCode >= 500), + ?assertEqual(true, ErrCode == 503), ?assertMatch({match, _}, re:run(Body, "request timed out|{error,timeout}")), %% shows the app.config timeout HttpRes = http_query(Http, Query, [{timeout, 5000}]), @@ -65,8 +66,15 @@ confirm() -> pass. stream_http(Http, Query, ExpectedKeys) -> - Res = http_stream(Http, Query, []), - ?assert(lists:member({<<"error">>,<<"timeout">>}, Res)), - Res2 = http_stream(Http, Query, [{timeout, 5000}]), - ?assertEqual(ExpectedKeys, lists:sort(proplists:get_value(<<"keys">>, Res2, []))). + {TC, Res} = timer:tc(fun() -> http_stream(Http, Query, []) end), + case lists:keyfind(<<"keys">>, 1, Res) of + {<<"keys">>, Keys} -> + lager:info( + "Stream returned in ~w microseconds result with keys ~p", + [TC, length(Keys)]); + _ -> + ok + end, + Res2 = http_stream(Http, Query, [{timeout, 5000}]), + ?assertEqual(ExpectedKeys, lists:sort(proplists:get_value(<<"keys">>, Res2, []))).