Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/chttpd/src/chttpd_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,13 @@ db_req(#httpd{method='POST', path_parts=[DbName], user_ctx=Ctx}=Req, Db) ->
db_req(#httpd{path_parts=[_DbName]}=Req, _Db) ->
send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");

db_req(#httpd{method='POST',path_parts=[_,<<"_ensure_full_commit">>]}=Req, _Db) ->
db_req(#httpd{method='POST', path_parts=[DbName, <<"_ensure_full_commit">>],
user_ctx=Ctx}=Req, _Db) ->
chttpd:validate_ctype(Req, "application/json"),
%% use fabric call to trigger a database_does_not_exist exception
%% for missing databases that'd return error 404 from chttpd
%% get_security used to prefer shards on the same node over other nodes
fabric:get_security(DbName, [{user_ctx, Ctx}]),
send_json(Req, 201, {[
{ok, true},
{instance_start_time, <<"0">>}
Expand Down
22 changes: 22 additions & 0 deletions src/chttpd/test/chttpd_db_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ all_test_() ->
fun setup/0, fun teardown/1,
[
fun should_return_ok_true_on_bulk_update/1,
fun should_return_ok_true_on_ensure_full_commit/1,
fun should_return_404_for_ensure_full_commit_on_no_db/1,
fun should_accept_live_as_an_alias_for_continuous/1,
fun should_return_404_for_delete_att_on_notadoc/1,
fun should_return_409_for_del_att_without_rev/1,
Expand Down Expand Up @@ -100,6 +102,26 @@ should_return_ok_true_on_bulk_update(Url) ->
end).


should_return_ok_true_on_ensure_full_commit(Url0) ->
?_test(begin
Url = Url0 ++ "/_ensure_full_commit",
{ok, RC, _, Body} = test_request:post(Url, [?CONTENT_JSON, ?AUTH], []),
{Json} = ?JSON_DECODE(Body),
?assertEqual(201, RC),
?assert(couch_util:get_value(<<"ok">>, Json))
end).


should_return_404_for_ensure_full_commit_on_no_db(Url0) ->
?_test(begin
Url = Url0 ++ "-missing-db" ++ "/_ensure_full_commit",
{ok, RC, _, Body} = test_request:post(Url, [?CONTENT_JSON, ?AUTH], []),
{Json} = ?JSON_DECODE(Body),
?assertEqual(404, RC),
?assertEqual(<<"not_found">>, couch_util:get_value(<<"error">>, Json))
end).


should_accept_live_as_an_alias_for_continuous(Url) ->
GetLastSeq = fun(Bin) ->
Parts = binary:split(Bin, <<"\n">>, [global]),
Expand Down