...

Text file src/go.mongodb.org/mongo-driver/testdata/client-side-operations-timeout/gridfs-delete.yml

Documentation: go.mongodb.org/mongo-driver/testdata/client-side-operations-timeout

     1description: "timeoutMS behaves correctly for GridFS delete operations"
     2
     3schemaVersion: "1.9"
     4
     5runOnRequirements:
     6  - minServerVersion: "4.4"
     7    serverless: forbid  # GridFS ops can be slow on serverless.
     8
     9createEntities:
    10  - client:
    11      id: &failPointClient failPointClient
    12      useMultipleMongoses: false
    13  - client:
    14      id: &client client
    15      uriOptions:
    16        timeoutMS: 75
    17      useMultipleMongoses: false
    18      observeEvents:
    19        - commandStartedEvent
    20  - database:
    21      id: &database database
    22      client: *client
    23      databaseName: &databaseName test
    24  - bucket:
    25      id: &bucket bucket
    26      database: *database
    27  - collection:
    28      id: &filesCollection filesCollection
    29      database: *database
    30      collectionName: &filesCollectionName fs.files
    31  - collection:
    32      id: &chunksCollection chunksCollection
    33      database: *database
    34      collectionName: &chunksCollectionName fs.chunks
    35
    36initialData:
    37  - collectionName: *filesCollectionName
    38    databaseName: *databaseName
    39    documents:
    40      - _id: &fileDocumentId { $oid: "000000000000000000000005" }
    41        length: 8
    42        chunkSize: 4
    43        uploadDate: { $date: "1970-01-01T00:00:00.000Z" }
    44        filename: "length-8"
    45        contentType: "application/octet-stream"
    46        aliases: []
    47        metadata: {}
    48  - collectionName: *chunksCollectionName
    49    databaseName: *databaseName
    50    documents:
    51      - _id: { $oid: "000000000000000000000005" }
    52        files_id: *fileDocumentId
    53        n: 0
    54        data: { $binary: { base64: "ESIzRA==", subType: "00" } } # hex: 11223344
    55      - _id: { $oid: "000000000000000000000006" }
    56        files_id: *fileDocumentId
    57        n: 1
    58        data: { $binary: { base64: "ESIzRA==", subType: "00" } } # hex: 11223344
    59
    60tests:
    61  - description: "timeoutMS can be overridden for delete"
    62    operations:
    63      - name: failPoint
    64        object: testRunner
    65        arguments:
    66          client: *failPointClient
    67          failPoint:
    68            configureFailPoint: failCommand
    69            mode: { times: 1 }
    70            data:
    71              failCommands: ["delete"]
    72              blockConnection: true
    73              blockTimeMS: 100
    74      - name: delete
    75        object: *bucket
    76        arguments:
    77          id: *fileDocumentId
    78          timeoutMS: 1000 # The client timeoutMS is 75ms and the operation blocks for 100ms, so 1000ms should let it succeed.
    79
    80  - description: "timeoutMS applied to delete against the files collection"
    81    operations:
    82      - name: failPoint
    83        object: testRunner
    84        arguments:
    85          client: *failPointClient
    86          failPoint:
    87            configureFailPoint: failCommand
    88            mode: { times: 1 }
    89            data:
    90              failCommands: ["delete"]
    91              blockConnection: true
    92              blockTimeMS: 100
    93      - name: delete
    94        object: *bucket
    95        arguments:
    96          id: *fileDocumentId
    97        expectError:
    98          isTimeoutError: true
    99    expectEvents:
   100      - client: *client
   101        events:
   102          - commandStartedEvent:
   103              commandName: delete
   104              databaseName: *databaseName
   105              command:
   106                delete: *filesCollectionName
   107                maxTimeMS: { $$type: ["int", "long"] }
   108
   109  - description: "timeoutMS applied to delete against the chunks collection"
   110    operations:
   111      - name: failPoint
   112        object: testRunner
   113        arguments:  
   114          client: *failPointClient
   115          failPoint:
   116            configureFailPoint: failCommand
   117            mode:
   118              # The first "delete" will be against the files collection, so we skip it.
   119              skip: 1
   120            data:
   121              failCommands: ["delete"]
   122              blockConnection: true
   123              blockTimeMS: 100
   124      - name: delete
   125        object: *bucket
   126        arguments:
   127          id: *fileDocumentId
   128        expectError:
   129          isTimeoutError: true
   130
   131  # Test that drivers are not refreshing the timeout between commands. We test this by blocking both "delete" commands
   132  # for 50ms each. The delete should inherit timeoutMS=75 from the client/database and the server takes over 75ms
   133  # total, so the operation should fail.
   134  - description: "timeoutMS applied to entire delete, not individual parts"
   135    operations:
   136      - name: failPoint
   137        object: testRunner
   138        arguments:  
   139          client: *failPointClient
   140          failPoint:
   141            configureFailPoint: failCommand
   142            mode: { times: 2 }
   143            data:
   144              failCommands: ["delete"]
   145              blockConnection: true
   146              blockTimeMS: 50
   147      - name: delete
   148        object: *bucket
   149        arguments:
   150          id: *fileDocumentId
   151        expectError:
   152          isTimeoutError: true

View as plain text