...
1description: "poc-crud"
2
3schemaVersion: "1.4"
4
5createEntities:
6 - client:
7 id: &client0 client0
8 observeEvents: [ commandStartedEvent ]
9 - database:
10 id: &database0 database0
11 client: *client0
12 databaseName: &database0Name crud-tests
13 - database:
14 id: &database1 database1
15 client: *client0
16 databaseName: &database1Name admin
17 - collection:
18 id: &collection0 collection0
19 database: *database0
20 collectionName: &collection0Name coll0
21 - collection:
22 id: &collection1 collection1
23 database: *database0
24 collectionName: &collection1Name coll1
25 - collection:
26 id: &collection2 collection2
27 database: *database0
28 collectionName: &collection2Name coll2
29 collectionOptions:
30 readConcern: { level: majority }
31
32initialData:
33 - collectionName: *collection0Name
34 databaseName: *database0Name
35 documents:
36 - { _id: 1, x: 11 }
37 - { _id: 2, x: 22 }
38 - collectionName: *collection1Name
39 databaseName: *database0Name
40 documents:
41 - { _id: 1, x: 11 }
42 - collectionName: *collection2Name
43 databaseName: *database0Name
44 documents:
45 - { _id: 1, x: 11 }
46 - { _id: 2, x: 22 }
47 - { _id: 3, x: 33 }
48 - collectionName: &out aggregate_out
49 databaseName: *database0Name
50 documents: []
51
52tests:
53 - description: "BulkWrite with mixed ordered operations"
54 operations:
55 - name: bulkWrite
56 object: *collection0
57 arguments:
58 requests:
59 - insertOne:
60 document: { _id: 3, x: 33 }
61 - updateOne:
62 filter: { _id: 2 }
63 update: { $inc: { x: 1 } }
64 - updateMany:
65 filter: { _id: { $gt: 1 } }
66 update: { $inc: { x: 1 } }
67 - insertOne:
68 document: { _id: 4, x: 44 }
69 - deleteMany:
70 filter: { x: { $nin: [ 24, 34 ] } }
71 - replaceOne:
72 filter: { _id: 4 }
73 replacement: { _id: 4, x: 44 }
74 upsert: true
75 ordered: true
76 expectResult:
77 deletedCount: 2
78 insertedCount: 2
79 insertedIds: { $$unsetOrMatches: { 0: 3, 3: 4 } }
80 matchedCount: 3
81 modifiedCount: 3
82 upsertedCount: 1
83 upsertedIds: { 5: 4 }
84 outcome:
85 - collectionName: *collection0Name
86 databaseName: *database0Name
87 documents:
88 - {_id: 2, x: 24 }
89 - {_id: 3, x: 34 }
90 - {_id: 4, x: 44 }
91
92 - description: "InsertMany continue-on-error behavior with unordered (duplicate key in requests)"
93 operations:
94 - name: insertMany
95 object: *collection1
96 arguments:
97 documents:
98 - { _id: 2, x: 22 }
99 - { _id: 2, x: 22 }
100 - { _id: 3, x: 33 }
101 ordered: false
102 expectError:
103 expectResult:
104 # insertMany throws BulkWriteException, which may optionally include
105 # an intermediary BulkWriteResult
106 $$unsetOrMatches:
107 deletedCount: 0
108 insertedCount: 2
109 # Since the map of insertedIds is generated before execution it
110 # could indicate inserts that did not actually succeed. We omit
111 # this field rather than expect drivers to provide an accurate
112 # map filtered by write errors.
113 matchedCount: 0
114 modifiedCount: 0
115 upsertedCount: 0
116 upsertedIds: { }
117 outcome:
118 - collectionName: *collection1Name
119 databaseName: *database0Name
120 documents:
121 - { _id: 1, x: 11 }
122 - { _id: 2, x: 22 }
123 - { _id: 3, x: 33 }
124
125 - description: "ReplaceOne prohibits atomic modifiers"
126 operations:
127 - name: replaceOne
128 object: *collection1
129 arguments:
130 filter: { _id: 1 }
131 replacement: { $set: { x: 22 }}
132 expectError:
133 isClientError: true
134 expectEvents:
135 - client: *client0
136 events: []
137 outcome:
138 - collectionName: *collection1Name
139 databaseName: *database0Name
140 documents:
141 - { _id: 1, x: 11 }
142
143 - description: "readConcern majority with out stage"
144 runOnRequirements:
145 - minServerVersion: "4.1.0"
146 topologies: [ replicaset, sharded-replicaset ]
147 serverless: "forbid"
148 operations:
149 - name: aggregate
150 object: *collection2
151 arguments:
152 pipeline: &pipeline
153 - $sort: { x : 1 }
154 - $match: { _id: { $gt: 1 } }
155 - $out: *out
156 expectEvents:
157 - client: *client0
158 events:
159 - commandStartedEvent:
160 command:
161 aggregate: *collection2Name
162 pipeline: *pipeline
163 readConcern: { level: majority }
164 # The following two assertions were not in the original test
165 commandName: aggregate
166 databaseName: *database0Name
167 outcome:
168 - collectionName: *out
169 databaseName: *database0Name
170 documents:
171 - { _id: 2, x: 22 }
172 - { _id: 3, x: 33 }
173
174 - description: "Aggregate with $listLocalSessions"
175 runOnRequirements:
176 - minServerVersion: "3.6.0"
177 # serverless does not support either of the current database-level aggregation stages ($listLocalSessions and
178 # $currentOp)
179 serverless: forbid
180 operations:
181 - name: aggregate
182 object: *database1
183 arguments:
184 pipeline:
185 - $listLocalSessions: { }
186 - $limit: 1
187 - $addFields: { dummy: "dummy field"}
188 - $project: { _id: 0, dummy: 1}
189 expectResult:
190 - { dummy: "dummy field" }
View as plain text