...

Text file src/go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass/poc-transactions.yml

Documentation: go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass

     1description: "poc-transactions"
     2
     3schemaVersion: "1.0"
     4
     5runOnRequirements:
     6  - minServerVersion: "4.0"
     7    topologies: [ replicaset ]
     8  - minServerVersion: "4.1.8"
     9    topologies: [ sharded-replicaset ]
    10
    11createEntities:
    12  - client:
    13      id: &client0 client0
    14      observeEvents: [ commandStartedEvent ]
    15  - database:
    16      id: &database0 database0
    17      client: *client0
    18      databaseName: &database0Name transaction-tests
    19  - collection:
    20      id: &collection0 collection0
    21      database: *database0
    22      collectionName: &collection0Name test
    23  - session:
    24      id: &session0 session0
    25      client: *client0
    26
    27initialData:
    28  - collectionName: *collection0Name
    29    databaseName: *database0Name
    30    documents: []
    31
    32tests:
    33  - description: "Client side error in command starting transaction"
    34    operations:
    35      - name: startTransaction
    36        object: *session0
    37      - name: updateOne
    38        object: *collection0
    39        arguments:
    40          session: *session0
    41          filter: { _id: 1 }
    42          update: { x: 1 }
    43        # Original test only asserted a generic error
    44        expectError: { isClientError: true }
    45      - name: assertSessionTransactionState
    46        object: testRunner
    47        arguments:
    48          session: *session0
    49          state: starting
    50
    51  - description: "explicitly create collection using create command"
    52    runOnRequirements:
    53      - minServerVersion: "4.3.4"
    54        topologies: [ replicaset, sharded-replicaset ]
    55    operations:
    56      - name: dropCollection
    57        object: *database0
    58        arguments:
    59          collection: *collection0Name
    60      - name: startTransaction
    61        object: *session0
    62      - name: createCollection
    63        object: *database0
    64        arguments:
    65          session: *session0
    66          collection: *collection0Name
    67      - name: assertCollectionNotExists
    68        object: testRunner
    69        arguments:
    70          databaseName: *database0Name
    71          collectionName: *collection0Name
    72      - name: commitTransaction
    73        object: *session0
    74      - name: assertCollectionExists
    75        object: testRunner
    76        arguments:
    77          databaseName: *database0Name
    78          collectionName: *collection0Name
    79    expectEvents:
    80      - client: *client0
    81        events:
    82          - commandStartedEvent:
    83              command:
    84                drop: *collection0Name
    85                writeConcern: { $$exists: false }
    86              commandName: drop
    87              databaseName: *database0Name
    88          - commandStartedEvent:
    89              command:
    90                create: *collection0Name
    91                lsid: { $$sessionLsid: *session0 }
    92                txnNumber: 1
    93                startTransaction: true
    94                autocommit: false
    95                writeConcern: { $$exists: false }
    96              commandName: create
    97              databaseName: *database0Name
    98          - commandStartedEvent:
    99              command:
   100                commitTransaction: 1
   101                lsid: { $$sessionLsid: *session0 }
   102                txnNumber: 1
   103                startTransaction: { $$exists: false }
   104                autocommit: false
   105                writeConcern: { $$exists: false }
   106              commandName: commitTransaction
   107              databaseName: admin
   108
   109  - description: "create index on a non-existing collection"
   110    runOnRequirements:
   111      - minServerVersion: "4.3.4"
   112        topologies: [ replicaset, sharded-replicaset ]
   113    operations:
   114      - name: dropCollection
   115        object: *database0
   116        arguments:
   117          collection: *collection0Name
   118      - name: startTransaction
   119        object: *session0
   120      - name: createIndex
   121        object: *collection0
   122        arguments:
   123          session: *session0
   124          name: &indexName "x_1"
   125          keys: { x: 1 }
   126      - name: assertIndexNotExists
   127        object: testRunner
   128        arguments:
   129          databaseName: *database0Name
   130          collectionName: *collection0Name
   131          indexName: *indexName
   132      - name: commitTransaction
   133        object: *session0
   134      - name: assertIndexExists
   135        object: testRunner
   136        arguments:
   137          databaseName: *database0Name
   138          collectionName: *collection0Name
   139          indexName: *indexName
   140    expectEvents:
   141      - client: *client0
   142        events:
   143          - commandStartedEvent:
   144              command:
   145                drop: *collection0Name
   146                writeConcern: { $$exists: false }
   147              commandName: drop
   148              databaseName: *database0Name
   149          - commandStartedEvent:
   150              command:
   151                createIndexes: *collection0Name
   152                indexes:
   153                  - name: *indexName
   154                    key: { x: 1 }
   155                lsid: { $$sessionLsid: *session0 }
   156                txnNumber: 1
   157                startTransaction: true
   158                autocommit: false
   159                writeConcern: { $$exists: false }
   160              commandName: createIndexes
   161              databaseName: *database0Name
   162          - commandStartedEvent:
   163              command:
   164                commitTransaction: 1
   165                lsid: { $$sessionLsid: *session0 }
   166                txnNumber: 1
   167                startTransaction: { $$exists: false }
   168                autocommit: false
   169                writeConcern: { $$exists: false }
   170              commandName: commitTransaction
   171              databaseName: admin

View as plain text