Skip to content

Commit 283326f

Browse files
author
Divjot Arora
authored
GODRIVER-1489 Implement streaming heartbeat protocol (#423)
1 parent b7bf0e0 commit 283326f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4282
-227
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.0",
5+
"topology": [
6+
"replicaset"
7+
]
8+
},
9+
{
10+
"minServerVersion": "4.2",
11+
"topology": [
12+
"sharded"
13+
]
14+
}
15+
],
16+
"database_name": "sdam-tests",
17+
"collection_name": "cancel-server-check",
18+
"data": [],
19+
"tests": [
20+
{
21+
"description": "Cancel server check",
22+
"clientOptions": {
23+
"retryWrites": true,
24+
"heartbeatFrequencyMS": 10000,
25+
"serverSelectionTimeoutMS": 5000,
26+
"appname": "cancelServerCheckTest"
27+
},
28+
"operations": [
29+
{
30+
"name": "insertOne",
31+
"object": "collection",
32+
"arguments": {
33+
"document": {
34+
"_id": 1
35+
}
36+
}
37+
},
38+
{
39+
"name": "configureFailPoint",
40+
"object": "testRunner",
41+
"arguments": {
42+
"failPoint": {
43+
"configureFailPoint": "failCommand",
44+
"mode": {
45+
"times": 1
46+
},
47+
"data": {
48+
"failCommands": [
49+
"insert"
50+
],
51+
"closeConnection": true
52+
}
53+
}
54+
}
55+
},
56+
{
57+
"name": "insertOne",
58+
"object": "collection",
59+
"arguments": {
60+
"document": {
61+
"_id": 2
62+
}
63+
},
64+
"result": {
65+
"insertedId": 2
66+
}
67+
},
68+
{
69+
"name": "waitForEvent",
70+
"object": "testRunner",
71+
"arguments": {
72+
"event": "ServerMarkedUnknownEvent",
73+
"count": 1
74+
}
75+
},
76+
{
77+
"name": "waitForEvent",
78+
"object": "testRunner",
79+
"arguments": {
80+
"event": "PoolClearedEvent",
81+
"count": 1
82+
}
83+
},
84+
{
85+
"name": "insertOne",
86+
"object": "collection",
87+
"arguments": {
88+
"document": {
89+
"_id": 3
90+
}
91+
},
92+
"result": {
93+
"insertedId": 3
94+
}
95+
},
96+
{
97+
"name": "assertEventCount",
98+
"object": "testRunner",
99+
"arguments": {
100+
"event": "ServerMarkedUnknownEvent",
101+
"count": 1
102+
}
103+
},
104+
{
105+
"name": "assertEventCount",
106+
"object": "testRunner",
107+
"arguments": {
108+
"event": "PoolClearedEvent",
109+
"count": 1
110+
}
111+
}
112+
],
113+
"outcome": {
114+
"collection": {
115+
"data": [
116+
{
117+
"_id": 1
118+
},
119+
{
120+
"_id": 2
121+
},
122+
{
123+
"_id": 3
124+
}
125+
]
126+
}
127+
}
128+
}
129+
]
130+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Test SDAM error handling.
2+
runOn:
3+
# General failCommand requirements (this file does not use appName
4+
# with failCommand).
5+
- minServerVersion: "4.0"
6+
topology: ["replicaset"]
7+
- minServerVersion: "4.2"
8+
topology: ["sharded"]
9+
10+
database_name: &database_name "sdam-tests"
11+
collection_name: &collection_name "cancel-server-check"
12+
13+
data: []
14+
15+
tests:
16+
- description: Cancel server check
17+
clientOptions:
18+
retryWrites: true
19+
heartbeatFrequencyMS: 10000
20+
# Server selection timeout MUST be less than heartbeatFrequencyMS for
21+
# this test. This setting ensures that the retried insert will fail
22+
# after 5 seconds if the driver does not properly cancel the in progress
23+
# check.
24+
serverSelectionTimeoutMS: 5000
25+
appname: cancelServerCheckTest
26+
operations:
27+
# Perform an operation to ensure the node is discovered.
28+
- name: insertOne
29+
object: collection
30+
arguments:
31+
document:
32+
_id: 1
33+
# Configure the next inserts to fail with a non-timeout network error.
34+
# This should:
35+
# 1) Mark the server Unknown
36+
# 2) Clear the connection pool
37+
# 3) Cancel the in progress isMaster check and close the Monitor
38+
# connection
39+
# 4) The write will be then we retried, server selection will request an
40+
# immediate check, and block for ~500ms until the next Monitor check
41+
# proceeds.
42+
# 5) The write will succeed on the second attempt.
43+
- name: configureFailPoint
44+
object: testRunner
45+
arguments:
46+
failPoint:
47+
configureFailPoint: failCommand
48+
mode: { times: 1 }
49+
data:
50+
failCommands: ["insert"]
51+
closeConnection: True
52+
- name: insertOne
53+
object: collection
54+
arguments:
55+
document:
56+
_id: 2
57+
result:
58+
insertedId: 2
59+
# The first error should mark the server Unknown and then clear the pool.
60+
- name: waitForEvent
61+
object: testRunner
62+
arguments:
63+
event: ServerMarkedUnknownEvent
64+
count: 1
65+
- name: waitForEvent
66+
object: testRunner
67+
arguments:
68+
event: PoolClearedEvent
69+
count: 1
70+
# Perform another operation to ensure the node still selectable.
71+
- name: insertOne
72+
object: collection
73+
arguments:
74+
document:
75+
_id: 3
76+
result:
77+
insertedId: 3
78+
# Assert the server was marked Unknown and pool was cleared exactly once.
79+
- name: assertEventCount
80+
object: testRunner
81+
arguments:
82+
event: ServerMarkedUnknownEvent
83+
count: 1
84+
- name: assertEventCount
85+
object: testRunner
86+
arguments:
87+
event: PoolClearedEvent
88+
count: 1
89+
90+
# Order of operations is non-deterministic so we cannot check events.
91+
outcome:
92+
collection:
93+
data:
94+
- {_id: 1}
95+
- {_id: 2}
96+
- {_id: 3}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.4"
5+
}
6+
],
7+
"database_name": "sdam-tests",
8+
"collection_name": "connectTimeoutMS",
9+
"data": [],
10+
"tests": [
11+
{
12+
"description": "connectTimeoutMS=0",
13+
"clientOptions": {
14+
"retryWrites": false,
15+
"connectTimeoutMS": 0,
16+
"heartbeatFrequencyMS": 500,
17+
"appname": "connectTimeoutMS=0"
18+
},
19+
"operations": [
20+
{
21+
"name": "insertMany",
22+
"object": "collection",
23+
"arguments": {
24+
"documents": [
25+
{
26+
"_id": 1
27+
},
28+
{
29+
"_id": 2
30+
}
31+
]
32+
}
33+
},
34+
{
35+
"name": "configureFailPoint",
36+
"object": "testRunner",
37+
"arguments": {
38+
"failPoint": {
39+
"configureFailPoint": "failCommand",
40+
"mode": {
41+
"times": 2
42+
},
43+
"data": {
44+
"failCommands": [
45+
"isMaster"
46+
],
47+
"appName": "connectTimeoutMS=0",
48+
"blockConnection": true,
49+
"blockTimeMS": 550
50+
}
51+
}
52+
}
53+
},
54+
{
55+
"name": "wait",
56+
"object": "testRunner",
57+
"arguments": {
58+
"ms": 750
59+
}
60+
},
61+
{
62+
"name": "insertMany",
63+
"object": "collection",
64+
"arguments": {
65+
"documents": [
66+
{
67+
"_id": 3
68+
},
69+
{
70+
"_id": 4
71+
}
72+
]
73+
}
74+
},
75+
{
76+
"name": "assertEventCount",
77+
"object": "testRunner",
78+
"arguments": {
79+
"event": "ServerMarkedUnknownEvent",
80+
"count": 0
81+
}
82+
},
83+
{
84+
"name": "assertEventCount",
85+
"object": "testRunner",
86+
"arguments": {
87+
"event": "PoolClearedEvent",
88+
"count": 0
89+
}
90+
}
91+
],
92+
"expectations": [
93+
{
94+
"command_started_event": {
95+
"command": {
96+
"insert": "connectTimeoutMS",
97+
"documents": [
98+
{
99+
"_id": 1
100+
},
101+
{
102+
"_id": 2
103+
}
104+
]
105+
},
106+
"command_name": "insert",
107+
"database_name": "sdam-tests"
108+
}
109+
},
110+
{
111+
"command_started_event": {
112+
"command": {
113+
"insert": "connectTimeoutMS",
114+
"documents": [
115+
{
116+
"_id": 3
117+
},
118+
{
119+
"_id": 4
120+
}
121+
]
122+
},
123+
"command_name": "insert",
124+
"database_name": "sdam-tests"
125+
}
126+
}
127+
],
128+
"outcome": {
129+
"collection": {
130+
"data": [
131+
{
132+
"_id": 1
133+
},
134+
{
135+
"_id": 2
136+
},
137+
{
138+
"_id": 3
139+
},
140+
{
141+
"_id": 4
142+
}
143+
]
144+
}
145+
}
146+
}
147+
]
148+
}

0 commit comments

Comments
 (0)