File: retryable-commit-handshake.yml

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (118 lines) | stat: -rw-r--r-- 3,835 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
description: "retryable commitTransaction on handshake errors"

schemaVersion: "1.4"

runOnRequirements:
  - minServerVersion: "4.2"
    topologies: [replicaset, sharded, load-balanced]
    serverless: "forbid"
    auth: true

createEntities:
  - client:
      id: &client0 client0
      useMultipleMongoses: false
      observeEvents: [commandStartedEvent, connectionCheckOutStartedEvent]
      uriOptions: { retryWrites: false } # commitTransaction is retryable regardless of this option being set
  - database:
      id: &database0 database0
      client: *client0
      databaseName: &databaseName retryable-handshake-tests
  - collection:
      id: &collection0 collection0
      database: *database0
      collectionName: &collectionName coll
  - session:
      id: &session0 session0
      client: *client0
  - session:
      id: &session1 session1
      client: *client0

initialData:
  - collectionName: *collectionName
    databaseName: *databaseName
    documents:
      - { _id: 1, x: 11 }

tests:
  - description: "CommitTransaction succeeds after handshake network error"
    skipReason: "DRIVERS-2032: Pinned servers need to be checked if they are still selectable"
    operations:

      - name: startTransaction
        object: *session0

      - name: insertOne
        object: *collection0
        arguments:
          session: *session0
          document: { _id: 2, x: 22 }

      # The following failPoint and ping utilize session1 so that
      # the transaction won't be failed by the intentional erroring of ping
      # and it will have an empty pool when it goes to run commitTransaction
      - name: failPoint # fail the next connection establishment
        object: testRunner
        arguments:
          client: *client0
          session: *session1
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 2 }
            data:
              # use saslContinue here to avoid SDAM errors
              # this failPoint itself will create a usable connection in the connection pool
              # so we run a ping (that also fails) in order to discard the connection
              # before testing that commitTransaction gets retried
              failCommands: [saslContinue, ping]
              closeConnection: true

      - name: runCommand
        object: *database0
        arguments:
          commandName: ping
          command: { ping: 1 }
          session: *session1
        expectError:
          isError: true

      - name: commitTransaction
        object: *session0

    expectEvents:
      - client: *client0
        eventType: cmap
        events:
          - { connectionCheckOutStartedEvent: {} } # startTransaction
          - { connectionCheckOutStartedEvent: {} } # insertOne
          - { connectionCheckOutStartedEvent: {} } # failPoint
          - { connectionCheckOutStartedEvent: {} } # commitTransaction
          - { connectionCheckOutStartedEvent: {} } # commitTransaction retry
      - client: *client0
        events:
          - commandStartedEvent:
              command:
                insert: *collectionName
                documents: [{ _id: 2, x: 22 }]
                startTransaction: true
              commandName: insert
              databaseName: *databaseName
          - commandStartedEvent:
              command:
                ping: 1
              databaseName: *databaseName
          - commandStartedEvent:
              command:
                commitTransaction: 1
                lsid:
                  $$sessionLsid: *session0
              commandName: commitTransaction
              databaseName: admin

    outcome:
      - collectionName: *collectionName
        databaseName: *databaseName
        documents:
          - { _id: 1, x: 11 }
          - { _id: 2, x: 22 } # The write was still applied