| {
  "collection_name": "test",
  "database_name": "change-stream-tests",
  "collection2_name": "test2",
  "database2_name": "change-stream-tests-2",
  "tests": [
    {
      "description": "$changeStream must be the first stage in a change stream pipeline sent to the server",
      "minServerVersion": "3.6.0",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "_id": "42",
            "documentKey": "42",
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          }
        ]
      }
    },
    {
      "description": "The server returns change stream responses in the specified server response format",
      "minServerVersion": "3.6.0",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        }
      ],
      "expectations": [],
      "result": {
        "success": [
          {
            "_id": "42",
            "documentKey": "42",
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          }
        ]
      }
    },
    {
      "description": "Executing a watch helper on a Collection results in notifications for changes to the specified collection",
      "minServerVersion": "3.6.0",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test2",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        },
        {
          "database": "change-stream-tests-2",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "y": 2
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "z": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "z": {
                "$numberInt": "3"
              }
            }
          }
        ]
      }
    },
    {
      "description": "Change Stream should allow valid aggregate pipeline stages",
      "minServerVersion": "3.6.0",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [
        {
          "$match": {
            "fullDocument.z": 3
          }
        }
      ],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "y": 2
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "z": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                },
                {
                  "$match": {
                    "fullDocument.z": {
                      "$numberInt": "3"
                    }
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "z": {
                "$numberInt": "3"
              }
            }
          }
        ]
      }
    },
    {
      "description": "Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.",
      "minServerVersion": "3.8.0",
      "target": "database",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test2",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        },
        {
          "database": "change-stream-tests-2",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "y": 2
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "z": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": {
                "$numberInt": "1"
              },
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test2"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          },
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "z": {
                "$numberInt": "3"
              }
            }
          }
        ]
      }
    },
    {
      "description": "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.",
      "minServerVersion": "3.8.0",
      "target": "client",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test2",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        },
        {
          "database": "change-stream-tests-2",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "y": 2
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "z": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": {
                "$numberInt": "1"
              },
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default",
                    "allChangesForCluster": true
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "admin"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test2"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          },
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests-2",
              "coll": "test"
            },
            "fullDocument": {
              "y": {
                "$numberInt": "2"
              }
            }
          },
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "z": {
                "$numberInt": "3"
              }
            }
          }
        ]
      }
    },
    {
      "description": "Test insert, update, replace, and delete event types",
      "minServerVersion": "3.6.0",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "updateOne",
          "arguments": {
            "filter": {
              "x": 1
            },
            "update": {
              "$set": {
                "x": 2
              }
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "replaceOne",
          "arguments": {
            "filter": {
              "x": 2
            },
            "replacement": {
              "x": 3
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "deleteOne",
          "arguments": {
            "filter": {
              "x": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          },
          {
            "operationType": "update",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "updateDescription": {
              "updatedFields": {
                "x": {
                  "$numberInt": "2"
                }
              }
            }
          },
          {
            "operationType": "replace",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "3"
              }
            }
          },
          {
            "operationType": "delete",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            }
          }
        ]
      }
    },
    {
      "description": "Test rename and invalidate event types",
      "minServerVersion": "4.0.1",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "rename",
          "arguments": {
            "to": "test2"
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "rename",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "to": {
              "db": "change-stream-tests",
              "coll": "test2"
            }
          },
          {
            "operationType": "invalidate"
          }
        ]
      }
    },
    {
      "description": "Test drop and invalidate event types",
      "minServerVersion": "4.0.1",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {},
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "drop"
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {},
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "drop",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            }
          },
          {
            "operationType": "invalidate"
          }
        ]
      }
    },
    {
      "description": "Test consecutive resume",
      "minServerVersion": "4.1.7",
      "target": "collection",
      "topology": [
        "replicaset"
      ],
      "changeStreamPipeline": [],
      "changeStreamOptions": {
        "batchSize": 1
      },
      "failPoint": {
        "configureFailPoint": "failCommand",
        "mode": {
          "times": 2
        },
        "data": {
          "failCommands": [
            "getMore"
          ],
          "closeConnection": true
        }
      },
      "operations": [
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 2
            }
          }
        },
        {
          "database": "change-stream-tests",
          "collection": "test",
          "name": "insertOne",
          "arguments": {
            "document": {
              "x": 3
            }
          }
        }
      ],
      "expectations": [
        {
          "command_started_event": {
            "command": {
              "aggregate": "test",
              "cursor": {
                "batchSize": 1
              },
              "pipeline": [
                {
                  "$changeStream": {
                    "fullDocument": "default"
                  }
                }
              ]
            },
            "command_name": "aggregate",
            "database_name": "change-stream-tests"
          }
        }
      ],
      "result": {
        "success": [
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "1"
              }
            }
          },
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "2"
              }
            }
          },
          {
            "operationType": "insert",
            "ns": {
              "db": "change-stream-tests",
              "coll": "test"
            },
            "fullDocument": {
              "x": {
                "$numberInt": "3"
              }
            }
          }
        ]
      }
    }
  ]
}
 |