diff options
author | Peng Hui Jiang <jiangphcn@apache.org> | 2019-01-18 08:31:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 08:31:25 +0800 |
commit | a3f99df48669431afc8ef4f32514bafabb8bbb45 (patch) | |
tree | e4956874d791168f2e6deda855cb252e27f92b9d | |
parent | 5269d7967667a5b8b9dfd923bf53d4c1b3ffcfb5 (diff) | |
parent | 90d5bf6e454d8ea08c646fb19059173325e71a0b (diff) | |
download | couchdb-a3f99df48669431afc8ef4f32514bafabb8bbb45.tar.gz |
Merge pull request #1865 from apache/purge_request_with_101_docid
Support one purge request with more than 100 docid
-rw-r--r-- | src/chttpd/test/chttpd_purge_tests.erl | 21 | ||||
-rw-r--r-- | src/fabric/src/fabric_doc_purge.erl | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/chttpd/test/chttpd_purge_tests.erl b/src/chttpd/test/chttpd_purge_tests.erl index b3acb0668..50f7e18e5 100644 --- a/src/chttpd/test/chttpd_purge_tests.erl +++ b/src/chttpd/test/chttpd_purge_tests.erl @@ -70,6 +70,7 @@ purge_test_() -> [ fun test_empty_purge_request/1, fun test_ok_purge_request/1, + fun test_ok_purge_request_with_101_docid/1, fun test_accepted_purge_request/1, fun test_partial_purge_request/1, fun test_mixed_purge_request/1, @@ -137,6 +138,26 @@ test_ok_purge_request(Url) -> end). +test_ok_purge_request_with_101_docid(Url) -> + ?_test(begin + PurgedDocsNum = 101, + IdsRevsEJson = lists:foldl(fun(I, CIdRevs) -> + Id = list_to_binary(integer_to_list(I)), + {ok, _, _, Body} = create_doc(Url, Id), + {Json} = ?JSON_DECODE(Body), + Rev = couch_util:get_value(<<"rev">>, Json, undefined), + [{Id, [Rev]} | CIdRevs] + end, [], lists:seq(1, PurgedDocsNum)), + + IdsRevs = binary_to_list(?JSON_ENCODE({IdsRevsEJson})), + ok = config:set("purge", "max_document_id_number", "101"), + {ok, Status, _, _} = test_request:post(Url ++ "/_purge/", + [?CONTENT_JSON, ?AUTH], IdsRevs), + ok = config:delete("purge", "max_document_id_number"), + ?assert(Status =:= 201 orelse Status =:= 202) + end). + + test_accepted_purge_request(Url) -> ?_test(begin {ok, _, _, Body} = create_doc(Url, "doc1"), diff --git a/src/fabric/src/fabric_doc_purge.erl b/src/fabric/src/fabric_doc_purge.erl index 2571d0d7f..7e447ff1b 100644 --- a/src/fabric/src/fabric_doc_purge.erl +++ b/src/fabric/src/fabric_doc_purge.erl @@ -191,7 +191,7 @@ format_resps(UUIDs, #acc{} = Acc) -> [{UUID, {Health, AllRevs}} | ReplyAcc] end end, - FinalReplies = dict:fold(FoldFun, {ok, []}, Resps), + FinalReplies = dict:fold(FoldFun, [], Resps), couch_util:reorder_results(UUIDs, FinalReplies); format_resps(_UUIDs, Else) -> |