summaryrefslogtreecommitdiff
path: root/src/mango/test/user_docs.py
diff options
context:
space:
mode:
authorGabor Pali <gabor.pali@ibm.com>2023-05-11 03:27:29 +0200
committerNick Vatamaniuc <nickva@users.noreply.github.com>2023-05-11 12:55:24 -0400
commita854625d74a5b3847b99c6f536187723821d0aae (patch)
tree22229beeafdf5e1c650825026986ab1070061c46 /src/mango/test/user_docs.py
parent98fc76d67230a4472c9ef8597dd80d01f7eee224 (diff)
downloadcouchdb-a854625d74a5b3847b99c6f536187723821d0aae.tar.gz
fix(mango): covering indexes for partitioned databases
The previous work that introduced the keys-only covering indexes did not count with the case that database might be partitioned. And since they use a different format for their own local indexes and the code does not handle that, it will crash. When indexes are defined globally for the partitioned databases, there is no problem because the view row does not include information about the partition, i.e. it is transparent. Add the missing support for these scenarios and extend the test suite to cover them as well. That latter required some changes to the base classes in the integration test suite as it apparently completely misses out on running test cases for partitioned databases.
Diffstat (limited to 'src/mango/test/user_docs.py')
-rw-r--r--src/mango/test/user_docs.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mango/test/user_docs.py b/src/mango/test/user_docs.py
index a1b6c6e1a..b2a19eea7 100644
--- a/src/mango/test/user_docs.py
+++ b/src/mango/test/user_docs.py
@@ -58,9 +58,18 @@ def setup_users(db, **kwargs):
db.save_docs(copy.deepcopy(USERS_DOCS))
-def setup(db, index_type="view", **kwargs):
+def setup(db, index_type="view", partitioned=False, **kwargs):
db.recreate()
- db.save_docs(copy.deepcopy(DOCS))
+ p = str(partitioned).lower()
+ docs = copy.deepcopy(DOCS)
+
+ if partitioned:
+ for index, doc in enumerate(docs):
+ partition = index % PARTITIONS
+ doc["_id"] = "{}:{}".format(partition, doc["_id"])
+
+ db.save_docs(docs, partitioned=p)
+
if index_type == "view":
add_view_indexes(db, kwargs)
elif index_type == "text":
@@ -96,6 +105,8 @@ def add_text_indexes(db, kwargs):
db.create_text_index(**kwargs)
+PARTITIONS = 3
+
DOCS = [
{
"_id": "71562648-6acb-42bc-a182-df6b1f005b09",