Skip to content

Commit bbc3701

Browse files
committed
feat(NODE-6329): client bulk write happy path
1 parent f525403 commit bbc3701

File tree

13 files changed

+1986
-5
lines changed

13 files changed

+1986
-5
lines changed

src/mongo_client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
475475
return this.s.bsonOptions;
476476
}
477477

478+
async bulkWrite(): Promise<ClientBulkWriteResult> {
479+
480+
}
481+
478482
/**
479483
* Connect to MongoDB using a url
480484
*

test/integration/crud/crud.spec.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
55

66
const clientBulkWriteTests = new RegExp(
77
[
8-
'client bulk write delete with collation',
9-
'client bulk write delete with hint',
108
'client bulkWrite operations support errorResponse assertions',
119
'an individual operation fails during an ordered bulkWrite',
1210
'an individual operation fails during an unordered bulkWrite',
1311
'detailed results are omitted from error when verboseResults is false',
1412
'a top-level failure occurs during a bulkWrite',
1513
'a bulk write with only errors does not report a partial result',
1614
'an empty list of write models is a client-side error',
17-
'a write concern error occurs during a bulkWrite',
18-
'client bulkWrite'
15+
'a write concern error occurs during a bulkWrite'
1916
].join('|')
2017
);
2118

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
{
2+
"description": "unacknowledged-client-bulkWrite",
3+
"schemaVersion": "1.7",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "8.0"
7+
}
8+
],
9+
"createEntities": [
10+
{
11+
"client": {
12+
"id": "client",
13+
"useMultipleMongoses": false,
14+
"observeEvents": [
15+
"commandStartedEvent",
16+
"commandSucceededEvent",
17+
"commandFailedEvent"
18+
],
19+
"uriOptions": {
20+
"w": 0
21+
}
22+
}
23+
},
24+
{
25+
"database": {
26+
"id": "database",
27+
"client": "client",
28+
"databaseName": "command-monitoring-tests"
29+
}
30+
},
31+
{
32+
"collection": {
33+
"id": "collection",
34+
"database": "database",
35+
"collectionName": "test"
36+
}
37+
}
38+
],
39+
"initialData": [
40+
{
41+
"collectionName": "test",
42+
"databaseName": "command-monitoring-tests",
43+
"documents": [
44+
{
45+
"_id": 1,
46+
"x": 11
47+
},
48+
{
49+
"_id": 2,
50+
"x": 22
51+
},
52+
{
53+
"_id": 3,
54+
"x": 33
55+
}
56+
]
57+
}
58+
],
59+
"_yamlAnchors": {
60+
"namespace": "command-monitoring-tests.test"
61+
},
62+
"tests": [
63+
{
64+
"description": "A successful mixed client bulkWrite",
65+
"operations": [
66+
{
67+
"object": "client",
68+
"name": "clientBulkWrite",
69+
"arguments": {
70+
"models": [
71+
{
72+
"insertOne": {
73+
"namespace": "command-monitoring-tests.test",
74+
"document": {
75+
"_id": 4,
76+
"x": 44
77+
}
78+
}
79+
},
80+
{
81+
"updateOne": {
82+
"namespace": "command-monitoring-tests.test",
83+
"filter": {
84+
"_id": 3
85+
},
86+
"update": {
87+
"$set": {
88+
"x": 333
89+
}
90+
}
91+
}
92+
}
93+
]
94+
},
95+
"expectResult": {
96+
"insertedCount": {
97+
"$$unsetOrMatches": 0
98+
},
99+
"upsertedCount": {
100+
"$$unsetOrMatches": 0
101+
},
102+
"matchedCount": {
103+
"$$unsetOrMatches": 0
104+
},
105+
"modifiedCount": {
106+
"$$unsetOrMatches": 0
107+
},
108+
"deletedCount": {
109+
"$$unsetOrMatches": 0
110+
},
111+
"insertResults": {
112+
"$$unsetOrMatches": {}
113+
},
114+
"updateResults": {
115+
"$$unsetOrMatches": {}
116+
},
117+
"deleteResults": {
118+
"$$unsetOrMatches": {}
119+
}
120+
}
121+
},
122+
{
123+
"object": "collection",
124+
"name": "find",
125+
"arguments": {
126+
"filter": {}
127+
},
128+
"expectResult": [
129+
{
130+
"_id": 1,
131+
"x": 11
132+
},
133+
{
134+
"_id": 2,
135+
"x": 22
136+
},
137+
{
138+
"_id": 3,
139+
"x": 333
140+
},
141+
{
142+
"_id": 4,
143+
"x": 44
144+
}
145+
]
146+
}
147+
],
148+
"expectEvents": [
149+
{
150+
"client": "client",
151+
"ignoreExtraEvents": true,
152+
"events": [
153+
{
154+
"commandStartedEvent": {
155+
"commandName": "bulkWrite",
156+
"databaseName": "admin",
157+
"command": {
158+
"bulkWrite": 1,
159+
"errorsOnly": true,
160+
"ordered": true,
161+
"ops": [
162+
{
163+
"insert": 0,
164+
"document": {
165+
"_id": 4,
166+
"x": 44
167+
}
168+
},
169+
{
170+
"update": 0,
171+
"filter": {
172+
"_id": 3
173+
},
174+
"updateMods": {
175+
"$set": {
176+
"x": 333
177+
}
178+
},
179+
"multi": false
180+
}
181+
],
182+
"nsInfo": [
183+
{
184+
"ns": "command-monitoring-tests.test"
185+
}
186+
]
187+
}
188+
}
189+
},
190+
{
191+
"commandSucceededEvent": {
192+
"commandName": "bulkWrite",
193+
"reply": {
194+
"ok": 1,
195+
"nInserted": {
196+
"$$exists": false
197+
},
198+
"nMatched": {
199+
"$$exists": false
200+
},
201+
"nModified": {
202+
"$$exists": false
203+
},
204+
"nUpserted": {
205+
"$$exists": false
206+
},
207+
"nDeleted": {
208+
"$$exists": false
209+
}
210+
}
211+
}
212+
}
213+
]
214+
}
215+
]
216+
}
217+
]
218+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
description: "unacknowledged-client-bulkWrite"
2+
3+
schemaVersion: "1.7"
4+
5+
runOnRequirements:
6+
- minServerVersion: "8.0"
7+
8+
createEntities:
9+
- client:
10+
id: &client client
11+
useMultipleMongoses: false
12+
observeEvents:
13+
- commandStartedEvent
14+
- commandSucceededEvent
15+
- commandFailedEvent
16+
uriOptions:
17+
w: 0
18+
- database:
19+
id: &database database
20+
client: *client
21+
databaseName: &databaseName command-monitoring-tests
22+
- collection:
23+
id: &collection collection
24+
database: *database
25+
collectionName: &collectionName test
26+
27+
initialData:
28+
- collectionName: *collectionName
29+
databaseName: *databaseName
30+
documents:
31+
- { _id: 1, x: 11 }
32+
- { _id: 2, x: 22 }
33+
- { _id: 3, x: 33 }
34+
35+
_yamlAnchors:
36+
namespace: &namespace "command-monitoring-tests.test"
37+
38+
tests:
39+
- description: 'A successful mixed client bulkWrite'
40+
operations:
41+
- object: *client
42+
name: clientBulkWrite
43+
arguments:
44+
models:
45+
- insertOne:
46+
namespace: *namespace
47+
document: { _id: 4, x: 44 }
48+
- updateOne:
49+
namespace: *namespace
50+
filter: { _id: 3 }
51+
update: { $set: { x: 333 } }
52+
expectResult:
53+
insertedCount:
54+
$$unsetOrMatches: 0
55+
upsertedCount:
56+
$$unsetOrMatches: 0
57+
matchedCount:
58+
$$unsetOrMatches: 0
59+
modifiedCount:
60+
$$unsetOrMatches: 0
61+
deletedCount:
62+
$$unsetOrMatches: 0
63+
insertResults:
64+
$$unsetOrMatches: {}
65+
updateResults:
66+
$$unsetOrMatches: {}
67+
deleteResults:
68+
$$unsetOrMatches: {}
69+
# Force completion of the w:0 write by executing a find on the same connection
70+
- object: *collection
71+
name: find
72+
arguments:
73+
filter: {}
74+
expectResult:
75+
- { _id: 1, x: 11 }
76+
- { _id: 2, x: 22 }
77+
- { _id: 3, x: 333 }
78+
- { _id: 4, x: 44 }
79+
80+
expectEvents:
81+
-
82+
client: *client
83+
ignoreExtraEvents: true
84+
events:
85+
- commandStartedEvent:
86+
commandName: bulkWrite
87+
databaseName: admin
88+
command:
89+
bulkWrite: 1
90+
errorsOnly: true
91+
ordered: true
92+
ops:
93+
- insert: 0
94+
document: { _id: 4, x: 44 }
95+
- update: 0
96+
filter: { _id: 3 }
97+
updateMods: { $set: { x: 333 } }
98+
multi: false
99+
nsInfo:
100+
- ns: *namespace
101+
- commandSucceededEvent:
102+
commandName: bulkWrite
103+
reply:
104+
ok: 1
105+
nInserted: { $$exists: false }
106+
nMatched: { $$exists: false }
107+
nModified: { $$exists: false }
108+
nUpserted: { $$exists: false }
109+
nDeleted: { $$exists: false }

0 commit comments

Comments
 (0)