...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/aggregate.yml

Documentation: go.mongodb.org/mongo-driver/testdata/crud/unified

     1description: "aggregate"
     2
     3schemaVersion: "1.0"
     4
     5createEntities:
     6  - client:
     7      id: &client0 client0
     8      useMultipleMongoses: true # ensure cursors pin to a single server
     9      observeEvents: [ commandStartedEvent ]
    10  - database:
    11      id: &database0 database0
    12      client: *client0
    13      databaseName: &database0Name aggregate-tests
    14  - collection:
    15      id: &collection0 collection0
    16      database: *database0
    17      collectionName: &collection0Name coll0
    18
    19initialData:
    20  - collectionName: *collection0Name
    21    databaseName: *database0Name
    22    documents:
    23      - { _id: 1, x: 11 }
    24      - { _id: 2, x: 22 }
    25      - { _id: 3, x: 33 }
    26      - { _id: 4, x: 44 }
    27      - { _id: 5, x: 55 }
    28      - { _id: 6, x: 66 }
    29
    30tests:
    31  - description: "aggregate with multiple batches works"
    32    operations:
    33      - name: aggregate
    34        arguments:
    35          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
    36          batchSize: 2
    37        object: *collection0
    38        expectResult:
    39          - { _id: 2, x: 22 }
    40          - { _id: 3, x: 33 }
    41          - { _id: 4, x: 44 }
    42          - { _id: 5, x: 55 }
    43          - { _id: 6, x: 66 }
    44    expectEvents:
    45      - client: *client0
    46        events:
    47          - commandStartedEvent:
    48              command:
    49                aggregate: *collection0Name
    50                pipeline: [ { $match: { _id: { $gt: 1 } }} ]
    51                cursor: { batchSize: 2 }
    52              commandName: aggregate
    53              databaseName: *database0Name
    54          - commandStartedEvent:
    55              command:
    56                getMore: { $$type: [ int, long ] }
    57                collection: *collection0Name
    58                batchSize: 2
    59              commandName: getMore
    60              databaseName: *database0Name
    61          - commandStartedEvent:
    62              command:
    63                getMore: { $$type: [ int, long ] }
    64                collection: *collection0Name
    65                batchSize: 2
    66              commandName: getMore
    67              databaseName: *database0Name
    68
    69  - description: "aggregate with a string comment"
    70    runOnRequirements:
    71      - minServerVersion: "3.6.0"
    72    operations:
    73      - name: aggregate
    74        arguments:
    75          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
    76          comment: "comment"
    77        object: *collection0
    78    expectEvents:
    79      - client: *client0
    80        events:
    81          - commandStartedEvent:
    82              command:
    83                aggregate: *collection0Name
    84                pipeline: [ { $match: { _id: { $gt: 1 } } } ]
    85                comment: "comment"
    86
    87  - description: "aggregate with a document comment"
    88    runOnRequirements:
    89      - minServerVersion: "4.4"
    90    operations:
    91      - name: aggregate
    92        arguments:
    93          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
    94          comment: &comment0 { content: "test" }
    95        object: *collection0
    96    expectEvents:
    97      - client: *client0
    98        events:
    99          - commandStartedEvent:
   100              command:
   101                aggregate: *collection0Name
   102                pipeline: [ { $match: { _id: { $gt: 1 } } } ]
   103                comment: *comment0
   104
   105  - description: "aggregate with a document comment - pre 4.4"
   106    skipReason: "TODO(GODRIVER-2386): aggregate only supports string comments"
   107    runOnRequirements:
   108      - minServerVersion: "3.6.0"
   109        maxServerVersion: "4.2.99"
   110    operations:
   111      - name: aggregate
   112        object: *collection0
   113        arguments:
   114          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   115          comment: *comment0
   116        expectError:
   117          isClientError: false
   118    expectEvents:
   119      - client: *client0
   120        events:
   121          - commandStartedEvent:
   122              command:
   123                aggregate: *collection0Name
   124                pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   125                comment: *comment0
   126              commandName: aggregate
   127              databaseName: *database0Name
   128
   129  - description: "aggregate with comment sets comment on getMore"
   130    runOnRequirements:
   131      - minServerVersion: "4.4.0"
   132        topologies: [ single, replicaset ]
   133       operations:
   134      - name: aggregate
   135        arguments:
   136          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   137          batchSize: 2
   138          comment: *comment0
   139        object: *collection0
   140        expectResult:
   141          - { _id: 2, x: 22 }
   142          - { _id: 3, x: 33 }
   143          - { _id: 4, x: 44 }
   144          - { _id: 5, x: 55 }
   145          - { _id: 6, x: 66 }
   146    expectEvents:
   147      - client: *client0
   148        events:
   149          - commandStartedEvent:
   150              command:
   151                aggregate: *collection0Name
   152                pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   153                cursor: { batchSize: 2 }
   154                comment: *comment0
   155              commandName: aggregate
   156              databaseName: *database0Name
   157          - commandStartedEvent:
   158              command:
   159                getMore: { $$type: [ int, long ] }
   160                collection: *collection0Name
   161                batchSize: 2
   162                comment: *comment0
   163              commandName: getMore
   164              databaseName: *database0Name
   165          - commandStartedEvent:
   166              command:
   167                getMore: { $$type: [ int, long ] }
   168                collection: *collection0Name
   169                batchSize: 2
   170                comment: *comment0
   171              commandName: getMore
   172              databaseName: *database0Name
   173
   174  - description: "aggregate with comment does not set comment on getMore - pre 4.4"
   175    runOnRequirements:
   176      - minServerVersion: "3.6.0"
   177        maxServerVersion: "4.3.99"
   178    operations:
   179      - name: aggregate
   180        arguments:
   181          pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   182          batchSize: 2
   183          comment: "comment"
   184        object: *collection0
   185        expectResult:
   186          - { _id: 2, x: 22 }
   187          - { _id: 3, x: 33 }
   188          - { _id: 4, x: 44 }
   189          - { _id: 5, x: 55 }
   190          - { _id: 6, x: 66 }
   191    expectEvents:
   192      - client: *client0
   193        events:
   194          - commandStartedEvent:
   195              command:
   196                aggregate: *collection0Name
   197                pipeline: [ { $match: { _id: { $gt: 1 } }} ]
   198                cursor: { batchSize: 2 }
   199                comment: "comment"
   200              commandName: aggregate
   201              databaseName: *database0Name
   202          - commandStartedEvent:
   203              command:
   204                getMore: { $$type: [ int, long ] }
   205                collection: *collection0Name
   206                batchSize: 2
   207                comment: { $$exists: false }
   208              commandName: getMore
   209              databaseName: *database0Name
   210          - commandStartedEvent:
   211              command:
   212                getMore: { $$type: [ int, long ] }
   213                collection: *collection0Name
   214                batchSize: 2
   215                comment: { $$exists: false }
   216              commandName: getMore
   217              databaseName: *database0Name

View as plain text