...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/estimatedDocumentCount.json

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

     1{
     2  "description": "estimatedDocumentCount",
     3  "schemaVersion": "1.0",
     4  "createEntities": [
     5    {
     6      "client": {
     7        "id": "client0",
     8        "useMultipleMongoses": false,
     9        "uriOptions": {
    10          "retryReads": false
    11        },
    12        "observeEvents": [
    13          "commandStartedEvent"
    14        ]
    15      }
    16    },
    17    {
    18      "database": {
    19        "id": "database0",
    20        "client": "client0",
    21        "databaseName": "edc-tests"
    22      }
    23    },
    24    {
    25      "collection": {
    26        "id": "collection0",
    27        "database": "database0",
    28        "collectionName": "coll0"
    29      }
    30    },
    31    {
    32      "collection": {
    33        "id": "collection1",
    34        "database": "database0",
    35        "collectionName": "coll1"
    36      }
    37    },
    38    {
    39      "collection": {
    40        "id": "collection0View",
    41        "database": "database0",
    42        "collectionName": "coll0view"
    43      }
    44    }
    45  ],
    46  "initialData": [
    47    {
    48      "collectionName": "coll0",
    49      "databaseName": "edc-tests",
    50      "documents": [
    51        {
    52          "_id": 1,
    53          "x": 11
    54        },
    55        {
    56          "_id": 2,
    57          "x": 22
    58        },
    59        {
    60          "_id": 3,
    61          "x": 33
    62        }
    63      ]
    64    }
    65  ],
    66  "tests": [
    67    {
    68      "description": "estimatedDocumentCount always uses count",
    69      "operations": [
    70        {
    71          "name": "estimatedDocumentCount",
    72          "object": "collection0",
    73          "expectResult": 3
    74        }
    75      ],
    76      "expectEvents": [
    77        {
    78          "client": "client0",
    79          "events": [
    80            {
    81              "commandStartedEvent": {
    82                "command": {
    83                  "count": "coll0"
    84                },
    85                "commandName": "count",
    86                "databaseName": "edc-tests"
    87              }
    88            }
    89          ]
    90        }
    91      ]
    92    },
    93    {
    94      "description": "estimatedDocumentCount with maxTimeMS",
    95      "operations": [
    96        {
    97          "name": "estimatedDocumentCount",
    98          "object": "collection0",
    99          "arguments": {
   100            "maxTimeMS": 6000
   101          },
   102          "expectResult": 3
   103        }
   104      ],
   105      "expectEvents": [
   106        {
   107          "client": "client0",
   108          "events": [
   109            {
   110              "commandStartedEvent": {
   111                "command": {
   112                  "count": "coll0",
   113                  "maxTimeMS": 6000
   114                },
   115                "commandName": "count",
   116                "databaseName": "edc-tests"
   117              }
   118            }
   119          ]
   120        }
   121      ]
   122    },
   123    {
   124      "description": "estimatedDocumentCount on non-existent collection",
   125      "operations": [
   126        {
   127          "name": "estimatedDocumentCount",
   128          "object": "collection1",
   129          "expectResult": 0
   130        }
   131      ],
   132      "expectEvents": [
   133        {
   134          "client": "client0",
   135          "events": [
   136            {
   137              "commandStartedEvent": {
   138                "command": {
   139                  "count": "coll1"
   140                },
   141                "commandName": "count",
   142                "databaseName": "edc-tests"
   143              }
   144            }
   145          ]
   146        }
   147      ]
   148    },
   149    {
   150      "description": "estimatedDocumentCount errors correctly--command error",
   151      "runOnRequirements": [
   152        {
   153          "minServerVersion": "4.0.0",
   154          "topologies": [
   155            "single",
   156            "replicaset"
   157          ]
   158        },
   159        {
   160          "minServerVersion": "4.2.0",
   161          "topologies": [
   162            "sharded"
   163          ]
   164        }
   165      ],
   166      "operations": [
   167        {
   168          "name": "failPoint",
   169          "object": "testRunner",
   170          "arguments": {
   171            "client": "client0",
   172            "failPoint": {
   173              "configureFailPoint": "failCommand",
   174              "mode": {
   175                "times": 1
   176              },
   177              "data": {
   178                "failCommands": [
   179                  "count"
   180                ],
   181                "errorCode": 8
   182              }
   183            }
   184          }
   185        },
   186        {
   187          "name": "estimatedDocumentCount",
   188          "object": "collection0",
   189          "expectError": {
   190            "errorCode": 8
   191          }
   192        }
   193      ],
   194      "expectEvents": [
   195        {
   196          "client": "client0",
   197          "events": [
   198            {
   199              "commandStartedEvent": {
   200                "command": {
   201                  "count": "coll0"
   202                },
   203                "commandName": "count",
   204                "databaseName": "edc-tests"
   205              }
   206            }
   207          ]
   208        }
   209      ]
   210    },
   211    {
   212      "description": "estimatedDocumentCount errors correctly--socket error",
   213      "runOnRequirements": [
   214        {
   215          "minServerVersion": "4.0.0",
   216          "topologies": [
   217            "single",
   218            "replicaset"
   219          ]
   220        },
   221        {
   222          "minServerVersion": "4.2.0",
   223          "topologies": [
   224            "sharded"
   225          ]
   226        }
   227      ],
   228      "operations": [
   229        {
   230          "name": "failPoint",
   231          "object": "testRunner",
   232          "arguments": {
   233            "client": "client0",
   234            "failPoint": {
   235              "configureFailPoint": "failCommand",
   236              "mode": {
   237                "times": 1
   238              },
   239              "data": {
   240                "failCommands": [
   241                  "count"
   242                ],
   243                "closeConnection": true
   244              }
   245            }
   246          }
   247        },
   248        {
   249          "name": "estimatedDocumentCount",
   250          "object": "collection0",
   251          "expectError": {
   252            "isError": true
   253          }
   254        }
   255      ],
   256      "expectEvents": [
   257        {
   258          "client": "client0",
   259          "events": [
   260            {
   261              "commandStartedEvent": {
   262                "command": {
   263                  "count": "coll0"
   264                },
   265                "commandName": "count",
   266                "databaseName": "edc-tests"
   267              }
   268            }
   269          ]
   270        }
   271      ]
   272    },
   273    {
   274      "description": "estimatedDocumentCount works correctly on views",
   275      "runOnRequirements": [
   276        {
   277          "minServerVersion": "3.4.0"
   278        }
   279      ],
   280      "operations": [
   281        {
   282          "name": "dropCollection",
   283          "object": "database0",
   284          "arguments": {
   285            "collection": "coll0view"
   286          }
   287        },
   288        {
   289          "name": "createCollection",
   290          "object": "database0",
   291          "arguments": {
   292            "collection": "coll0view",
   293            "viewOn": "coll0",
   294            "pipeline": [
   295              {
   296                "$match": {
   297                  "_id": {
   298                    "$gt": 1
   299                  }
   300                }
   301              }
   302            ]
   303          }
   304        },
   305        {
   306          "name": "estimatedDocumentCount",
   307          "object": "collection0View",
   308          "expectResult": 2
   309        }
   310      ],
   311      "expectEvents": [
   312        {
   313          "client": "client0",
   314          "events": [
   315            {
   316              "commandStartedEvent": {
   317                "command": {
   318                  "drop": "coll0view"
   319                },
   320                "commandName": "drop",
   321                "databaseName": "edc-tests"
   322              }
   323            },
   324            {
   325              "commandStartedEvent": {
   326                "command": {
   327                  "create": "coll0view",
   328                  "viewOn": "coll0",
   329                  "pipeline": [
   330                    {
   331                      "$match": {
   332                        "_id": {
   333                          "$gt": 1
   334                        }
   335                      }
   336                    }
   337                  ]
   338                },
   339                "commandName": "create",
   340                "databaseName": "edc-tests"
   341              }
   342            },
   343            {
   344              "commandStartedEvent": {
   345                "command": {
   346                  "count": "coll0view"
   347                },
   348                "commandName": "count",
   349                "databaseName": "edc-tests"
   350              }
   351            }
   352          ]
   353        }
   354      ]
   355    }
   356  ]
   357}

View as plain text