Skip to content

Commit ee82cd7

Browse files
Update connection churn tests
1 parent ff9b5d9 commit ee82cd7

File tree

2 files changed

+219
-2
lines changed

2 files changed

+219
-2
lines changed

testdata/client-side-operations-timeout/connection-churn.json

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"name": "insertOne",
8484
"object": "coll",
8585
"arguments": {
86-
"timeoutMS": 500,
86+
"timeoutMS": 50,
8787
"document": {
8888
"_id": 3,
8989
"x": 1
@@ -139,6 +139,138 @@
139139
}
140140
]
141141
},
142+
{
143+
"description": "Concurrent write operation with successful pending read",
144+
"operations": [
145+
{
146+
"name": "failPoint",
147+
"object": "testRunner",
148+
"arguments": {
149+
"client": "failPointClient",
150+
"failPoint": {
151+
"configureFailPoint": "failCommand",
152+
"mode": {
153+
"times": 1
154+
},
155+
"data": {
156+
"failCommands": [
157+
"insert"
158+
],
159+
"blockConnection": true,
160+
"blockTimeMS": 750
161+
}
162+
}
163+
}
164+
},
165+
{
166+
"name": "createEntities",
167+
"object": "testRunner",
168+
"arguments": {
169+
"entities": [
170+
{
171+
"thread": {
172+
"id": "thread0"
173+
}
174+
},
175+
{
176+
"thread": {
177+
"id": "thread1"
178+
}
179+
}
180+
]
181+
}
182+
},
183+
{
184+
"name": "runOnThread",
185+
"object": "testRunner",
186+
"arguments": {
187+
"thread": "thread0",
188+
"operation": {
189+
"name": "insertOne",
190+
"object": "coll",
191+
"arguments": {
192+
"timeoutMS": 500,
193+
"document": {
194+
"_id": 2
195+
}
196+
}
197+
},
198+
"expectError": {
199+
"isTimeoutError": true
200+
}
201+
}
202+
},
203+
{
204+
"name": "waitForEvent",
205+
"object": "testRunner",
206+
"arguments": {
207+
"client": "client",
208+
"event": {
209+
"connectionCheckedOutEvent": {}
210+
},
211+
"count": 1
212+
}
213+
},
214+
{
215+
"name": "runOnThread",
216+
"object": "testRunner",
217+
"arguments": {
218+
"thread": "thread1",
219+
"operation": {
220+
"name": "insertOne",
221+
"object": "coll",
222+
"arguments": {
223+
"document": {
224+
"_id": 3
225+
}
226+
}
227+
}
228+
}
229+
},
230+
{
231+
"name": "waitForThread",
232+
"object": "testRunner",
233+
"arguments": {
234+
"thread": "thread1"
235+
}
236+
}
237+
],
238+
"expectEvents": [
239+
{
240+
"client": "client",
241+
"events": [
242+
{
243+
"commandFailedEvent": {
244+
"commandName": "insert"
245+
}
246+
},
247+
{
248+
"commandSucceededEvent": {
249+
"commandName": "insert"
250+
}
251+
}
252+
]
253+
},
254+
{
255+
"client": "client",
256+
"eventType": "cmap",
257+
"events": [
258+
{
259+
"connectionCheckedOutEvent": {}
260+
},
261+
{
262+
"connectionCheckedInEvent": {}
263+
},
264+
{
265+
"connectionCheckedOutEvent": {}
266+
},
267+
{
268+
"connectionCheckedInEvent": {}
269+
}
270+
]
271+
}
272+
]
273+
},
142274
{
143275
"description": "Write operation with unsuccessful pending read",
144276
"operations": [

testdata/client-side-operations-timeout/connection-churn.yml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ tests:
5959
- name: insertOne
6060
object: *collection
6161
arguments:
62-
timeoutMS: 500
62+
timeoutMS: 50
6363
document: { _id: 3, x: 1 }
6464
expectError:
6565
isTimeoutError: true
@@ -85,6 +85,91 @@ tests:
8585
- connectionCheckedOutEvent: {} # find
8686
- connectionCheckedInEvent: {} # find succeeds
8787

88+
- description: "Concurrent write operation with successful pending read"
89+
operations:
90+
# Create a failpoint to block the first operation
91+
- name: failPoint
92+
object: testRunner
93+
arguments:
94+
client: *failPointClient
95+
failPoint:
96+
configureFailPoint: failCommand
97+
mode: { times: 1 }
98+
data:
99+
failCommands: ["insert"]
100+
blockConnection: true
101+
blockTimeMS: 750
102+
103+
# Start threads.
104+
- name: createEntities
105+
object: testRunner
106+
arguments:
107+
entities:
108+
- thread:
109+
id: &thread0 thread0
110+
- thread:
111+
id: &thread1 thread1
112+
113+
# Run an insert in two threads. We expect the first to time out and the
114+
# second to finish the pending read from the first and complete
115+
# successfully.
116+
- name: runOnThread
117+
object: testRunner
118+
arguments:
119+
thread: *thread0
120+
operation:
121+
name: insertOne
122+
object: *collection
123+
arguments:
124+
timeoutMS: 500
125+
document:
126+
_id: 2
127+
expectError:
128+
isTimeoutError: true
129+
130+
# Ensure the first thread checks out a connection before executing the
131+
# operation in the second thread. This maintains concurrent behavior but
132+
# presents the worst case scenario.
133+
- name: waitForEvent
134+
object: testRunner
135+
arguments:
136+
client: *client
137+
event:
138+
connectionCheckedOutEvent: {}
139+
count: 1
140+
141+
- name: runOnThread
142+
object: testRunner
143+
arguments:
144+
thread: *thread1
145+
operation:
146+
name: insertOne
147+
object: *collection
148+
arguments:
149+
document:
150+
_id: 3
151+
152+
# Stop threads.
153+
- name: waitForThread
154+
object: testRunner
155+
arguments:
156+
thread: *thread1
157+
158+
expectEvents:
159+
- client: *client
160+
events:
161+
- commandFailedEvent:
162+
commandName: insert
163+
- commandSucceededEvent:
164+
commandName: insert
165+
- client: *client
166+
eventType: cmap
167+
events:
168+
- connectionCheckedOutEvent: {} # insert
169+
- connectionCheckedInEvent: {} # insert fails
170+
- connectionCheckedOutEvent: {} # find
171+
- connectionCheckedInEvent: {} # find succeeds
172+
88173
- description: "Write operation with unsuccessful pending read"
89174
operations:
90175
# Create a failpoint to block the first operation

0 commit comments

Comments
 (0)