Skip to content

Commit 9e6f65b

Browse files
Added spec files for multipeer functional tests (#311)
* Added check for minimum 6 test servers * Added markdown files for multipeer tests
1 parent d417605 commit 9e6f65b

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed

spec/tests/QE/test_multipeer.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Multipeer Tests
2+
3+
This document describes the multipeer replication tests for Couchbase Lite, testing multipeer replication functionality with multiple devices.
4+
5+
## test_large_mesh_sanity
6+
7+
Test basic multipeer mesh replication sanity with a small number of documents.
8+
9+
1. Verify CBL version >= 3.3.0 on all test servers.
10+
2. Reset local database and load `empty` dataset on all devices.
11+
3. Add 20 documents to the database on device 1:
12+
* Documents named: `doc1`, `doc2`, ..., `doc20`
13+
* Each document contains a random integer value
14+
4. Start multipeer replicator on all devices:
15+
* peer_id: `"mesh-test"`
16+
* database: `db1` (on each device)
17+
* collections: `["_default._default"]`
18+
5. Wait for idle status on all devices:
19+
* timeout: 60 seconds
20+
* Verify no replicator errors
21+
6. Check that all device databases have the same content:
22+
* All databases should have identical documents
23+
7. Stop multipeer replicator on all devices.
24+
25+
## test_large_mesh_consistency
26+
27+
Test multipeer mesh replication consistency with documents added on all devices.
28+
29+
1. Verify CBL version >= 3.3.0 on all test servers.
30+
2. Reset local database and load `empty` dataset on all devices.
31+
3. Add 50 documents to the database on all devices:
32+
* Each device adds documents with naming pattern: `device{device_idx}-doc{doc_num}`
33+
* Each document contains a random integer value
34+
* Total documents across all devices: 50 * number_of_devices
35+
4. Start multipeer replicator on all devices:
36+
* peer_id: `"mesh-test"`
37+
* database: `db1` (on each device)
38+
* collections: `["_default._default"]`
39+
5. Wait for idle status on all devices:
40+
* timeout: 300 seconds
41+
* Verify no replicator errors
42+
6. Check that all device databases have the same content:
43+
* All databases should have identical documents from all devices
44+
7. Stop multipeer replicator on all devices.
45+
46+
## test_scalable_conflict_resolution
47+
48+
Test scalable conflict resolution using merge conflict resolver in multipeer mesh replication.
49+
50+
1. Verify CBL version >= 3.3.0 on all test servers.
51+
2. Reset local database and load `empty` dataset on all devices.
52+
3. Insert conflict1 on each device with its unique key in 'counter':
53+
* Document ID: `conflict1`
54+
* Format: `{"counter": {"deviceX": X}}`
55+
* Each device adds its own device key with device number as value
56+
4. Start multipeer replication with merge conflict resolver:
57+
* peer_id: `"couchtest"`
58+
* database: `db1` (on each device)
59+
* collections: `["_default._default"]`
60+
* conflict_resolver: `merge-dict` with property `counter`
61+
5. Wait for idle status on all devices:
62+
* timeout: 60 seconds
63+
* Verify no replicator errors
64+
6. Verify conflict1 is resolved identically on all devices with all device keys:
65+
* All devices should have the same document with all device keys merged
66+
* Each key's value must match the device_id
67+
* Retry up to 5 times if revision IDs don't match initially
68+
7. Stop multipeer replicator on all devices.
69+
70+
## test_network_partition
71+
72+
Test network partition scenarios with peer groups in multipeer mesh replication.
73+
74+
1. Verify CBL version >= 3.3.0 on all test servers.
75+
2. Reset local database and load `empty` dataset on all devices.
76+
3. Verify we have 6-15 devices for this test.
77+
4. Dynamically split devices into 3 groups:
78+
* Group 1: first portion of devices
79+
* Group 2: middle portion of devices
80+
* Group 3: remaining devices
81+
5. Add unique documents to each peer group:
82+
* Group 1: documents named `group1-doc1`, `group1-doc2`, ... (100 docs total)
83+
* Group 2: documents named `group2-doc1`, `group2-doc2`, ... (100 docs total)
84+
* Group 3: documents named `group3-doc1`, `group3-doc2`, ... (100 docs total)
85+
* Documents distributed across devices in each group
86+
6. Start multipeer replicators with different peer groups:
87+
* Group 1 replicators: peer_id `"group1"`
88+
* Group 2 replicators: peer_id `"group2"`
89+
* Group 3 replicators: peer_id `"group3"`
90+
* database: `db1` (on each device)
91+
* collections: `["_default._default"]`
92+
7. Wait for initial replication within each group:
93+
* timeout: 300 seconds
94+
* Verify no replicator errors
95+
8. Verify groups are isolated from each other:
96+
* Each group should only see peers within its own group
97+
* Group 1 should only see Group 1 peers
98+
* Group 2 should only see Group 2 peers
99+
* Group 3 should only see Group 3 peers
100+
9. Verify each group can see its own documents:
101+
* Group 1 devices should have 100 documents (group1-doc*)
102+
* Group 2 devices should have 100 documents (group2-doc*)
103+
* Group 3 devices should have 100 documents (group3-doc*)
104+
10. Stop group 2 replicators and restart with group 1's peer ID:
105+
* Stop all group 2 replicators
106+
* Restart group 2 replicators with peer_id `"group1"`
107+
11. Wait for replication between group 1 and group 2:
108+
* timeout: 300 seconds
109+
* Verify no replicator errors
110+
12. Verify group 1 and group 2 devices have combined documents:
111+
* Combined group should have 200 documents (100 from group1 + 100 from group2)
112+
13. Stop group 3 replicators and restart with group 1's peer ID:
113+
* Stop all group 3 replicators
114+
* Restart group 3 replicators with peer_id `"group1"`
115+
14. Wait for replication across all groups:
116+
* timeout: 300 seconds
117+
* Verify no replicator errors
118+
15. Verify all devices have all documents:
119+
* All devices should have 300 documents total (100 from each group)
120+
* All databases should have identical content
121+
16. Stop all multipeer replicators.
122+
123+
## test_dynamic_peer_addition_removal
124+
125+
Test dynamic peer addition and removal during active replication in multipeer mesh.
126+
127+
1. Verify CBL version >= 3.3.0 on all test servers.
128+
2. Reset local database and load `empty` dataset on all devices.
129+
3. Verify we have at least 6 devices for this test.
130+
4. Calculate device distribution:
131+
* Initial devices: at least 3, up to half of total devices
132+
* Additional devices: up to 3 additional devices
133+
* Devices to remove: 1-2 devices
134+
5. Add documents to initial devices:
135+
* Each device adds 20 documents
136+
* Documents named: `device{device_idx}-doc{doc_num}`
137+
6. Start multipeer replicator on initial devices:
138+
* peer_id: `"dynamic-mesh"`
139+
* database: `db1` (on each device)
140+
* collections: `["_default._default"]`
141+
7. Wait for some initial replication progress:
142+
* Wait for at least half of initial devices to reach idle
143+
* timeout: 300 seconds
144+
* Verify no replicator errors
145+
8. Add additional devices to the mesh:
146+
* Add 20 documents to each additional device
147+
* Documents named: `device{device_idx}-doc{doc_num}`
148+
9. Start replicators on additional devices:
149+
* peer_id: `"dynamic-mesh"` (same as initial devices)
150+
* database: `db1` (on each device)
151+
* collections: `["_default._default"]`
152+
10. Wait a short time for replication to start (2 seconds).
153+
11. Remove random devices from the mesh while replication is active:
154+
* Randomly select 1-2 devices to remove (mix of initial and additional)
155+
* Stop replicators on selected devices
156+
12. Wait for remaining devices to stabilize after removal:
157+
* timeout: 300 seconds
158+
* Verify no replicator errors
159+
13. Verify remaining devices achieve full data consistency:
160+
* All remaining devices should have the same document count
161+
* All databases should have identical content
162+
14. Stop all remaining multipeer replicators.
163+
164+
## test_large_document_replication
165+
166+
Test multipeer mesh replication with large documents containing blobs.
167+
168+
1. Verify CBL version >= 3.3.0 on all test servers.
169+
2. Reset local database and load `empty` dataset on all devices.
170+
3. Add 10 large documents with xl1.jpg blob to the database on device 1:
171+
* Documents named: `large_doc1`, `large_doc2`, ..., `large_doc10`
172+
* Each document contains a blob: `{"image": "xl1.jpg"}`
173+
4. Start multipeer replicator on all devices:
174+
* peer_id: `"large-doc-mesh"`
175+
* database: `db1` (on each device)
176+
* collections: `["_default._default"]`
177+
5. Wait for idle status on all devices:
178+
* timeout: 200 seconds
179+
* Verify no replicator errors
180+
6. Check that all device databases have the same content:
181+
* Each device should have exactly 10 documents
182+
* All databases should have identical content including blobs
183+
7. Stop multipeer replicator on all devices.

tests/QE/test_multipeer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ async def test_large_mesh_consistency(self, cblpytest: CBLPyTest):
222222

223223
await asyncio.gather(*[multipeer.stop() for multipeer in multipeer_replicators])
224224

225+
@pytest.mark.min_test_servers(6)
225226
@pytest.mark.asyncio(loop_scope="session")
226227
async def test_network_partition(self, cblpytest: CBLPyTest):
227228
for ts in cblpytest.test_servers:
@@ -508,6 +509,7 @@ async def test_network_partition(self, cblpytest: CBLPyTest):
508509

509510
await asyncio.gather(*[replicator.stop() for replicator in all_replicators])
510511

512+
@pytest.mark.min_test_servers(6)
511513
@pytest.mark.asyncio(loop_scope="session")
512514
async def test_dynamic_peer_addition_removal(self, cblpytest: CBLPyTest):
513515
for ts in cblpytest.test_servers:

0 commit comments

Comments
 (0)