summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2021-03-18 18:06:31 +0000
committerGitHub <noreply@github.com>2021-03-18 18:06:31 +0000
commit36eae8f7f6fb1ea67a51bed77499d50921d6738f (patch)
treedee3d0ff28150ec992ceae712b425abded6daec0
parenteeec561abc42dd358c4d473282e3442c1519089f (diff)
parentb125036f79b5c12ffd85146cceeed8e99c14eeb3 (diff)
downloadcouchdb-36eae8f7f6fb1ea67a51bed77499d50921d6738f.tar.gz
Merge pull request #3441 from apache/concurrent-write-test-with-updates
Add Secondary data tests with updates test
-rw-r--r--test/elixir/test/concurrent_writes_test.exs24
-rw-r--r--test/elixir/test/config/suite.elixir3
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.",