...

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

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

     1{
     2  "description": "change-streams",
     3  "schemaVersion": "1.7",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "3.6",
     7      "topologies": [
     8        "replicaset"
     9      ],
    10      "serverless": "forbid"
    11    }
    12  ],
    13  "createEntities": [
    14    {
    15      "client": {
    16        "id": "client0",
    17        "observeEvents": [
    18          "commandStartedEvent"
    19        ],
    20        "ignoreCommandMonitoringEvents": [
    21          "killCursors"
    22        ],
    23        "useMultipleMongoses": false
    24      }
    25    },
    26    {
    27      "client": {
    28        "id": "globalClient",
    29        "useMultipleMongoses": false
    30      }
    31    },
    32    {
    33      "database": {
    34        "id": "database0",
    35        "client": "client0",
    36        "databaseName": "database0"
    37      }
    38    },
    39    {
    40      "collection": {
    41        "id": "collection0",
    42        "database": "database0",
    43        "collectionName": "collection0"
    44      }
    45    },
    46    {
    47      "database": {
    48        "id": "database1",
    49        "client": "client0",
    50        "databaseName": "database1"
    51      }
    52    },
    53    {
    54      "collection": {
    55        "id": "collection1",
    56        "database": "database1",
    57        "collectionName": "collection1"
    58      }
    59    },
    60    {
    61      "database": {
    62        "id": "globalDatabase0",
    63        "client": "globalClient",
    64        "databaseName": "database0"
    65      }
    66    },
    67    {
    68      "collection": {
    69        "id": "globalCollection0",
    70        "database": "globalDatabase0",
    71        "collectionName": "collection0"
    72      }
    73    },
    74    {
    75      "database": {
    76        "id": "globalDatabase1",
    77        "client": "globalClient",
    78        "databaseName": "database1"
    79      }
    80    },
    81    {
    82      "collection": {
    83        "id": "globalCollection1",
    84        "database": "globalDatabase1",
    85        "collectionName": "collection1"
    86      }
    87    },
    88    {
    89      "collection": {
    90        "id": "globalDb1Collection0",
    91        "database": "globalDatabase1",
    92        "collectionName": "collection0"
    93      }
    94    },
    95    {
    96      "collection": {
    97        "id": "globalDb0Collection1",
    98        "database": "globalDatabase0",
    99        "collectionName": "collection1"
   100      }
   101    }
   102  ],
   103  "initialData": [
   104    {
   105      "collectionName": "collection0",
   106      "databaseName": "database0",
   107      "documents": []
   108    }
   109  ],
   110  "tests": [
   111    {
   112      "description": "Test array truncation",
   113      "runOnRequirements": [
   114        {
   115          "minServerVersion": "4.7"
   116        }
   117      ],
   118      "operations": [
   119        {
   120          "name": "insertOne",
   121          "object": "collection0",
   122          "arguments": {
   123            "document": {
   124              "_id": 1,
   125              "a": 1,
   126              "array": [
   127                "foo",
   128                {
   129                  "a": "bar"
   130                },
   131                1,
   132                2,
   133                3
   134              ]
   135            }
   136          }
   137        },
   138        {
   139          "name": "createChangeStream",
   140          "object": "collection0",
   141          "arguments": {
   142            "pipeline": []
   143          },
   144          "saveResultAsEntity": "changeStream0"
   145        },
   146        {
   147          "name": "updateOne",
   148          "object": "collection0",
   149          "arguments": {
   150            "filter": {
   151              "_id": 1
   152            },
   153            "update": [
   154              {
   155                "$set": {
   156                  "array": [
   157                    "foo",
   158                    {
   159                      "a": "bar"
   160                    }
   161                  ]
   162                }
   163              }
   164            ]
   165          }
   166        },
   167        {
   168          "name": "iterateUntilDocumentOrError",
   169          "object": "changeStream0",
   170          "expectResult": {
   171            "operationType": "update",
   172            "ns": {
   173              "db": "database0",
   174              "coll": "collection0"
   175            },
   176            "updateDescription": {
   177              "updatedFields": {},
   178              "removedFields": [],
   179              "truncatedArrays": [
   180                {
   181                  "field": "array",
   182                  "newSize": 2
   183                }
   184              ]
   185            }
   186          }
   187        }
   188      ]
   189    },
   190    {
   191      "description": "Test with document comment",
   192      "runOnRequirements": [
   193        {
   194          "minServerVersion": "4.4"
   195        }
   196      ],
   197      "operations": [
   198        {
   199          "name": "createChangeStream",
   200          "object": "collection0",
   201          "arguments": {
   202            "pipeline": [],
   203            "comment": {
   204              "name": "test1"
   205            }
   206          },
   207          "saveResultAsEntity": "changeStream0"
   208        }
   209      ],
   210      "expectEvents": [
   211        {
   212          "client": "client0",
   213          "events": [
   214            {
   215              "commandStartedEvent": {
   216                "command": {
   217                  "aggregate": "collection0",
   218                  "pipeline": [
   219                    {
   220                      "$changeStream": {}
   221                    }
   222                  ],
   223                  "comment": {
   224                    "name": "test1"
   225                  }
   226                }
   227              }
   228            }
   229          ]
   230        }
   231      ]
   232    },
   233    {
   234      "description": "Test with document comment - pre 4.4",
   235      "skipReason": "TODO(GODRIVER-2386): aggregate only supports string comments",
   236      "runOnRequirements": [
   237        {
   238          "maxServerVersion": "4.2.99"
   239        }
   240      ],
   241      "operations": [
   242        {
   243          "name": "createChangeStream",
   244          "object": "collection0",
   245          "arguments": {
   246            "pipeline": [],
   247            "comment": {
   248              "name": "test1"
   249            }
   250          },
   251          "expectError": {
   252            "isClientError": false
   253          }
   254        }
   255      ],
   256      "expectEvents": [
   257        {
   258          "client": "client0",
   259          "events": [
   260            {
   261              "commandStartedEvent": {
   262                "command": {
   263                  "aggregate": "collection0",
   264                  "pipeline": [
   265                    {
   266                      "$changeStream": {}
   267                    }
   268                  ],
   269                  "comment": {
   270                    "name": "test1"
   271                  }
   272                }
   273              }
   274            }
   275          ]
   276        }
   277      ]
   278    },
   279    {
   280      "description": "Test with string comment",
   281      "operations": [
   282        {
   283          "name": "createChangeStream",
   284          "object": "collection0",
   285          "arguments": {
   286            "pipeline": [],
   287            "comment": "comment"
   288          },
   289          "saveResultAsEntity": "changeStream0"
   290        }
   291      ],
   292      "expectEvents": [
   293        {
   294          "client": "client0",
   295          "events": [
   296            {
   297              "commandStartedEvent": {
   298                "command": {
   299                  "aggregate": "collection0",
   300                  "pipeline": [
   301                    {
   302                      "$changeStream": {}
   303                    }
   304                  ],
   305                  "comment": "comment"
   306                }
   307              }
   308            }
   309          ]
   310        }
   311      ]
   312    },
   313    {
   314      "description": "Test that comment is set on getMore",
   315      "runOnRequirements": [
   316        {
   317          "minServerVersion": "4.4.0"
   318        }
   319      ],
   320      "operations": [
   321        {
   322          "name": "createChangeStream",
   323          "object": "collection0",
   324          "arguments": {
   325            "pipeline": [],
   326            "comment": {
   327              "key": "value"
   328            }
   329          },
   330          "saveResultAsEntity": "changeStream0"
   331        },
   332        {
   333          "name": "insertOne",
   334          "object": "collection0",
   335          "arguments": {
   336            "document": {
   337              "_id": 1,
   338              "a": 1
   339            }
   340          }
   341        },
   342        {
   343          "name": "iterateUntilDocumentOrError",
   344          "object": "changeStream0"
   345        }
   346      ],
   347      "expectEvents": [
   348        {
   349          "client": "client0",
   350          "events": [
   351            {
   352              "commandStartedEvent": {
   353                "command": {
   354                  "aggregate": "collection0",
   355                  "pipeline": [
   356                    {
   357                      "$changeStream": {}
   358                    }
   359                  ],
   360                  "comment": {
   361                    "key": "value"
   362                  }
   363                }
   364              }
   365            },
   366            {
   367              "commandStartedEvent": {
   368                "command": {
   369                  "insert": "collection0",
   370                  "documents": [
   371                    {
   372                      "_id": 1,
   373                      "a": 1
   374                    }
   375                  ]
   376                }
   377              }
   378            },
   379            {
   380              "commandStartedEvent": {
   381                "command": {
   382                  "getMore": {
   383                    "$$type": [
   384                      "int",
   385                      "long"
   386                    ]
   387                  },
   388                  "collection": "collection0",
   389                  "comment": {
   390                    "key": "value"
   391                  }
   392                },
   393                "commandName": "getMore",
   394                "databaseName": "database0"
   395              }
   396            }
   397          ]
   398        }
   399      ]
   400    },
   401    {
   402      "description": "Test that comment is not set on getMore - pre 4.4",
   403      "runOnRequirements": [
   404        {
   405          "maxServerVersion": "4.3.99"
   406        }
   407      ],
   408      "operations": [
   409        {
   410          "name": "createChangeStream",
   411          "object": "collection0",
   412          "arguments": {
   413            "pipeline": [],
   414            "comment": "comment"
   415          },
   416          "saveResultAsEntity": "changeStream0"
   417        },
   418        {
   419          "name": "insertOne",
   420          "object": "collection0",
   421          "arguments": {
   422            "document": {
   423              "_id": 1,
   424              "a": 1
   425            }
   426          }
   427        },
   428        {
   429          "name": "iterateUntilDocumentOrError",
   430          "object": "changeStream0"
   431        }
   432      ],
   433      "expectEvents": [
   434        {
   435          "client": "client0",
   436          "events": [
   437            {
   438              "commandStartedEvent": {
   439                "command": {
   440                  "aggregate": "collection0",
   441                  "pipeline": [
   442                    {
   443                      "$changeStream": {}
   444                    }
   445                  ],
   446                  "comment": "comment"
   447                }
   448              }
   449            },
   450            {
   451              "commandStartedEvent": {
   452                "command": {
   453                  "insert": "collection0",
   454                  "documents": [
   455                    {
   456                      "_id": 1,
   457                      "a": 1
   458                    }
   459                  ]
   460                }
   461              }
   462            },
   463            {
   464              "commandStartedEvent": {
   465                "command": {
   466                  "getMore": {
   467                    "$$type": [
   468                      "int",
   469                      "long"
   470                    ]
   471                  },
   472                  "collection": "collection0",
   473                  "comment": {
   474                    "$$exists": false
   475                  }
   476                },
   477                "commandName": "getMore",
   478                "databaseName": "database0"
   479              }
   480            }
   481          ]
   482        }
   483      ]
   484    },
   485    {
   486      "description": "to field is set in a rename change event",
   487      "runOnRequirements": [
   488        {
   489          "minServerVersion": "4.0.1"
   490        }
   491      ],
   492      "operations": [
   493        {
   494          "name": "createChangeStream",
   495          "object": "collection0",
   496          "arguments": {
   497            "pipeline": []
   498          },
   499          "saveResultAsEntity": "changeStream0"
   500        },
   501        {
   502          "name": "dropCollection",
   503          "object": "database0",
   504          "arguments": {
   505            "collection": "collection1"
   506          }
   507        },
   508        {
   509          "name": "rename",
   510          "object": "collection0",
   511          "arguments": {
   512            "to": "collection1"
   513          }
   514        },
   515        {
   516          "name": "iterateUntilDocumentOrError",
   517          "object": "changeStream0",
   518          "expectResult": {
   519            "operationType": "rename",
   520            "ns": {
   521              "db": "database0",
   522              "coll": "collection0"
   523            },
   524            "to": {
   525              "db": "database0",
   526              "coll": "collection1"
   527            }
   528          }
   529        }
   530      ]
   531    },
   532    {
   533      "description": "Test unknown operationType MUST NOT err",
   534      "operations": [
   535        {
   536          "name": "createChangeStream",
   537          "object": "collection0",
   538          "arguments": {
   539            "pipeline": [
   540              {
   541                "$project": {
   542                  "operationType": "addedInFutureMongoDBVersion",
   543                  "ns": 1
   544                }
   545              }
   546            ]
   547          },
   548          "saveResultAsEntity": "changeStream0"
   549        },
   550        {
   551          "name": "insertOne",
   552          "object": "collection0",
   553          "arguments": {
   554            "document": {
   555              "_id": 1,
   556              "a": 1
   557            }
   558          }
   559        },
   560        {
   561          "name": "iterateUntilDocumentOrError",
   562          "object": "changeStream0",
   563          "expectResult": {
   564            "operationType": "addedInFutureMongoDBVersion",
   565            "ns": {
   566              "db": "database0",
   567              "coll": "collection0"
   568            }
   569          }
   570        }
   571      ]
   572    },
   573    {
   574      "description": "Test newField added in response MUST NOT err",
   575      "operations": [
   576        {
   577          "name": "createChangeStream",
   578          "object": "collection0",
   579          "arguments": {
   580            "pipeline": [
   581              {
   582                "$project": {
   583                  "operationType": 1,
   584                  "ns": 1,
   585                  "newField": "newFieldValue"
   586                }
   587              }
   588            ]
   589          },
   590          "saveResultAsEntity": "changeStream0"
   591        },
   592        {
   593          "name": "insertOne",
   594          "object": "collection0",
   595          "arguments": {
   596            "document": {
   597              "_id": 1,
   598              "a": 1
   599            }
   600          }
   601        },
   602        {
   603          "name": "iterateUntilDocumentOrError",
   604          "object": "changeStream0",
   605          "expectResult": {
   606            "operationType": "insert",
   607            "ns": {
   608              "db": "database0",
   609              "coll": "collection0"
   610            },
   611            "newField": "newFieldValue"
   612          }
   613        }
   614      ]
   615    },
   616    {
   617      "description": "Test new structure in ns document MUST NOT err",
   618      "runOnRequirements": [
   619        {
   620          "minServerVersion": "3.6",
   621          "maxServerVersion": "5.2.99"
   622        },
   623        {
   624          "minServerVersion": "6.0"
   625        }
   626      ],
   627      "operations": [
   628        {
   629          "name": "createChangeStream",
   630          "object": "collection0",
   631          "arguments": {
   632            "pipeline": [
   633              {
   634                "$project": {
   635                  "operationType": "insert",
   636                  "ns.viewOn": "db.coll"
   637                }
   638              }
   639            ]
   640          },
   641          "saveResultAsEntity": "changeStream0"
   642        },
   643        {
   644          "name": "insertOne",
   645          "object": "collection0",
   646          "arguments": {
   647            "document": {
   648              "_id": 1,
   649              "a": 1
   650            }
   651          }
   652        },
   653        {
   654          "name": "iterateUntilDocumentOrError",
   655          "object": "changeStream0",
   656          "expectResult": {
   657            "operationType": "insert",
   658            "ns": {
   659              "viewOn": "db.coll"
   660            }
   661          }
   662        }
   663      ]
   664    },
   665    {
   666      "description": "Test modified structure in ns document MUST NOT err",
   667      "operations": [
   668        {
   669          "name": "createChangeStream",
   670          "object": "collection0",
   671          "arguments": {
   672            "pipeline": [
   673              {
   674                "$project": {
   675                  "operationType": "insert",
   676                  "ns": {
   677                    "db": "$ns.db",
   678                    "coll": "$ns.coll",
   679                    "viewOn": "db.coll"
   680                  }
   681                }
   682              }
   683            ]
   684          },
   685          "saveResultAsEntity": "changeStream0"
   686        },
   687        {
   688          "name": "insertOne",
   689          "object": "collection0",
   690          "arguments": {
   691            "document": {
   692              "_id": 1,
   693              "a": 1
   694            }
   695          }
   696        },
   697        {
   698          "name": "iterateUntilDocumentOrError",
   699          "object": "changeStream0",
   700          "expectResult": {
   701            "operationType": "insert",
   702            "ns": {
   703              "db": "database0",
   704              "coll": "collection0",
   705              "viewOn": "db.coll"
   706            }
   707          }
   708        }
   709      ]
   710    },
   711    {
   712      "description": "Test server error on projecting out _id",
   713      "runOnRequirements": [
   714        {
   715          "minServerVersion": "4.2"
   716        }
   717      ],
   718      "operations": [
   719        {
   720          "name": "createChangeStream",
   721          "object": "collection0",
   722          "arguments": {
   723            "pipeline": [
   724              {
   725                "$project": {
   726                  "_id": 0
   727                }
   728              }
   729            ]
   730          },
   731          "saveResultAsEntity": "changeStream0"
   732        },
   733        {
   734          "name": "insertOne",
   735          "object": "collection0",
   736          "arguments": {
   737            "document": {
   738              "_id": 1,
   739              "a": 1
   740            }
   741          }
   742        },
   743        {
   744          "name": "iterateUntilDocumentOrError",
   745          "object": "changeStream0",
   746          "expectError": {
   747            "errorCode": 280,
   748            "errorCodeName": "ChangeStreamFatalError",
   749            "errorLabelsContain": [
   750              "NonResumableChangeStreamError"
   751            ]
   752          }
   753        }
   754      ]
   755    },
   756    {
   757      "description": "Test projection in change stream returns expected fields",
   758      "operations": [
   759        {
   760          "name": "createChangeStream",
   761          "object": "collection0",
   762          "arguments": {
   763            "pipeline": [
   764              {
   765                "$project": {
   766                  "optype": "$operationType",
   767                  "ns": 1,
   768                  "newField": "value"
   769                }
   770              }
   771            ]
   772          },
   773          "saveResultAsEntity": "changeStream0"
   774        },
   775        {
   776          "name": "insertOne",
   777          "object": "collection0",
   778          "arguments": {
   779            "document": {
   780              "_id": 1,
   781              "a": 1
   782            }
   783          }
   784        },
   785        {
   786          "name": "iterateUntilDocumentOrError",
   787          "object": "changeStream0",
   788          "expectResult": {
   789            "optype": "insert",
   790            "ns": {
   791              "db": "database0",
   792              "coll": "collection0"
   793            },
   794            "newField": "value"
   795          }
   796        }
   797      ]
   798    },
   799    {
   800      "description": "$changeStream must be the first stage in a change stream pipeline sent to the server",
   801      "runOnRequirements": [
   802        {
   803          "minServerVersion": "3.6.0"
   804        }
   805      ],
   806      "operations": [
   807        {
   808          "name": "createChangeStream",
   809          "object": "collection0",
   810          "arguments": {
   811            "pipeline": []
   812          },
   813          "saveResultAsEntity": "changeStream0"
   814        },
   815        {
   816          "name": "insertOne",
   817          "object": "globalCollection0",
   818          "arguments": {
   819            "document": {
   820              "x": 1
   821            }
   822          }
   823        },
   824        {
   825          "name": "iterateUntilDocumentOrError",
   826          "object": "changeStream0",
   827          "expectResult": {
   828            "_id": {
   829              "$$exists": true
   830            },
   831            "documentKey": {
   832              "$$exists": true
   833            },
   834            "operationType": "insert",
   835            "ns": {
   836              "db": "database0",
   837              "coll": "collection0"
   838            },
   839            "fullDocument": {
   840              "x": 1,
   841              "_id": {
   842                "$$exists": true
   843              }
   844            }
   845          }
   846        }
   847      ],
   848      "expectEvents": [
   849        {
   850          "client": "client0",
   851          "ignoreExtraEvents": true,
   852          "events": [
   853            {
   854              "commandStartedEvent": {
   855                "command": {
   856                  "aggregate": "collection0",
   857                  "cursor": {},
   858                  "pipeline": [
   859                    {
   860                      "$changeStream": {}
   861                    }
   862                  ]
   863                },
   864                "commandName": "aggregate",
   865                "databaseName": "database0"
   866              }
   867            }
   868          ]
   869        }
   870      ]
   871    },
   872    {
   873      "description": "The server returns change stream responses in the specified server response format",
   874      "runOnRequirements": [
   875        {
   876          "minServerVersion": "3.6.0"
   877        }
   878      ],
   879      "operations": [
   880        {
   881          "name": "createChangeStream",
   882          "object": "collection0",
   883          "arguments": {
   884            "pipeline": []
   885          },
   886          "saveResultAsEntity": "changeStream0"
   887        },
   888        {
   889          "name": "insertOne",
   890          "object": "globalCollection0",
   891          "arguments": {
   892            "document": {
   893              "x": 1
   894            }
   895          }
   896        },
   897        {
   898          "name": "iterateUntilDocumentOrError",
   899          "object": "changeStream0",
   900          "expectResult": {
   901            "_id": {
   902              "$$exists": true
   903            },
   904            "documentKey": {
   905              "$$exists": true
   906            },
   907            "operationType": "insert",
   908            "ns": {
   909              "db": "database0",
   910              "coll": "collection0"
   911            },
   912            "fullDocument": {
   913              "x": 1,
   914              "_id": {
   915                "$$exists": true
   916              }
   917            }
   918          }
   919        }
   920      ]
   921    },
   922    {
   923      "description": "Executing a watch helper on a Collection results in notifications for changes to the specified collection",
   924      "runOnRequirements": [
   925        {
   926          "minServerVersion": "3.6.0"
   927        }
   928      ],
   929      "operations": [
   930        {
   931          "name": "createChangeStream",
   932          "object": "collection0",
   933          "arguments": {
   934            "pipeline": []
   935          },
   936          "saveResultAsEntity": "changeStream0"
   937        },
   938        {
   939          "name": "insertOne",
   940          "object": "globalDb0Collection1",
   941          "arguments": {
   942            "document": {
   943              "x": 1
   944            }
   945          }
   946        },
   947        {
   948          "name": "insertOne",
   949          "object": "globalDb1Collection0",
   950          "arguments": {
   951            "document": {
   952              "y": 2
   953            }
   954          }
   955        },
   956        {
   957          "name": "insertOne",
   958          "object": "globalCollection0",
   959          "arguments": {
   960            "document": {
   961              "z": 3
   962            }
   963          }
   964        },
   965        {
   966          "name": "iterateUntilDocumentOrError",
   967          "object": "changeStream0",
   968          "expectResult": {
   969            "operationType": "insert",
   970            "ns": {
   971              "db": "database0",
   972              "coll": "collection0"
   973            },
   974            "fullDocument": {
   975              "z": 3,
   976              "_id": {
   977                "$$exists": true
   978              }
   979            }
   980          }
   981        }
   982      ],
   983      "expectEvents": [
   984        {
   985          "client": "client0",
   986          "ignoreExtraEvents": true,
   987          "events": [
   988            {
   989              "commandStartedEvent": {
   990                "command": {
   991                  "aggregate": "collection0",
   992                  "cursor": {},
   993                  "pipeline": [
   994                    {
   995                      "$changeStream": {}
   996                    }
   997                  ]
   998                },
   999                "commandName": "aggregate",
  1000                "databaseName": "database0"
  1001              }
  1002            }
  1003          ]
  1004        }
  1005      ]
  1006    },
  1007    {
  1008      "description": "Change Stream should allow valid aggregate pipeline stages",
  1009      "runOnRequirements": [
  1010        {
  1011          "minServerVersion": "3.6.0"
  1012        }
  1013      ],
  1014      "operations": [
  1015        {
  1016          "name": "createChangeStream",
  1017          "object": "collection0",
  1018          "arguments": {
  1019            "pipeline": [
  1020              {
  1021                "$match": {
  1022                  "fullDocument.z": 3
  1023                }
  1024              }
  1025            ]
  1026          },
  1027          "saveResultAsEntity": "changeStream0"
  1028        },
  1029        {
  1030          "name": "insertOne",
  1031          "object": "globalCollection0",
  1032          "arguments": {
  1033            "document": {
  1034              "y": 2
  1035            }
  1036          }
  1037        },
  1038        {
  1039          "name": "insertOne",
  1040          "object": "globalCollection0",
  1041          "arguments": {
  1042            "document": {
  1043              "z": 3
  1044            }
  1045          }
  1046        },
  1047        {
  1048          "name": "iterateUntilDocumentOrError",
  1049          "object": "changeStream0",
  1050          "expectResult": {
  1051            "operationType": "insert",
  1052            "ns": {
  1053              "db": "database0",
  1054              "coll": "collection0"
  1055            },
  1056            "fullDocument": {
  1057              "z": 3,
  1058              "_id": {
  1059                "$$exists": true
  1060              }
  1061            }
  1062          }
  1063        }
  1064      ],
  1065      "expectEvents": [
  1066        {
  1067          "client": "client0",
  1068          "ignoreExtraEvents": true,
  1069          "events": [
  1070            {
  1071              "commandStartedEvent": {
  1072                "command": {
  1073                  "aggregate": "collection0",
  1074                  "cursor": {},
  1075                  "pipeline": [
  1076                    {
  1077                      "$changeStream": {}
  1078                    },
  1079                    {
  1080                      "$match": {
  1081                        "fullDocument.z": 3
  1082                      }
  1083                    }
  1084                  ]
  1085                },
  1086                "commandName": "aggregate",
  1087                "databaseName": "database0"
  1088              }
  1089            }
  1090          ]
  1091        }
  1092      ]
  1093    },
  1094    {
  1095      "description": "Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.",
  1096      "runOnRequirements": [
  1097        {
  1098          "minServerVersion": "3.8.0"
  1099        }
  1100      ],
  1101      "operations": [
  1102        {
  1103          "name": "createChangeStream",
  1104          "object": "database0",
  1105          "arguments": {
  1106            "pipeline": []
  1107          },
  1108          "saveResultAsEntity": "changeStream0"
  1109        },
  1110        {
  1111          "name": "insertOne",
  1112          "object": "globalDb0Collection1",
  1113          "arguments": {
  1114            "document": {
  1115              "x": 1
  1116            }
  1117          }
  1118        },
  1119        {
  1120          "name": "insertOne",
  1121          "object": "globalDb1Collection0",
  1122          "arguments": {
  1123            "document": {
  1124              "y": 2
  1125            }
  1126          }
  1127        },
  1128        {
  1129          "name": "insertOne",
  1130          "object": "globalCollection0",
  1131          "arguments": {
  1132            "document": {
  1133              "z": 3
  1134            }
  1135          }
  1136        },
  1137        {
  1138          "name": "iterateUntilDocumentOrError",
  1139          "object": "changeStream0",
  1140          "expectResult": {
  1141            "operationType": "insert",
  1142            "ns": {
  1143              "db": "database0",
  1144              "coll": "collection1"
  1145            },
  1146            "fullDocument": {
  1147              "x": 1,
  1148              "_id": {
  1149                "$$exists": true
  1150              }
  1151            }
  1152          }
  1153        },
  1154        {
  1155          "name": "iterateUntilDocumentOrError",
  1156          "object": "changeStream0",
  1157          "expectResult": {
  1158            "operationType": "insert",
  1159            "ns": {
  1160              "db": "database0",
  1161              "coll": "collection0"
  1162            },
  1163            "fullDocument": {
  1164              "z": 3,
  1165              "_id": {
  1166                "$$exists": true
  1167              }
  1168            }
  1169          }
  1170        }
  1171      ],
  1172      "expectEvents": [
  1173        {
  1174          "client": "client0",
  1175          "ignoreExtraEvents": true,
  1176          "events": [
  1177            {
  1178              "commandStartedEvent": {
  1179                "command": {
  1180                  "aggregate": 1,
  1181                  "cursor": {},
  1182                  "pipeline": [
  1183                    {
  1184                      "$changeStream": {}
  1185                    }
  1186                  ]
  1187                },
  1188                "commandName": "aggregate",
  1189                "databaseName": "database0"
  1190              }
  1191            }
  1192          ]
  1193        }
  1194      ]
  1195    },
  1196    {
  1197      "description": "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.",
  1198      "runOnRequirements": [
  1199        {
  1200          "minServerVersion": "3.8.0"
  1201        }
  1202      ],
  1203      "operations": [
  1204        {
  1205          "name": "createChangeStream",
  1206          "object": "client0",
  1207          "arguments": {
  1208            "pipeline": []
  1209          },
  1210          "saveResultAsEntity": "changeStream0"
  1211        },
  1212        {
  1213          "name": "insertOne",
  1214          "object": "globalDb0Collection1",
  1215          "arguments": {
  1216            "document": {
  1217              "x": 1
  1218            }
  1219          }
  1220        },
  1221        {
  1222          "name": "insertOne",
  1223          "object": "globalDb1Collection0",
  1224          "arguments": {
  1225            "document": {
  1226              "y": 2
  1227            }
  1228          }
  1229        },
  1230        {
  1231          "name": "insertOne",
  1232          "object": "globalCollection0",
  1233          "arguments": {
  1234            "document": {
  1235              "z": 3
  1236            }
  1237          }
  1238        },
  1239        {
  1240          "name": "iterateUntilDocumentOrError",
  1241          "object": "changeStream0",
  1242          "expectResult": {
  1243            "operationType": "insert",
  1244            "ns": {
  1245              "db": "database0",
  1246              "coll": "collection1"
  1247            },
  1248            "fullDocument": {
  1249              "x": 1,
  1250              "_id": {
  1251                "$$exists": true
  1252              }
  1253            }
  1254          }
  1255        },
  1256        {
  1257          "name": "iterateUntilDocumentOrError",
  1258          "object": "changeStream0",
  1259          "expectResult": {
  1260            "operationType": "insert",
  1261            "ns": {
  1262              "db": "database1",
  1263              "coll": "collection0"
  1264            },
  1265            "fullDocument": {
  1266              "y": 2,
  1267              "_id": {
  1268                "$$exists": true
  1269              }
  1270            }
  1271          }
  1272        },
  1273        {
  1274          "name": "iterateUntilDocumentOrError",
  1275          "object": "changeStream0",
  1276          "expectResult": {
  1277            "operationType": "insert",
  1278            "ns": {
  1279              "db": "database0",
  1280              "coll": "collection0"
  1281            },
  1282            "fullDocument": {
  1283              "z": 3,
  1284              "_id": {
  1285                "$$exists": true
  1286              }
  1287            }
  1288          }
  1289        }
  1290      ],
  1291      "expectEvents": [
  1292        {
  1293          "client": "client0",
  1294          "ignoreExtraEvents": true,
  1295          "events": [
  1296            {
  1297              "commandStartedEvent": {
  1298                "command": {
  1299                  "aggregate": 1,
  1300                  "cursor": {},
  1301                  "pipeline": [
  1302                    {
  1303                      "$changeStream": {
  1304                        "allChangesForCluster": true
  1305                      }
  1306                    }
  1307                  ]
  1308                },
  1309                "commandName": "aggregate",
  1310                "databaseName": "admin"
  1311              }
  1312            }
  1313          ]
  1314        }
  1315      ]
  1316    },
  1317    {
  1318      "description": "Test insert, update, replace, and delete event types",
  1319      "runOnRequirements": [
  1320        {
  1321          "minServerVersion": "3.6.0"
  1322        }
  1323      ],
  1324      "operations": [
  1325        {
  1326          "name": "createChangeStream",
  1327          "object": "collection0",
  1328          "arguments": {
  1329            "pipeline": []
  1330          },
  1331          "saveResultAsEntity": "changeStream0"
  1332        },
  1333        {
  1334          "name": "insertOne",
  1335          "object": "globalCollection0",
  1336          "arguments": {
  1337            "document": {
  1338              "x": 1
  1339            }
  1340          }
  1341        },
  1342        {
  1343          "name": "updateOne",
  1344          "object": "globalCollection0",
  1345          "arguments": {
  1346            "filter": {
  1347              "x": 1
  1348            },
  1349            "update": {
  1350              "$set": {
  1351                "x": 2
  1352              }
  1353            }
  1354          }
  1355        },
  1356        {
  1357          "name": "replaceOne",
  1358          "object": "globalCollection0",
  1359          "arguments": {
  1360            "filter": {
  1361              "x": 2
  1362            },
  1363            "replacement": {
  1364              "x": 3
  1365            }
  1366          }
  1367        },
  1368        {
  1369          "name": "deleteOne",
  1370          "object": "globalCollection0",
  1371          "arguments": {
  1372            "filter": {
  1373              "x": 3
  1374            }
  1375          }
  1376        },
  1377        {
  1378          "name": "iterateUntilDocumentOrError",
  1379          "object": "changeStream0",
  1380          "expectResult": {
  1381            "operationType": "insert",
  1382            "ns": {
  1383              "db": "database0",
  1384              "coll": "collection0"
  1385            },
  1386            "fullDocument": {
  1387              "x": 1,
  1388              "_id": {
  1389                "$$exists": true
  1390              }
  1391            }
  1392          }
  1393        },
  1394        {
  1395          "name": "iterateUntilDocumentOrError",
  1396          "object": "changeStream0",
  1397          "expectResult": {
  1398            "operationType": "update",
  1399            "ns": {
  1400              "db": "database0",
  1401              "coll": "collection0"
  1402            },
  1403            "updateDescription": {
  1404              "updatedFields": {
  1405                "x": 2
  1406              },
  1407              "removedFields": [],
  1408              "truncatedArrays": {
  1409                "$$unsetOrMatches": {
  1410                  "$$exists": true
  1411                }
  1412              }
  1413            }
  1414          }
  1415        },
  1416        {
  1417          "name": "iterateUntilDocumentOrError",
  1418          "object": "changeStream0",
  1419          "expectResult": {
  1420            "operationType": "replace",
  1421            "ns": {
  1422              "db": "database0",
  1423              "coll": "collection0"
  1424            },
  1425            "fullDocument": {
  1426              "x": 3,
  1427              "_id": {
  1428                "$$exists": true
  1429              }
  1430            }
  1431          }
  1432        },
  1433        {
  1434          "name": "iterateUntilDocumentOrError",
  1435          "object": "changeStream0",
  1436          "expectResult": {
  1437            "operationType": "delete",
  1438            "ns": {
  1439              "db": "database0",
  1440              "coll": "collection0"
  1441            }
  1442          }
  1443        }
  1444      ],
  1445      "expectEvents": [
  1446        {
  1447          "client": "client0",
  1448          "ignoreExtraEvents": true,
  1449          "events": [
  1450            {
  1451              "commandStartedEvent": {
  1452                "command": {
  1453                  "aggregate": "collection0",
  1454                  "cursor": {},
  1455                  "pipeline": [
  1456                    {
  1457                      "$changeStream": {}
  1458                    }
  1459                  ]
  1460                },
  1461                "commandName": "aggregate",
  1462                "databaseName": "database0"
  1463              }
  1464            }
  1465          ]
  1466        }
  1467      ]
  1468    },
  1469    {
  1470      "description": "Test rename and invalidate event types",
  1471      "runOnRequirements": [
  1472        {
  1473          "minServerVersion": "4.0.1"
  1474        }
  1475      ],
  1476      "operations": [
  1477        {
  1478          "name": "createChangeStream",
  1479          "object": "collection0",
  1480          "arguments": {
  1481            "pipeline": []
  1482          },
  1483          "saveResultAsEntity": "changeStream0"
  1484        },
  1485        {
  1486          "name": "dropCollection",
  1487          "object": "database0",
  1488          "arguments": {
  1489            "collection": "collection1"
  1490          }
  1491        },
  1492        {
  1493          "name": "rename",
  1494          "object": "globalCollection0",
  1495          "arguments": {
  1496            "to": "collection1"
  1497          }
  1498        },
  1499        {
  1500          "name": "iterateUntilDocumentOrError",
  1501          "object": "changeStream0",
  1502          "expectResult": {
  1503            "operationType": "rename",
  1504            "ns": {
  1505              "db": "database0",
  1506              "coll": "collection0"
  1507            },
  1508            "to": {
  1509              "db": "database0",
  1510              "coll": "collection1"
  1511            }
  1512          }
  1513        },
  1514        {
  1515          "name": "iterateUntilDocumentOrError",
  1516          "object": "changeStream0",
  1517          "expectResult": {
  1518            "operationType": "invalidate"
  1519          }
  1520        }
  1521      ],
  1522      "expectEvents": [
  1523        {
  1524          "client": "client0",
  1525          "ignoreExtraEvents": true,
  1526          "events": [
  1527            {
  1528              "commandStartedEvent": {
  1529                "command": {
  1530                  "aggregate": "collection0",
  1531                  "cursor": {},
  1532                  "pipeline": [
  1533                    {
  1534                      "$changeStream": {}
  1535                    }
  1536                  ]
  1537                },
  1538                "commandName": "aggregate",
  1539                "databaseName": "database0"
  1540              }
  1541            }
  1542          ]
  1543        }
  1544      ]
  1545    },
  1546    {
  1547      "description": "Test drop and invalidate event types",
  1548      "runOnRequirements": [
  1549        {
  1550          "minServerVersion": "4.0.1"
  1551        }
  1552      ],
  1553      "operations": [
  1554        {
  1555          "name": "createChangeStream",
  1556          "object": "collection0",
  1557          "arguments": {
  1558            "pipeline": []
  1559          },
  1560          "saveResultAsEntity": "changeStream0"
  1561        },
  1562        {
  1563          "name": "dropCollection",
  1564          "object": "database0",
  1565          "arguments": {
  1566            "collection": "collection0"
  1567          }
  1568        },
  1569        {
  1570          "name": "iterateUntilDocumentOrError",
  1571          "object": "changeStream0",
  1572          "expectResult": {
  1573            "operationType": "drop",
  1574            "ns": {
  1575              "db": "database0",
  1576              "coll": "collection0"
  1577            }
  1578          }
  1579        },
  1580        {
  1581          "name": "iterateUntilDocumentOrError",
  1582          "object": "changeStream0",
  1583          "expectResult": {
  1584            "operationType": "invalidate"
  1585          }
  1586        }
  1587      ],
  1588      "expectEvents": [
  1589        {
  1590          "client": "client0",
  1591          "ignoreExtraEvents": true,
  1592          "events": [
  1593            {
  1594              "commandStartedEvent": {
  1595                "command": {
  1596                  "aggregate": "collection0",
  1597                  "cursor": {},
  1598                  "pipeline": [
  1599                    {
  1600                      "$changeStream": {}
  1601                    }
  1602                  ]
  1603                },
  1604                "commandName": "aggregate",
  1605                "databaseName": "database0"
  1606              }
  1607            }
  1608          ]
  1609        }
  1610      ]
  1611    },
  1612    {
  1613      "description": "Test consecutive resume",
  1614      "runOnRequirements": [
  1615        {
  1616          "minServerVersion": "4.1.7"
  1617        }
  1618      ],
  1619      "operations": [
  1620        {
  1621          "name": "failPoint",
  1622          "object": "testRunner",
  1623          "arguments": {
  1624            "client": "globalClient",
  1625            "failPoint": {
  1626              "configureFailPoint": "failCommand",
  1627              "mode": {
  1628                "times": 2
  1629              },
  1630              "data": {
  1631                "failCommands": [
  1632                  "getMore"
  1633                ],
  1634                "closeConnection": true
  1635              }
  1636            }
  1637          }
  1638        },
  1639        {
  1640          "name": "createChangeStream",
  1641          "object": "collection0",
  1642          "arguments": {
  1643            "pipeline": [],
  1644            "batchSize": 1
  1645          },
  1646          "saveResultAsEntity": "changeStream0"
  1647        },
  1648        {
  1649          "name": "insertOne",
  1650          "object": "globalCollection0",
  1651          "arguments": {
  1652            "document": {
  1653              "x": 1
  1654            }
  1655          }
  1656        },
  1657        {
  1658          "name": "insertOne",
  1659          "object": "globalCollection0",
  1660          "arguments": {
  1661            "document": {
  1662              "x": 2
  1663            }
  1664          }
  1665        },
  1666        {
  1667          "name": "insertOne",
  1668          "object": "globalCollection0",
  1669          "arguments": {
  1670            "document": {
  1671              "x": 3
  1672            }
  1673          }
  1674        },
  1675        {
  1676          "name": "iterateUntilDocumentOrError",
  1677          "object": "changeStream0",
  1678          "expectResult": {
  1679            "operationType": "insert",
  1680            "ns": {
  1681              "db": "database0",
  1682              "coll": "collection0"
  1683            },
  1684            "fullDocument": {
  1685              "x": 1,
  1686              "_id": {
  1687                "$$exists": true
  1688              }
  1689            }
  1690          }
  1691        },
  1692        {
  1693          "name": "iterateUntilDocumentOrError",
  1694          "object": "changeStream0",
  1695          "expectResult": {
  1696            "operationType": "insert",
  1697            "ns": {
  1698              "db": "database0",
  1699              "coll": "collection0"
  1700            },
  1701            "fullDocument": {
  1702              "x": 2,
  1703              "_id": {
  1704                "$$exists": true
  1705              }
  1706            }
  1707          }
  1708        },
  1709        {
  1710          "name": "iterateUntilDocumentOrError",
  1711          "object": "changeStream0",
  1712          "expectResult": {
  1713            "operationType": "insert",
  1714            "ns": {
  1715              "db": "database0",
  1716              "coll": "collection0"
  1717            },
  1718            "fullDocument": {
  1719              "x": 3,
  1720              "_id": {
  1721                "$$exists": true
  1722              }
  1723            }
  1724          }
  1725        }
  1726      ],
  1727      "expectEvents": [
  1728        {
  1729          "client": "client0",
  1730          "ignoreExtraEvents": true,
  1731          "events": [
  1732            {
  1733              "commandStartedEvent": {
  1734                "command": {
  1735                  "aggregate": "collection0",
  1736                  "cursor": {
  1737                    "batchSize": 1
  1738                  },
  1739                  "pipeline": [
  1740                    {
  1741                      "$changeStream": {}
  1742                    }
  1743                  ]
  1744                },
  1745                "commandName": "aggregate",
  1746                "databaseName": "database0"
  1747              }
  1748            }
  1749          ]
  1750        }
  1751      ]
  1752    },
  1753    {
  1754      "description": "Test wallTime field is set in a change event",
  1755      "runOnRequirements": [
  1756        {
  1757          "minServerVersion": "6.0.0"
  1758        }
  1759      ],
  1760      "operations": [
  1761        {
  1762          "name": "createChangeStream",
  1763          "object": "collection0",
  1764          "arguments": {
  1765            "pipeline": []
  1766          },
  1767          "saveResultAsEntity": "changeStream0"
  1768        },
  1769        {
  1770          "name": "insertOne",
  1771          "object": "collection0",
  1772          "arguments": {
  1773            "document": {
  1774              "_id": 1,
  1775              "a": 1
  1776            }
  1777          }
  1778        },
  1779        {
  1780          "name": "iterateUntilDocumentOrError",
  1781          "object": "changeStream0",
  1782          "expectResult": {
  1783            "operationType": "insert",
  1784            "ns": {
  1785              "db": "database0",
  1786              "coll": "collection0"
  1787            },
  1788            "wallTime": {
  1789              "$$exists": true
  1790            }
  1791          }
  1792        }
  1793      ]
  1794    }
  1795  ]
  1796}

View as plain text