diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-19 14:41:38 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2019-12-25 13:52:32 -0600 |
commit | 3880c0bf0880c52636a98130d508b63df4af63c2 (patch) | |
tree | 65f4baf784979301018ecdcb1a66c4dd3222d3d0 | |
parent | eee00b3197d30a96ff2cd3a38ed8183852995626 (diff) | |
download | couchdb-3880c0bf0880c52636a98130d508b63df4af63c2.tar.gz |
Speedup eunit: couch_replicator_compact_tests
Increase the doc write batch count in the background writer process to
speed up the should_populate_and_compact test.
-rw-r--r-- | src/couch_replicator/test/eunit/couch_replicator_compact_tests.erl | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/couch_replicator/test/eunit/couch_replicator_compact_tests.erl b/src/couch_replicator/test/eunit/couch_replicator_compact_tests.erl index eb3fc82c5..997c84863 100644 --- a/src/couch_replicator/test/eunit/couch_replicator_compact_tests.erl +++ b/src/couch_replicator/test/eunit/couch_replicator_compact_tests.erl @@ -26,6 +26,7 @@ -define(TIMEOUT, 360000). -define(TIMEOUT_WRITER, 100000). -define(TIMEOUT_EUNIT, ?TIMEOUT div 1000 + 70). +-define(WRITE_BATCH_SIZE, 25). setup() -> DbName = ?tempdb(), @@ -408,33 +409,35 @@ writer_loop(Db0, Parent, Counter) -> DbName = couch_db:name(Db0), {ok, Data} = file:read_file(?ATTFILE), maybe_pause(Parent, Counter), - Doc = couch_doc:from_json_obj({[ - {<<"_id">>, ?l2b(integer_to_list(Counter + 1))}, - {<<"value">>, Counter + 1}, - {<<"_attachments">>, {[ - {<<"icon1.png">>, {[ - {<<"data">>, base64:encode(Data)}, - {<<"content_type">>, <<"image/png">>} - ]}}, - {<<"icon2.png">>, {[ - {<<"data">>, base64:encode(iolist_to_binary([Data, Data]))}, - {<<"content_type">>, <<"image/png">>} + Docs = lists:map(fun(I) -> + couch_doc:from_json_obj({[ + {<<"_id">>, ?l2b(integer_to_list(Counter + I))}, + {<<"value">>, Counter + I}, + {<<"_attachments">>, {[ + {<<"icon1.png">>, {[ + {<<"data">>, base64:encode(Data)}, + {<<"content_type">>, <<"image/png">>} + ]}}, + {<<"icon2.png">>, {[ + {<<"data">>, base64:encode(iolist_to_binary([Data, Data]))}, + {<<"content_type">>, <<"image/png">>} + ]}} ]}} - ]}} - ]}), + ]}) + end, lists:seq(1, ?WRITE_BATCH_SIZE)), maybe_pause(Parent, Counter), {ok, Db} = couch_db:open_int(DbName, []), - {ok, _} = couch_db:update_doc(Db, Doc, []), + {ok, _} = couch_db:update_docs(Db, Docs, []), ok = couch_db:close(Db), receive {get_count, Ref} -> - Parent ! {count, Ref, Counter + 1}, - writer_loop(Db, Parent, Counter + 1); + Parent ! {count, Ref, Counter + ?WRITE_BATCH_SIZE}, + writer_loop(Db, Parent, Counter + ?WRITE_BATCH_SIZE); {stop, Ref} -> - Parent ! {stopped, Ref, Counter + 1} + Parent ! {stopped, Ref, Counter + ?WRITE_BATCH_SIZE} after 0 -> timer:sleep(?DELAY), - writer_loop(Db, Parent, Counter + 1) + writer_loop(Db, Parent, Counter + ?WRITE_BATCH_SIZE) end. maybe_pause(Parent, Counter) -> |