You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2019/12/13 07:49:03 UTC
[couchdb] 01/01: Block on index available in tests
This is an automated email from the ASF dual-hosted git repository.
willholley pushed a commit to branch mango_test_fixes
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ed44ad94ec80fb1208df5be52a7b9126d02949b7
Author: Will Holley <wi...@gmail.com>
AuthorDate: Fri Dec 13 07:46:46 2019 +0000
Block on index available in tests
When creating a Mango index in the Elixir tests, we need to
block until the database reports the index as available. This
workaround was present in the python Mango tests but did not
get ported to Elixir when the partitioned Mango tests were added.
Presumambly this is needed to workaround an underlying race condition
between the index write and the ddoc cache.
---
test/elixir/test/partition_mango_test.exs | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/test/elixir/test/partition_mango_test.exs b/test/elixir/test/partition_mango_test.exs
index 3fd38d5..9ff83b1 100644
--- a/test/elixir/test/partition_mango_test.exs
+++ b/test/elixir/test/partition_mango_test.exs
@@ -17,6 +17,26 @@ defmodule PartitionMangoTest do
assert resp.status_code == 200
assert resp.body["result"] == "created"
+
+ # wait until the database reports the index as available
+ retry_until(fn ->
+ i = get_index(db_name, resp.body["ddoc"], resp.body["name"])
+ assert i != nil
+ {:ok, i}
+ end)
+ end
+
+ def list_indexes(db_name) do
+ resp = Couch.get("/#{db_name}/_index")
+ assert resp.status_code == 200
+ resp.body["indexes"]
+ end
+
+ def get_index(db_name, ddocid, name) do
+ indexes = list_indexes(db_name)
+ Enum.find(indexes, fn(index) ->
+ match?(%{"ddoc" => ddocid, "name" => name}, index)
+ end)
end
def get_partitions(resp) do