diff options
author | Bessenyei Balázs Donát <bessbd@users.noreply.github.com> | 2021-03-03 23:35:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-03 23:35:30 +0100 |
commit | ad30fea6bbc8766c8f575eb664da924f27ec1893 (patch) | |
tree | 505e6ea160aa89086f0101de6d1d58b2bf5d8f22 /test | |
parent | 2ef72d60945bcda80845015cfb7c8426c4f9d0f3 (diff) | |
download | couchdb-ad30fea6bbc8766c8f575eb664da924f27ec1893.tar.gz |
Re-add transaction size exceeded test (#3395)
Diffstat (limited to 'test')
-rw-r--r-- | test/elixir/test/bulk_docs_test.exs | 18 | ||||
-rw-r--r-- | test/elixir/test/config/suite.elixir | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/test/elixir/test/bulk_docs_test.exs b/test/elixir/test/bulk_docs_test.exs index cbbc53340..2fd1f4830 100644 --- a/test/elixir/test/bulk_docs_test.exs +++ b/test/elixir/test/bulk_docs_test.exs @@ -130,6 +130,17 @@ defmodule BulkDocsTest do assert Enum.at(rows, 2)["error"] == "conflict" end + @tag :with_db + test "bulk docs raises error for transaction larger than 10MB", ctx do + docs = [%{_id: "0", a: random_string(16_000_000)}] + old_size = Couch.get("/_node/node1@127.0.0.1/_config/couchdb/max_document_size").body + set_config_raw("couchdb", "max_document_size", "67108864") # 64M + resp = Couch.post("/#{ctx[:db_name]}/_bulk_docs", body: %{docs: docs}) + set_config_raw("couchdb", "max_document_size", old_size) # set back + assert resp.status_code == 500 + assert resp.body["reason"] == "code: 2101, desc: Transaction exceeds byte limit" + end + defp bulk_post(docs, db) do retry_until(fn -> resp = Couch.post("/#{db}/_bulk_docs", body: %{docs: docs}) @@ -152,4 +163,11 @@ defmodule BulkDocsTest do assert resp.body["error"] == "bad_request" assert resp.body["reason"] == reason end + + defp random_string(length) do + raw = :crypto.strong_rand_bytes(length) + raw + |> Base.url_encode64 + |> binary_part(0, length) + end end diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index d4155f331..a87918246 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -95,7 +95,7 @@ "bulk docs raises error for invlaid `docs` parameter", "bulk docs raises error for invlaid `new_edits` parameter", "bulk docs raises error for missing `docs` parameter", - "bulk docs raises transaction_too_large error for transaction larger than 10MB", + "bulk docs raises error for transaction larger than 10MB", "bulk docs supplies `id` if not provided in doc" ], "ChangesAsyncTest": [ |