...
1description: "poc-sessions"
2
3schemaVersion: "1.0"
4
5runOnRequirements:
6 - minServerVersion: "3.6.0"
7
8createEntities:
9 - client:
10 id: &client0 client0
11 useMultipleMongoses: false
12 observeEvents: [ commandStartedEvent ]
13 - database:
14 id: &database0 database0
15 client: *client0
16 databaseName: &database0Name session-tests
17 - collection:
18 id: &collection0 collection0
19 database: *database0
20 collectionName: &collection0Name test
21 - session:
22 id: &session0 session0
23 client: *client0
24
25initialData:
26 - collectionName: *collection0Name
27 databaseName: *database0Name
28 documents:
29 - { _id: 1 }
30
31tests:
32 - description: "Server supports explicit sessions"
33 operations:
34 - name: assertSessionNotDirty
35 object: testRunner
36 arguments:
37 session: *session0
38 - name: insertOne
39 object: *collection0
40 arguments:
41 session: *session0
42 document: { _id: 2 }
43 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
44 - name: assertSessionNotDirty
45 object: testRunner
46 arguments:
47 session: *session0
48 - name: endSession
49 object: *session0
50 - &find_with_implicit_session
51 name: find
52 object: *collection0
53 arguments:
54 filter: { _id: -1 }
55 expectResult: []
56 - name: assertSameLsidOnLastTwoCommands
57 object: testRunner
58 arguments:
59 client: *client0
60 expectEvents:
61 - client: *client0
62 events:
63 - commandStartedEvent:
64 command:
65 insert: *collection0Name
66 documents: [ { _id: 2 } ]
67 ordered: true
68 lsid: { $$sessionLsid: *session0 }
69 commandName: insert
70 databaseName: *database0Name
71 - commandStartedEvent:
72 command:
73 find: *collection0Name
74 filter: { _id: -1 }
75 lsid: { $$sessionLsid: *session0 }
76 commandName: find
77 databaseName: *database0Name
78 outcome:
79 - collectionName: *collection0Name
80 databaseName: *database0Name
81 documents:
82 - { _id: 1 }
83 - { _id: 2 }
84
85 - description: "Server supports implicit sessions"
86 operations:
87 - name: insertOne
88 object: *collection0
89 arguments:
90 document: { _id: 2 }
91 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
92 - *find_with_implicit_session
93 - name: assertSameLsidOnLastTwoCommands
94 object: testRunner
95 arguments:
96 client: *client0
97 expectEvents:
98 - client: *client0
99 events:
100 - commandStartedEvent:
101 command:
102 insert: *collection0Name
103 documents:
104 - { _id: 2 }
105 ordered: true
106 # Original test did not include any assertion, but we can use
107 # $$type to expect an arbitrary lsid document
108 lsid: { $$type: object }
109 commandName: insert
110 databaseName: *database0Name
111 - commandStartedEvent:
112 command:
113 find: *collection0Name
114 filter: { _id: -1 }
115 lsid: { $$type: object }
116 commandName: find
117 databaseName: *database0Name
118 outcome:
119 - collectionName: *collection0Name
120 databaseName: *database0Name
121 documents:
122 - { _id: 1 }
123 - { _id: 2 }
124
125 - description: "Dirty explicit session is discarded"
126 # Original test specified retryWrites=true, but that is now the default.
127 # Retryable writes will require a sharded-replicaset, though.
128 runOnRequirements:
129 - minServerVersion: "4.0"
130 topologies: [ replicaset ]
131 - minServerVersion: "4.1.8"
132 topologies: [ sharded-replicaset ]
133 operations:
134 - name: failPoint
135 object: testRunner
136 arguments:
137 client: *client0
138 failPoint:
139 configureFailPoint: failCommand
140 mode: { times: 1 }
141 data:
142 failCommands: [ insert ]
143 closeConnection: true
144 - name: assertSessionNotDirty
145 object: testRunner
146 arguments:
147 session: *session0
148 - name: insertOne
149 object: *collection0
150 arguments:
151 session: *session0
152 document: { _id: 2 }
153 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
154 - name: assertSessionDirty
155 object: testRunner
156 arguments:
157 session: *session0
158 - name: insertOne
159 object: *collection0
160 arguments:
161 session: *session0
162 document: { _id: 3 }
163 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } }
164 - name: assertSessionDirty
165 object: testRunner
166 arguments:
167 session: *session0
168 - name: endSession
169 object: *session0
170 - *find_with_implicit_session
171 - name: assertDifferentLsidOnLastTwoCommands
172 object: testRunner
173 arguments:
174 client: *client0
175 expectEvents:
176 - client: *client0
177 events:
178 # ajv's YAML parser is unable to handle anchors on array elements, so
179 # we define an anchor on the commandStartedEvent object instead
180 - commandStartedEvent: &insert_attempt
181 command:
182 insert: *collection0Name
183 documents:
184 - { _id: 2 }
185 ordered: true
186 lsid: { $$sessionLsid: *session0 }
187 txnNumber: 1
188 commandName: insert
189 databaseName: *database0Name
190 - commandStartedEvent: *insert_attempt
191 - commandStartedEvent:
192 command:
193 insert: *collection0Name
194 documents:
195 - { _id: 3 }
196 ordered: true
197 lsid: { $$sessionLsid: *session0 }
198 txnNumber: 2
199 commandName: insert
200 databaseName: *database0Name
201 - commandStartedEvent:
202 command:
203 find: *collection0Name
204 filter: { _id: -1 }
205 lsid: { $$type: object }
206 commandName: find
207 databaseName: *database0Name
208 outcome:
209 - collectionName: *collection0Name
210 databaseName: *database0Name
211 documents:
212 - { _id: 1 }
213 - { _id: 2 }
214 - { _id: 3 }
View as plain text