Skip to content

Commit 1128129

Browse files
authored
PYTHON-2482 Test Versioned API with a server started with acceptAPIVersion2 (#545)
1 parent dea4b90 commit 1128129

File tree

4 files changed

+174
-6
lines changed

4 files changed

+174
-6
lines changed

.evergreen/config.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,18 +1970,27 @@ axes:
19701970
test_pyopenssl: true
19711971
batchtime: 10080 # 7 days
19721972

1973-
- id: requireApiVersion
1974-
display_name: "requireApiVersion"
1973+
- id: versionedApi
1974+
display_name: "versionedApi"
19751975
values:
1976+
# Test against a cluster with requireApiVersion=1.
19761977
- id: "requireApiVersion1"
19771978
display_name: "requireApiVersion1"
1978-
tags: [ "requireApiVersion_tag" ]
1979+
tags: [ "versionedApi_tag" ]
19791980
variables:
19801981
# REQUIRE_API_VERSION is set to make drivers-evergreen-tools
19811982
# start a cluster with the requireApiVersion parameter.
19821983
REQUIRE_API_VERSION: "1"
19831984
# MONGODB_API_VERSION is the apiVersion to use in the test suite.
19841985
MONGODB_API_VERSION: "1"
1986+
# Test against a cluster with acceptAPIVersion2 but without
1987+
# requireApiVersion, and don't automatically add apiVersion to
1988+
# clients created in the test suite.
1989+
- id: "acceptAPIVersion2"
1990+
display_name: "acceptAPIVersion2"
1991+
tags: [ "versionedApi_tag" ]
1992+
variables:
1993+
ORCHESTRATION_FILE: "versioned-api-testing.json"
19851994

19861995
buildvariants:
19871996
- matrix_name: "tests-all"
@@ -2514,8 +2523,9 @@ buildvariants:
25142523
platform: ubuntu-16.04
25152524
python-version: ["3.6", "3.9"]
25162525
auth: "auth"
2517-
requireApiVersion: "*"
2518-
display_name: "requireApiVersion ${python-version}"
2526+
versionedApi: "*"
2527+
display_name: "Versioned API ${versionedApi} ${python-version}"
2528+
batchtime: 10080 # 7 days
25192529
tasks:
25202530
# Versioned API was introduced in MongoDB 4.7
25212531
- "test-latest-standalone"

test/versioned-api/crud-api-version-1-strict.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
},
142142
{
143143
"description": "aggregate on database appends declared API version",
144+
"skipReason": "DRIVERS-1505 $listLocalSessions is not supported in API version 1",
144145
"operations": [
145146
{
146147
"name": "aggregate",

test/versioned-api/test-commands-deprecation-errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"minServerVersion": "4.7",
77
"serverParameters": {
88
"enableTestCommands": true,
9-
"acceptAPIVersion2": true
9+
"acceptAPIVersion2": true,
10+
"requireApiVersion": false
1011
}
1112
}
1213
],

test/versioned-api/transaction-handling.json

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,162 @@
227227
]
228228
}
229229
]
230+
},
231+
{
232+
"description": "Committing a transaction twice does not append server API options",
233+
"runOnRequirements": [
234+
{
235+
"topologies": [
236+
"replicaset",
237+
"sharded-replicaset"
238+
]
239+
}
240+
],
241+
"operations": [
242+
{
243+
"name": "startTransaction",
244+
"object": "session"
245+
},
246+
{
247+
"name": "insertOne",
248+
"object": "collection",
249+
"arguments": {
250+
"session": "session",
251+
"document": {
252+
"_id": 6,
253+
"x": 66
254+
}
255+
},
256+
"expectResult": {
257+
"$$unsetOrMatches": {
258+
"insertedId": {
259+
"$$unsetOrMatches": 6
260+
}
261+
}
262+
}
263+
},
264+
{
265+
"name": "insertOne",
266+
"object": "collection",
267+
"arguments": {
268+
"session": "session",
269+
"document": {
270+
"_id": 7,
271+
"x": 77
272+
}
273+
},
274+
"expectResult": {
275+
"$$unsetOrMatches": {
276+
"insertedId": {
277+
"$$unsetOrMatches": 7
278+
}
279+
}
280+
}
281+
},
282+
{
283+
"name": "commitTransaction",
284+
"object": "session"
285+
},
286+
{
287+
"name": "commitTransaction",
288+
"object": "session"
289+
}
290+
],
291+
"expectEvents": [
292+
{
293+
"client": "client",
294+
"events": [
295+
{
296+
"commandStartedEvent": {
297+
"command": {
298+
"insert": "test",
299+
"documents": [
300+
{
301+
"_id": 6,
302+
"x": 66
303+
}
304+
],
305+
"lsid": {
306+
"$$sessionLsid": "session"
307+
},
308+
"startTransaction": true,
309+
"apiVersion": "1",
310+
"apiStrict": {
311+
"$$unsetOrMatches": false
312+
},
313+
"apiDeprecationErrors": {
314+
"$$unsetOrMatches": false
315+
}
316+
}
317+
}
318+
},
319+
{
320+
"commandStartedEvent": {
321+
"command": {
322+
"insert": "test",
323+
"documents": [
324+
{
325+
"_id": 7,
326+
"x": 77
327+
}
328+
],
329+
"lsid": {
330+
"$$sessionLsid": "session"
331+
},
332+
"apiVersion": {
333+
"$$exists": false
334+
},
335+
"apiStrict": {
336+
"$$exists": false
337+
},
338+
"apiDeprecationErrors": {
339+
"$$exists": false
340+
}
341+
}
342+
}
343+
},
344+
{
345+
"commandStartedEvent": {
346+
"command": {
347+
"commitTransaction": 1,
348+
"lsid": {
349+
"$$sessionLsid": "session"
350+
},
351+
"apiVersion": {
352+
"$$exists": false
353+
},
354+
"apiStrict": {
355+
"$$exists": false
356+
},
357+
"apiDeprecationErrors": {
358+
"$$exists": false
359+
}
360+
}
361+
}
362+
},
363+
{
364+
"commandStartedEvent": {
365+
"command": {
366+
"commitTransaction": 1,
367+
"lsid": {
368+
"$$sessionLsid": "session"
369+
},
370+
"apiVersion": {
371+
"$$exists": false
372+
},
373+
"apiStrict": {
374+
"$$exists": false
375+
},
376+
"apiDeprecationErrors": {
377+
"$$exists": false
378+
}
379+
}
380+
}
381+
}
382+
]
383+
}
384+
]
230385
}
231386
]
232387
}
388+

0 commit comments

Comments
 (0)