description: "change-streams-clusterTime"
schemaVersion: "1.4"
createEntities:
  - client:
      id: &client0 client0
      useMultipleMongoses: false
  - database:
      id: &database0 database0
      client: *client0
      databaseName: *database0
  - collection:
      id: &collection0 collection0
      database: *database0
      collectionName: *collection0

runOnRequirements:
  - minServerVersion: "4.0.0"
    # TODO(DRIVERS-2323): Run all possible tests against sharded clusters once we know the
    # cause of unexpected command monitoring events.
    topologies: [ replicaset ]
    serverless: forbid

initialData:
  - collectionName: *collection0
    databaseName: *database0
    documents: []

tests:
  - description: "clusterTime is present"
    operations:
      - name: createChangeStream
        object: *collection0
        arguments: { pipeline: [] }
        saveResultAsEntity: &changeStream0 changeStream0
      - name: insertOne
        object: *collection0
        arguments:
          document: { _id: 1 }
      - name: iterateUntilDocumentOrError
        object: *changeStream0
        expectResult:
          ns: { db: *database0, coll: *collection0 }
          clusterTime: { $$exists: true }
