...

Text file src/go.mongodb.org/mongo-driver/testdata/change-streams/change-streams-pre_and_post_images.yml

Documentation: go.mongodb.org/mongo-driver/testdata/change-streams

     1description: "change-streams-pre_and_post_images"
     2
     3schemaVersion: "1.4"
     4
     5runOnRequirements:
     6  - minServerVersion: "6.0.0"
     7    topologies: [ replicaset, sharded-replicaset, load-balanced ]
     8    serverless: forbid
     9
    10createEntities:
    11  - client:
    12      id: &client0 client0
    13      observeEvents: [ commandStartedEvent ]
    14      ignoreCommandMonitoringEvents: [ collMod, insert, update, getMore, killCursors ]
    15  - database:
    16      id: &database0 database0
    17      client: *client0
    18      databaseName: &database0Name change-stream-tests
    19  - collection:
    20      id: &collection0 collection0
    21      database: *database0
    22      collectionName: &collection0Name test
    23
    24initialData:
    25  - collectionName: *collection0Name
    26    databaseName: *database0Name
    27    documents:
    28      - { _id: 1 }
    29
    30tests:
    31  - description: "fullDocument:whenAvailable with changeStreamPreAndPostImages enabled"
    32    operations:
    33      - name: runCommand
    34        object: *database0
    35        arguments: &enablePreAndPostImages
    36          commandName: collMod
    37          command:
    38            collMod: *collection0Name
    39            changeStreamPreAndPostImages: { enabled: true }
    40      - name: createChangeStream
    41        object: *collection0
    42        arguments:
    43          pipeline: []
    44          fullDocument: "whenAvailable"
    45        saveResultAsEntity: &changeStream0 changeStream0
    46      - name: updateOne
    47        object: *collection0
    48        arguments:
    49          filter: { _id: 1 }
    50          update: { $set: { x: 1 }}
    51      - name: iterateUntilDocumentOrError
    52        object: *changeStream0
    53        expectResult:
    54          operationType: "update"
    55          ns: { db: *database0Name, coll: *collection0Name }
    56          updateDescription: { $$type: "object" }
    57          fullDocument: { _id: 1, x: 1 }
    58    expectEvents:
    59      - client: *client0
    60        events:
    61          - commandStartedEvent:
    62              command:
    63                aggregate: *collection0Name
    64                pipeline:
    65                  - $changeStream: { fullDocument: "whenAvailable" }
    66
    67  - description: "fullDocument:whenAvailable with changeStreamPreAndPostImages disabled"
    68    operations:
    69      - name: runCommand
    70        object: *database0
    71        arguments: &disablePreAndPostImages
    72          commandName: collMod
    73          command:
    74            collMod: *collection0Name
    75            changeStreamPreAndPostImages: { enabled: false }
    76      - name: createChangeStream
    77        object: *collection0
    78        arguments:
    79          pipeline: []
    80          fullDocument: "whenAvailable"
    81        saveResultAsEntity: &changeStream0 changeStream0
    82      - name: updateOne
    83        object: *collection0
    84        arguments:
    85          filter: { _id: 1 }
    86          update: { $set: { x: 1 }}
    87      - name: iterateUntilDocumentOrError
    88        object: *changeStream0
    89        expectResult:
    90          operationType: "update"
    91          ns: { db: *database0Name, coll: *collection0Name }
    92          updateDescription: { $$type: "object" }
    93          fullDocument: null
    94    expectEvents:
    95      - client: *client0
    96        events:
    97          - commandStartedEvent:
    98              command:
    99                aggregate: *collection0Name
   100                pipeline:
   101                  - $changeStream: { fullDocument: "whenAvailable" }
   102
   103  - description: "fullDocument:required with changeStreamPreAndPostImages enabled"
   104    operations:
   105      - name: runCommand
   106        object: *database0
   107        arguments: *enablePreAndPostImages
   108      - name: createChangeStream
   109        object: *collection0
   110        arguments:
   111          pipeline: []
   112          fullDocument: "required"
   113        saveResultAsEntity: &changeStream0 changeStream0
   114      - name: updateOne
   115        object: *collection0
   116        arguments:
   117          filter: { _id: 1 }
   118          update: { $set: { x: 1 }}
   119      - name: iterateUntilDocumentOrError
   120        object: *changeStream0
   121        expectResult:
   122          operationType: "update"
   123          ns: { db: *database0Name, coll: *collection0Name }
   124          updateDescription: { $$type: "object" }
   125          fullDocument: { _id: 1, x: 1 }
   126    expectEvents:
   127      - client: *client0
   128        events:
   129          - commandStartedEvent:
   130              command:
   131                aggregate: *collection0Name
   132                pipeline:
   133                  - $changeStream: { fullDocument: "required" }
   134
   135  - description: "fullDocument:required with changeStreamPreAndPostImages disabled"
   136    operations:
   137      - name: runCommand
   138        object: *database0
   139        arguments: *disablePreAndPostImages
   140      - name: createChangeStream
   141        object: *collection0
   142        arguments:
   143          pipeline: []
   144          fullDocument: "required"
   145        saveResultAsEntity: &changeStream0 changeStream0
   146      - name: updateOne
   147        object: *collection0
   148        arguments:
   149          filter: { _id: 1 }
   150          update: { $set: { x: 1 }}
   151      - name: iterateUntilDocumentOrError
   152        object: *changeStream0
   153        expectError:
   154          isClientError: false
   155    expectEvents:
   156      - client: *client0
   157        events:
   158          - commandStartedEvent:
   159              command:
   160                aggregate: *collection0Name
   161                pipeline:
   162                  - $changeStream: { fullDocument: "required" }
   163
   164  - description: "fullDocumentBeforeChange:whenAvailable with changeStreamPreAndPostImages enabled"
   165    operations:
   166      - name: runCommand
   167        object: *database0
   168        arguments: *enablePreAndPostImages
   169      - name: createChangeStream
   170        object: *collection0
   171        arguments:
   172          pipeline: []
   173          fullDocumentBeforeChange: "whenAvailable"
   174        saveResultAsEntity: &changeStream0 changeStream0
   175      - name: updateOne
   176        object: *collection0
   177        arguments:
   178          filter: { _id: 1 }
   179          update: { $set: { x: 1 }}
   180      - name: iterateUntilDocumentOrError
   181        object: *changeStream0
   182        expectResult:
   183          operationType: "update"
   184          ns: { db: *database0Name, coll: *collection0Name }
   185          updateDescription: { $$type: "object" }
   186          fullDocumentBeforeChange: { _id: 1 }
   187    expectEvents:
   188      - client: *client0
   189        events:
   190          - commandStartedEvent:
   191              command:
   192                aggregate: *collection0Name
   193                pipeline:
   194                  - $changeStream: { fullDocumentBeforeChange: "whenAvailable" }
   195
   196  - description: "fullDocumentBeforeChange:whenAvailable with changeStreamPreAndPostImages disabled"
   197    operations:
   198      - name: runCommand
   199        object: *database0
   200        arguments: *disablePreAndPostImages
   201      - name: createChangeStream
   202        object: *collection0
   203        arguments:
   204          pipeline: []
   205          fullDocumentBeforeChange: "whenAvailable"
   206        saveResultAsEntity: &changeStream0 changeStream0
   207      - name: updateOne
   208        object: *collection0
   209        arguments:
   210          filter: { _id: 1 }
   211          update: { $set: { x: 1 }}
   212      - name: iterateUntilDocumentOrError
   213        object: *changeStream0
   214        expectResult:
   215          operationType: "update"
   216          ns: { db: *database0Name, coll: *collection0Name }
   217          updateDescription: { $$type: "object" }
   218          fullDocumentBeforeChange: null
   219    expectEvents:
   220      - client: *client0
   221        events:
   222          - commandStartedEvent:
   223              command:
   224                aggregate: *collection0Name
   225                pipeline:
   226                  - $changeStream: { fullDocumentBeforeChange: "whenAvailable" }
   227
   228  - description: "fullDocumentBeforeChange:required with changeStreamPreAndPostImages enabled"
   229    operations:
   230      - name: runCommand
   231        object: *database0
   232        arguments: *enablePreAndPostImages
   233      - name: createChangeStream
   234        object: *collection0
   235        arguments:
   236          pipeline: []
   237          fullDocumentBeforeChange: "required"
   238        saveResultAsEntity: &changeStream0 changeStream0
   239      - name: updateOne
   240        object: *collection0
   241        arguments:
   242          filter: { _id: 1 }
   243          update: { $set: { x: 1 }}
   244      - name: iterateUntilDocumentOrError
   245        object: *changeStream0
   246        expectResult:
   247          operationType: "update"
   248          ns: { db: *database0Name, coll: *collection0Name }
   249          updateDescription: { $$type: "object" }
   250          fullDocumentBeforeChange: { _id: 1 }
   251    expectEvents:
   252      - client: *client0
   253        events:
   254          - commandStartedEvent:
   255              command:
   256                aggregate: *collection0Name
   257                pipeline:
   258                  - $changeStream: { fullDocumentBeforeChange: "required" }
   259
   260  - description: "fullDocumentBeforeChange:required with changeStreamPreAndPostImages disabled"
   261    operations:
   262      - name: runCommand
   263        object: *database0
   264        arguments: *disablePreAndPostImages
   265      - name: createChangeStream
   266        object: *collection0
   267        arguments:
   268          pipeline: []
   269          fullDocumentBeforeChange: "required"
   270        saveResultAsEntity: &changeStream0 changeStream0
   271      - name: updateOne
   272        object: *collection0
   273        arguments:
   274          filter: { _id: 1 }
   275          update: { $set: { x: 1 }}
   276      - name: iterateUntilDocumentOrError
   277        object: *changeStream0
   278        expectError:
   279          isClientError: false
   280    expectEvents:
   281      - client: *client0
   282        events:
   283          - commandStartedEvent:
   284              command:
   285                aggregate: *collection0Name
   286                pipeline:
   287                  - $changeStream: { fullDocumentBeforeChange: "required" }
   288
   289  - description: "fullDocumentBeforeChange:off with changeStreamPreAndPostImages enabled"
   290    operations:
   291      - name: runCommand
   292        object: *database0
   293        arguments: *enablePreAndPostImages
   294      - name: createChangeStream
   295        object: *collection0
   296        arguments:
   297          pipeline: []
   298          fullDocumentBeforeChange: "off"
   299        saveResultAsEntity: &changeStream0 changeStream0
   300      - name: updateOne
   301        object: *collection0
   302        arguments:
   303          filter: { _id: 1 }
   304          update: { $set: { x: 1 }}
   305      - name: iterateUntilDocumentOrError
   306        object: *changeStream0
   307        expectResult:
   308          operationType: "update"
   309          ns: { db: *database0Name, coll: *collection0Name }
   310          updateDescription: { $$type: "object" }
   311          fullDocumentBeforeChange: { $$exists: false }
   312    expectEvents:
   313      - client: *client0
   314        events:
   315          - commandStartedEvent:
   316              command:
   317                aggregate: *collection0Name
   318                pipeline:
   319                  - $changeStream: { fullDocumentBeforeChange: "off" }
   320
   321  - description: "fullDocumentBeforeChange:off with changeStreamPreAndPostImages disabled"
   322    operations:
   323      - name: runCommand
   324        object: *database0
   325        arguments: *disablePreAndPostImages
   326      - name: createChangeStream
   327        object: *collection0
   328        arguments:
   329          pipeline: []
   330          fullDocumentBeforeChange: "off"
   331        saveResultAsEntity: &changeStream0 changeStream0
   332      - name: updateOne
   333        object: *collection0
   334        arguments:
   335          filter: { _id: 1 }
   336          update: { $set: { x: 1 }}
   337      - name: iterateUntilDocumentOrError
   338        object: *changeStream0
   339        expectResult:
   340          operationType: "update"
   341          ns: { db: *database0Name, coll: *collection0Name }
   342          updateDescription: { $$type: "object" }
   343          fullDocumentBeforeChange: { $$exists: false }
   344    expectEvents:
   345      - client: *client0
   346        events:
   347          - commandStartedEvent:
   348              command:
   349                aggregate: *collection0Name
   350                pipeline:
   351                  - $changeStream: { fullDocumentBeforeChange: "off" }

View as plain text