...

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

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

     1description: "change-streams"
     2
     3schemaVersion: "1.7"
     4
     5runOnRequirements:
     6  - minServerVersion: "3.6"
     7    # TODO(DRIVERS-2323): Run all possible tests against sharded clusters once we know the
     8    # cause of unexpected command monitoring events.
     9    topologies: [ replicaset ]
    10    serverless: forbid
    11
    12createEntities:
    13  - client:
    14      id: &client0 client0
    15      observeEvents: [ commandStartedEvent ]
    16      ignoreCommandMonitoringEvents: [ killCursors ]
    17      useMultipleMongoses: false
    18  - client:
    19      id: &globalClient globalClient
    20      useMultipleMongoses: false
    21  - database:
    22      id: &database0 database0
    23      client: *client0
    24      databaseName: *database0
    25  - collection:
    26      id: &collection0 collection0
    27      database: *database0
    28      collectionName: *collection0
    29  - database:
    30      id: &database1 database1
    31      client: *client0
    32      databaseName: *database1
    33  - collection:
    34      id: &collection1 collection1
    35      database: *database1
    36      collectionName: *collection1
    37  - database:
    38      id: &globalDatabase0 globalDatabase0
    39      client: *globalClient
    40      databaseName: *database0
    41  - collection:
    42      id: &globalCollection0 globalCollection0
    43      database: *globalDatabase0
    44      collectionName: *collection0
    45  - database:
    46      id: &globalDatabase1 globalDatabase1
    47      client: *globalClient
    48      databaseName: *database1
    49  - collection:
    50      id: &globalCollection1 globalCollection1
    51      database: *globalDatabase1
    52      collectionName: *collection1
    53  # Some tests run operations against db1.coll0 or db0.coll1
    54  - collection:
    55      id: &globalDb1Collection0 globalDb1Collection0
    56      database: *globalDatabase1
    57      collectionName: *collection0
    58  - collection:
    59      id: &globalDb0Collection1 globalDb0Collection1
    60      database: *globalDatabase0
    61      collectionName: *collection1
    62
    63initialData:
    64  - collectionName: *collection0
    65    databaseName: *database0
    66    documents: []
    67
    68tests:
    69  - description: "Test array truncation"
    70    runOnRequirements:
    71      - minServerVersion: "4.7"
    72    operations:
    73      - name: insertOne
    74        object: *collection0
    75        arguments:
    76          document: {
    77            "_id": 1,
    78            "a": 1,
    79            "array": ["foo", {"a": "bar"}, 1, 2, 3]
    80          }
    81      - name: createChangeStream
    82        object: *collection0
    83        arguments: { pipeline: [] }
    84        saveResultAsEntity: &changeStream0 changeStream0
    85      - name: updateOne
    86        object: *collection0
    87        arguments:
    88          filter: {
    89            "_id": 1
    90          }
    91          update: [
    92            {
    93              "$set": {
    94                "array": ["foo", {"a": "bar"}]
    95              }
    96            }
    97          ]
    98      - name: iterateUntilDocumentOrError
    99        object: *changeStream0
   100        expectResult: {
   101          "operationType": "update",
   102          "ns": {
   103            "db": "database0",
   104            "coll": "collection0"
   105          },
   106          # It is up to the MongoDB server to decide how to report a change.
   107          # This expectation is based on the current MongoDB server behavior.
   108          # Alternatively, we could have used a set of possible expectations of which only one
   109          # must be satisfied, but the unified test format does not support this.
   110          "updateDescription": {
   111            "updatedFields": {},
   112            "removedFields": [],
   113            "truncatedArrays": [
   114              {
   115                "field": "array",
   116                "newSize": 2
   117              }
   118            ]
   119          }
   120        }
   121
   122  - description: "Test with document comment"
   123    runOnRequirements:
   124      - minServerVersion: "4.4"
   125    operations:
   126      - name: createChangeStream
   127        object: *collection0
   128        arguments:
   129          pipeline: []
   130          comment: &comment0 { name: "test1" }
   131        saveResultAsEntity: &changeStream0 changeStream0
   132    expectEvents:
   133      - client: *client0
   134        events:
   135          - commandStartedEvent:
   136              command:
   137                aggregate: *collection0
   138                pipeline:
   139                  - $changeStream: {}
   140                comment: *comment0
   141
   142  - description: "Test with document comment - pre 4.4"
   143    skipReason: "TODO(GODRIVER-2386): aggregate only supports string comments"
   144    runOnRequirements:
   145      - maxServerVersion: "4.2.99"
   146    operations:
   147      - name: createChangeStream
   148        object: *collection0
   149        arguments:
   150          pipeline: []
   151          comment: &comment0 { name: "test1" }
   152        expectError:
   153          isClientError: false
   154    expectEvents:
   155      - client: *client0
   156        events:
   157          - commandStartedEvent:
   158              command:
   159                aggregate: *collection0
   160                pipeline:
   161                  - $changeStream: {}
   162                comment: *comment0
   163
   164  - description: "Test with string comment"
   165    operations:
   166      - name: createChangeStream
   167        object: *collection0
   168        arguments:
   169          pipeline: []
   170          comment: "comment"
   171        saveResultAsEntity: &changeStream0 changeStream0
   172    expectEvents:
   173      - client: *client0
   174        events:
   175          - commandStartedEvent:
   176              command:
   177                aggregate: *collection0
   178                pipeline:
   179                  - $changeStream: {}
   180                comment: "comment"
   181
   182  - description: "Test that comment is set on getMore"
   183    runOnRequirements:
   184      - minServerVersion: "4.4.0"
   185    operations:
   186      - name: createChangeStream
   187        object: *collection0
   188        arguments:
   189          pipeline: []
   190          comment: &commentDoc
   191            key: "value"
   192        saveResultAsEntity: &changeStream0 changeStream0
   193      - name: insertOne
   194        object: *collection0
   195        arguments:
   196          document: &new_document
   197            _id: 1
   198            a: 1
   199      - name: iterateUntilDocumentOrError
   200        object: *changeStream0
   201    expectEvents:
   202      - client: *client0
   203        events:
   204          - commandStartedEvent:
   205              command:
   206                aggregate: *collection0
   207                pipeline:
   208                  - $changeStream: {}
   209                comment: *commentDoc
   210          - commandStartedEvent:
   211              command:
   212                insert: *collection0
   213                documents:
   214                  - *new_document
   215          - commandStartedEvent:
   216              command:
   217                getMore: { $$type: [ int, long ] }
   218                collection: *collection0
   219                comment: *commentDoc
   220              commandName: getMore
   221              databaseName: *database0
   222
   223  - description: "Test that comment is not set on getMore - pre 4.4"
   224    runOnRequirements:
   225      - maxServerVersion: "4.3.99"
   226    operations:
   227      - name: createChangeStream
   228        object: *collection0
   229        arguments:
   230          pipeline: []
   231          comment: "comment"
   232        saveResultAsEntity: &changeStream0 changeStream0
   233      - name: insertOne
   234        object: *collection0
   235        arguments:
   236          document: &new_document
   237            _id: 1
   238            a: 1
   239      - name: iterateUntilDocumentOrError
   240        object: *changeStream0
   241    expectEvents:
   242      - client: *client0
   243        events:
   244          - commandStartedEvent:
   245              command:
   246                aggregate: *collection0
   247                pipeline:
   248                  - $changeStream: {}
   249                comment: "comment"
   250          - commandStartedEvent:
   251              command:
   252                insert: *collection0
   253                documents:
   254                  - *new_document
   255          - commandStartedEvent:
   256              command:
   257                getMore: { $$type: [ int, long ] }
   258                collection: *collection0
   259                comment: { $$exists: false }
   260              commandName: getMore
   261              databaseName: *database0
   262
   263  - description: "to field is set in a rename change event"
   264    runOnRequirements:
   265      - minServerVersion: "4.0.1"
   266    operations:
   267      - name: createChangeStream
   268        object: *collection0
   269        arguments: { pipeline: [] }
   270        saveResultAsEntity: &changeStream0 changeStream0
   271      - name: dropCollection
   272        object: *database0
   273        arguments:
   274          collection: &collection1 collection1
   275      - name: rename
   276        object: *collection0
   277        arguments:
   278          to: *collection1
   279      - name: iterateUntilDocumentOrError
   280        object: *changeStream0
   281        expectResult:
   282          operationType: rename
   283          ns:
   284            db: *database0
   285            coll: *collection0
   286          to:
   287            db: *database0
   288            coll: *collection1
   289
   290  - description: "Test unknown operationType MUST NOT err"
   291    operations:
   292      - name: createChangeStream
   293        object: *collection0
   294        arguments:
   295          # using $project to simulate future changes to ChangeStreamDocument structure
   296          pipeline: [ { $project: { operationType: "addedInFutureMongoDBVersion", ns: 1 } } ]
   297        saveResultAsEntity: &changeStream0 changeStream0
   298      - name: insertOne
   299        object: *collection0
   300        arguments:
   301          document: { "_id": 1, "a": 1 }
   302      - name: iterateUntilDocumentOrError
   303        object: *changeStream0
   304        expectResult:
   305          operationType: "addedInFutureMongoDBVersion"
   306          ns:
   307            db: *database0
   308            coll: *collection0
   309
   310  - description: "Test newField added in response MUST NOT err"
   311    operations:
   312      - name: createChangeStream
   313        object: *collection0
   314        arguments:
   315          # using $project to simulate future changes to ChangeStreamDocument structure
   316          pipeline: [ { $project: { operationType: 1, ns: 1, newField: "newFieldValue" } } ]
   317        saveResultAsEntity: &changeStream0 changeStream0
   318      - name: insertOne
   319        object: *collection0
   320        arguments:
   321          document: { "_id": 1, "a": 1 }
   322      - name: iterateUntilDocumentOrError
   323        object: *changeStream0
   324        expectResult:
   325          operationType: "insert"
   326          ns:
   327            db: *database0
   328            coll: *collection0
   329          newField: "newFieldValue"
   330
   331  - description: "Test new structure in ns document MUST NOT err"
   332    runOnRequirements:
   333      - minServerVersion: "3.6"
   334        maxServerVersion: "5.2.99"
   335      - minServerVersion: "6.0"
   336    operations:
   337      - name: createChangeStream
   338        object: *collection0
   339        arguments:
   340          # using $project to simulate future changes to ChangeStreamDocument structure
   341          pipeline: [ { $project: { operationType: "insert", "ns.viewOn": "db.coll" } } ]
   342        saveResultAsEntity: &changeStream0 changeStream0
   343      - name: insertOne
   344        object: *collection0
   345        arguments:
   346          document: { "_id": 1, "a": 1 }
   347      - name: iterateUntilDocumentOrError
   348        object: *changeStream0
   349        expectResult:
   350          operationType: "insert"
   351          ns:
   352            viewOn: "db.coll"
   353
   354  - description: "Test modified structure in ns document MUST NOT err"
   355    operations:
   356      - name: createChangeStream
   357        object: *collection0
   358        arguments:
   359          # using $project to simulate future changes to ChangeStreamDocument structure
   360          pipeline: [ { $project: { operationType: "insert", ns: { db: "$ns.db", coll: "$ns.coll", viewOn: "db.coll" } } } ]
   361        saveResultAsEntity: &changeStream0 changeStream0
   362      - name: insertOne
   363        object: *collection0
   364        arguments:
   365          document: { "_id": 1, "a": 1 }
   366      - name: iterateUntilDocumentOrError
   367        object: *changeStream0
   368        expectResult:
   369          operationType: "insert"
   370          ns:
   371            db: *database0
   372            coll: *collection0
   373            viewOn: "db.coll"
   374
   375  - description: "Test server error on projecting out _id"
   376    runOnRequirements:
   377      - minServerVersion: "4.2"
   378        # Server returns an error if _id is modified on versions 4.2 and higher
   379    operations:
   380      - name: createChangeStream
   381        object: *collection0
   382        arguments:
   383          pipeline: [ { $project: { _id: 0 } } ]
   384        saveResultAsEntity: &changeStream0 changeStream0
   385      - name: insertOne
   386        object: *collection0
   387        arguments:
   388          document: { "_id": 1, "a": 1 }
   389      - name: iterateUntilDocumentOrError
   390        object: *changeStream0
   391        expectError:
   392          errorCode: 280
   393          errorCodeName: "ChangeStreamFatalError"
   394          errorLabelsContain: [ "NonResumableChangeStreamError" ]
   395
   396  - description: "Test projection in change stream returns expected fields"
   397    operations:
   398      - name: createChangeStream
   399        object: *collection0
   400        arguments:
   401          pipeline: [ { $project: { optype: "$operationType", ns: 1, newField: "value" } } ]
   402        saveResultAsEntity: &changeStream0 changeStream0
   403      - name: insertOne
   404        object: *collection0
   405        arguments:
   406          document: { "_id": 1, "a": 1 }
   407      - name: iterateUntilDocumentOrError
   408        object: *changeStream0
   409        expectResult:
   410          optype: "insert"
   411          ns:
   412            db: *database0
   413            coll: *collection0
   414          newField: "value"
   415
   416  - description: $changeStream must be the first stage in a change stream pipeline sent to the server
   417    runOnRequirements:
   418      - minServerVersion: "3.6.0"
   419    operations:
   420      - name: createChangeStream
   421        object: *collection0
   422        arguments: { pipeline: [] }
   423        saveResultAsEntity: &changeStream0 changeStream0
   424      - name: insertOne
   425        object: *globalCollection0
   426        arguments:
   427          document: { x: 1 }
   428      - name: iterateUntilDocumentOrError
   429        object: *changeStream0
   430        expectResult:
   431          _id: { $$exists: true }
   432          documentKey: { $$exists: true }
   433          operationType: insert
   434          ns:
   435            db: *database0
   436            coll: *collection0
   437          fullDocument:
   438            x: 1
   439            _id: { $$exists: true }
   440    expectEvents:
   441      - client: *client0
   442        ignoreExtraEvents: true
   443        events:
   444          - commandStartedEvent:
   445              command:
   446                aggregate: *collection0
   447                cursor: {}
   448                pipeline: [ { $changeStream: {} } ]
   449              commandName: aggregate
   450              databaseName: *database0
   451
   452  - description: The server returns change stream responses in the specified server response format
   453    runOnRequirements:
   454      - minServerVersion: "3.6.0"
   455    operations:
   456      - name: createChangeStream
   457        object: *collection0
   458        arguments: { pipeline: [] }
   459        saveResultAsEntity: &changeStream0 changeStream0
   460      - name: insertOne
   461        object: *globalCollection0
   462        arguments:
   463          document: { x: 1 }
   464      - name: iterateUntilDocumentOrError
   465        object: *changeStream0
   466        expectResult:
   467          _id: { $$exists: true }
   468          documentKey: { $$exists: true }
   469          operationType: insert
   470          ns:
   471            db: *database0
   472            coll: *collection0
   473          fullDocument:
   474            x: 1
   475            _id: { $$exists: true }
   476
   477  - description: Executing a watch helper on a Collection results in notifications for changes to the specified collection
   478    runOnRequirements:
   479      - minServerVersion: "3.6.0"
   480    operations:
   481      - name: createChangeStream
   482        object: *collection0
   483        arguments: { pipeline: [] }
   484        saveResultAsEntity: &changeStream0 changeStream0
   485      - name: insertOne
   486        object: *globalDb0Collection1
   487        arguments:
   488          document: { x: 1 }
   489      - name: insertOne
   490        object: *globalDb1Collection0
   491        arguments:
   492          document: { y: 2 }
   493      - name: insertOne
   494        object: *globalCollection0
   495        arguments:
   496          document: { z: 3 }
   497      - name: iterateUntilDocumentOrError
   498        object: *changeStream0
   499        expectResult:
   500          operationType: insert
   501          ns:
   502            db: *database0
   503            coll: *collection0
   504          fullDocument:
   505            z: 3
   506            _id: { $$exists: true }
   507    expectEvents:
   508      - client: *client0
   509        ignoreExtraEvents: true
   510        events:
   511          - commandStartedEvent:
   512              command:
   513                aggregate: *collection0
   514                cursor: {}
   515                pipeline: [ { $changeStream: {} } ]
   516              commandName: aggregate
   517              databaseName: *database0
   518
   519  - description: Change Stream should allow valid aggregate pipeline stages
   520    runOnRequirements:
   521      - minServerVersion: "3.6.0"
   522    operations:
   523      - name: createChangeStream
   524        object: *collection0
   525        arguments:
   526          pipeline:
   527            - $match:
   528                fullDocument.z: 3
   529        saveResultAsEntity: &changeStream0 changeStream0
   530      - name: insertOne
   531        object: *globalCollection0
   532        arguments:
   533          document: { y: 2 }
   534      - name: insertOne
   535        object: *globalCollection0
   536        arguments:
   537          document: { z: 3 }
   538      - name: iterateUntilDocumentOrError
   539        object: *changeStream0
   540        expectResult:
   541          operationType: insert
   542          ns:
   543            db: *database0
   544            coll: *collection0
   545          fullDocument:
   546            z: 3
   547            _id: { $$exists: true }
   548    expectEvents:
   549      - client: *client0
   550        ignoreExtraEvents: true
   551        events:
   552          - commandStartedEvent:
   553              command:
   554                aggregate: *collection0
   555                cursor: {}
   556                pipeline:
   557                  - $changeStream: {}
   558                  - $match:
   559                      fullDocument.z: 3
   560              commandName: aggregate
   561              databaseName: *database0
   562
   563  - description: Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.
   564    runOnRequirements:
   565      - minServerVersion: "3.8.0"
   566    operations:
   567      - name: createChangeStream
   568        object: *database0
   569        arguments: { pipeline: [] }
   570        saveResultAsEntity: &changeStream0 changeStream0
   571      - name: insertOne
   572        object: *globalDb0Collection1
   573        arguments:
   574          document: { x: 1 }
   575      - name: insertOne
   576        object: *globalDb1Collection0
   577        arguments:
   578          document: { y: 2 }
   579      - name: insertOne
   580        object: *globalCollection0
   581        arguments:
   582          document: { z: 3 }
   583      - name: iterateUntilDocumentOrError
   584        object: *changeStream0
   585        expectResult:
   586          operationType: insert
   587          ns:
   588            db: *database0
   589            coll: *collection1
   590          fullDocument:
   591            x: 1
   592            _id: { $$exists: true }
   593      - name: iterateUntilDocumentOrError
   594        object: *changeStream0
   595        expectResult:
   596          operationType: insert
   597          ns:
   598            db: *database0
   599            coll: *collection0
   600          fullDocument:
   601            z: 3
   602            _id: { $$exists: true }
   603    expectEvents:
   604      - client: *client0
   605        ignoreExtraEvents: true
   606        events:
   607          - commandStartedEvent:
   608              command:
   609                aggregate: 1
   610                cursor: {}
   611                pipeline: [ { $changeStream: {} } ]
   612              commandName: aggregate
   613              databaseName: *database0
   614
   615  - description: Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.
   616    runOnRequirements:
   617      - minServerVersion: "3.8.0"
   618    operations:
   619      - name: createChangeStream
   620        object: *client0
   621        arguments: { pipeline: [] }
   622        saveResultAsEntity: &changeStream0 changeStream0
   623      - name: insertOne
   624        object: *globalDb0Collection1
   625        arguments:
   626          document: { x: 1 }
   627      - name: insertOne
   628        object: *globalDb1Collection0
   629        arguments:
   630          document: { y: 2 }
   631      - name: insertOne
   632        object: *globalCollection0
   633        arguments:
   634          document: { z: 3 }
   635      - name: iterateUntilDocumentOrError
   636        object: *changeStream0
   637        expectResult:
   638          operationType: insert
   639          ns:
   640            db: *database0
   641            coll: *collection1
   642          fullDocument:
   643            x: 1
   644            _id: { $$exists: true }
   645      - name: iterateUntilDocumentOrError
   646        object: *changeStream0
   647        expectResult:
   648          operationType: insert
   649          ns:
   650            db: *database1
   651            coll: *collection0
   652          fullDocument:
   653            y: 2
   654            _id: { $$exists: true }
   655      - name: iterateUntilDocumentOrError
   656        object: *changeStream0
   657        expectResult:
   658          operationType: insert
   659          ns:
   660            db: *database0
   661            coll: *collection0
   662          fullDocument:
   663            z: 3
   664            _id: { $$exists: true }
   665    expectEvents:
   666      - client: *client0
   667        ignoreExtraEvents: true
   668        events:
   669          - commandStartedEvent:
   670              command:
   671                aggregate: 1
   672                cursor: {}
   673                pipeline:
   674                  - $changeStream: { allChangesForCluster: true }
   675              commandName: aggregate
   676              databaseName: admin
   677
   678  - description: "Test insert, update, replace, and delete event types"
   679    runOnRequirements:
   680      - minServerVersion: "3.6.0"
   681    operations:
   682      - name: createChangeStream
   683        object: *collection0
   684        arguments: { pipeline: [] }
   685        saveResultAsEntity: &changeStream0 changeStream0
   686      - name: insertOne
   687        object: *globalCollection0
   688        arguments:
   689          document: { x: 1 }
   690      - name: updateOne
   691        object: *globalCollection0
   692        arguments:
   693          filter: { x: 1 }
   694          update:
   695            $set: { x: 2 }
   696      - name: replaceOne
   697        object: *globalCollection0
   698        arguments:
   699          filter: { x: 2 }
   700          replacement: { x: 3 }
   701      - name: deleteOne
   702        object: *globalCollection0
   703        arguments:
   704          filter: { x: 3 }
   705      - name: iterateUntilDocumentOrError
   706        object: *changeStream0
   707        expectResult:
   708          operationType: insert
   709          ns:
   710            db: *database0
   711            coll: *collection0
   712          fullDocument:
   713            x: 1
   714            _id: { $$exists: true }
   715      - name: iterateUntilDocumentOrError
   716        object: *changeStream0
   717        expectResult:
   718          operationType: update
   719          ns:
   720            db: *database0
   721            coll: *collection0
   722          updateDescription:
   723            updatedFields: { x: 2 }
   724            removedFields: []
   725            truncatedArrays: { $$unsetOrMatches: { $$exists: true } }
   726      - name: iterateUntilDocumentOrError
   727        object: *changeStream0
   728        expectResult:
   729          operationType: replace
   730          ns:
   731            db: *database0
   732            coll: *collection0
   733          fullDocument:
   734            x: 3
   735            _id: { $$exists: true }
   736      - name: iterateUntilDocumentOrError
   737        object: *changeStream0
   738        expectResult:
   739          operationType: delete
   740          ns:
   741            db: *database0
   742            coll: *collection0
   743    expectEvents:
   744      - client: *client0
   745        ignoreExtraEvents: true
   746        events:
   747          - commandStartedEvent:
   748              command:
   749                aggregate: *collection0
   750                cursor: {}
   751                pipeline: [ { $changeStream: {} } ]
   752              commandName: aggregate
   753              databaseName: *database0
   754
   755  - description: Test rename and invalidate event types
   756    runOnRequirements:
   757      - minServerVersion: "4.0.1"
   758    operations:
   759      - name: createChangeStream
   760        object: *collection0
   761        arguments: { pipeline: [] }
   762        saveResultAsEntity: &changeStream0 changeStream0
   763      - name: dropCollection
   764        object: *database0
   765        arguments:
   766          collection: *collection1
   767      - name: rename
   768        object: *globalCollection0
   769        arguments:
   770          to: *collection1
   771      - name: iterateUntilDocumentOrError
   772        object: *changeStream0
   773        expectResult:
   774          operationType: rename
   775          ns:
   776            db: *database0
   777            coll: *collection0
   778          to:
   779            db: *database0
   780            coll: *collection1
   781      - name: iterateUntilDocumentOrError
   782        object: *changeStream0
   783        expectResult:
   784          operationType: invalidate
   785    expectEvents:
   786      - client: *client0
   787        ignoreExtraEvents: true
   788        events:
   789          - commandStartedEvent:
   790              command:
   791                aggregate: *collection0
   792                cursor: {}
   793                pipeline: [ { $changeStream: {} } ]
   794              commandName: aggregate
   795              databaseName: *database0
   796
   797  - description: Test drop and invalidate event types
   798    runOnRequirements:
   799      - minServerVersion: "4.0.1"
   800    operations:
   801      - name: createChangeStream
   802        object: *collection0
   803        arguments: { pipeline: [] }
   804        saveResultAsEntity: &changeStream0 changeStream0
   805      - name: dropCollection
   806        object: *database0
   807        arguments:
   808          collection: *collection0
   809      - name: iterateUntilDocumentOrError
   810        object: *changeStream0
   811        expectResult:
   812          operationType: drop
   813          ns:
   814            db: *database0
   815            coll: *collection0
   816      - name: iterateUntilDocumentOrError
   817        object: *changeStream0
   818        expectResult:
   819          operationType: invalidate
   820    expectEvents:
   821      - client: *client0
   822        ignoreExtraEvents: true
   823        events:
   824          - commandStartedEvent:
   825              command:
   826                aggregate: *collection0
   827                cursor: {}
   828                pipeline: [ { $changeStream: {} } ]
   829              commandName: aggregate
   830              databaseName: *database0
   831
   832  # Test that resume logic works correctly even after consecutive retryable failures of a getMore command,
   833  # with no intervening events. This is ensured by setting the batch size of the change stream to 1,
   834  - description: Test consecutive resume
   835    runOnRequirements:
   836      - minServerVersion: "4.1.7"
   837    operations:
   838      - name: failPoint
   839        object: testRunner
   840        arguments:
   841          client: *globalClient
   842          failPoint:
   843            configureFailPoint: failCommand
   844            mode: { times: 2 }
   845            data:
   846              failCommands: [ getMore ]
   847              closeConnection: true
   848      - name: createChangeStream
   849        object: *collection0
   850        arguments:
   851          pipeline: []
   852          batchSize: 1
   853        saveResultAsEntity: &changeStream0 changeStream0
   854      - name: insertOne
   855        object: *globalCollection0
   856        arguments:
   857          document: { x: 1 }
   858      - name: insertOne
   859        object: *globalCollection0
   860        arguments:
   861          document: { x: 2 }
   862      - name: insertOne
   863        object: *globalCollection0
   864        arguments:
   865          document: { x: 3 }
   866      - name: iterateUntilDocumentOrError
   867        object: *changeStream0
   868        expectResult:
   869          operationType: insert
   870          ns:
   871            db: *database0
   872            coll: *collection0
   873          fullDocument:
   874            x: 1
   875            _id: { $$exists: true }
   876      - name: iterateUntilDocumentOrError
   877        object: *changeStream0
   878        expectResult:
   879          operationType: insert
   880          ns:
   881            db: *database0
   882            coll: *collection0
   883          fullDocument:
   884            x: 2
   885            _id: { $$exists: true }
   886      - name: iterateUntilDocumentOrError
   887        object: *changeStream0
   888        expectResult:
   889          operationType: insert
   890          ns:
   891            db: *database0
   892            coll: *collection0
   893          fullDocument:
   894            x: 3
   895            _id: { $$exists: true }
   896    expectEvents:
   897      - client: *client0
   898        ignoreExtraEvents: true
   899        events:
   900          - commandStartedEvent:
   901              command:
   902                aggregate: *collection0
   903                cursor:
   904                  batchSize: 1
   905                pipeline: [ { $changeStream: {} } ]
   906              commandName: aggregate
   907              databaseName: *database0
   908
   909  - description: "Test wallTime field is set in a change event"
   910    runOnRequirements:
   911      - minServerVersion: "6.0.0"
   912    operations:
   913      - name: createChangeStream
   914        object: *collection0
   915        arguments: { pipeline: [] }
   916        saveResultAsEntity: &changeStream0 changeStream0
   917      - name: insertOne
   918        object: *collection0
   919        arguments:
   920          document: { "_id": 1, "a": 1 }
   921      - name: iterateUntilDocumentOrError
   922        object: *changeStream0
   923        expectResult:
   924          operationType: "insert"
   925          ns:
   926            db: *database0
   927            coll: *collection0
   928          wallTime: { $$exists: true }

View as plain text