Skip to content

Commit

Permalink
MB-7467: added mapreduce test of context usability after timeout
Browse files Browse the repository at this point in the history
Change-Id: I977b997e70c1b052ee939ca81317094e9b58769c
Reviewed-on: http://review.couchbase.org/23584
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-on: http://review.couchbase.org/24950
  • Loading branch information
Aliaksey Kandratsenka authored and fdmanana committed Mar 4, 2013
1 parent dade4e4 commit aa2c26f
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/mapreduce/test/01-map.t
Expand Up @@ -26,7 +26,7 @@
main(_) -> main(_) ->
test_util:init_code_path(), test_util:init_code_path(),


etap:plan(90), etap:plan(120),
case (catch test()) of case (catch test()) of
ok -> ok ->
etap:end_tests(); etap:end_tests();
Expand Down Expand Up @@ -58,6 +58,7 @@ test() ->
test_parallel_burst_maps(25000, 10), test_parallel_burst_maps(25000, 10),
test_parallel_burst_maps(25000, 20), test_parallel_burst_maps(25000, 20),
ok = mapreduce:set_timeout(1000), ok = mapreduce:set_timeout(1000),
test_context_is_usable_after_timeout(),
test_many_timeouts(1), test_many_timeouts(1),
test_many_timeouts(5), test_many_timeouts(5),
test_many_timeouts(10), test_many_timeouts(10),
Expand Down Expand Up @@ -307,6 +308,35 @@ test_many_timeouts(NumProcesses) ->
end, end,
Pids). Pids).


test_context_is_usable_after_timeout() ->
Doc1 = <<"{\"_id\": \"doc1\", \"value\": 1}">>,
Doc2 = <<"{\"_id\": \"doc2\", \"value\": 1}">>,
NumProcesses = 30,
Pids = lists:map(
fun(_) ->
spawn_monitor(fun() ->
{ok, Ctx} = mapreduce:start_map_context([
<<"function(doc) { if (doc._id == \"doc1\") {while (true) { };} else {emit(doc._id, null)} }">>
]),
erlang:bump_reductions(100000),
RVs = [mapreduce:map_doc(Ctx, D, <<"{}">>) || D <- [Doc1, Doc2]],
exit({ok, RVs})
end)
end,
lists:seq(1, NumProcesses)),
lists:foreach(
fun({Pid, Ref}) ->
receive
{'DOWN', Ref, process, Pid, {ok, Value}} ->
etap:is(Value, [{error, <<"timeout">>}, {ok, [[{<<"\"doc2\"">>, <<"null">>}]]}], "Worker got timeout error and value");
{'DOWN', Ref, process, Pid, _Reason} ->
etap:bail("Worker died unexpectedly")
after 120000 ->
etap:bail("Timeout waiting for worker result")
end
end,
Pids).



test_half_timeouts(NumProcesses) -> test_half_timeouts(NumProcesses) ->
Pids = lists:map( Pids = lists:map(
Expand Down

0 comments on commit aa2c26f

Please sign in to comment.