diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-02-06 10:21:13 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-02-07 09:36:57 -0600 |
commit | c4aee4dc5b19cdcc55bb44e8863bc62403d635e6 (patch) | |
tree | 7f0a3fc1756123167c3d8a1603c11ab5d020f5df | |
parent | 981ee9105e23ce3aaa98d81674986175b22d819c (diff) | |
download | couchdb-c4aee4dc5b19cdcc55bb44e8863bc62403d635e6.tar.gz |
Force OOM error
This changes the couchjs OOM test so that it will trigger more reliably
on SpiderMonkey 60. It appears that newer SpiderMonkeys are better at
conserving memory usage which takes this test longer to trigger.
-rw-r--r-- | src/couch/test/eunit/couch_js_tests.erl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/couch/test/eunit/couch_js_tests.erl b/src/couch/test/eunit/couch_js_tests.erl index d3d92a288..cd6452cf9 100644 --- a/src/couch/test/eunit/couch_js_tests.erl +++ b/src/couch/test/eunit/couch_js_tests.erl @@ -15,9 +15,12 @@ -define(FUNC, << + "var state = [];\n" "function(doc) {\n" " var val = \"0123456789ABCDEF\";\n" - " while(true) {emit(val, val);}\n" + " for(var i = 0; i < 165535; i++) {\n" + " state.push([val, val]);\n" + " }\n" "}\n" >>). @@ -30,7 +33,7 @@ couch_js_test_() -> fun test_util:start_couch/0, fun test_util:stop_couch/1, [ - fun should_exit_on_oom/0 + {timeout, 60000, fun should_exit_on_oom/0} ] } }. @@ -39,7 +42,16 @@ couch_js_test_() -> should_exit_on_oom() -> Proc = couch_query_servers:get_os_process(<<"javascript">>), true = couch_query_servers:proc_prompt(Proc, [<<"add_fun">>, ?FUNC]), - ?assertThrow( - {os_process_error, {exit_status, 1}}, - couch_query_servers:proc_prompt(Proc, [<<"map_doc">>, <<"{}">>]) - ). + trigger_oom(Proc). + +trigger_oom(Proc) -> + Status = try + couch_query_servers:proc_prompt(Proc, [<<"map_doc">>, <<"{}">>]), + continue + catch throw:{os_process_error, {exit_status, 1}} -> + done + end, + case Status of + continue -> trigger_oom(Proc); + done -> ok + end. |