description: tests that connections are returned to the pool on retry attempts for overload errors
schemaVersion: "1.3"
runOnRequirements:
  - minServerVersion: "4.4"
    topologies:
      - replicaset
      - sharded
      - load-balanced
createEntities:
  - client:
      id: client
      useMultipleMongoses: false
      observeEvents:
        - connectionCheckedOutEvent
        - connectionCheckedInEvent
  - client:
      id: fail_point_client
      useMultipleMongoses: false
  - database:
      id: database
      client: client
      databaseName: backpressure-connection-checkin
  - collection:
      id: collection
      database: database
      collectionName: coll
tests:
  - description: overload error retry attempts return connections to the pool
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: fail_point_client
          failPoint:
            configureFailPoint: failCommand
            mode: alwaysOn
            data:
              failCommands:
                - find
              errorLabels:
                - RetryableError
                - SystemOverloadedError
              errorCode: 2
      - name: find
        object: collection
        arguments:
          filter: {}
        expectError:
          isError: true
          isClientError: false
    expectEvents:
      - client: client
        eventType: cmap
        events:
          - connectionCheckedOutEvent: {}
          - connectionCheckedInEvent: {}
          - connectionCheckedOutEvent: {}
          - connectionCheckedInEvent: {}
          - connectionCheckedOutEvent: {}
          - connectionCheckedInEvent: {}
