...

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

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

     1{
     2  "description": "change-streams-pre_and_post_images",
     3  "schemaVersion": "1.4",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "6.0.0",
     7      "topologies": [
     8        "replicaset",
     9        "sharded-replicaset",
    10        "load-balanced"
    11      ],
    12      "serverless": "forbid"
    13    }
    14  ],
    15  "createEntities": [
    16    {
    17      "client": {
    18        "id": "client0",
    19        "observeEvents": [
    20          "commandStartedEvent"
    21        ],
    22        "ignoreCommandMonitoringEvents": [
    23          "collMod",
    24          "insert",
    25          "update",
    26          "getMore",
    27          "killCursors"
    28        ]
    29      }
    30    },
    31    {
    32      "database": {
    33        "id": "database0",
    34        "client": "client0",
    35        "databaseName": "change-stream-tests"
    36      }
    37    },
    38    {
    39      "collection": {
    40        "id": "collection0",
    41        "database": "database0",
    42        "collectionName": "test"
    43      }
    44    }
    45  ],
    46  "initialData": [
    47    {
    48      "collectionName": "test",
    49      "databaseName": "change-stream-tests",
    50      "documents": [
    51        {
    52          "_id": 1
    53        }
    54      ]
    55    }
    56  ],
    57  "tests": [
    58    {
    59      "description": "fullDocument:whenAvailable with changeStreamPreAndPostImages enabled",
    60      "operations": [
    61        {
    62          "name": "runCommand",
    63          "object": "database0",
    64          "arguments": {
    65            "commandName": "collMod",
    66            "command": {
    67              "collMod": "test",
    68              "changeStreamPreAndPostImages": {
    69                "enabled": true
    70              }
    71            }
    72          }
    73        },
    74        {
    75          "name": "createChangeStream",
    76          "object": "collection0",
    77          "arguments": {
    78            "pipeline": [],
    79            "fullDocument": "whenAvailable"
    80          },
    81          "saveResultAsEntity": "changeStream0"
    82        },
    83        {
    84          "name": "updateOne",
    85          "object": "collection0",
    86          "arguments": {
    87            "filter": {
    88              "_id": 1
    89            },
    90            "update": {
    91              "$set": {
    92                "x": 1
    93              }
    94            }
    95          }
    96        },
    97        {
    98          "name": "iterateUntilDocumentOrError",
    99          "object": "changeStream0",
   100          "expectResult": {
   101            "operationType": "update",
   102            "ns": {
   103              "db": "change-stream-tests",
   104              "coll": "test"
   105            },
   106            "updateDescription": {
   107              "$$type": "object"
   108            },
   109            "fullDocument": {
   110              "_id": 1,
   111              "x": 1
   112            }
   113          }
   114        }
   115      ],
   116      "expectEvents": [
   117        {
   118          "client": "client0",
   119          "events": [
   120            {
   121              "commandStartedEvent": {
   122                "command": {
   123                  "aggregate": "test",
   124                  "pipeline": [
   125                    {
   126                      "$changeStream": {
   127                        "fullDocument": "whenAvailable"
   128                      }
   129                    }
   130                  ]
   131                }
   132              }
   133            }
   134          ]
   135        }
   136      ]
   137    },
   138    {
   139      "description": "fullDocument:whenAvailable with changeStreamPreAndPostImages disabled",
   140      "operations": [
   141        {
   142          "name": "runCommand",
   143          "object": "database0",
   144          "arguments": {
   145            "commandName": "collMod",
   146            "command": {
   147              "collMod": "test",
   148              "changeStreamPreAndPostImages": {
   149                "enabled": false
   150              }
   151            }
   152          }
   153        },
   154        {
   155          "name": "createChangeStream",
   156          "object": "collection0",
   157          "arguments": {
   158            "pipeline": [],
   159            "fullDocument": "whenAvailable"
   160          },
   161          "saveResultAsEntity": "changeStream0"
   162        },
   163        {
   164          "name": "updateOne",
   165          "object": "collection0",
   166          "arguments": {
   167            "filter": {
   168              "_id": 1
   169            },
   170            "update": {
   171              "$set": {
   172                "x": 1
   173              }
   174            }
   175          }
   176        },
   177        {
   178          "name": "iterateUntilDocumentOrError",
   179          "object": "changeStream0",
   180          "expectResult": {
   181            "operationType": "update",
   182            "ns": {
   183              "db": "change-stream-tests",
   184              "coll": "test"
   185            },
   186            "updateDescription": {
   187              "$$type": "object"
   188            },
   189            "fullDocument": null
   190          }
   191        }
   192      ],
   193      "expectEvents": [
   194        {
   195          "client": "client0",
   196          "events": [
   197            {
   198              "commandStartedEvent": {
   199                "command": {
   200                  "aggregate": "test",
   201                  "pipeline": [
   202                    {
   203                      "$changeStream": {
   204                        "fullDocument": "whenAvailable"
   205                      }
   206                    }
   207                  ]
   208                }
   209              }
   210            }
   211          ]
   212        }
   213      ]
   214    },
   215    {
   216      "description": "fullDocument:required with changeStreamPreAndPostImages enabled",
   217      "operations": [
   218        {
   219          "name": "runCommand",
   220          "object": "database0",
   221          "arguments": {
   222            "commandName": "collMod",
   223            "command": {
   224              "collMod": "test",
   225              "changeStreamPreAndPostImages": {
   226                "enabled": true
   227              }
   228            }
   229          }
   230        },
   231        {
   232          "name": "createChangeStream",
   233          "object": "collection0",
   234          "arguments": {
   235            "pipeline": [],
   236            "fullDocument": "required"
   237          },
   238          "saveResultAsEntity": "changeStream0"
   239        },
   240        {
   241          "name": "updateOne",
   242          "object": "collection0",
   243          "arguments": {
   244            "filter": {
   245              "_id": 1
   246            },
   247            "update": {
   248              "$set": {
   249                "x": 1
   250              }
   251            }
   252          }
   253        },
   254        {
   255          "name": "iterateUntilDocumentOrError",
   256          "object": "changeStream0",
   257          "expectResult": {
   258            "operationType": "update",
   259            "ns": {
   260              "db": "change-stream-tests",
   261              "coll": "test"
   262            },
   263            "updateDescription": {
   264              "$$type": "object"
   265            },
   266            "fullDocument": {
   267              "_id": 1,
   268              "x": 1
   269            }
   270          }
   271        }
   272      ],
   273      "expectEvents": [
   274        {
   275          "client": "client0",
   276          "events": [
   277            {
   278              "commandStartedEvent": {
   279                "command": {
   280                  "aggregate": "test",
   281                  "pipeline": [
   282                    {
   283                      "$changeStream": {
   284                        "fullDocument": "required"
   285                      }
   286                    }
   287                  ]
   288                }
   289              }
   290            }
   291          ]
   292        }
   293      ]
   294    },
   295    {
   296      "description": "fullDocument:required with changeStreamPreAndPostImages disabled",
   297      "operations": [
   298        {
   299          "name": "runCommand",
   300          "object": "database0",
   301          "arguments": {
   302            "commandName": "collMod",
   303            "command": {
   304              "collMod": "test",
   305              "changeStreamPreAndPostImages": {
   306                "enabled": false
   307              }
   308            }
   309          }
   310        },
   311        {
   312          "name": "createChangeStream",
   313          "object": "collection0",
   314          "arguments": {
   315            "pipeline": [],
   316            "fullDocument": "required"
   317          },
   318          "saveResultAsEntity": "changeStream0"
   319        },
   320        {
   321          "name": "updateOne",
   322          "object": "collection0",
   323          "arguments": {
   324            "filter": {
   325              "_id": 1
   326            },
   327            "update": {
   328              "$set": {
   329                "x": 1
   330              }
   331            }
   332          }
   333        },
   334        {
   335          "name": "iterateUntilDocumentOrError",
   336          "object": "changeStream0",
   337          "expectError": {
   338            "isClientError": false
   339          }
   340        }
   341      ],
   342      "expectEvents": [
   343        {
   344          "client": "client0",
   345          "events": [
   346            {
   347              "commandStartedEvent": {
   348                "command": {
   349                  "aggregate": "test",
   350                  "pipeline": [
   351                    {
   352                      "$changeStream": {
   353                        "fullDocument": "required"
   354                      }
   355                    }
   356                  ]
   357                }
   358              }
   359            }
   360          ]
   361        }
   362      ]
   363    },
   364    {
   365      "description": "fullDocumentBeforeChange:whenAvailable with changeStreamPreAndPostImages enabled",
   366      "operations": [
   367        {
   368          "name": "runCommand",
   369          "object": "database0",
   370          "arguments": {
   371            "commandName": "collMod",
   372            "command": {
   373              "collMod": "test",
   374              "changeStreamPreAndPostImages": {
   375                "enabled": true
   376              }
   377            }
   378          }
   379        },
   380        {
   381          "name": "createChangeStream",
   382          "object": "collection0",
   383          "arguments": {
   384            "pipeline": [],
   385            "fullDocumentBeforeChange": "whenAvailable"
   386          },
   387          "saveResultAsEntity": "changeStream0"
   388        },
   389        {
   390          "name": "updateOne",
   391          "object": "collection0",
   392          "arguments": {
   393            "filter": {
   394              "_id": 1
   395            },
   396            "update": {
   397              "$set": {
   398                "x": 1
   399              }
   400            }
   401          }
   402        },
   403        {
   404          "name": "iterateUntilDocumentOrError",
   405          "object": "changeStream0",
   406          "expectResult": {
   407            "operationType": "update",
   408            "ns": {
   409              "db": "change-stream-tests",
   410              "coll": "test"
   411            },
   412            "updateDescription": {
   413              "$$type": "object"
   414            },
   415            "fullDocumentBeforeChange": {
   416              "_id": 1
   417            }
   418          }
   419        }
   420      ],
   421      "expectEvents": [
   422        {
   423          "client": "client0",
   424          "events": [
   425            {
   426              "commandStartedEvent": {
   427                "command": {
   428                  "aggregate": "test",
   429                  "pipeline": [
   430                    {
   431                      "$changeStream": {
   432                        "fullDocumentBeforeChange": "whenAvailable"
   433                      }
   434                    }
   435                  ]
   436                }
   437              }
   438            }
   439          ]
   440        }
   441      ]
   442    },
   443    {
   444      "description": "fullDocumentBeforeChange:whenAvailable with changeStreamPreAndPostImages disabled",
   445      "operations": [
   446        {
   447          "name": "runCommand",
   448          "object": "database0",
   449          "arguments": {
   450            "commandName": "collMod",
   451            "command": {
   452              "collMod": "test",
   453              "changeStreamPreAndPostImages": {
   454                "enabled": false
   455              }
   456            }
   457          }
   458        },
   459        {
   460          "name": "createChangeStream",
   461          "object": "collection0",
   462          "arguments": {
   463            "pipeline": [],
   464            "fullDocumentBeforeChange": "whenAvailable"
   465          },
   466          "saveResultAsEntity": "changeStream0"
   467        },
   468        {
   469          "name": "updateOne",
   470          "object": "collection0",
   471          "arguments": {
   472            "filter": {
   473              "_id": 1
   474            },
   475            "update": {
   476              "$set": {
   477                "x": 1
   478              }
   479            }
   480          }
   481        },
   482        {
   483          "name": "iterateUntilDocumentOrError",
   484          "object": "changeStream0",
   485          "expectResult": {
   486            "operationType": "update",
   487            "ns": {
   488              "db": "change-stream-tests",
   489              "coll": "test"
   490            },
   491            "updateDescription": {
   492              "$$type": "object"
   493            },
   494            "fullDocumentBeforeChange": null
   495          }
   496        }
   497      ],
   498      "expectEvents": [
   499        {
   500          "client": "client0",
   501          "events": [
   502            {
   503              "commandStartedEvent": {
   504                "command": {
   505                  "aggregate": "test",
   506                  "pipeline": [
   507                    {
   508                      "$changeStream": {
   509                        "fullDocumentBeforeChange": "whenAvailable"
   510                      }
   511                    }
   512                  ]
   513                }
   514              }
   515            }
   516          ]
   517        }
   518      ]
   519    },
   520    {
   521      "description": "fullDocumentBeforeChange:required with changeStreamPreAndPostImages enabled",
   522      "operations": [
   523        {
   524          "name": "runCommand",
   525          "object": "database0",
   526          "arguments": {
   527            "commandName": "collMod",
   528            "command": {
   529              "collMod": "test",
   530              "changeStreamPreAndPostImages": {
   531                "enabled": true
   532              }
   533            }
   534          }
   535        },
   536        {
   537          "name": "createChangeStream",
   538          "object": "collection0",
   539          "arguments": {
   540            "pipeline": [],
   541            "fullDocumentBeforeChange": "required"
   542          },
   543          "saveResultAsEntity": "changeStream0"
   544        },
   545        {
   546          "name": "updateOne",
   547          "object": "collection0",
   548          "arguments": {
   549            "filter": {
   550              "_id": 1
   551            },
   552            "update": {
   553              "$set": {
   554                "x": 1
   555              }
   556            }
   557          }
   558        },
   559        {
   560          "name": "iterateUntilDocumentOrError",
   561          "object": "changeStream0",
   562          "expectResult": {
   563            "operationType": "update",
   564            "ns": {
   565              "db": "change-stream-tests",
   566              "coll": "test"
   567            },
   568            "updateDescription": {
   569              "$$type": "object"
   570            },
   571            "fullDocumentBeforeChange": {
   572              "_id": 1
   573            }
   574          }
   575        }
   576      ],
   577      "expectEvents": [
   578        {
   579          "client": "client0",
   580          "events": [
   581            {
   582              "commandStartedEvent": {
   583                "command": {
   584                  "aggregate": "test",
   585                  "pipeline": [
   586                    {
   587                      "$changeStream": {
   588                        "fullDocumentBeforeChange": "required"
   589                      }
   590                    }
   591                  ]
   592                }
   593              }
   594            }
   595          ]
   596        }
   597      ]
   598    },
   599    {
   600      "description": "fullDocumentBeforeChange:required with changeStreamPreAndPostImages disabled",
   601      "operations": [
   602        {
   603          "name": "runCommand",
   604          "object": "database0",
   605          "arguments": {
   606            "commandName": "collMod",
   607            "command": {
   608              "collMod": "test",
   609              "changeStreamPreAndPostImages": {
   610                "enabled": false
   611              }
   612            }
   613          }
   614        },
   615        {
   616          "name": "createChangeStream",
   617          "object": "collection0",
   618          "arguments": {
   619            "pipeline": [],
   620            "fullDocumentBeforeChange": "required"
   621          },
   622          "saveResultAsEntity": "changeStream0"
   623        },
   624        {
   625          "name": "updateOne",
   626          "object": "collection0",
   627          "arguments": {
   628            "filter": {
   629              "_id": 1
   630            },
   631            "update": {
   632              "$set": {
   633                "x": 1
   634              }
   635            }
   636          }
   637        },
   638        {
   639          "name": "iterateUntilDocumentOrError",
   640          "object": "changeStream0",
   641          "expectError": {
   642            "isClientError": false
   643          }
   644        }
   645      ],
   646      "expectEvents": [
   647        {
   648          "client": "client0",
   649          "events": [
   650            {
   651              "commandStartedEvent": {
   652                "command": {
   653                  "aggregate": "test",
   654                  "pipeline": [
   655                    {
   656                      "$changeStream": {
   657                        "fullDocumentBeforeChange": "required"
   658                      }
   659                    }
   660                  ]
   661                }
   662              }
   663            }
   664          ]
   665        }
   666      ]
   667    },
   668    {
   669      "description": "fullDocumentBeforeChange:off with changeStreamPreAndPostImages enabled",
   670      "operations": [
   671        {
   672          "name": "runCommand",
   673          "object": "database0",
   674          "arguments": {
   675            "commandName": "collMod",
   676            "command": {
   677              "collMod": "test",
   678              "changeStreamPreAndPostImages": {
   679                "enabled": true
   680              }
   681            }
   682          }
   683        },
   684        {
   685          "name": "createChangeStream",
   686          "object": "collection0",
   687          "arguments": {
   688            "pipeline": [],
   689            "fullDocumentBeforeChange": "off"
   690          },
   691          "saveResultAsEntity": "changeStream0"
   692        },
   693        {
   694          "name": "updateOne",
   695          "object": "collection0",
   696          "arguments": {
   697            "filter": {
   698              "_id": 1
   699            },
   700            "update": {
   701              "$set": {
   702                "x": 1
   703              }
   704            }
   705          }
   706        },
   707        {
   708          "name": "iterateUntilDocumentOrError",
   709          "object": "changeStream0",
   710          "expectResult": {
   711            "operationType": "update",
   712            "ns": {
   713              "db": "change-stream-tests",
   714              "coll": "test"
   715            },
   716            "updateDescription": {
   717              "$$type": "object"
   718            },
   719            "fullDocumentBeforeChange": {
   720              "$$exists": false
   721            }
   722          }
   723        }
   724      ],
   725      "expectEvents": [
   726        {
   727          "client": "client0",
   728          "events": [
   729            {
   730              "commandStartedEvent": {
   731                "command": {
   732                  "aggregate": "test",
   733                  "pipeline": [
   734                    {
   735                      "$changeStream": {
   736                        "fullDocumentBeforeChange": "off"
   737                      }
   738                    }
   739                  ]
   740                }
   741              }
   742            }
   743          ]
   744        }
   745      ]
   746    },
   747    {
   748      "description": "fullDocumentBeforeChange:off with changeStreamPreAndPostImages disabled",
   749      "operations": [
   750        {
   751          "name": "runCommand",
   752          "object": "database0",
   753          "arguments": {
   754            "commandName": "collMod",
   755            "command": {
   756              "collMod": "test",
   757              "changeStreamPreAndPostImages": {
   758                "enabled": false
   759              }
   760            }
   761          }
   762        },
   763        {
   764          "name": "createChangeStream",
   765          "object": "collection0",
   766          "arguments": {
   767            "pipeline": [],
   768            "fullDocumentBeforeChange": "off"
   769          },
   770          "saveResultAsEntity": "changeStream0"
   771        },
   772        {
   773          "name": "updateOne",
   774          "object": "collection0",
   775          "arguments": {
   776            "filter": {
   777              "_id": 1
   778            },
   779            "update": {
   780              "$set": {
   781                "x": 1
   782              }
   783            }
   784          }
   785        },
   786        {
   787          "name": "iterateUntilDocumentOrError",
   788          "object": "changeStream0",
   789          "expectResult": {
   790            "operationType": "update",
   791            "ns": {
   792              "db": "change-stream-tests",
   793              "coll": "test"
   794            },
   795            "updateDescription": {
   796              "$$type": "object"
   797            },
   798            "fullDocumentBeforeChange": {
   799              "$$exists": false
   800            }
   801          }
   802        }
   803      ],
   804      "expectEvents": [
   805        {
   806          "client": "client0",
   807          "events": [
   808            {
   809              "commandStartedEvent": {
   810                "command": {
   811                  "aggregate": "test",
   812                  "pipeline": [
   813                    {
   814                      "$changeStream": {
   815                        "fullDocumentBeforeChange": "off"
   816                      }
   817                    }
   818                  ]
   819                }
   820              }
   821            }
   822          ]
   823        }
   824      ]
   825    }
   826  ]
   827}

View as plain text