Skip to content

Commit c14a5a9

Browse files
committed
minor: sync retryable reads spec tests
1 parent f1a7035 commit c14a5a9

9 files changed

+1380
-5
lines changed

src/test/spec/json/retryable-reads/README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ data.
150150
Speeding Up Tests
151151
-----------------
152152

153-
Drivers may benefit reducing `minHeartbeatFrequencyMS`_ in order to speed up
154-
tests. Python was able to decrease the run time of the tests greatly by lowering
155-
the SDAM's ``minHeartbeatFrequencyMS`` from 500ms to 50ms, thus decreasing the
156-
waiting time after a "not master" error:
153+
Drivers can greatly reduce the execution time of tests by setting `heartbeatFrequencyMS`_
154+
and `minHeartbeatFrequencyMS`_ (internally) to a small value (e.g. 5ms), below what
155+
is normally permitted in the SDAM spec. If a test specifies an explicit value for
156+
heartbeatFrequencyMS (e.g. client or URI options), drivers MUST use that value.
157+
158+
.. _minHeartbeatFrequencyMS: ../../server-discovery-and-monitoring/server-discovery-and-monitoring.rst#minheartbeatfrequencyms
159+
.. _heartbeatFrequencyMS: ../../server-discovery-and-monitoring/server-discovery-and-monitoring.rst#heartbeatfrequencyms
157160

158-
.. _minHeartbeatFrequencyMS: https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#minheartbeatfrequencyms
159161
Optional Enumeration Commands
160162
=============================
161163

@@ -171,3 +173,5 @@ Changelog
171173
now expressed within ``runOn`` elements.
172174

