{
  "description": "timeoutMS behaves correctly for retryable operations",
  "schemaVersion": "1.9",
  "runOnRequirements": [
    {
      "minServerVersion": "4.0",
      "topologies": [
        "replicaset"
      ]
    },
    {
      "minServerVersion": "4.2",
      "topologies": [
        "replicaset",
        "sharded-replicaset"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "failPointClient",
        "useMultipleMongoses": false
      }
    },
    {
      "client": {
        "id": "client",
        "uriOptions": {
          "timeoutMS": 100
        },
        "useMultipleMongoses": false,
        "observeEvents": [
          "commandStartedEvent"
        ],
        "ignoreCommandMonitoringEvents": [
          "killCursors"
        ]
      }
    },
    {
      "database": {
        "id": "database",
        "client": "client",
        "databaseName": "test"
      }
    },
    {
      "collection": {
        "id": "collection",
        "database": "database",
        "collectionName": "coll"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll",
      "databaseName": "test",
      "documents": []
    }
  ],
  "tests": [
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - insertOne on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "x": 1
            }
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - insertOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "document": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - insertOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "document": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - insertMany on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "x": 1
              }
            ]
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - insertMany on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "documents": [
              {
                "x": 1
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - insertMany on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "documents": [
              {
                "x": 1
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - deleteOne on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "delete"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "deleteOne",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - deleteOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "delete"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "deleteOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - deleteOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "delete"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "deleteOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "delete",
                "databaseName": "test",
                "command": {
                  "delete": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - replaceOne on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "replaceOne",
          "object": "collection",
          "arguments": {
            "filter": {},
            "replacement": {
              "x": 1
            }
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - replaceOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "replaceOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {},
            "replacement": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - replaceOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "replaceOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {},
            "replacement": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - updateOne on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "updateOne",
          "object": "collection",
          "arguments": {
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - updateOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "updateOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - updateOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "updateOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "update",
                "databaseName": "test",
                "command": {
                  "update": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - findOneAndDelete on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndDelete",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - findOneAndDelete on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndDelete",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - findOneAndDelete on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndDelete",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - findOneAndReplace on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndReplace",
          "object": "collection",
          "arguments": {
            "filter": {},
            "replacement": {
              "x": 1
            }
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - findOneAndReplace on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndReplace",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {},
            "replacement": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - findOneAndReplace on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndReplace",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {},
            "replacement": {
              "x": 1
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - findOneAndUpdate on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndUpdate",
          "object": "collection",
          "arguments": {
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - findOneAndUpdate on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndUpdate",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - findOneAndUpdate on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "findAndModify"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOneAndUpdate",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {},
            "update": {
              "$set": {
                "x": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "findAndModify",
                "databaseName": "test",
                "command": {
                  "findAndModify": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - bulkWrite on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "bulkWrite",
          "object": "collection",
          "arguments": {
            "requests": [
              {
                "insertOne": {
                  "document": {
                    "_id": 1
                  }
                }
              }
            ]
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - bulkWrite on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "bulkWrite",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "requests": [
              {
                "insertOne": {
                  "document": {
                    "_id": 1
                  }
                }
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - bulkWrite on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "bulkWrite",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "requests": [
              {
                "insertOne": {
                  "document": {
                    "_id": 1
                  }
                }
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "insert",
                "databaseName": "test",
                "command": {
                  "insert": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - listDatabases on client",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabases",
          "object": "client",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - listDatabases on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabases",
          "object": "client",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - listDatabases on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabases",
          "object": "client",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - listDatabaseNames on client",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabaseNames",
          "object": "client",
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - listDatabaseNames on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabaseNames",
          "object": "client",
          "arguments": {
            "timeoutMS": 500
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - listDatabaseNames on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listDatabases"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listDatabaseNames",
          "object": "client",
          "arguments": {
            "timeoutMS": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listDatabases",
                "databaseName": "admin",
                "command": {
                  "listDatabases": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - createChangeStream on client",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "client",
          "arguments": {
            "pipeline": []
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - createChangeStream on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "client",
          "arguments": {
            "timeoutMS": 500,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - createChangeStream on client",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "client",
          "arguments": {
            "timeoutMS": 0,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "admin",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - aggregate on database",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "database",
          "arguments": {
            "pipeline": [
              {
                "$listLocalSessions": {}
              },
              {
                "$limit": 1
              }
            ]
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - aggregate on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "database",
          "arguments": {
            "timeoutMS": 500,
            "pipeline": [
              {
                "$listLocalSessions": {}
              },
              {
                "$limit": 1
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - aggregate on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "database",
          "arguments": {
            "timeoutMS": 0,
            "pipeline": [
              {
                "$listLocalSessions": {}
              },
              {
                "$limit": 1
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - listCollections on database",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollections",
          "object": "database",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - listCollections on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollections",
          "object": "database",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - listCollections on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollections",
          "object": "database",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - listCollectionNames on database",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollectionNames",
          "object": "database",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - listCollectionNames on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollectionNames",
          "object": "database",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - listCollectionNames on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listCollections"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listCollectionNames",
          "object": "database",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listCollections",
                "databaseName": "test",
                "command": {
                  "listCollections": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - createChangeStream on database",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "database",
          "arguments": {
            "pipeline": []
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - createChangeStream on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "database",
          "arguments": {
            "timeoutMS": 500,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - createChangeStream on database",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "database",
          "arguments": {
            "timeoutMS": 0,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": 1,
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - aggregate on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "collection",
          "arguments": {
            "pipeline": []
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - aggregate on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - aggregate on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "aggregate",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - count on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "count",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - count on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "count",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - count on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "count",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - countDocuments on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "countDocuments",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - countDocuments on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "countDocuments",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - countDocuments on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "countDocuments",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - estimatedDocumentCount on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "estimatedDocumentCount",
          "object": "collection",
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - estimatedDocumentCount on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "estimatedDocumentCount",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - estimatedDocumentCount on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "count"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "estimatedDocumentCount",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "count",
                "databaseName": "test",
                "command": {
                  "count": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - distinct on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "distinct"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "distinct",
          "object": "collection",
          "arguments": {
            "fieldName": "x",
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - distinct on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "distinct"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "distinct",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "fieldName": "x",
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - distinct on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "distinct"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "distinct",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "fieldName": "x",
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "distinct",
                "databaseName": "test",
                "command": {
                  "distinct": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - find on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "find",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - find on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "find",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - find on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "find",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - findOne on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOne",
          "object": "collection",
          "arguments": {
            "filter": {}
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - findOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - findOne on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "findOne",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "filter": {}
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "find",
                "databaseName": "test",
                "command": {
                  "find": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - listIndexes on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "listIndexes"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listIndexes",
          "object": "collection",
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - listIndexes on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listIndexes"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listIndexes",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - listIndexes on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "listIndexes"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "listIndexes",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "listIndexes",
                "databaseName": "test",
                "command": {
                  "listIndexes": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "timeoutMS applies to whole operation, not individual attempts - createChangeStream on collection",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "blockConnection": true,
                "blockTimeMS": 60,
                "errorCode": 7,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "collection",
          "arguments": {
            "pipeline": []
          },
          "expectError": {
            "isTimeoutError": true
          }
        }
      ]
    },
    {
      "description": "operation is retried multiple times for non-zero timeoutMS - createChangeStream on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "collection",
          "arguments": {
            "timeoutMS": 500,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$type": [
                      "int",
                      "long"
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "operation is retried multiple times if timeoutMS is zero - createChangeStream on collection",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "aggregate"
                ],
                "errorCode": 7,
                "closeConnection": false,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "name": "createChangeStream",
          "object": "collection",
          "arguments": {
            "timeoutMS": 0,
            "pipeline": []
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "events": [
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            },
            {
              "commandStartedEvent": {
                "commandName": "aggregate",
                "databaseName": "test",
                "command": {
                  "aggregate": "coll",
                  "maxTimeMS": {
                    "$$exists": false
                  }
                }
              }
            }
          ]
        }
      ]
    }
  ]
}