Skip to content

Commit 9848ef7

Browse files
committed
test(NODE-4756): add unified spec tests
1 parent aad1aa7 commit 9848ef7

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

test/spec/command-logging-and-monitoring/monitoring/insertOne.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,86 @@
139139
]
140140
}
141141
]
142+
},
143+
{
144+
"description": "A failed insertOne with write concern errors publishes success event",
145+
"operations": [
146+
{
147+
"name": "failPoint",
148+
"object": "testRunner",
149+
"arguments": {
150+
"client": "client",
151+
"failPoint": {
152+
"configureFailPoint": "failCommand",
153+
"mode": {
154+
"times": 1
155+
},
156+
"data": {
157+
"failCommands": [
158+
"insert"
159+
],
160+
"writeConcernError": {
161+
"code": 91,
162+
"errorLabels": [
163+
"RetryableWriteError"
164+
]
165+
}
166+
}
167+
}
168+
}
169+
},
170+
{
171+
"name": "insertOne",
172+
"object": "collection",
173+
"arguments": {
174+
"document": {
175+
"_id": 3,
176+
"x": 33
177+
}
178+
},
179+
"expectError": {
180+
"isClientError": false
181+
}
182+
}
183+
],
184+
"expectEvents": [
185+
{
186+
"client": "client",
187+
"events": [
188+
{
189+
"commandStartedEvent": {
190+
"command": {
191+
"insert": "test",
192+
"documents": [
193+
{
194+
"_id": 3,
195+
"x": 33
196+
}
197+
],
198+
"ordered": true
199+
},
200+
"commandName": "insert",
201+
"databaseName": "command-monitoring-tests"
202+
}
203+
},
204+
{
205+
"commandSucceededEvent": {
206+
"reply": {
207+
"ok": 1,
208+
"n": 1,
209+
"writeConcernError": {
210+
"code": 91,
211+
"errorLabels": [
212+
"RetryableWriteError"
213+
]
214+
}
215+
},
216+
"commandName": "insert"
217+
}
218+
}
219+
]
220+
}
221+
]
142222
}
143223
]
144224
}

test/spec/command-logging-and-monitoring/monitoring/insertOne.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,41 @@ tests:
7575
# so those assertions are not present here.
7676
writeErrors: { $$type: array }
7777
commandName: insert
78+
79+
- description: "A failed insertOne with write concern errors publishes success event"
80+
operations:
81+
- name: failPoint
82+
object: testRunner
83+
arguments:
84+
client: *client
85+
failPoint:
86+
configureFailPoint: failCommand
87+
mode: { times: 1 }
88+
data:
89+
failCommands: [ insert ]
90+
writeConcernError:
91+
code: 91 # ShutdownInProgress
92+
errorLabels: [RetryableWriteError]
93+
- name: insertOne
94+
object: *collection
95+
arguments:
96+
document: { _id: 3, x: 33 }
97+
expectError:
98+
isClientError: false
99+
expectEvents:
100+
- client: *client
101+
events:
102+
- commandStartedEvent:
103+
command:
104+
insert: *collectionName
105+
documents:
106+
- { _id: 3, x: 33 }
107+
ordered: true
108+
commandName: insert
109+
databaseName: *databaseName
110+
- commandSucceededEvent:
111+
reply:
112+
ok: 1
113+
n: 1
114+
writeConcernError: { code: 91, errorLabels: [ "RetryableWriteError" ] }
115+
commandName: insert

0 commit comments

Comments
 (0)