173175
Add test-level ``useMultipleMongoses`` field.
176+
177+
:2020-09-16: Suggest lowering heartbeatFrequencyMS in addition to minHeartbeatFrequencyMS.
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.9.0"
5+
}
6+
],
7+
"database_name": "retryable-reads-tests",
8+
"collection_name": "coll",
9+
"data": [
10+
{
11+
"_id": 1,
12+
"x": 11
13+
},
14+
{
15+
"_id": 2,
16+
"x": 22
17+
}
18+
],
19+
"tests": [
20+
{
21+
"description": "EstimatedDocumentCount succeeds on first attempt",
22+
"operations": [
23+
{
24+
"name": "estimatedDocumentCount",
25+
"object": "collection",
26+
"result": 2
27+
}
28+
],
29+
"expectations": [
30+
{
31+
"command_started_event": {
32+
"command": {
33+
"aggregate": "coll",
34+
"pipeline": [
35+
{
36+
"$collStats": {
37+
"count": {}
38+
}
39+
},
40+
{
41+
"$group": {
42+
"_id": 1,
43+
"n": {
44+
"$sum": "$count"
45+
}
46+
}
47+
}
48+
]
49+
},
50+
"database_name": "retryable-reads-tests"
51+
}
52+
}
53+
]
54+
},
55+
{
56+
"description": "EstimatedDocumentCount succeeds on second attempt",
57+
"failPoint": {
58+
"configureFailPoint": "failCommand",
59+
"mode": {
60+
"times": 1
61+
},
62+
"data": {
63+
"failCommands": [
64+
"aggregate"
65+
],
66+
"closeConnection": true
67+
}
68+
},
69+
"operations": [
70+
{
71+
"name": "estimatedDocumentCount",
72+
"object": "collection",
73+
"result": 2
74+
}
75+
],
76+
"expectations": [
77+
{
78+
"command_started_event": {
79+
"command": {
80+
"aggregate": "coll",
81+
"pipeline": [
82+
{
83+
"$collStats": {
84+
"count": {}
85+
}
86+
},
87+
{
88+
"$group": {
89+
"_id": 1,
90+
"n": {
91+
"$sum": "$count"
92+
}
93+
}
94+
}
95+
]
96+
},
97+
"database_name": "retryable-reads-tests"
98+
}
99+
},
100+
{
101+
"command_started_event": {
102+
"command": {
103+
"aggregate": "coll",
104+
"pipeline": [
105+
{
106+
"$collStats": {
107+
"count": {}
108+
}
109+
},
110+
{
111+
"$group": {
112+
"_id": 1,
113+
"n": {
114+
"$sum": "$count"
115+
}
116+
}
117+
}
118+
]
119+
},
120+
"database_name": "retryable-reads-tests"
121+
}
122+
}
123+
]
124+
},
125+
{
126+
"description": "EstimatedDocumentCount fails on first attempt",
127+
"clientOptions": {
128+
"retryReads": false
129+
},
130+
"failPoint": {
131+
"configureFailPoint": "failCommand",
132+
"mode": {
133+
"times": 1
134+
},
135+
"data": {
136+
"failCommands": [
137+
"aggregate"
138+
],
139+
"closeConnection": true
140+
}
141+
},
142+
"operations": [
143+
{
144+
"name": "estimatedDocumentCount",
145+
"object": "collection",
146+
"error": true
147+
}
148+
],
149+
"expectations": [
150+
{
151+
"command_started_event": {
152+
"command": {
153+
"aggregate": "coll",
154+
"pipeline": [
155+
{
156+
"$collStats": {
157+
"count": {}
158+
}
159+
},
160+
{
161+
"$group": {
162+
"_id": 1,
163+
"n": {
164+
"$sum": "$count"
165+
}
166+
}
167+
}
168+
]
169+
},
170+
"database_name": "retryable-reads-tests"
171+
}
172+
}
173+
]
174+
},
175+
{
176+
"description": "EstimatedDocumentCount fails on second attempt",
177+
"failPoint": {
178+
"configureFailPoint": "failCommand",
179+
"mode": {
180+
"times": 2
181+
},
182+
"data": {
183+
"failCommands": [
184+
"aggregate"
185+
],
186+
"closeConnection": true
187+
}
188+
},
189+
"operations": [
190+
{
191+
"name": "estimatedDocumentCount",
192+
"object": "collection",
193+
"error": true
194+
}
195+
],
196+
"expectations": [
197+
{
198+
"command_started_event": {
199+
"command": {
200+
"aggregate": "coll",
201+
"pipeline": [
202+
{
203+
"$collStats": {
204+
"count": {}
205+
}
206+
},
207+
{
208+
"$group": {
209+
"_id": 1,
210+
"n": {
211+
"$sum": "$count"
212+
}
213+
}
214+
}
215+
]
216+
},
217+
"database_name": "retryable-reads-tests"
218+
}
219+
},
220+
{
221+
"command_started_event": {
222+
"command": {
223+
"aggregate": "coll",
224+
"pipeline": [
225+
{
226+
"$collStats": {
227+
"count": {}
228+
}
229+
},
230+
{
231+
"$group": {
232+
"_id": 1,
233+
"n": {
234+
"$sum": "$count"
235+
}
236+
}
237+
}
238+
]
239+
},
240+
"database_name": "retryable-reads-tests"
241+
}
242+
}
243+
]
244+
}
245+
]
246+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
runOn:
2+
- minServerVersion: "4.9.0"
3+
4+
database_name: &database_name "retryable-reads-tests"
5+
collection_name: &collection_name "coll"
6+
7+
data:
8+
- { _id: 1, x: 11 }
9+
- { _id: 2, x: 22 }
10+
11+
tests:
12+
-
13+
description: "EstimatedDocumentCount succeeds on first attempt"
14+
operations:
15+
- &retryable_operation_succeeds
16+
<<: &retryable_operation
17+
name: estimatedDocumentCount
18+
object: collection
19+
result: 2
20+
expectations:
21+
- &retryable_command_started_event
22+
command_started_event:
23+
command:
24+
aggregate: *collection_name
25+
pipeline: &pipeline
26+
- $collStats: { count: {} }
27+
- $group: { _id: 1, n: { $sum: $count }}
28+
database_name: *database_name
29+
-
30+
description: "EstimatedDocumentCount succeeds on second attempt"
31+
failPoint: &failCommand_failPoint
32+
configureFailPoint: failCommand
33+
mode: { times: 1 }
34+
data:
35+
failCommands: [aggregate]
36+
closeConnection: true
37+
operations: [*retryable_operation_succeeds]
38+
expectations:
39+
- *retryable_command_started_event
40+
- *retryable_command_started_event
41+
-
42+
description: "EstimatedDocumentCount fails on first attempt"
43+
clientOptions:
44+
retryReads: false
45+
failPoint: *failCommand_failPoint
46+
operations:
47+
- &retryable_operation_fails
48+
<<: *retryable_operation
49+
error: true
50+
expectations:
51+
- *retryable_command_started_event
52+
-
53+
description: "EstimatedDocumentCount fails on second attempt"
54+
failPoint:
55+
<<: *failCommand_failPoint
56+
mode: { times: 2 }
57+
operations: [*retryable_operation_fails]
58+
expectations:
59+
- *retryable_command_started_event
60+
- *retryable_command_started_event

src/test/spec/json/retryable-reads/estimatedDocumentCount.json renamed to src/test/spec/json/retryable-reads/estimatedDocumentCount-pre4.9.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"runOn": [
33
{
44
"minServerVersion": "4.0",
5+
"maxServerVersion": "4.8.99",
56
"topology": [
67
"single",
78
"replicaset"
89
]
910
},
1011
{
1112
"minServerVersion": "4.1.7",
13+
"maxServerVersion": "4.8.99",
1214
"topology": [
1315
"sharded"
1416
]

src/test/spec/json/retryable-reads/estimatedDocumentCount.yml renamed to src/test/spec/json/retryable-reads/estimatedDocumentCount-pre4.9.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
runOn:
22
-
33
minServerVersion: "4.0"
4+
maxServerVersion: "4.8.99"
45
topology: ["single", "replicaset"]
56
-
67
minServerVersion: "4.1.7"
8+
maxServerVersion: "4.8.99"
79
topology: ["sharded"]
810

911
database_name: &database_name "retryable-reads-tests"

0 commit comments

Comments
 (0)