...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/db-aggregate-write-readPreference.json

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

     1{
     2  "description": "db-aggregate-write-readPreference",
     3  "schemaVersion": "1.4",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "3.6",
     7      "topologies": [
     8        "replicaset"
     9      ],
    10      "serverless": "forbid"
    11    }
    12  ],
    13  "_yamlAnchors": {
    14    "readConcern": {
    15      "level": "local"
    16    },
    17    "writeConcern": {
    18      "w": 1
    19    }
    20  },
    21  "createEntities": [
    22    {
    23      "client": {
    24        "id": "client0",
    25        "observeEvents": [
    26          "commandStartedEvent"
    27        ],
    28        "uriOptions": {
    29          "readConcernLevel": "local",
    30          "w": 1
    31        }
    32      }
    33    },
    34    {
    35      "database": {
    36        "id": "database0",
    37        "client": "client0",
    38        "databaseName": "db0",
    39        "databaseOptions": {
    40          "readPreference": {
    41            "mode": "secondaryPreferred",
    42            "maxStalenessSeconds": 600
    43          }
    44        }
    45      }
    46    },
    47    {
    48      "collection": {
    49        "id": "collection0",
    50        "database": "database0",
    51        "collectionName": "coll0"
    52      }
    53    }
    54  ],
    55  "initialData": [
    56    {
    57      "collectionName": "coll0",
    58      "databaseName": "db0",
    59      "documents": []
    60    }
    61  ],
    62  "tests": [
    63    {
    64      "description": "Database-level aggregate with $out includes read preference for 5.0+ server",
    65      "runOnRequirements": [
    66        {
    67          "minServerVersion": "5.0",
    68          "serverless": "forbid"
    69        }
    70      ],
    71      "operations": [
    72        {
    73          "object": "database0",
    74          "name": "aggregate",
    75          "arguments": {
    76            "pipeline": [
    77              {
    78                "$listLocalSessions": {}
    79              },
    80              {
    81                "$limit": 1
    82              },
    83              {
    84                "$addFields": {
    85                  "_id": 1
    86                }
    87              },
    88              {
    89                "$project": {
    90                  "_id": 1
    91                }
    92              },
    93              {
    94                "$out": "coll0"
    95              }
    96            ]
    97          }
    98        }
    99      ],
   100      "expectEvents": [
   101        {
   102          "client": "client0",
   103          "events": [
   104            {
   105              "commandStartedEvent": {
   106                "command": {
   107                  "aggregate": 1,
   108                  "pipeline": [
   109                    {
   110                      "$listLocalSessions": {}
   111                    },
   112                    {
   113                      "$limit": 1
   114                    },
   115                    {
   116                      "$addFields": {
   117                        "_id": 1
   118                      }
   119                    },
   120                    {
   121                      "$project": {
   122                        "_id": 1
   123                      }
   124                    },
   125                    {
   126                      "$out": "coll0"
   127                    }
   128                  ],
   129                  "$readPreference": {
   130                    "mode": "secondaryPreferred",
   131                    "maxStalenessSeconds": 600
   132                  },
   133                  "readConcern": {
   134                    "level": "local"
   135                  },
   136                  "writeConcern": {
   137                    "w": 1
   138                  }
   139                }
   140              }
   141            }
   142          ]
   143        }
   144      ],
   145      "outcome": [
   146        {
   147          "collectionName": "coll0",
   148          "databaseName": "db0",
   149          "documents": [
   150            {
   151              "_id": 1
   152            }
   153          ]
   154        }
   155      ]
   156    },
   157    {
   158      "description": "Database-level aggregate with $out omits read preference for pre-5.0 server",
   159      "runOnRequirements": [
   160        {
   161          "minServerVersion": "4.2",
   162          "maxServerVersion": "4.4.99",
   163          "serverless": "forbid"
   164        }
   165      ],
   166      "operations": [
   167        {
   168          "object": "database0",
   169          "name": "aggregate",
   170          "arguments": {
   171            "pipeline": [
   172              {
   173                "$listLocalSessions": {}
   174              },
   175              {
   176                "$limit": 1
   177              },
   178              {
   179                "$addFields": {
   180                  "_id": 1
   181                }
   182              },
   183              {
   184                "$project": {
   185                  "_id": 1
   186                }
   187              },
   188              {
   189                "$out": "coll0"
   190              }
   191            ]
   192          }
   193        }
   194      ],
   195      "expectEvents": [
   196        {
   197          "client": "client0",
   198          "events": [
   199            {
   200              "commandStartedEvent": {
   201                "command": {
   202                  "aggregate": 1,
   203                  "pipeline": [
   204                    {
   205                      "$listLocalSessions": {}
   206                    },
   207                    {
   208                      "$limit": 1
   209                    },
   210                    {
   211                      "$addFields": {
   212                        "_id": 1
   213                      }
   214                    },
   215                    {
   216                      "$project": {
   217                        "_id": 1
   218                      }
   219                    },
   220                    {
   221                      "$out": "coll0"
   222                    }
   223                  ],
   224                  "$readPreference": {
   225                    "$$exists": false
   226                  },
   227                  "readConcern": {
   228                    "level": "local"
   229                  },
   230                  "writeConcern": {
   231                    "w": 1
   232                  }
   233                }
   234              }
   235            }
   236          ]
   237        }
   238      ],
   239      "outcome": [
   240        {
   241          "collectionName": "coll0",
   242          "databaseName": "db0",
   243          "documents": [
   244            {
   245              "_id": 1
   246            }
   247          ]
   248        }
   249      ]
   250    },
   251    {
   252      "description": "Database-level aggregate with $merge includes read preference for 5.0+ server",
   253      "runOnRequirements": [
   254        {
   255          "minServerVersion": "5.0"
   256        }
   257      ],
   258      "operations": [
   259        {
   260          "object": "database0",
   261          "name": "aggregate",
   262          "arguments": {
   263            "pipeline": [
   264              {
   265                "$listLocalSessions": {}
   266              },
   267              {
   268                "$limit": 1
   269              },
   270              {
   271                "$addFields": {
   272                  "_id": 1
   273                }
   274              },
   275              {
   276                "$project": {
   277                  "_id": 1
   278                }
   279              },
   280              {
   281                "$merge": {
   282                  "into": "coll0"
   283                }
   284              }
   285            ]
   286          }
   287        }
   288      ],
   289      "expectEvents": [
   290        {
   291          "client": "client0",
   292          "events": [
   293            {
   294              "commandStartedEvent": {
   295                "command": {
   296                  "aggregate": 1,
   297                  "pipeline": [
   298                    {
   299                      "$listLocalSessions": {}
   300                    },
   301                    {
   302                      "$limit": 1
   303                    },
   304                    {
   305                      "$addFields": {
   306                        "_id": 1
   307                      }
   308                    },
   309                    {
   310                      "$project": {
   311                        "_id": 1
   312                      }
   313                    },
   314                    {
   315                      "$merge": {
   316                        "into": "coll0"
   317                      }
   318                    }
   319                  ],
   320                  "$readPreference": {
   321                    "mode": "secondaryPreferred",
   322                    "maxStalenessSeconds": 600
   323                  },
   324                  "readConcern": {
   325                    "level": "local"
   326                  },
   327                  "writeConcern": {
   328                    "w": 1
   329                  }
   330                }
   331              }
   332            }
   333          ]
   334        }
   335      ],
   336      "outcome": [
   337        {
   338          "collectionName": "coll0",
   339          "databaseName": "db0",
   340          "documents": [
   341            {
   342              "_id": 1
   343            }
   344          ]
   345        }
   346      ]
   347    },
   348    {
   349      "description": "Database-level aggregate with $merge omits read preference for pre-5.0 server",
   350      "runOnRequirements": [
   351        {
   352          "minServerVersion": "4.2",
   353          "maxServerVersion": "4.4.99"
   354        }
   355      ],
   356      "operations": [
   357        {
   358          "object": "database0",
   359          "name": "aggregate",
   360          "arguments": {
   361            "pipeline": [
   362              {
   363                "$listLocalSessions": {}
   364              },
   365              {
   366                "$limit": 1
   367              },
   368              {
   369                "$addFields": {
   370                  "_id": 1
   371                }
   372              },
   373              {
   374                "$project": {
   375                  "_id": 1
   376                }
   377              },
   378              {
   379                "$merge": {
   380                  "into": "coll0"
   381                }
   382              }
   383            ]
   384          }
   385        }
   386      ],
   387      "expectEvents": [
   388        {
   389          "client": "client0",
   390          "events": [
   391            {
   392              "commandStartedEvent": {
   393                "command": {
   394                  "aggregate": 1,
   395                  "pipeline": [
   396                    {
   397                      "$listLocalSessions": {}
   398                    },
   399                    {
   400                      "$limit": 1
   401                    },
   402                    {
   403                      "$addFields": {
   404                        "_id": 1
   405                      }
   406                    },
   407                    {
   408                      "$project": {
   409                        "_id": 1
   410                      }
   411                    },
   412                    {
   413                      "$merge": {
   414                        "into": "coll0"
   415                      }
   416                    }
   417                  ],
   418                  "$readPreference": {
   419                    "$$exists": false
   420                  },
   421                  "readConcern": {
   422                    "level": "local"
   423                  },
   424                  "writeConcern": {
   425                    "w": 1
   426                  }
   427                }
   428              }
   429            }
   430          ]
   431        }
   432      ],
   433      "outcome": [
   434        {
   435          "collectionName": "coll0",
   436          "databaseName": "db0",
   437          "documents": [
   438            {
   439              "_id": 1
   440            }
   441          ]
   442        }
   443      ]
   444    }
   445  ]
   446}

View as plain text