Skip to content

Commit 11e7e00

Browse files
authored
test(NODE-4255): sync clustered index spec tests (#3266)
1 parent 6845069 commit 11e7e00

File tree

2 files changed

+169
-15
lines changed

2 files changed

+169
-15
lines changed

test/spec/collection-management/clustered-indexes.json

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"createEntities": [
1111
{
1212
"client": {
13-
"id": "client0"
13+
"id": "client0",
14+
"observeEvents": [
15+
"commandStartedEvent"
16+
]
1417
}
1518
},
1619
{
1720
"database": {
1821
"id": "database0",
1922
"client": "client0",
20-
"databaseName": "ts-tests"
23+
"databaseName": "ci-tests"
2124
}
2225
},
2326
{
@@ -31,7 +34,7 @@
3134
"initialData": [
3235
{
3336
"collectionName": "test",
34-
"databaseName": "ts-tests",
37+
"databaseName": "ci-tests",
3538
"documents": []
3639
}
3740
],
@@ -64,10 +67,40 @@
6467
"name": "assertCollectionExists",
6568
"object": "testRunner",
6669
"arguments": {
67-
"databaseName": "ts-tests",
70+
"databaseName": "ci-tests",
6871
"collectionName": "test"
6972
}
7073
}
74+
],
75+
"expectEvents": [
76+
{
77+
"client": "client0",
78+
"events": [
79+
{
80+
"commandStartedEvent": {
81+
"command": {
82+
"drop": "test"
83+
},
84+
"databaseName": "ci-tests"
85+
}
86+
},
87+
{
88+
"commandStartedEvent": {
89+
"command": {
90+
"create": "test",
91+
"clusteredIndex": {
92+
"key": {
93+
"_id": 1
94+
},
95+
"unique": true,
96+
"name": "test index"
97+
}
98+
},
99+
"databaseName": "ci-tests"
100+
}
101+
}
102+
]
103+
}
71104
]
72105
},
73106
{
@@ -125,6 +158,49 @@
125158
}
126159
]
127160
}
161+
],
162+
"expectEvents": [
163+
{
164+
"client": "client0",
165+
"events": [
166+
{
167+
"commandStartedEvent": {
168+
"command": {
169+
"drop": "test"
170+
},
171+
"databaseName": "ci-tests"
172+
}
173+
},
174+
{
175+
"commandStartedEvent": {
176+
"command": {
177+
"create": "test",
178+
"clusteredIndex": {
179+
"key": {
180+
"_id": 1
181+
},
182+
"unique": true,
183+
"name": "test index"
184+
}
185+
},
186+
"databaseName": "ci-tests"
187+
}
188+
},
189+
{
190+
"commandStartedEvent": {
191+
"command": {
192+
"listCollections": 1,
193+
"filter": {
194+
"name": {
195+
"$eq": "test"
196+
}
197+
}
198+
},
199+
"databaseName": "ci-tests"
200+
}
201+
}
202+
]
203+
}
128204
]
129205
},
130206
{
@@ -171,6 +247,44 @@
171247
}
172248
]
173249
}
250+
],
251+
"expectEvents": [
252+
{
253+
"client": "client0",
254+
"events": [
255+
{
256+
"commandStartedEvent": {
257+
"command": {
258+
"drop": "test"
259+
},
260+
"databaseName": "ci-tests"
261+
}
262+
},
263+
{
264+
"commandStartedEvent": {
265+
"command": {
266+
"create": "test",
267+
"clusteredIndex": {
268+
"key": {
269+
"_id": 1
270+
},
271+
"unique": true,
272+
"name": "test index"
273+
}
274+
},
275+
"databaseName": "ci-tests"
276+
}
277+
},
278+
{
279+
"commandStartedEvent": {
280+
"command": {
281+
"listIndexes": "test"
282+
},
283+
"databaseName": "ci-tests"
284+
}
285+
}
286+
]
287+
}
174288
]
175289
}
176290
]

test/spec/collection-management/clustered-indexes.yml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ runOnRequirements:
99
createEntities:
1010
- client:
1111
id: &client0 client0
12+
observeEvents: [ commandStartedEvent ]
1213
- database:
1314
id: &database0 database0
1415
client: *client0
15-
databaseName: &database0Name ts-tests
16+
databaseName: &database0Name ci-tests
1617
- collection:
1718
id: &collection0 collection0
1819
database: *database0
@@ -34,7 +35,7 @@ tests:
3435
object: *database0
3536
arguments:
3637
collection: *collection0Name
37-
clusteredIndex:
38+
clusteredIndex: &clusteredIndex
3839
key: { _id: 1 }
3940
unique: true
4041
name: &index0Name "test index"
@@ -43,6 +44,18 @@ tests:
4344
arguments:
4445
databaseName: *database0Name
4546
collectionName: *collection0Name
47+
expectEvents:
48+
- client: *client0
49+
events:
50+
- commandStartedEvent:
51+
command:
52+
drop: *collection0Name
53+
databaseName: *database0Name
54+
- commandStartedEvent:
55+
command:
56+
create: *collection0Name
57+
clusteredIndex: *clusteredIndex
58+
databaseName: *database0Name
4659

4760
- description: "listCollections includes clusteredIndex"
4861
operations:
@@ -54,14 +67,11 @@ tests:
5467
object: *database0
5568
arguments:
5669
collection: *collection0Name
57-
clusteredIndex:
58-
key: { _id: 1 }
59-
unique: true
60-
name: &index0Name "test index"
70+
clusteredIndex: *clusteredIndex
6171
- name: listCollections
6272
object: *database0
6373
arguments:
64-
filter: { name: { $eq: *collection0Name } }
74+
filter: &filter { name: { $eq: *collection0Name } }
6575
expectResult:
6676
- name: *collection0Name
6777
options:
@@ -70,6 +80,23 @@ tests:
7080
unique: true
7181
name: *index0Name
7282
v: { $$type: [ int, long ] }
83+
expectEvents:
84+
- client: *client0
85+
events:
86+
- commandStartedEvent:
87+
command:
88+
drop: *collection0Name
89+
databaseName: *database0Name
90+
- commandStartedEvent:
91+
command:
92+
create: *collection0Name
93+
clusteredIndex: *clusteredIndex
94+
databaseName: *database0Name
95+
- commandStartedEvent:
96+
command:
97+
listCollections: 1
98+
filter: *filter
99+
databaseName: *database0Name
73100

74101
- description: "listIndexes returns the index"
75102
operations:
@@ -81,10 +108,7 @@ tests:
81108
object: *database0
82109
arguments:
83110
collection: *collection0Name
84-
clusteredIndex:
85-
key: { _id: 1 }
86-
unique: true
87-
name: *index0Name
111+
clusteredIndex: *clusteredIndex
88112
- name: listIndexes
89113
object: *collection0
90114
expectResult:
@@ -93,3 +117,19 @@ tests:
93117
clustered: true
94118
unique: true
95119
v: { $$type: [ int, long ] }
120+
expectEvents:
121+
- client: *client0
122+
events:
123+
- commandStartedEvent:
124+
command:
125+
drop: *collection0Name
126+
databaseName: *database0Name
127+
- commandStartedEvent:
128+
command:
129+
create: *collection0Name
130+
clusteredIndex: *clusteredIndex
131+
databaseName: *database0Name
132+
- commandStartedEvent:
133+
command:
134+
listIndexes: *collection0Name
135+
databaseName: *database0Name

0 commit comments

Comments
 (0)