Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ Task("TestSocks5Proxy")
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"Socks5Proxy\""));

Task("CSOTPendingResponse")
.IsDependentOn("Build")
.DoesForEach(
items: GetFiles("./**/MongoDB.Driver.Tests.csproj"),
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"CSOTPendingResponse\""));

Task("CSOTPendingResponseNet60").IsDependentOn("CSOTPendingResponse");

Task("Package")
.IsDependentOn("PackageNugetPackages");

Expand Down
37 changes: 37 additions & 0 deletions evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,15 @@ functions:
git clone https://github.com/microsoft/semantic-kernel.git
./evergreen/run-sk.sh

run-csot-pendingresponse-tests:
- command: shell.exec
type: test
params:
working_dir: mongo-csharp-driver
script: |
${PREPARE_SHELL}
evergreen/run-csot-pendingresponse-tests.sh

setup-csfle-secrets:
- command: ec2.assume_role
params:
Expand Down Expand Up @@ -1823,6 +1832,25 @@ tasks:
vars:
FRAMEWORK: net60

- name: test-csot-pendingresponse
commands:
- func: bootstrap-mongo-orchestration
vars:
MONGODB_VERSION: latest
TOPOLOGY: standalone
AUTH: noauth
SSL: nossl
- command: subprocess.exec
params:
working_dir: mongo-csharp-driver
binary: bash
background: true
include_expansions_in_env:
- MONGODB_URI
args:
- ${DRIVERS_TOOLS}/.evergreen/start-mongoproxy.sh
- func: install-dotnet
- func: run-csot-pendingresponse-tests
axes:
- id: version
display_name: MongoDB Version
Expand Down Expand Up @@ -2556,6 +2584,15 @@ buildvariants:
- name: "test-load-balancer-netstandard21"
- name: "test-load-balancer-net60"

# CSOT
- name: csot-pendingresponse-tests
display_name: "CSOT Pending Response tests"
batchtime: 720 # 12 hours
run_on:
- ubuntu2204-small
tasks:
- name: test-csot-pendingresponse

# Performance tests
- name: driver-performance-tests
display_name: "Driver Performance Tests"
Expand Down
8 changes: 8 additions & 0 deletions evergreen/run-csot-pendingresponse-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -o errexit # Exit the script with error if any of the commands fail

export ENABLE_CSOT_PENDING_RESPONSE_TESTS=1
export MONGODB_URI="mongodb://127.0.0.1:28017/?directConnection=true"

