Skip to content

Commit 5185f71

Browse files
authored
CSHARP-4660: Add search index management helpers (#1119)
1 parent 8f4e119 commit 5185f71

28 files changed

+2230
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
======================
2+
Index Management Tests
3+
======================
4+
5+
.. contents::
6+
7+
----
8+
9+
Test Plan
10+
=========
11+
12+
These prose tests are ported from the legacy enumerate-indexes spec.
13+
14+
Configurations
15+
--------------
16+
17+
- standalone node
18+
- replica set primary node
19+
- replica set secondary node
20+
- mongos node
21+
22+
Preparation
23+
-----------
24+
25+
For each of the configurations:
26+
27+
- Create a (new) database
28+
- Create a collection
29+
- Create a single column index, a compound index, and a unique index
30+
- Insert at least one document containing all the fields that the above
31+
indicated indexes act on
32+
33+
Tests
34+
-----
35+
36+
- Run the driver's method that returns a list of index names, and:
37+
38+
- verify that *all* index names are represented in the result
39+
- verify that there are no duplicate index names
40+
- verify there are no returned indexes that do not exist
41+
42+
- Run the driver's method that returns a list of index information records, and:
43+
44+
- verify all the indexes are represented in the result
45+
- verify the "unique" flags show up for the unique index
46+
- verify there are no duplicates in the returned list
47+
- if the result consists of statically defined index models that include an ``ns`` field, verify
48+
that its value is accurate
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"description": "createSearchIndex",
3+
"schemaVersion": "1.4",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": false,
9+
"observeEvents": [
10+
"commandStartedEvent"
11+
]
12+
}
13+
},
14+
{
15+
"database": {
16+
"id": "database0",
17+
"client": "client0",
18+
"databaseName": "database0"
19+
}
20+
},
21+
{
22+
"collection": {
23+
"id": "collection0",
24+
"database": "database0",
25+
"collectionName": "collection0"
26+
}
27+
}
28+
],
29+
"runOnRequirements": [
30+
{
31+
"minServerVersion": "7.0.0",
32+
"topologies": [
33+
"replicaset",
34+
"load-balanced",
35+
"sharded"
36+
],
37+
"serverless": "forbid"
38+
}
39+
],
40+
"tests": [
41+
{
42+
"description": "no name provided for an index definition",
43+
"operations": [
44+
{
45+
"name": "createSearchIndex",
46+
"object": "collection0",
47+
"arguments": {
48+
"model": {
49+
"definition": {
50+
"mappings": {
51+
"dynamic": true
52+
}
53+
}
54+
}
55+
},
56+
"expectError": {
57+
"isError": true
58+
}
59+
}
60+
],
61+
"expectEvents": [
62+
{
63+
"client": "client0",
64+
"events": [
65+
{
66+
"commandStartedEvent": {
67+
"command": {
68+
"createSearchIndexes": "collection0",
69+
"indexes": [
70+
{
71+
"definition": {
72+
"mappings": {
73+
"dynamic": true
74+
}
75+
}
76+
}
77+
],
78+
"$db": "database0"
79+
}
80+
}
81+
}
82+
]
83+
}
84+
]
85+
},
86+
{
87+
"description": "name provided for an index definition",
88+
"operations": [
89+
{
90+
"name": "createSearchIndex",
91+
"object": "collection0",
92+
"arguments": {
93+
"model": {
94+
"definition": {
95+
"mappings": {
96+
"dynamic": true
97+
}
98+
},
99+
"name": "test index"
100+
}
101+
},
102+
"expectError": {
103+
"isError": true
104+
}
105+
}
106+
],
107+
"expectEvents": [
108+
{
109+
"client": "client0",
110+
"events": [
111+
{
112+
"commandStartedEvent": {
113+
"command": {
114+
"createSearchIndexes": "collection0",
115+
"indexes": [
116+
{
117+
"definition": {
118+
"mappings": {
119+
"dynamic": true
120+
}
121+
},
122+
"name": "test index"
123+
}
124+
],
125+
"$db": "database0"
126+
}
127+
}
128+
}
129+
]
130+
}
131+
]
132+
}
133+
]
134+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
description: "createSearchIndex"
2+
schemaVersion: "1.4"
3+
createEntities:
4+
- client:
5+
id: &client0 client0
6+
useMultipleMongoses: false
7+
observeEvents:
8+
- commandStartedEvent
9+
- database:
10+
id: &database0 database0
11+
client: *client0
12+
databaseName: *database0
13+
- collection:
14+
id: &collection0 collection0
15+
database: *database0
16+
collectionName: *collection0
17+
18+
runOnRequirements:
19+
- minServerVersion: "7.0.0"
20+
topologies: [ replicaset, load-balanced, sharded ]
21+
serverless: forbid
22+
23+
tests:
24+
- description: "no name provided for an index definition"
25+
operations:
26+
- name: createSearchIndex
27+
object: *collection0
28+
arguments:
29+
model: { definition: &definition { mappings: { dynamic: true } } }
30+
expectError:
31+
# Search indexes are only available on 7.0+ atlas clusters. DRIVERS-2630 will add e2e testing
32+
# against an Atlas cluster and the expectError will be removed.
33+
isError: true
34+
expectEvents:
35+
- client: *client0
36+
events:
37+
- commandStartedEvent:
38+
command:
39+
createSearchIndexes: *collection0
40+
indexes: [ { definition: *definition } ]
41+
$db: *database0
42+
43+
- description: "name provided for an index definition"
44+
operations:
45+
- name: createSearchIndex
46+
object: *collection0
47+
arguments:
48+
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index' }
49+
expectError:
50+
# Search indexes are only available on 7.0+ atlas clusters. DRIVERS-2630 will add e2e testing
51+
# against an Atlas cluster and the expectError will be removed.
52+
isError: true
53+
expectEvents:
54+
- client: *client0
55+
events:
56+
- commandStartedEvent:
57+
command:
58+
createSearchIndexes: *collection0
59+
indexes: [ { definition: *definition, name: 'test index' } ]
60+
$db: *database0

0 commit comments

Comments
 (0)