diff options
author | Robert Newson <rnewson@apache.org> | 2021-03-18 15:44:52 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2021-03-18 15:44:52 +0000 |
commit | b125036f79b5c12ffd85146cceeed8e99c14eeb3 (patch) | |
tree | d5940af53bb0dd60f8000857235f1654ef655fb5 | |
parent | a411fe220f94be73b9364fc0e923b8401d4e73ff (diff) | |
download | couchdb-concurrent-write-test-with-updates.tar.gz |
Add Secondary data tests with updates testconcurrent-write-test-with-updates
-rw-r--r-- | test/elixir/test/concurrent_writes_test.exs | 24 | ||||
-rw-r--r-- | test/elixir/test/config/suite.elixir | 3 |
2 files changed, 26 insertions, 1 deletions
diff --git a/test/elixir/test/concurrent_writes_test.exs b/test/elixir/test/concurrent_writes_test.exs index bf3c0a652..397c5e880 100644 --- a/test/elixir/test/concurrent_writes_test.exs +++ b/test/elixir/test/concurrent_writes_test.exs @@ -48,4 +48,28 @@ defmodule ConcurrentWritesTest do assert result == Enum.sum(1..n) end + @tag :with_db + test "Secondary data tests with updates", context do + n = 120 + db_name = context[:db_name] + map_fun = "function(doc) { emit(null, doc.a); }" + red_fun = "_sum" + ddoc_id = "_design/foo" + ddoc = %{:views => %{:foo => %{:map => map_fun, :reduce => red_fun}}} + Couch.put("/#{db_name}/#{ddoc_id}", body: ddoc) + parent = self() + Enum.each(1..n, + fn x -> spawn fn -> + r = Couch.put("/#{db_name}/doc#{x}", body: %{:a => x}) + assert r.status_code == 201 + rev = r.body["rev"] + Couch.put("/#{db_name}/doc#{x}", body: %{:_rev => rev, :a => x + 1}) + send parent, :done + end end) + Enum.each(1..n, fn _x -> receive do :done -> :done end end) + rows = Couch.get("/#{db_name}/#{ddoc_id}/_view/foo").body["rows"] + result = hd(rows)["value"] + assert result == Enum.sum(2..n + 1) + end + end diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index 65f972c2f..c508b4449 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -133,7 +133,8 @@ ], "ConcurrentWritesTest": [ "Primary data tests", - "Secondary data tests" + "Secondary data tests", + "Secondary data tests with updates" ], "ConfigTest": [ "Atoms, binaries, and strings suffice as whitelist sections and keys.", |