Skip to content

GODRIVER-1489 Implement streaming heartbeat protocol #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 9, 2020
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.2",
"topology": [
"sharded"
]
}
],
"database_name": "sdam-tests",
"collection_name": "cancel-server-check",
"data": [],
"tests": [
{
"description": "Cancel server check",
"clientOptions": {
"retryWrites": true,
"heartbeatFrequencyMS": 10000,
"serverSelectionTimeoutMS": 5000,
"appname": "cancelServerCheckTest"
},
"operations": [
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 1
}
}
},
{
"name": "configureFailPoint",
"object": "testRunner",
"arguments": {
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"closeConnection": true
}
}
}
},
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 2
}
},
"result": {
"insertedId": 2
}
},
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"event": "ServerMarkedUnknownEvent",
"count": 1
}
},
{
"name": "waitForEvent",
"object": "testRunner",
"arguments": {
"event": "PoolClearedEvent",
"count": 1
}
},
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 3
}
},
"result": {
"insertedId": 3
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "ServerMarkedUnknownEvent",
"count": 1
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "PoolClearedEvent",
"count": 1
}
}
],
"outcome": {
"collection": {
"data": [
{
"_id": 1
},
{
"_id": 2
},
{
"_id": 3
}
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Test SDAM error handling.
runOn:
# General failCommand requirements (this file does not use appName
# with failCommand).
- minServerVersion: "4.0"
topology: ["replicaset"]
- minServerVersion: "4.2"
topology: ["sharded"]

database_name: &database_name "sdam-tests"
collection_name: &collection_name "cancel-server-check"

data: []

tests:
- description: Cancel server check
clientOptions:
retryWrites: true
heartbeatFrequencyMS: 10000
# Server selection timeout MUST be less than heartbeatFrequencyMS for
# this test. This setting ensures that the retried insert will fail
# after 5 seconds if the driver does not properly cancel the in progress
# check.
serverSelectionTimeoutMS: 5000
appname: cancelServerCheckTest
operations:
# Perform an operation to ensure the node is discovered.
- name: insertOne
object: collection
arguments:
document:
_id: 1
# Configure the next inserts to fail with a non-timeout network error.
# This should:
# 1) Mark the server Unknown
# 2) Clear the connection pool
# 3) Cancel the in progress isMaster check and close the Monitor
# connection
# 4) The write will be then we retried, server selection will request an
# immediate check, and block for ~500ms until the next Monitor check
# proceeds.
# 5) The write will succeed on the second attempt.
- name: configureFailPoint
object: testRunner
arguments:
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["insert"]
closeConnection: True
- name: insertOne
object: collection
arguments:
document:
_id: 2
result:
insertedId: 2
# The first error should mark the server Unknown and then clear the pool.
- name: waitForEvent
object: testRunner
arguments:
event: ServerMarkedUnknownEvent
count: 1
- name: waitForEvent
object: testRunner
arguments:
event: PoolClearedEvent
count: 1
# Perform another operation to ensure the node still selectable.
- name: insertOne
object: collection
arguments:
document:
_id: 3
result:
insertedId: 3
# Assert the server was marked Unknown and pool was cleared exactly once.
- name: assertEventCount
object: testRunner
arguments:
event: ServerMarkedUnknownEvent
count: 1
- name: assertEventCount
object: testRunner
arguments:
event: PoolClearedEvent
count: 1

# Order of operations is non-deterministic so we cannot check events.
outcome:
collection:
data:
- {_id: 1}
- {_id: 2}
- {_id: 3}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"runOn": [
{
"minServerVersion": "4.4"
}
],
"database_name": "sdam-tests",
"collection_name": "connectTimeoutMS",
"data": [],
"tests": [
{
"description": "connectTimeoutMS=0",
"clientOptions": {
"retryWrites": false,
"connectTimeoutMS": 0,
"heartbeatFrequencyMS": 500,
"appname": "connectTimeoutMS=0"
},
"operations": [
{
"name": "insertMany",
"object": "collection",
"arguments": {
"documents": [
{
"_id": 1
},
{
"_id": 2
}
]
}
},
{
"name": "configureFailPoint",
"object": "testRunner",
"arguments": {
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
},
"data": {
"failCommands": [
"isMaster"
],
"appName": "connectTimeoutMS=0",
"blockConnection": true,
"blockTimeMS": 550
}
}
}
},
{
"name": "wait",
"object": "testRunner",
"arguments": {
"ms": 750
}
},
{
"name": "insertMany",
"object": "collection",
"arguments": {
"documents": [
{
"_id": 3
},
{
"_id": 4
}
]
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "ServerMarkedUnknownEvent",
"count": 0
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "PoolClearedEvent",
"count": 0
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"insert": "connectTimeoutMS",
"documents": [
{
"_id": 1
},
{
"_id": 2
}
]
},
"command_name": "insert",
"database_name": "sdam-tests"
}
},
{
"command_started_event": {
"command": {
"insert": "connectTimeoutMS",
"documents": [
{
"_id": 3
},
{
"_id": 4
}
]
},
"command_name": "insert",
"database_name": "sdam-tests"
}
}
],
"outcome": {
"collection": {
"data": [
{
"_id": 1
},
{
"_id": 2
},
{
"_id": 3
},
{
"_id": 4
}
]
}
}
}
]
}
Loading