Skip to content

Commit 102a608

Browse files
committed
PYTHON-2482 Test Versioned API with a server started with acceptAPIVersion2 (#545)
(cherry picked from commit 1128129)
1 parent 26c3949 commit 102a608

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
@@ -2025,18 +2025,27 @@ axes:
20252025
variables:
20262026
SETDEFAULTENCODING: "cp1251"
20272027

2028-
- id: requireApiVersion
2029-
display_name: "requireApiVersion"
2028+
- id: versionedApi
2029+
display_name: "versionedApi"
20302030
values:
2031+
# Test against a cluster with requireApiVersion=1.
20312032
- id: "requireApiVersion1"
20322033
display_name: "requireApiVersion1"
2033-
tags: [ "requireApiVersion_tag" ]
2034+
tags: [ "versionedApi_tag" ]
20342035
variables:
20352036
# REQUIRE_API_VERSION is set to make drivers-evergreen-tools
20362037
# start a cluster with the requireApiVersion parameter.
20372038
REQUIRE_API_VERSION: "1"
20382039
# MONGODB_API_VERSION is the apiVersion to use in the test suite.
20392040
MONGODB_API_VERSION: "1"
2041+
# Test against a cluster with acceptAPIVersion2 but without
2042+
# requireApiVersion, and don't automatically add apiVersion to
2043+
# clients created in the test suite.
2044+
- id: "acceptAPIVersion2"
2045+
display_name: "acceptAPIVersion2"
2046+
tags: [ "versionedApi_tag" ]
2047+
variables:
2048+
ORCHESTRATION_FILE: "versioned-api-testing.json"
20402049

20412050
buildvariants:
20422051
- matrix_name: "tests-all"
@@ -2625,8 +2634,9 @@ buildvariants:
26252634
platform: ubuntu-16.04
26262635
python-version: ["2.7", "3.9"]
26272636
auth: "auth"
2628-
requireApiVersion: "*"
2629-
display_name: "requireApiVersion ${python-version}"
2637+
versionedApi: "*"
2638+
display_name: "Versioned API ${versionedApi} ${python-version}"
2639+
batchtime: 10080 # 7 days
26302640
tasks:
26312641
# Versioned API was introduced in MongoDB 4.7
26322642
- "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)