diff options
author | Will Holley <willholley@gmail.com> | 2019-12-13 07:46:46 +0000 |
---|---|---|
committer | Will Holley <willholley@gmail.com> | 2019-12-16 07:51:14 +0000 |
commit | 5c0cf2e305a34cd30c04f09b18c6e78462aa96c1 (patch) | |
tree | 9795420a8e5e076adc94b644cecd6be53c1a9cf7 | |
parent | 18b97f7c44d8143ea6231f2547ae20d480becdb5 (diff) | |
download | couchdb-mango_test_fixes.tar.gz |
Block on index available in testsmango_test_fixes
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.
-rw-r--r-- | test/elixir/test/partition_mango_test.exs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/elixir/test/partition_mango_test.exs b/test/elixir/test/partition_mango_test.exs index 3fd38d52b..992999fb9 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" + assert resp.body["id"] != nil + assert resp.body["name"] != nil + + # wait until the database reports the index as available + retry_until(fn -> + get_index(db_name, resp.body["id"], resp.body["name"]) != nil + 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 |