...

Text file src/go.mongodb.org/mongo-driver/testdata/convenient-transactions/transaction-options.yml

Documentation: go.mongodb.org/mongo-driver/testdata/convenient-transactions

     1runOn:
     2    -
     3        minServerVersion: "4.0"
     4        topology: ["replicaset"]
     5    -
     6        minServerVersion: "4.1.8"
     7        topology: ["sharded"]
     8
     9database_name: &database_name "withTransaction-tests"
    10collection_name: &collection_name "test"
    11
    12data: []
    13
    14tests:
    15  -
    16    description: withTransaction and no transaction options set
    17    useMultipleMongoses: true
    18    operations: &operations
    19      -
    20        name: withTransaction
    21        object: session0
    22        arguments:
    23          callback:
    24            operations:
    25              -
    26                name: insertOne
    27                object: collection
    28                arguments:
    29                  session: session0
    30                  document: { _id: 1 }
    31                result:
    32                  insertedId: 1
    33    expectations:
    34      -
    35        command_started_event:
    36          command:
    37            insert: *collection_name
    38            documents:
    39              - { _id: 1 }
    40            ordered: true
    41            lsid: session0
    42            txnNumber: { $numberLong: "1" }
    43            startTransaction: true
    44            autocommit: false
    45            # omitted fields
    46            readConcern: ~
    47            writeConcern: ~
    48          command_name: insert
    49          database_name: *database_name
    50      -
    51        command_started_event:
    52          command:
    53            commitTransaction: 1
    54            lsid: session0
    55            txnNumber: { $numberLong: "1" }
    56            autocommit: false
    57            # omitted fields
    58            readConcern: ~
    59            startTransaction: ~
    60            writeConcern: ~
    61          command_name: commitTransaction
    62          database_name: admin
    63    outcome: &outcome
    64      collection:
    65        data:
    66          - { _id: 1 }
    67  -
    68    description: withTransaction inherits transaction options from client
    69    useMultipleMongoses: true
    70    clientOptions:
    71      readConcernLevel: local
    72      w: 1
    73    operations: *operations
    74    expectations:
    75      -
    76        command_started_event:
    77          command:
    78            insert: *collection_name
    79            documents:
    80              - { _id: 1 }
    81            ordered: true
    82            lsid: session0
    83            txnNumber: { $numberLong: "1" }
    84            startTransaction: true
    85            autocommit: false
    86            readConcern: { level: local }
    87            # omitted fields
    88            writeConcern: ~
    89          command_name: insert
    90          database_name: *database_name
    91      -
    92        command_started_event:
    93          command:
    94            commitTransaction: 1
    95            lsid: session0
    96            txnNumber: { $numberLong: "1" }
    97            autocommit: false
    98            writeConcern: { w: 1 }
    99            # omitted fields
   100            readConcern: ~
   101            startTransaction: ~
   102          command_name: commitTransaction
   103          database_name: admin
   104    outcome: *outcome
   105  -
   106    description: withTransaction inherits transaction options from defaultTransactionOptions
   107    useMultipleMongoses: true
   108    sessionOptions:
   109      session0:
   110        defaultTransactionOptions:
   111          readConcern: { level: majority }
   112          writeConcern: { w: 1 }
   113    operations: *operations
   114    expectations:
   115      -
   116        command_started_event:
   117          command:
   118            insert: *collection_name
   119            documents:
   120              - { _id: 1 }
   121            ordered: true
   122            lsid: session0
   123            txnNumber: { $numberLong: "1" }
   124            startTransaction: true
   125            autocommit: false
   126            readConcern: { level: majority }
   127            # omitted fields
   128            writeConcern: ~
   129          command_name: insert
   130          database_name: *database_name
   131      -
   132        command_started_event:
   133          command:
   134            commitTransaction: 1
   135            lsid: session0
   136            txnNumber: { $numberLong: "1" }
   137            autocommit: false
   138            writeConcern: { w: 1 }
   139            # omitted fields
   140            readConcern: ~
   141            startTransaction: ~
   142          command_name: commitTransaction
   143          database_name: admin
   144    outcome: *outcome
   145  -
   146    description: withTransaction explicit transaction options
   147    useMultipleMongoses: true
   148    operations: &operations_explicit_transactionOptions
   149      -
   150        name: withTransaction
   151        object: session0
   152        arguments:
   153          callback:
   154            operations:
   155              -
   156                name: insertOne
   157                object: collection
   158                arguments:
   159                  session: session0
   160                  document: { _id: 1 }
   161                result:
   162                  insertedId: 1
   163          options:
   164            readConcern: { level: majority }
   165            writeConcern: { w: 1 }
   166    expectations:
   167      -
   168        command_started_event:
   169          command:
   170            insert: *collection_name
   171            documents:
   172              - { _id: 1 }
   173            ordered: true
   174            lsid: session0
   175            txnNumber: { $numberLong: "1" }
   176            startTransaction: true
   177            autocommit: false
   178            readConcern: { level: majority }
   179            # omitted fields
   180            writeConcern: ~
   181          command_name: insert
   182          database_name: *database_name
   183      -
   184        command_started_event:
   185          command:
   186            commitTransaction: 1
   187            lsid: session0
   188            txnNumber: { $numberLong: "1" }
   189            autocommit: false
   190            writeConcern: { w: 1 }
   191            # omitted fields
   192            readConcern: ~
   193            startTransaction: ~
   194          command_name: commitTransaction
   195          database_name: admin
   196    outcome: *outcome
   197  -
   198    description: withTransaction explicit transaction options override defaultTransactionOptions
   199    useMultipleMongoses: true
   200    sessionOptions:
   201      session0:
   202        defaultTransactionOptions:
   203          readConcern: { level: snapshot }
   204          writeConcern: { w: majority }
   205    operations: *operations_explicit_transactionOptions
   206    expectations:
   207      -
   208        command_started_event:
   209          command:
   210            insert: *collection_name
   211            documents:
   212              - { _id: 1 }
   213            ordered: true
   214            lsid: session0
   215            txnNumber: { $numberLong: "1" }
   216            startTransaction: true
   217            autocommit: false
   218            readConcern: { level: majority }
   219            # omitted fields
   220            writeConcern: ~
   221          command_name: insert
   222          database_name: *database_name
   223      -
   224        command_started_event:
   225          command:
   226            commitTransaction: 1
   227            lsid: session0
   228            txnNumber: { $numberLong: "1" }
   229            autocommit: false
   230            writeConcern: { w: 1 }
   231            # omitted fields
   232            readConcern: ~
   233            startTransaction: ~
   234          command_name: commitTransaction
   235          database_name: admin
   236    outcome: *outcome
   237  -
   238    description: withTransaction explicit transaction options override client options
   239    useMultipleMongoses: true
   240    clientOptions:
   241      readConcernLevel: local
   242      w: majority
   243    operations: *operations_explicit_transactionOptions
   244    expectations:
   245      -
   246        command_started_event:
   247          command:
   248            insert: *collection_name
   249            documents:
   250              - { _id: 1 }
   251            ordered: true
   252            lsid: session0
   253            txnNumber: { $numberLong: "1" }
   254            startTransaction: true
   255            autocommit: false
   256            readConcern: { level: majority }
   257            # omitted fields
   258            writeConcern: ~
   259          command_name: insert
   260          database_name: *database_name
   261      -
   262        command_started_event:
   263          command:
   264            commitTransaction: 1
   265            lsid: session0
   266            txnNumber: { $numberLong: "1" }
   267            autocommit: false
   268            writeConcern: { w: 1 }
   269            # omitted fields
   270            readConcern: ~
   271            startTransaction: ~
   272          command_name: commitTransaction
   273          database_name: admin
   274    outcome: *outcome

View as plain text