Skip to content

Commit 50b905e

Browse files
committed
PYTHON-1801 Update transactions count test for MongoDB >= 4.0.7
(cherry picked from commit f09d6fa) Changes: Replace runOn with minServerVersion.
1 parent 35a408c commit 50b905e

File tree

3 files changed

+113
-86
lines changed

3 files changed

+113
-86
lines changed

test/test_transactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ def kill_all_sessions():
537537
read_concern=ReadConcern('local'))
538538
self.assertEqual(list(primary_coll.find()), expected_c['data'])
539539

540+
if 'minServerVersion' in scenario_def:
541+
min_ver = tuple(
542+
int(elt) for
543+
elt in scenario_def['minServerVersion'].split('.'))
544+
return client_context.require_version_min(*min_ver)(run_scenario)
545+
540546
return run_scenario
541547

542548

test/transactions/count.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"minServerVersion": "4.0.2",
3+
"database_name": "transaction-tests",
4+
"collection_name": "test",
5+
"data": [
6+
{
7+
"_id": 1
8+
},
9+
{
10+
"_id": 2
11+
},
12+
{
13+
"_id": 3
14+
},
15+
{
16+
"_id": 4
17+
}
18+
],
19+
"tests": [
20+
{
21+
"description": "count",
22+
"operations": [
23+
{
24+
"name": "startTransaction",
25+
"object": "session0"
26+
},
27+
{
28+
"name": "count",
29+
"object": "collection",
30+
"arguments": {
31+
"session": "session0",
32+
"filter": {
33+
"_id": 1
34+
}
35+
},
36+
"result": {
37+
"errorCodeName": "OperationNotSupportedInTransaction",
38+
"errorLabelsOmit": [
39+
"TransientTransactionError",
40+
"UnknownTransactionCommitResult"
41+
]
42+
}
43+
},
44+
{
45+
"name": "abortTransaction",
46+
"object": "session0"
47+
}
48+
],
49+
"expectations": [
50+
{
51+
"command_started_event": {
52+
"command": {
53+
"count": "test",
54+
"query": {
55+
"_id": 1
56+
},
57+
"readConcern": null,
58+
"lsid": "session0",
59+
"txnNumber": {
60+
"$numberLong": "1"
61+
},
62+
"startTransaction": true,
63+
"autocommit": false,
64+
"writeConcern": null
65+
},
66+
"command_name": "count",
67+
"database_name": "transaction-tests"
68+
}
69+
},
70+
{
71+
"command_started_event": {
72+
"command": {
73+
"abortTransaction": 1,
74+
"lsid": "session0",
75+
"txnNumber": {
76+
"$numberLong": "1"
77+
},
78+
"startTransaction": null,
79+
"autocommit": false,
80+
"writeConcern": null
81+
},
82+
"command_name": "abortTransaction",
83+
"database_name": "admin"
84+
}
85+
}
86+
],
87+
"outcome": {
88+
"collection": {
89+
"data": [
90+
{
91+
"_id": 1
92+
},
93+
{
94+
"_id": 2
95+
},
96+
{
97+
"_id": 3
98+
},
99+
{
100+
"_id": 4
101+
}
102+
]
103+
}
104+
}
105+
}
106+
]
107+
}

test/transactions/reads.json

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -83,92 +83,6 @@
8383
}
8484
}
8585
},
86-
{
87-
"description": "count",
88-
"operations": [
89-
{
90-
"name": "startTransaction",
91-
"object": "session0"
92-
},
93-
{
94-
"name": "count",
95-
"object": "collection",
96-
"arguments": {
97-
"session": "session0",
98-
"filter": {
99-
"_id": 1
100-
}
101-
},
102-
"result": {
103-
"errorContains": "Cannot run 'count' in a multi-document transaction",
104-
"errorLabelsOmit": [
105-
"TransientTransactionError",
106-
"UnknownTransactionCommitResult"
107-
]
108-
}
109-
},
110-
{
111-
"name": "abortTransaction",
112-
"object": "session0"
113-
}
114-
],
115-
"expectations": [
116-
{
117-
"command_started_event": {
118-
"command": {
119-
"count": "test",
120-
"query": {
121-
"_id": 1
122-
},
123-
"readConcern": null,
124-
"lsid": "session0",
125-
"txnNumber": {
126-
"$numberLong": "1"
127-
},
128-
"startTransaction": true,
129-
"autocommit": false,
130-
"writeConcern": null
131-
},
132-
"command_name": "count",
133-
"database_name": "transaction-tests"
134-
}
135-
},
136-
{
137-
"command_started_event": {
138-
"command": {
139-
"abortTransaction": 1,
140-
"lsid": "session0",
141-
"txnNumber": {
142-
"$numberLong": "1"
143-
},
144-
"startTransaction": null,
145-
"autocommit": false,
146-
"writeConcern": null
147-
},
148-
"command_name": "abortTransaction",
149-
"database_name": "admin"
150-
}
151-
}
152-
],
153-
"outcome": {
154-
"collection": {
155-
"data": [
156-
{
157-
"_id": 1
158-
},
159-
{
160-
"_id": 2
161-
},
162-
{
163-
"_id": 3
164-
},
165-
{
166-
"_id": 4
167-
}
168-
]
169-
}
170-
}
171-
},
17286
{
17387
"description": "find",
17488
"operations": [

0 commit comments

Comments
 (0)