Skip to content

Commit 95de0fb

Browse files
authored
GODRIVER-2341 Sync CSOT bulkWrite spec tests. (#992)
1 parent b9fe7de commit 95de0fb

File tree

2 files changed

+243
-0
lines changed

2 files changed

+243
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"description": "timeoutMS behaves correctly for bulkWrite operations",
3+
"schemaVersion": "1.9",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.4"
7+
}
8+
],
9+
"createEntities": [
10+
{
11+
"client": {
12+
"id": "failPointClient",
13+
"useMultipleMongoses": false
14+
}
15+
},
16+
{
17+
"client": {
18+
"id": "client",
19+
"useMultipleMongoses": false,
20+
"observeEvents": [
21+
"commandStartedEvent"
22+
]
23+
}
24+
},
25+
{
26+
"database": {
27+
"id": "database",
28+
"client": "client",
29+
"databaseName": "test"
30+
}
31+
},
32+
{
33+
"collection": {
34+
"id": "collection",
35+
"database": "database",
36+
"collectionName": "coll"
37+
}
38+
}
39+
],
40+
"initialData": [
41+
{
42+
"collectionName": "coll",
43+
"databaseName": "test",
44+
"documents": []
45+
}
46+
],
47+
"tests": [
48+
{
49+
"description": "timeoutMS applied to entire bulkWrite, not individual commands",
50+
"operations": [
51+
{
52+
"name": "failPoint",
53+
"object": "testRunner",
54+
"arguments": {
55+
"client": "failPointClient",
56+
"failPoint": {
57+
"configureFailPoint": "failCommand",
58+
"mode": {
59+
"times": 2
60+
},
61+
"data": {
62+
"failCommands": [
63+
"insert",
64+
"update"
65+
],
66+
"blockConnection": true,
67+
"blockTimeMS": 120
68+
}
69+
}
70+
}
71+
},
72+
{
73+
"name": "find",
74+
"object": "collection",
75+
"arguments": {
76+
"filter": {
77+
"_id": 1
78+
}
79+
}
80+
},
81+
{
82+
"name": "bulkWrite",
83+
"object": "collection",
84+
"arguments": {
85+
"requests": [
86+
{
87+
"insertOne": {
88+
"document": {
89+
"_id": 1
90+
}
91+
}
92+
},
93+
{
94+
"replaceOne": {
95+
"filter": {
96+
"_id": 1
97+
},
98+
"replacement": {
99+
"x": 1
100+
}
101+
}
102+
}
103+
],
104+
"timeoutMS": 200
105+
},
106+
"expectError": {
107+
"isTimeoutError": true
108+
}
109+
}
110+
],
111+
"expectEvents": [
112+
{
113+
"client": "client",
114+
"events": [
115+
{
116+
"commandStartedEvent": {
117+
"commandName": "find",
118+
"databaseName": "test",
119+
"command": {
120+
"find": "coll"
121+
}
122+
}
123+
},
124+
{
125+
"commandStartedEvent": {
126+
"commandName": "insert",
127+
"databaseName": "test",
128+
"command": {
129+
"insert": "coll",
130+
"maxTimeMS": {
131+
"$$type": [
132+
"int",
133+
"long"
134+
]
135+
}
136+
}
137+
}
138+
},
139+
{
140+
"commandStartedEvent": {
141+
"commandName": "update",
142+
"databaseName": "test",
143+
"command": {
144+
"update": "coll",
145+
"maxTimeMS": {
146+
"$$type": [
147+
"int",
148+
"long"
149+
]
150+
}
151+
}
152+
}
153+
}
154+
]
155+
}
156+
]
157+
}
158+
]
159+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
description: "timeoutMS behaves correctly for bulkWrite operations"
2+
3+
schemaVersion: "1.9"
4+
5+
runOnRequirements:
6+
- minServerVersion: "4.4"
7+
8+
createEntities:
9+
- client:
10+
id: &failPointClient failPointClient
11+
useMultipleMongoses: false
12+
- client:
13+
id: &client client
14+
useMultipleMongoses: false
15+
observeEvents:
16+
- commandStartedEvent
17+
- database:
18+
id: &database database
19+
client: *client
20+
databaseName: &databaseName test
21+
- collection:
22+
id: &collection collection
23+
database: *database
24+
collectionName: &collectionName coll
25+
26+
initialData:
27+
- collectionName: *collectionName
28+
databaseName: *databaseName
29+
documents: []
30+
31+
tests:
32+
# Test that drivers do not refresh timeoutMS between commands. This is done by running a bulkWrite that will require
33+
# two commands with timeoutMS=200 and blocking each command for 120ms. The server should take over 200ms total, so the
34+
# bulkWrite should fail with a timeout error.
35+
- description: "timeoutMS applied to entire bulkWrite, not individual commands"
36+
operations:
37+
- name: failPoint
38+
object: testRunner
39+
arguments:
40+
client: *failPointClient
41+
failPoint:
42+
configureFailPoint: failCommand
43+
mode: { times: 2 }
44+
data:
45+
failCommands: ["insert", "update"]
46+
blockConnection: true
47+
blockTimeMS: 120
48+
# Do an operation without a timeout to ensure the servers are discovered.
49+
- name: find
50+
object: *collection
51+
arguments:
52+
filter: { _id : 1 }
53+
- name: bulkWrite
54+
object: *collection
55+
arguments:
56+
requests:
57+
- insertOne:
58+
document: { _id: 1 }
59+
- replaceOne:
60+
filter: { _id: 1 }
61+
replacement: { x: 1 }
62+
timeoutMS: 200
63+
expectError:
64+
isTimeoutError: true
65+
expectEvents:
66+
- client: *client
67+
events:
68+
- commandStartedEvent:
69+
commandName: find
70+
databaseName: *databaseName
71+
command:
72+
find: *collectionName
73+
- commandStartedEvent:
74+
commandName: insert
75+
databaseName: *databaseName
76+
command:
77+
insert: *collectionName
78+
maxTimeMS: { $$type: ["int", "long"] }
79+
- commandStartedEvent:
80+
commandName: update
81+
databaseName: *databaseName
82+
command:
83+
update: *collectionName
84+
maxTimeMS: { $$type: ["int", "long"] }

0 commit comments

Comments
 (0)