./build.sh --target=CSOTPendingResponseNet60
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"description": "Connection churn is prevented by reading pending responses during connection checkout",
"schemaVersion": "1.28",
"runOnRequirements": [
{
"minServerVersion": "5.0",
"topologies": [
"single",
"replicaset"
]
}
],
"createEntities": [
{
"client": {
"id": "failPointClient",
"useMultipleMongoses": false
}
},
{
"client": {
"id": "client",
"uriOptions": {
"maxPoolSize": 1,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"useMultipleMongoses": false,
"observeEvents": [
"commandFailedEvent",
"commandSucceededEvent",
"connectionCheckOutStartedEvent",
"connectionCheckedOutEvent",
"connectionCheckOutFailedEvent",
"connectionCheckedInEvent",
"connectionCreatedEvent",
"connectionReadyEvent",
"connectionClosedEvent",
"connectionPendingResponseSucceededEvent",
"connectionPendingResponseStartedEvent",
"connectionPendingResponseFailedEvent"
]
}
},
{
"database": {
"id": "test",
"client": "client",
"databaseName": "test"
}
},
{
"collection": {
"id": "coll",
"database": "test",
"collectionName": "coll"
}
}
],
"initialData": [
{
"collectionName": "coll",
"databaseName": "test",
"documents": []
}
],
"tests": [
{
"description": "write op retries when connection closes server-side while draining response",
"operations": [
{
"name": "failPoint",
"object": "testRunner",
"arguments": {
"client": "failPointClient",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"blockConnection": true,
"blockTimeMS": 200,
"closeConnection": true
}
}
}
},
{
"name": "insertOne",
"object": "coll",
"arguments": {
"timeoutMS": 50,
"document": {
"_id": 3,
"x": 1
}
},
"expectError": {
"isTimeoutError": true
}
},
{
"name": "insertOne",
"object": "coll",
"arguments": {
"timeoutMS": 1000,
"document": {
"_id": 3,
"x": 1
}
}
}
],
"expectEvents": [
{
"client": "client",
"events": [
{
"commandFailedEvent": {
"commandName": "insert"
}
},
{
"commandSucceededEvent": {
"commandName": "insert"
}
}
]
},
{
"client": "client",
"eventType": "cmap",
"events": [
{
"connectionCheckOutStartedEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
},
{
"connectionCheckOutStartedEvent": {}
},
{
"connectionPendingResponseStartedEvent": {}
},
{
"connectionPendingResponseFailedEvent": {
"reason": "error"
}
},
{
"connectionClosedEvent": {
"reason": "error"
}
},
{
"connectionCreatedEvent": {}
},
{
"connectionReadyEvent": {}
},
{
"connectionCheckedOutEvent": {}
},
{
"connectionCheckedInEvent": {}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
description: "Connection churn is prevented by reading pending responses during connection checkout"
schemaVersion: "1.28"
runOnRequirements:
- minServerVersion: "5.0"
# FailPoint on Server before 5.0 do not wait for blockTimeMS before closing the connection
topologies: ["single", "replicaset"]
createEntities:
- client:
id: &failPointClient failPointClient
useMultipleMongoses: false
- client:
id: &client client
uriOptions:
maxPoolSize: 1
minPoolSize: 1
awaitMinPoolSizeMS: 10000
useMultipleMongoses: false
observeEvents:
- commandFailedEvent
- commandSucceededEvent
- connectionCheckOutStartedEvent
- connectionCheckedOutEvent
- connectionCheckOutFailedEvent
- connectionCheckedInEvent
- connectionCreatedEvent
- connectionReadyEvent
- connectionClosedEvent
- connectionPendingResponseSucceededEvent
- connectionPendingResponseStartedEvent
- connectionPendingResponseFailedEvent
- database:
id: &database test
client: *client
databaseName: *database
- collection:
id: &collection coll
database: *database
collectionName: *collection
initialData:
- collectionName: *collection
databaseName: *database
documents: []
tests:
# If the connection is closed server-side while draining the response, the
# driver must retry with a different connection.
- description: "write op retries when connection closes server-side while draining response"
operations:
# Create a failpoint to block the first and second operation.
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: {times: 1}
data:
failCommands: ["insert"]
blockConnection: true
blockTimeMS: 200
closeConnection: true
# Execute operation with timeout less than block time.
- name: insertOne
object: *collection
arguments:
timeoutMS: 50
document: {_id: 3, x: 1}
expectError:
isTimeoutError: true
# Draining pending response should failure because of closed connection,
# but another connection should be established within the checkout and operation should succeed.
- name: insertOne
object: *collection
arguments:
timeoutMS: 1000
document: {_id: 3, x: 1}
expectEvents:
- client: *client
events:
- commandFailedEvent:
commandName: insert
- commandSucceededEvent:
commandName: insert
- client: *client
eventType: cmap
events:
- connectionCheckOutStartedEvent: { }
- connectionCheckedOutEvent: { }
- connectionCheckedInEvent: { } # Insert fails.
- connectionCheckOutStartedEvent: { }
- connectionPendingResponseStartedEvent: { }
- connectionPendingResponseFailedEvent: # Pending response failed.
reason: error
- connectionClosedEvent:
reason: error
- connectionCreatedEvent: { } # New connection should be created and checked out.
- connectionReadyEvent: { }
- connectionCheckedOutEvent: { }
- connectionCheckedInEvent: { } # Find finishes.
Loading