This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch concurrent-write-test-with-updates
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to 
refs/heads/concurrent-write-test-with-updates by this push:
     new b125036  Add Secondary data tests with updates test
b125036 is described below

commit b125036f79b5c12ffd85146cceeed8e99c14eeb3
Author: Robert Newson <[email protected]>
AuthorDate: Thu Mar 18 15:44:52 2021 +0000

    Add Secondary data tests with updates test
---
 test/elixir/test/concurrent_writes_test.exs | 24 ++++++++++++++++++++++++
 test/elixir/test/config/suite.elixir        |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/test/elixir/test/concurrent_writes_test.exs 
b/test/elixir/test/concurrent_writes_test.exs
index bf3c0a6..397c5e8 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 65f972c..c508b44 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.",

Reply via email to