...
1description: "updateMany"
2
3schemaVersion: "1.0"
4
5createEntities:
6 - client:
7 id: &client client
8 observeEvents:
9 - commandStartedEvent
10 - commandSucceededEvent
11 - commandFailedEvent
12 - database:
13 id: &database database
14 client: *client
15 databaseName: &databaseName command-monitoring-tests
16 - collection:
17 id: &collection collection
18 database: *database
19 collectionName: &collectionName test
20
21initialData:
22 - collectionName: *collectionName
23 databaseName: *databaseName
24 documents:
25 - { _id: 1, x: 11 }
26 - { _id: 2, x: 22 }
27 - { _id: 3, x: 33 }
28
29tests:
30 - description: "A successful updateMany"
31 operations:
32 - name: updateMany
33 object: *collection
34 arguments:
35 filter: { _id: { $gt: 1 } }
36 update: { $inc: { x: 1 } }
37 expectEvents:
38 - client: *client
39 events:
40 - commandStartedEvent:
41 command:
42 update: *collectionName
43 updates:
44 - q: { _id: { $gt: 1 } }
45 u: { $inc: { x: 1 } }
46 upsert: { $$unsetOrMatches: false }
47 multi: true
48 ordered: true
49 commandName: update
50 databaseName: *databaseName
51 - commandSucceededEvent:
52 reply: { ok: 1, n: 2 }
53 commandName: update
54
55 - description: "A successful updateMany with write errors"
56 operations:
57 - name: updateMany
58 object: *collection
59 arguments:
60 filter: { _id: { $gt: 1 } }
61 update: { $unsupported: { x: 1 } }
62 expectError:
63 isClientError: false
64 expectEvents:
65 - client: *client
66 events:
67 - commandStartedEvent:
68 command:
69 update: *collectionName
70 updates:
71 - q: { _id: { $gt: 1 } }
72 u: { $unsupported: { x: 1 } }
73 upsert: { $$unsetOrMatches: false }
74 multi: true
75 ordered: true
76 commandName: update
77 databaseName: *databaseName
78 - commandSucceededEvent:
79 reply:
80 ok: 1
81 n: 0
82 # The legacy version of this test included an assertion that writeErrors contained a single document
83 # with index=0, a "code" value, and a non-empty "errmsg". However, writeErrors can contain extra fields
84 # beyond these, and the unified format currently does not permit allowing extra fields in sub-documents,
85 # so those assertions are not present here.
86 writeErrors: { $$type: array }
87 commandName: update
View as plain text