This is an automated email from the ASF dual-hosted git repository. kocolosk pushed a commit to branch 3939-multipart-replicated-changes-race in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e85e343592827d3bf040c563bc0b211e4cac1eb5 Author: Adam Kocoloski <[email protected]> AuthorDate: Wed Feb 23 13:27:14 2022 -0500 Add an integration test This doesn't actually work as you'd expect. The response for the new_edits=false request does return quickly, but the request body is never consumed and so the _next_ request on the wire will hang. --- test/elixir/test/attachments_multipart_test.exs | 57 +++++++++++++++++++++++++ test/elixir/test/config/suite.elixir | 3 +- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/test/elixir/test/attachments_multipart_test.exs b/test/elixir/test/attachments_multipart_test.exs index f7d5d95..c5cd8fc 100644 --- a/test/elixir/test/attachments_multipart_test.exs +++ b/test/elixir/test/attachments_multipart_test.exs @@ -260,6 +260,63 @@ defmodule AttachmentMultipartTest do ) end + @tag :with_db + test "multipart attachments with new_edits=false", context do + db_name = context[:db_name] + + document = """ + { + "body": "This is a body.", + "_attachments": { + "foo.txt": { + "follows": true, + "content_type": "application/test", + "length": 21 + } + } + } + """ + + multipart_data = + "--abc123\r\n" <> + "content-type: application/json\r\n" <> + "\r\n" <> + document <> + "\r\n--abc123\r\n" <> + "\r\n" <> + "this is 21 chars long" <> + "\r\n--abc123--epilogue" + + resp = + Couch.put( + "/#{db_name}/multipart_replicated_changes", + body: multipart_data, + headers: ["Content-Type": "multipart/related;boundary=\"abc123\""] + ) + + assert resp.status_code in [201, 202] + assert resp.body["ok"] == true + + rev = resp.body["rev"] + + resp = Couch.get("/#{db_name}/multipart_replicated_changes/foo.txt") + + assert resp.body == "this is 21 chars long" + + # https://github.com/apache/couchdb/issues/3939 + # Repeating the request should not hang + resp = + Couch.put( + "/#{db_name}/multipart_replicated_changes?new_edits=false&rev=#{rev}", + body: multipart_data, + headers: ["Content-Type": "multipart/related;boundary=\"abc123\""] + ) + + assert resp.status_code in [201, 202] + assert resp.body["ok"] == true + + end + defp test_multipart_att_compression(dbname) do doc = %{ "_id" => "foobar" diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index 2e97553..e071da8 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -10,7 +10,8 @@ ], "AttachmentMultipartTest": [ "manages attachments multipart requests successfully", - "manages compressed attachments successfully" + "manages compressed attachments successfully", + "multipart attachments with new_edits=false" ], "AttachmentNamesTest": [ "saves attachment names successfully"
