Skip to content

Commit 2dac2a2

Browse files
matthewdaleiwysiubenjirewis
authored
Allow snapshot reads (#702)
* GODRIVER-2055 Add snapshot option to session * GODRIVER-2066 Allow snapshot writes to server error * GODRIVER-2067 Raise error for snapshot sessions < 5.0 Co-authored-by: matthewdale <[email protected]> Co-authored-by: iwysiu <[email protected]> Co-authored-by: benjirewis <[email protected]>
1 parent 21d5588 commit 2dac2a2

24 files changed

+3253
-287
lines changed

data/sessions/README.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Driver Session Tests
99
Introduction
1010
============
1111

12-
The YAML and JSON files in this directory are platform-independent tests that
13-
drivers can use to prove their conformance to the Driver Sessions Spec. They are
12+
The YAML and JSON files in the ``legacy`` and ``unified`` sub-directories are platform-independent tests
13+
that drivers can use to prove their conformance to the Driver Sessions Spec. They are
1414
designed with the intention of sharing most test-runner code with the
15-
Transactions spec tests.
15+
`Transactions Spec tests <../../transactions/tests/README.rst#test-format>`_.. Tests in the
16+
``unified`` directory are written using the `Unified Test Format <../../unified-test-format/unified-test-format.rst>`_.
1617

1718
Several prose tests, which are not easily expressed in YAML, are also presented
1819
in the Driver Sessions Spec. Those tests will need to be manually implemented
@@ -78,7 +79,26 @@ the given session is *not* marked dirty::
7879
arguments:
7980
session: session0
8081

82+
Snapshot session tests
83+
======================
84+
Snapshot sessions tests require server of version 5.0 or higher and
85+
replica set or a sharded cluster deployment.
86+
Default snapshot history window on the server is 5 minutes. Running the test in debug mode, or in any other slow configuration
87+
may lead to `SnapshotTooOld` errors. Drivers can work around this issue by increasing the server's `minSnapshotHistoryWindowInSeconds` parameter, for example:
88+
89+
.. code:: python
90+
91+
client.admin.command('setParameter', 1, minSnapshotHistoryWindowInSeconds=60)
92+
93+
Prose tests
94+
```````````
95+
- Setting both ``snapshot`` and ``causalConsistency`` is not allowed
96+
97+
* ``client.startSession(snapshot = true, causalConsistency = true)``
98+
* Assert that an error was raised by driver
99+
81100
Changelog
82101
=========
83102

84103
:2019-05-15: Initial version.
104+
:2021-06-15: Added snapshot-session tests. Introduced legacy and unified folders.

data/sessions/dirty-session-errors.json renamed to data/sessions/legacy/dirty-session-errors.json

Lines changed: 1 addition & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -21,171 +21,6 @@
2121
}
2222
],
2323
"tests": [
24-
{
25-
"description": "Clean explicit session is not discarded",
26-
"operations": [
27-
{
28-
"name": "assertSessionNotDirty",
29-
"object": "testRunner",
30-
"arguments": {
31-
"session": "session0"
32-
}
33-
},
34-
{
35-
"name": "insertOne",
36-
"object": "collection",
37-
"arguments": {
38-
"session": "session0",
39-
"document": {
40-
"_id": 2
41-
}
42-
},
43-
"result": {
44-
"insertedId": 2
45-
}
46-
},
47-
{
48-
"name": "assertSessionNotDirty",
49-
"object": "testRunner",
50-
"arguments": {
51-
"session": "session0"
52-
}
53-
},
54-
{
55-
"name": "endSession",
56-
"object": "session0"
57-
},
58-
{
59-
"name": "find",
60-
"object": "collection",
61-
"arguments": {
62-
"filter": {
63-
"_id": -1
64-
}
65-
},
66-
"result": []
67-
},
68-
{
69-
"name": "assertSameLsidOnLastTwoCommands",
70-
"object": "testRunner"
71-
}
72-
],
73-
"expectations": [
74-
{
75-
"command_started_event": {
76-
"command": {
77-
"insert": "test",
78-
"documents": [
79-
{
80-
"_id": 2
81-
}
82-
],
83-
"ordered": true,
84-
"lsid": "session0"
85-
},
86-
"command_name": "insert",
87-
"database_name": "session-tests"
88-
}
89-
},
90-
{
91-
"command_started_event": {
92-
"command": {
93-
"find": "test",
94-
"filter": {
95-
"_id": -1
96-
},
97-
"lsid": "session0"
98-
},
99-
"command_name": "find",
100-
"database_name": "session-tests"
101-
}
102-
}
103-
],
104-
"outcome": {
105-
"collection": {
106-
"data": [
107-
{
108-
"_id": 1
109-
},
110-
{
111-
"_id": 2
112-
}
113-
]
114-
}
115-
}
116-
},
117-
{
118-
"description": "Clean implicit session is not discarded",
119-
"operations": [
120-
{
121-
"name": "insertOne",
122-
"object": "collection",
123-
"arguments": {
124-
"document": {
125-
"_id": 2
126-
}
127-
},
128-
"result": {
129-
"insertedId": 2
130-
}
131-
},
132-
{
133-
"name": "find",
134-
"object": "collection",
135-
"arguments": {
136-
"filter": {
137-
"_id": -1
138-
}
139-
},
140-
"result": []
141-
},
142-
{
143-
"name": "assertSameLsidOnLastTwoCommands",
144-
"object": "testRunner"
145-
}
146-
],
147-
"expectations": [
148-
{
149-
"command_started_event": {
150-
"command": {
151-
"insert": "test",
152-
"documents": [
153-
{
154-
"_id": 2
155-
}
156-
],
157-
"ordered": true
158-
},
159-
"command_name": "insert",
160-
"database_name": "session-tests"
161-
}
162-
},
163-
{
164-
"command_started_event": {
165-
"command": {
166-
"find": "test",
167-
"filter": {
168-
"_id": -1
169-
}
170-
},
171-
"command_name": "find",
172-
"database_name": "session-tests"
173-
}
174-
}
175-
],
176-
"outcome": {
177-
"collection": {
178-
"data": [
179-
{
180-
"_id": 1
181-
},
182-
{
183-
"_id": 2
184-
}
185-
]
186-
}
187-
}
188-
},
18924
{
19025
"description": "Dirty explicit session is discarded",
19126
"clientOptions": {
@@ -833,4 +668,4 @@
833668
}
834669
}
835670
]
836-
}
671+
}

data/sessions/dirty-session-errors.yml renamed to data/sessions/legacy/dirty-session-errors.yml

Lines changed: 21 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -11,96 +11,6 @@ data:
1111
- {_id: 1}
1212

1313
tests:
14-
- description: Clean explicit session is not discarded
15-
16-
operations:
17-
- name: assertSessionNotDirty
18-
object: testRunner
19-
arguments:
20-
session: session0
21-
- &insert_with_explicit_session
22-
name: insertOne
23-
object: collection
24-
arguments:
25-
session: session0
26-
document: {_id: 2}
27-
result:
28-
insertedId: 2
29-
- name: assertSessionNotDirty
30-
object: testRunner
31-
arguments:
32-
session: session0
33-
- name: endSession
34-
object: session0
35-
- &find_with_implicit_session
36-
name: find
37-
object: collection
38-
arguments:
39-
filter: {_id: -1}
40-
result: []
41-
- name: assertSameLsidOnLastTwoCommands
42-
object: testRunner
43-
44-
expectations:
45-
- command_started_event:
46-
command:
47-
insert: *collection_name
48-
documents:
49-
- {_id: 2}
50-
ordered: true
51-
lsid: session0
52-
command_name: insert
53-
database_name: *database_name
54-
- command_started_event:
55-
command:
56-
find: *collection_name
57-
filter: {_id: -1}
58-
lsid: session0
59-
command_name: find
60-
database_name: *database_name
61-
62-
outcome:
63-
collection:
64-
data:
65-
- {_id: 1}
66-
- {_id: 2}
67-
68-
- description: Clean implicit session is not discarded
69-
70-
operations:
71-
- &insert_with_implicit_session
72-
name: insertOne
73-
object: collection
74-
arguments:
75-
document: {_id: 2}
76-
result:
77-
insertedId: 2
78-
- *find_with_implicit_session
79-
- name: assertSameLsidOnLastTwoCommands
80-
object: testRunner
81-
82-
expectations:
83-
- command_started_event:
84-
command:
85-
insert: *collection_name
86-
documents:
87-
- {_id: 2}
88-
ordered: true
89-
command_name: insert
90-
database_name: *database_name
91-
- command_started_event:
92-
command:
93-
find: *collection_name
94-
filter: {_id: -1}
95-
command_name: find
96-
database_name: *database_name
97-
98-
outcome:
99-
collection:
100-
data:
101-
- {_id: 1}
102-
- {_id: 2}
103-
10414
- description: Dirty explicit session is discarded
10515

10616
clientOptions:
@@ -118,7 +28,14 @@ tests:
11828
object: testRunner
11929
arguments:
12030
session: session0
121-
- *insert_with_explicit_session
31+
- &insert_with_explicit_session
32+
name: insertOne
33+
object: collection
34+
arguments:
35+
session: session0
36+
document: {_id: 2}
37+
result:
38+
insertedId: 2
12239
- name: assertSessionDirty
12340
object: testRunner
12441
arguments:
@@ -136,7 +53,12 @@ tests:
13653
session: session0
13754
- name: endSession
13855
object: session0
139-
- *find_with_implicit_session
56+
- &find_with_implicit_session
57+
name: find
58+
object: collection
59+
arguments:
60+
filter: {_id: -1}
61+
result: []
14062
- name: assertDifferentLsidOnLastTwoCommands
14163
object: testRunner
14264

@@ -277,7 +199,13 @@ tests:
277199
closeConnection: true
278200

279201
operations:
280-
- *insert_with_implicit_session
202+
- &insert_with_implicit_session
203+
name: insertOne
204+
object: collection
205+
arguments:
206+
document: {_id: 2}
207+
result:
208+
insertedId: 2
281209
- *find_with_implicit_session
282210
- name: assertDifferentLsidOnLastTwoCommands
283211
object: testRunner

0 commit comments

Comments
 (0)