...

Text file src/go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml

Documentation: go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/unified

     1---
     2description: interruptInUse
     3
     4schemaVersion: "1.11"
     5
     6runOnRequirements:
     7  # failCommand appName requirements
     8  - minServerVersion: "4.9"
     9    serverless: forbid
    10    topologies: [ replicaset, sharded ]
    11
    12createEntities:
    13  - client:
    14      id: &setupClient setupClient
    15      useMultipleMongoses: false
    16
    17initialData: &initialData
    18  - collectionName: &collectionName interruptInUse
    19    databaseName: &databaseName sdam-tests
    20    documents: []
    21
    22tests:
    23  - description: Connection pool clear uses interruptInUseConnections=true after monitor timeout
    24    operations:
    25      - name: createEntities
    26        object: testRunner
    27        arguments:
    28          entities:
    29            - client:
    30                id: &client client
    31                useMultipleMongoses: false
    32                observeEvents:
    33                  - poolClearedEvent
    34                  - connectionClosedEvent
    35                  - commandStartedEvent
    36                  - commandSucceededEvent
    37                  - commandFailedEvent
    38                  - connectionCheckedOutEvent
    39                  - connectionCheckedInEvent
    40                uriOptions:
    41                  connectTimeoutMS: 500
    42                  heartbeatFrequencyMS: 500
    43                  appname: interruptInUse
    44                  retryReads: false
    45                  minPoolSize: 0
    46            - database:
    47                id: &database database
    48                client: *client
    49                databaseName: *databaseName
    50            - collection:
    51                id: &collection collection
    52                database: *database
    53                collectionName: *collectionName
    54            - thread:
    55                id: &thread1 thread1
    56      - name: insertOne
    57        object: *collection
    58        arguments:
    59          document: { _id: 1 }
    60      # simulate a long-running query
    61      - name: runOnThread
    62        object: testRunner
    63        arguments:
    64          thread: *thread1
    65          operation:
    66            name: find
    67            object: *collection
    68            arguments:
    69              filter:
    70                $where : sleep(2000) || true
    71            expectError:
    72              isError: true
    73        # Configure the monitor check to fail with a timeout.
    74        # Use "times: 4" to increase the probability that the Monitor check triggers
    75        # the failpoint, since the RTT hello may trigger this failpoint one or many
    76        # times as well.
    77      - name: failPoint
    78        object: testRunner
    79        arguments:
    80          client: *setupClient
    81          failPoint:
    82            configureFailPoint: failCommand
    83            mode:
    84              times: 4
    85            data:
    86              failCommands:
    87                - hello
    88                - isMaster
    89              blockConnection: true
    90              blockTimeMS: 1500
    91              appName: interruptInUse
    92      - name: waitForThread
    93        object: testRunner
    94        arguments:
    95          thread: *thread1
    96
    97    expectEvents:
    98      - client: *client
    99        eventType: command
   100        events:
   101          - commandStartedEvent:
   102              commandName: insert
   103          - commandSucceededEvent:
   104              commandName: insert
   105          - commandStartedEvent:
   106              commandName: find
   107          - commandFailedEvent:
   108              commandName: find
   109      - client: *client
   110        eventType: cmap
   111        events:
   112          - connectionCheckedOutEvent: {}
   113          - connectionCheckedInEvent: {}
   114          - connectionCheckedOutEvent: {}
   115          - poolClearedEvent:
   116              interruptInUseConnections: true
   117          - connectionCheckedInEvent: {}
   118          - connectionClosedEvent: {}
   119
   120    outcome:
   121      - collectionName: *collectionName
   122        databaseName: *databaseName
   123        documents:
   124          - _id: 1
   125
   126  - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable
   127    operations:
   128      - name: createEntities
   129        object: testRunner
   130        arguments:
   131          entities:
   132            - client:
   133                id: &client client
   134                useMultipleMongoses: false
   135                observeEvents:
   136                  - poolClearedEvent
   137                  - connectionClosedEvent
   138                  - commandStartedEvent
   139                  - commandFailedEvent
   140                  - commandSucceededEvent
   141                  - connectionCheckedOutEvent
   142                  - connectionCheckedInEvent
   143                uriOptions:
   144                  connectTimeoutMS: 500
   145                  heartbeatFrequencyMS: 500
   146                  appname: interruptInUseRetryable
   147                  retryReads: true
   148                  minPoolSize: 0
   149            - database:
   150                id: &database database
   151                client: *client
   152                databaseName: *databaseName
   153            - collection:
   154                id: &collection collection
   155                database: *database
   156                collectionName: *collectionName
   157            - thread:
   158                id: &thread1 thread1
   159      - name: insertOne
   160        object: *collection
   161        arguments:
   162          document: { _id: 1 }
   163      # simulate a long-running query
   164      - name: runOnThread
   165        object: testRunner
   166        arguments:
   167          thread: *thread1
   168          operation:
   169            name: find
   170            object: *collection
   171            arguments:
   172              filter:
   173                $where : sleep(2000) || true
   174        # Configure the monitor check to fail with a timeout.
   175        # Use "times: 4" to increase the probability that the Monitor check triggers
   176        # the failpoint, since the RTT hello may trigger this failpoint one or many
   177        # times as well.
   178      - name: failPoint
   179        object: testRunner
   180        arguments:
   181          client: *setupClient
   182          failPoint:
   183            configureFailPoint: failCommand
   184            mode:
   185              times: 4
   186            data:
   187              failCommands:
   188                - hello
   189                - isMaster
   190              blockConnection: true
   191              blockTimeMS: 1500
   192              appName: interruptInUseRetryable
   193      - name: waitForThread
   194        object: testRunner
   195        arguments:
   196          thread: *thread1
   197
   198    expectEvents:
   199      - client: *client
   200        eventType: command
   201        events:
   202          - commandStartedEvent:
   203              commandName: insert
   204          - commandSucceededEvent:
   205              commandName: insert
   206          - commandStartedEvent:
   207              commandName: find
   208          - commandFailedEvent:
   209              commandName: find
   210          - commandStartedEvent:
   211              commandName: find
   212          - commandSucceededEvent:
   213              commandName: find
   214      - client: *client
   215        eventType: cmap
   216        events:
   217          - connectionCheckedOutEvent: {}
   218          - connectionCheckedInEvent: {}
   219          - connectionCheckedOutEvent: {}
   220          - poolClearedEvent:
   221              interruptInUseConnections: true
   222          - connectionCheckedInEvent: {}
   223          - connectionClosedEvent: {}
   224          - connectionCheckedOutEvent: {}
   225          - connectionCheckedInEvent: {}
   226
   227    outcome:
   228      - collectionName: *collectionName
   229        databaseName: *databaseName
   230        documents:
   231          - _id: 1
   232  - description: Error returned from connection pool clear with interruptInUseConnections=true is retryable for write
   233    operations:
   234      - name: createEntities
   235        object: testRunner
   236        arguments:
   237          entities:
   238            - client:
   239                id: &client client
   240                useMultipleMongoses: false
   241                observeEvents:
   242                  - poolClearedEvent
   243                  - connectionClosedEvent
   244                  - commandStartedEvent
   245                  - commandFailedEvent
   246                  - commandSucceededEvent
   247                  - connectionCheckedOutEvent
   248                  - connectionCheckedInEvent
   249                uriOptions:
   250                  connectTimeoutMS: 500
   251                  heartbeatFrequencyMS: 500
   252                  appname: interruptInUseRetryableWrite
   253                  retryWrites: true
   254                  minPoolSize: 0
   255            - database:
   256                id: &database database
   257                client: *client
   258                databaseName: *databaseName
   259            - collection:
   260                id: &collection collection
   261                database: *database
   262                collectionName: *collectionName
   263            - thread:
   264                id: &thread1 thread1
   265      # ensure the primary is discovered
   266      - name: insertOne
   267        object: *collection
   268        arguments:
   269          document: { _id: 1 }
   270      # simulate a long-running query
   271      - name: runOnThread
   272        object: testRunner
   273        arguments:
   274          thread: *thread1
   275          operation:
   276            name: updateOne
   277            object: *collection
   278            arguments:
   279              filter:
   280                $where: sleep(2000) || true
   281              update:
   282                "$set": { "a": "bar" }
   283        # Configure the monitor check to fail with a timeout.
   284        # Use "times: 4" to increase the probability that the Monitor check triggers
   285        # the failpoint, since the RTT hello may trigger this failpoint one or many
   286        # times as well.
   287      - name: failPoint
   288        object: testRunner
   289        arguments:
   290          client: *setupClient
   291          failPoint:
   292            configureFailPoint: failCommand
   293            mode:
   294              times: 4
   295            data:
   296              failCommands:
   297                - hello
   298                - isMaster
   299              blockConnection: true
   300              blockTimeMS: 1500
   301              appName: interruptInUseRetryableWrite
   302      - name: waitForThread
   303        object: testRunner
   304        arguments:
   305          thread: *thread1
   306
   307    expectEvents:
   308      - client: *client
   309        eventType: command
   310        events:
   311          - commandStartedEvent:
   312              commandName: insert
   313          - commandSucceededEvent:
   314              commandName: insert
   315          - commandStartedEvent:
   316              commandName: update
   317          - commandFailedEvent:
   318              commandName: update
   319          - commandStartedEvent:
   320              commandName: update
   321          - commandSucceededEvent:
   322              commandName: update
   323      - client: *client
   324        eventType: cmap
   325        events:
   326          - connectionCheckedOutEvent: {}
   327          - connectionCheckedInEvent: {}
   328          - connectionCheckedOutEvent: {}
   329          - poolClearedEvent:
   330              interruptInUseConnections: true
   331          - connectionCheckedInEvent: {}
   332          - connectionClosedEvent: {}
   333          - connectionCheckedOutEvent: {}
   334          - connectionCheckedInEvent: {}
   335
   336    outcome:
   337      - collectionName: *collectionName
   338        databaseName: *databaseName
   339        documents:
   340          - { _id: 1, a : bar }

View as plain text