Skip to content

Commit ecb80d8

Browse files
PCSM-226. Clone data with inconsistent index
1 parent 0f38bc6 commit ecb80d8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_indexes_sharded.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# pylint: disable=missing-docstring,redefined-outer-name
2+
import time
3+
4+
import pytest
5+
from pcsm import Runner
6+
from testing import Testing
7+
8+
@pytest.mark.timeout(20)
9+
@pytest.mark.parametrize("phase", [Runner.Phase.CLONE])
10+
def test_inconsistent_index(t: Testing, phase: Runner.Phase):
11+
t.source.admin.command({"enableSharding": "init_test_db"})
12+
t.source.admin.command("shardCollection", "init_test_db.text_collection", key={"_id": "hashed"})
13+
t.source["init_test_db"].text_collection.insert_many([{"a": {"b": i}, "words": f"text_{i}"} for i in range(50)])
14+
t.source["init_test_db"].text_collection.insert_one({"a": {"b": []}, "words": "omnibus"})
15+
16+
# Create inconsistent index
17+
try:
18+
t.source["init_test_db"].text_collection.create_index([("a.b", 1), ("words", "text")])
19+
assert False, "Index build should fail due array in doc for text index"
20+
except Exception:
21+
pass
22+
23+
time.sleep(15)
24+
with t.run(phase):
25+
pass
26+
t.compare_all_sharded()

0 commit comments

Comments
 (0)