File: poc-crud.yml

package info (click to toggle)
golang-mongodb-mongo-driver 1.8.1%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 18,500 kB
  • sloc: perl: 533; ansic: 491; python: 432; makefile: 187; sh: 72
file content (190 lines) | stat: -rw-r--r-- 5,769 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
description: "poc-crud"

schemaVersion: "1.4"

createEntities:
  - client:
      id: &client0 client0
      observeEvents: [ commandStartedEvent ]
  - database:
      id: &database0 database0
      client: *client0
      databaseName: &database0Name crud-tests
  - database:
      id: &database1 database1
      client: *client0
      databaseName: &database1Name admin
  - collection:
      id: &collection0 collection0
      database: *database0
      collectionName: &collection0Name coll0
  - collection:
      id: &collection1 collection1
      database: *database0
      collectionName: &collection1Name coll1
  - collection:
      id: &collection2 collection2
      database: *database0
      collectionName: &collection2Name coll2
      collectionOptions:
        readConcern: { level: majority }

initialData:
  - collectionName: *collection0Name
    databaseName: *database0Name
    documents:
      - { _id: 1, x: 11 }
      - { _id: 2, x: 22 }
  - collectionName: *collection1Name
    databaseName: *database0Name
    documents:
      - { _id: 1, x: 11 }
  - collectionName: *collection2Name
    databaseName: *database0Name
    documents:
      - { _id: 1, x: 11 }
      - { _id: 2, x: 22 }
      - { _id: 3, x: 33 }
  - collectionName: &out aggregate_out
    databaseName: *database0Name
    documents: []

tests:
  - description: "BulkWrite with mixed ordered operations"
    operations:
      - name: bulkWrite
        object: *collection0
        arguments:
          requests:
            - insertOne:
                document: { _id: 3, x: 33 }
            - updateOne:
                filter: { _id: 2 }
                update: { $inc: { x: 1 } }
            - updateMany:
                filter: { _id: { $gt: 1 } }
                update: { $inc: { x: 1 } }
            - insertOne:
                document: { _id: 4, x: 44 }
            - deleteMany:
                filter: { x: { $nin: [ 24, 34 ] } }
            - replaceOne:
                filter: { _id: 4 }
                replacement: { _id: 4, x: 44 }
                upsert: true
          ordered: true
        expectResult:
          deletedCount: 2
          insertedCount: 2
          insertedIds: { $$unsetOrMatches: { 0: 3, 3: 4 } }
          matchedCount: 3
          modifiedCount: 3
          upsertedCount: 1
          upsertedIds: { 5: 4 }
    outcome:
      - collectionName: *collection0Name
        databaseName: *database0Name
        documents:
          - {_id: 2, x: 24 }
          - {_id: 3, x: 34 }
          - {_id: 4, x: 44 }

  - description: "InsertMany continue-on-error behavior with unordered (duplicate key in requests)"
    operations:
      - name: insertMany
        object: *collection1
        arguments:
          documents:
            - { _id: 2, x: 22 }
            - { _id: 2, x: 22 }
            - { _id: 3, x: 33 }
          ordered: false
        expectError:
          expectResult:
            # insertMany throws BulkWriteException, which may optionally include
            # an intermediary BulkWriteResult
            $$unsetOrMatches:
              deletedCount: 0
              insertedCount: 2
              # Since the map of insertedIds is generated before execution it
              # could indicate inserts that did not actually succeed. We omit
              # this field rather than expect drivers to provide an accurate
              # map filtered by write errors.
              matchedCount: 0
              modifiedCount: 0
              upsertedCount: 0
              upsertedIds: { }
    outcome:
      - collectionName: *collection1Name
        databaseName: *database0Name
        documents:
          - { _id: 1, x: 11 }
          - { _id: 2, x: 22 }
          - { _id: 3, x: 33 }

  - description: "ReplaceOne prohibits atomic modifiers"
    operations:
      - name: replaceOne
        object: *collection1
        arguments:
          filter: { _id: 1 }
          replacement: { $set: { x: 22 }}
        expectError:
          isClientError: true
    expectEvents:
      - client: *client0
        events: []
    outcome:
      - collectionName: *collection1Name
        databaseName: *database0Name
        documents:
          - { _id: 1, x: 11 }

  - description: "readConcern majority with out stage"
    runOnRequirements:
      - minServerVersion: "4.1.0"
        topologies: [ replicaset, sharded-replicaset ]
        serverless: "forbid"
    operations:
      - name: aggregate
        object: *collection2
        arguments:
          pipeline: &pipeline
            - $sort: { x : 1 }
            - $match: { _id: { $gt: 1 } }
            - $out: *out
    expectEvents:
      - client: *client0
        events:
          - commandStartedEvent:
              command:
                aggregate: *collection2Name
                pipeline: *pipeline
                readConcern: { level: majority }
              # The following two assertions were not in the original test
              commandName: aggregate
              databaseName: *database0Name
    outcome:
      - collectionName: *out
        databaseName: *database0Name
        documents:
          - { _id: 2, x: 22 }
          - { _id: 3, x: 33 }

  - description: "Aggregate with $listLocalSessions"
    runOnRequirements:
      - minServerVersion: "3.6.0"
        # serverless does not support either of the current database-level aggregation stages ($listLocalSessions and
        # $currentOp)
        serverless: forbid
    operations:
      - name: aggregate
        object: *database1
        arguments:
          pipeline:
            - $listLocalSessions: { }
            - $limit: 1
            - $addFields: { dummy: "dummy field"}
            - $project: { _id: 0, dummy: 1}
        expectResult:
          - { dummy: "dummy field" }