mongo 2.13.0.beta1 → 2.13.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -5
- data/Rakefile +15 -9
- data/lib/mongo.rb +4 -2
- data/lib/mongo/auth/aws/request.rb +4 -2
- data/lib/mongo/bulk_write.rb +1 -0
- data/lib/mongo/client.rb +143 -21
- data/lib/mongo/cluster.rb +53 -17
- data/lib/mongo/cluster/sdam_flow.rb +13 -10
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -2
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/collection.rb +17 -13
- data/lib/mongo/collection/view/readable.rb +3 -1
- data/lib/mongo/collection/view/writable.rb +41 -5
- data/lib/mongo/database.rb +31 -4
- data/lib/mongo/database/view.rb +19 -4
- data/lib/mongo/distinguishing_semaphore.rb +55 -0
- data/lib/mongo/error.rb +1 -0
- data/lib/mongo/error/invalid_session.rb +2 -1
- data/lib/mongo/error/operation_failure.rb +6 -0
- data/lib/mongo/error/sessions_not_supported.rb +35 -0
- data/lib/mongo/event/base.rb +6 -0
- data/lib/mongo/grid/file.rb +5 -0
- data/lib/mongo/grid/file/chunk.rb +2 -0
- data/lib/mongo/grid/fs_bucket.rb +15 -13
- data/lib/mongo/grid/stream/write.rb +9 -3
- data/lib/mongo/monitoring.rb +38 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +10 -2
- data/lib/mongo/monitoring/event/command_failed.rb +11 -0
- data/lib/mongo/monitoring/event/command_started.rb +37 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +11 -0
- data/lib/mongo/monitoring/event/server_closed.rb +1 -1
- data/lib/mongo/monitoring/event/server_description_changed.rb +27 -4
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +9 -2
- data/lib/mongo/monitoring/event/server_opening.rb +1 -1
- data/lib/mongo/monitoring/event/topology_changed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_closed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_opening.rb +1 -1
- data/lib/mongo/monitoring/publishable.rb +6 -3
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +9 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +1 -1
- data/lib/mongo/protocol/message.rb +36 -8
- data/lib/mongo/protocol/msg.rb +14 -0
- data/lib/mongo/protocol/serializers.rb +5 -2
- data/lib/mongo/server.rb +10 -3
- data/lib/mongo/server/connection.rb +4 -4
- data/lib/mongo/server/connection_base.rb +3 -1
- data/lib/mongo/server/description.rb +5 -0
- data/lib/mongo/server/monitor.rb +76 -44
- data/lib/mongo/server/monitor/connection.rb +55 -7
- data/lib/mongo/server/pending_connection.rb +14 -4
- data/lib/mongo/server/push_monitor.rb +173 -0
- data/{spec/runners/transactions/context.rb → lib/mongo/server/push_monitor/connection.rb} +9 -14
- data/lib/mongo/server_selector.rb +0 -1
- data/lib/mongo/server_selector/base.rb +579 -1
- data/lib/mongo/server_selector/nearest.rb +1 -6
- data/lib/mongo/server_selector/primary.rb +1 -6
- data/lib/mongo/server_selector/primary_preferred.rb +7 -10
- data/lib/mongo/server_selector/secondary.rb +1 -6
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -7
- data/lib/mongo/session.rb +2 -0
- data/lib/mongo/socket.rb +20 -8
- data/lib/mongo/socket/ssl.rb +1 -1
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/topology_version.rb +9 -0
- data/lib/mongo/utils.rb +62 -0
- data/lib/mongo/version.rb +1 -1
- data/spec/README.aws-auth.md +2 -2
- data/spec/integration/awaited_ismaster_spec.rb +28 -0
- data/spec/integration/change_stream_examples_spec.rb +6 -2
- data/spec/integration/check_clean_slate_spec.rb +16 -0
- data/spec/integration/client_construction_spec.rb +1 -0
- data/spec/integration/connect_single_rs_name_spec.rb +5 -2
- data/spec/integration/connection_spec.rb +7 -4
- data/spec/integration/crud_spec.rb +4 -4
- data/spec/integration/docs_examples_spec.rb +6 -0
- data/spec/integration/grid_fs_bucket_spec.rb +48 -0
- data/spec/integration/heartbeat_events_spec.rb +4 -23
- data/spec/integration/read_concern_spec.rb +1 -1
- data/spec/integration/retryable_errors_spec.rb +1 -1
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -2
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -3
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +2 -2
- data/spec/integration/sdam_error_handling_spec.rb +37 -15
- data/spec/integration/sdam_events_spec.rb +77 -6
- data/spec/integration/sdam_prose_spec.rb +64 -0
- data/spec/integration/server_monitor_spec.rb +25 -1
- data/spec/integration/size_limit_spec.rb +7 -3
- data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +98 -0
- data/spec/integration/ssl_uri_options_spec.rb +2 -2
- data/spec/integration/zlib_compression_spec.rb +25 -0
- data/spec/lite_spec_helper.rb +12 -5
- data/spec/mongo/auth/aws/request_spec.rb +76 -0
- data/spec/mongo/auth/scram_spec.rb +1 -1
- data/spec/mongo/client_construction_spec.rb +207 -0
- data/spec/mongo/client_spec.rb +38 -3
- data/spec/mongo/cluster/topology/replica_set_spec.rb +52 -9
- data/spec/mongo/cluster/topology/single_spec.rb +4 -2
- data/spec/mongo/cluster_spec.rb +34 -35
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +6 -6
- data/spec/mongo/collection_spec.rb +500 -0
- data/spec/mongo/database_spec.rb +245 -8
- data/spec/mongo/distinguishing_semaphore_spec.rb +63 -0
- data/spec/mongo/error/operation_failure_spec.rb +40 -0
- data/spec/mongo/index/view_spec.rb +2 -2
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +1 -4
- data/spec/mongo/protocol/msg_spec.rb +10 -0
- data/spec/mongo/semaphore_spec.rb +51 -0
- data/spec/mongo/server/connection_auth_spec.rb +2 -2
- data/spec/mongo/server_selector/nearest_spec.rb +23 -23
- data/spec/mongo/server_selector/primary_preferred_spec.rb +26 -26
- data/spec/mongo/server_selector/primary_spec.rb +9 -9
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +22 -22
- data/spec/mongo/server_selector/secondary_spec.rb +18 -18
- data/spec/mongo/server_selector_spec.rb +4 -4
- data/spec/mongo/session_spec.rb +35 -0
- data/spec/runners/change_streams/test.rb +2 -2
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/command_monitoring.rb +3 -34
- data/spec/runners/crud/context.rb +9 -5
- data/spec/runners/crud/operation.rb +59 -27
- data/spec/runners/crud/spec.rb +0 -8
- data/spec/runners/crud/test.rb +1 -1
- data/spec/runners/sdam.rb +2 -2
- data/spec/runners/server_selection.rb +242 -28
- data/spec/runners/transactions.rb +12 -12
- data/spec/runners/transactions/operation.rb +151 -25
- data/spec/runners/transactions/test.rb +60 -16
- data/spec/spec_tests/command_monitoring_spec.rb +22 -12
- data/spec/spec_tests/crud_spec.rb +1 -1
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +4 -8
- data/spec/spec_tests/data/change_streams/change-streams-resume-whitelist.yml +66 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +4 -3
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -0
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-command-error.yml +168 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-network-error.yml +162 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-timeout.yml +229 -0
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +87 -0
- data/spec/spec_tests/max_staleness_spec.rb +4 -142
- data/spec/spec_tests/retryable_reads_spec.rb +2 -2
- data/spec/spec_tests/sdam_integration_spec.rb +13 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +1 -2
- data/spec/spec_tests/server_selection_spec.rb +4 -116
- data/spec/stress/cleanup_spec.rb +17 -2
- data/spec/stress/connection_pool_stress_spec.rb +10 -8
- data/spec/support/child_process_helper.rb +78 -0
- data/spec/support/client_registry.rb +1 -0
- data/spec/support/cluster_config.rb +4 -0
- data/spec/support/event_subscriber.rb +123 -33
- data/spec/support/keyword_struct.rb +26 -0
- data/spec/support/shared/server_selector.rb +13 -1
- data/spec/support/spec_config.rb +38 -13
- data/spec/support/spec_organizer.rb +129 -0
- data/spec/support/spec_setup.rb +1 -1
- data/spec/support/utils.rb +46 -0
- metadata +992 -942
- metadata.gz.sig +0 -0
- data/lib/mongo/server_selector/selectable.rb +0 -560
- data/spec/runners/sdam_monitoring.rb +0 -89
@@ -11,7 +11,7 @@ end
|
|
11
11
|
describe 'CRUD v2 spec tests' do
|
12
12
|
define_crud_spec_tests(CRUD2_TESTS) do |spec, req, test|
|
13
13
|
let(:client) do
|
14
|
-
authorized_client.tap do |client|
|
14
|
+
authorized_client.use(spec.database_name || 'crud-default').tap do |client|
|
15
15
|
client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
|
16
16
|
end
|
17
17
|
end
|
@@ -73,25 +73,21 @@ tests:
|
|
73
73
|
result:
|
74
74
|
error:
|
75
75
|
code: 280
|
76
|
-
errorLabels: [ "NonResumableChangeStreamError" ]
|
77
|
-
|
78
76
|
-
|
79
|
-
description: change stream errors on
|
77
|
+
description: change stream errors on ElectionInProgress
|
80
78
|
minServerVersion: "4.2"
|
81
79
|
failPoint:
|
82
80
|
configureFailPoint: failCommand
|
83
81
|
mode: { times: 1 }
|
84
82
|
data:
|
85
83
|
failCommands: ["getMore"]
|
86
|
-
errorCode:
|
84
|
+
errorCode: 216 # An error code that's not on the old blacklist or whitelist
|
87
85
|
closeConnection: false
|
88
86
|
target: collection
|
89
87
|
topology:
|
90
88
|
- replicaset
|
91
89
|
- sharded
|
92
|
-
changeStreamPipeline:
|
93
|
-
-
|
94
|
-
$project: { _id: 0 }
|
90
|
+
changeStreamPipeline: []
|
95
91
|
changeStreamOptions: {}
|
96
92
|
operations:
|
97
93
|
-
|
@@ -103,4 +99,4 @@ tests:
|
|
103
99
|
z: 3
|
104
100
|
result:
|
105
101
|
error:
|
106
|
-
code:
|
102
|
+
code: 216
|
@@ -1105,3 +1105,69 @@ tests:
|
|
1105
1105
|
fullDocument:
|
1106
1106
|
x:
|
1107
1107
|
$numberInt: "1"
|
1108
|
+
-
|
1109
|
+
# CursorNotFound is special-cased to be resumable regardless of server versions or error labels, so this test has
|
1110
|
+
# no maxWireVersion.
|
1111
|
+
description: "change stream resumes after CursorNotFound"
|
1112
|
+
minServerVersion: "4.2"
|
1113
|
+
failPoint:
|
1114
|
+
configureFailPoint: failCommand
|
1115
|
+
mode: { times: 1 }
|
1116
|
+
data:
|
1117
|
+
failCommands: ["getMore"]
|
1118
|
+
errorCode: 43
|
1119
|
+
closeConnection: false
|
1120
|
+
target: collection
|
1121
|
+
topology:
|
1122
|
+
- replicaset
|
1123
|
+
- sharded
|
1124
|
+
changeStreamPipeline: []
|
1125
|
+
changeStreamOptions: {}
|
1126
|
+
operations:
|
1127
|
+
-
|
1128
|
+
database: *database_name
|
1129
|
+
collection: *collection_name
|
1130
|
+
name: insertOne
|
1131
|
+
arguments:
|
1132
|
+
document:
|
1133
|
+
x: 1
|
1134
|
+
expectations:
|
1135
|
+
-
|
1136
|
+
command_started_event:
|
1137
|
+
command:
|
1138
|
+
aggregate: *collection_name
|
1139
|
+
cursor: {}
|
1140
|
+
pipeline:
|
1141
|
+
-
|
1142
|
+
$changeStream: {}
|
1143
|
+
command_name: aggregate
|
1144
|
+
database_name: *database_name
|
1145
|
+
-
|
1146
|
+
command_started_event:
|
1147
|
+
command:
|
1148
|
+
getMore: 42
|
1149
|
+
collection: *collection_name
|
1150
|
+
command_name: getMore
|
1151
|
+
database_name: *database_name
|
1152
|
+
-
|
1153
|
+
command_started_event:
|
1154
|
+
command:
|
1155
|
+
aggregate: *collection_name
|
1156
|
+
cursor: {}
|
1157
|
+
pipeline:
|
1158
|
+
-
|
1159
|
+
$changeStream: {}
|
1160
|
+
command_name: aggregate
|
1161
|
+
database_name: *database_name
|
1162
|
+
result:
|
1163
|
+
success:
|
1164
|
+
-
|
1165
|
+
_id: "42"
|
1166
|
+
documentKey: "42"
|
1167
|
+
operationType: insert
|
1168
|
+
ns:
|
1169
|
+
db: *database_name
|
1170
|
+
coll: *collection_name
|
1171
|
+
fullDocument:
|
1172
|
+
x:
|
1173
|
+
$numberInt: "1"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# maxStalenessSeconds must be at least 90 seconds, even with no known servers.
|
2
|
+
---
|
3
|
+
topology_description:
|
4
|
+
type: ReplicaSetNoPrimary
|
5
|
+
servers:
|
6
|
+
- &1
|
7
|
+
address: a:27017
|
8
|
+
type: Unknown
|
9
|
+
- &2
|
10
|
+
address: b:27017
|
11
|
+
type: Unknown
|
12
|
+
read_preference:
|
13
|
+
mode: Nearest
|
14
|
+
maxStalenessSeconds: 1 # Too small.
|
15
|
+
error: true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# maxStalenessSeconds
|
1
|
+
# valid maxStalenessSeconds and no known servers results in an empty set of suitable servers
|
2
2
|
---
|
3
3
|
topology_description:
|
4
4
|
type: ReplicaSetNoPrimary
|
@@ -11,5 +11,6 @@ topology_description:
|
|
11
11
|
type: Unknown
|
12
12
|
read_preference:
|
13
13
|
mode: Nearest
|
14
|
-
maxStalenessSeconds:
|
15
|
-
|
14
|
+
maxStalenessSeconds: 90
|
15
|
+
suitable_servers: []
|
16
|
+
in_latency_window: []
|
@@ -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}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Test SDAM error handling.
|
2
|
+
runOn:
|
3
|
+
# failCommand appName requirements
|
4
|
+
- minServerVersion: "4.4"
|
5
|
+
|
6
|
+
database_name: &database_name "sdam-tests"
|
7
|
+
collection_name: &collection_name "connectTimeoutMS"
|
8
|
+
|
9
|
+
data: []
|
10
|
+
|
11
|
+
tests:
|
12
|
+
- description: connectTimeoutMS=0
|
13
|
+
clientOptions:
|
14
|
+
retryWrites: false
|
15
|
+
connectTimeoutMS: 0
|
16
|
+
heartbeatFrequencyMS: 500
|
17
|
+
appname: connectTimeoutMS=0
|
18
|
+
operations:
|
19
|
+
# Perform an operation to ensure the node is discovered.
|
20
|
+
- name: insertMany
|
21
|
+
object: collection
|
22
|
+
arguments:
|
23
|
+
documents:
|
24
|
+
- _id: 1
|
25
|
+
- _id: 2
|
26
|
+
# Block the next streaming isMaster check for longer than
|
27
|
+
# heartbeatFrequencyMS to ensure that the connection timeout remains
|
28
|
+
# unlimited.
|
29
|
+
- name: configureFailPoint
|
30
|
+
object: testRunner
|
31
|
+
arguments:
|
32
|
+
failPoint:
|
33
|
+
configureFailPoint: failCommand
|
34
|
+
mode: { times: 2 }
|
35
|
+
data:
|
36
|
+
failCommands: ["isMaster"]
|
37
|
+
appName: connectTimeoutMS=0
|
38
|
+
blockConnection: true
|
39
|
+
blockTimeMS: 550
|
40
|
+
- name: wait
|
41
|
+
object: testRunner
|
42
|
+
arguments:
|
43
|
+
ms: 750
|
44
|
+
# Perform an operation to ensure the node is still selectable.
|
45
|
+
- name: insertMany
|
46
|
+
object: collection
|
47
|
+
arguments:
|
48
|
+
documents:
|
49
|
+
- _id: 3
|
50
|
+
- _id: 4
|
51
|
+
# Assert that the server was never marked Unknown and the pool was never
|
52
|
+
# cleared.
|
53
|
+
- name: assertEventCount
|
54
|
+
object: testRunner
|
55
|
+
arguments:
|
56
|
+
event: ServerMarkedUnknownEvent
|
57
|
+
count: 0
|
58
|
+
- name: assertEventCount
|
59
|
+
object: testRunner
|
60
|
+
arguments:
|
61
|
+
event: PoolClearedEvent
|
62
|
+
count: 0
|
63
|
+
|
64
|
+
expectations:
|
65
|
+
- command_started_event:
|
66
|
+
command:
|
67
|
+
insert: *collection_name
|
68
|
+
documents:
|
69
|
+
- _id: 1
|
70
|
+
- _id: 2
|
71
|
+
command_name: insert
|
72
|
+
database_name: *database_name
|
73
|
+
- command_started_event:
|
74
|
+
command:
|
75
|
+
insert: *collection_name
|
76
|
+
documents:
|
77
|
+
- _id: 3
|
78
|
+
- _id: 4
|
79
|
+
command_name: insert
|
80
|
+
database_name: *database_name
|
81
|
+
|
82
|
+
outcome:
|
83
|
+
collection:
|
84
|
+
data:
|
85
|
+
- {_id: 1}
|
86
|
+
- {_id: 2}
|
87
|
+
- {_id: 3}
|
88
|
+
- {_id: 4}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Test SDAM error handling.
|
2
|
+
runOn:
|
3
|
+
# failCommand appName requirements
|
4
|
+
- minServerVersion: "4.4"
|
5
|
+
|
6
|
+
database_name: &database_name "sdam-tests"
|
7
|
+
collection_name: &collection_name "find-network-error"
|
8
|
+
|
9
|
+
data: &data
|
10
|
+
- {_id: 1}
|
11
|
+
- {_id: 2}
|
12
|
+
|
13
|
+
tests:
|
14
|
+
- description: Reset server and pool after network error on find
|
15
|
+
failPoint:
|
16
|
+
configureFailPoint: failCommand
|
17
|
+
mode: { times: 1 }
|
18
|
+
data:
|
19
|
+
failCommands: ["find"]
|
20
|
+
closeConnection: true
|
21
|
+
appName: findNetworkErrorTest
|
22
|
+
clientOptions:
|
23
|
+
retryWrites: false
|
24
|
+
retryReads: false
|
25
|
+
appname: findNetworkErrorTest
|
26
|
+
operations:
|
27
|
+
- name: find
|
28
|
+
object: collection
|
29
|
+
arguments:
|
30
|
+
filter:
|
31
|
+
_id: 1
|
32
|
+
error: true
|
33
|
+
- name: waitForEvent
|
34
|
+
object: testRunner
|
35
|
+
arguments:
|
36
|
+
event: ServerMarkedUnknownEvent
|
37
|
+
count: 1
|
38
|
+
- name: waitForEvent
|
39
|
+
object: testRunner
|
40
|
+
arguments:
|
41
|
+
event: PoolClearedEvent
|
42
|
+
count: 1
|
43
|
+
# Perform another operation to ensure the node is rediscovered.
|
44
|
+
- name: insertMany
|
45
|
+
object: collection
|
46
|
+
arguments:
|
47
|
+
documents:
|
48
|
+
- _id: 5
|
49
|
+
- _id: 6
|
50
|
+
# Assert the server was marked Unknown and pool was cleared exactly once.
|
51
|
+
- name: assertEventCount
|
52
|
+
object: testRunner
|
53
|
+
arguments:
|
54
|
+
event: ServerMarkedUnknownEvent
|
55
|
+
count: 1
|
56
|
+
- name: assertEventCount
|
57
|
+
object: testRunner
|
58
|
+
arguments:
|
59
|
+
event: PoolClearedEvent
|
60
|
+
count: 1
|
61
|
+
|
62
|
+
expectations:
|
63
|
+
- command_started_event:
|
64
|
+
command:
|
65
|
+
find: *collection_name
|
66
|
+
command_name: find
|
67
|
+
database_name: *database_name
|
68
|
+
- command_started_event:
|
69
|
+
command:
|
70
|
+
insert: *collection_name
|
71
|
+
documents:
|
72
|
+
- _id: 5
|
73
|
+
- _id: 6
|
74
|
+
command_name: insert
|
75
|
+
database_name: *database_name
|
76
|
+
|
77
|
+
outcome:
|
78
|
+
collection:
|
79
|
+
data:
|
80
|
+
- {_id: 1}
|
81
|
+
- {_id: 2}
|
82
|
+
- {_id: 5}
|
83
|
+
- {_id: 6}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Test SDAM error handling.
|
2
|
+
runOn:
|
3
|
+
# failCommand appName requirements
|
4
|
+
- minServerVersion: "4.4"
|
5
|
+
|
6
|
+
database_name: &database_name "sdam-tests"
|
7
|
+
collection_name: &collection_name "find-shutdown-error"
|
8
|
+
|
9
|
+
data: []
|
10
|
+
|
11
|
+
tests:
|
12
|
+
- description: Concurrent shutdown error on find
|
13
|
+
clientOptions:
|
14
|
+
retryWrites: false
|
15
|
+
retryReads: false
|
16
|
+
heartbeatFrequencyMS: 500
|
17
|
+
appname: shutdownErrorFindTest
|
18
|
+
operations:
|
19
|
+
# Perform an operation to ensure the node is discovered.
|
20
|
+
- name: insertOne
|
21
|
+
object: collection
|
22
|
+
arguments:
|
23
|
+
document:
|
24
|
+
_id: 1
|
25
|
+
# Configure the next two finds to fail with a non-timeout shutdown
|
26
|
+
# errors. Block the connection for 500ms to ensure both operations check
|
27
|
+
# out connections from the same pool generation.
|
28
|
+
- name: configureFailPoint
|
29
|
+
object: testRunner
|
30
|
+
arguments:
|
31
|
+
failPoint:
|
32
|
+
configureFailPoint: failCommand
|
33
|
+
mode: { times: 2 }
|
34
|
+
data:
|
35
|
+
failCommands: ["find"]
|
36
|
+
appName: shutdownErrorFindTest
|
37
|
+
errorCode: 91
|
38
|
+
blockConnection: true
|
39
|
+
blockTimeMS: 500
|
40
|
+
# Start threads.
|
41
|
+
- name: startThread
|
42
|
+
object: testRunner
|
43
|
+
arguments:
|
44
|
+
name: thread1
|
45
|
+
- name: startThread
|
46
|
+
object: testRunner
|
47
|
+
arguments:
|
48
|
+
name: thread2
|
49
|
+
# Perform concurrent find operations. Both fail with shutdown errors.
|
50
|
+
- name: runOnThread
|
51
|
+
object: testRunner
|
52
|
+
arguments:
|
53
|
+
name: thread1
|
54
|
+
operation:
|
55
|
+
name: find
|
56
|
+
object: collection
|
57
|
+
arguments:
|
58
|
+
filter:
|
59
|
+
_id: 1
|
60
|
+
error: true
|
61
|
+
- name: runOnThread
|
62
|
+
object: testRunner
|
63
|
+
arguments:
|
64
|
+
name: thread2
|
65
|
+
operation:
|
66
|
+
name: find
|
67
|
+
object: collection
|
68
|
+
arguments:
|
69
|
+
filter:
|
70
|
+
_id: 1
|
71
|
+
error: true
|
72
|
+
# Stop threads.
|
73
|
+
- name: waitForThread
|
74
|
+
object: testRunner
|
75
|
+
arguments:
|
76
|
+
name: thread1
|
77
|
+
- name: waitForThread
|
78
|
+
object: testRunner
|
79
|
+
arguments:
|
80
|
+
name: thread2
|
81
|
+
# The first shutdown error should mark the server Unknown and then clear
|
82
|
+
# the pool.
|
83
|
+
- name: waitForEvent
|
84
|
+
object: testRunner
|
85
|
+
arguments:
|
86
|
+
event: ServerMarkedUnknownEvent
|
87
|
+
count: 1
|
88
|
+
- name: waitForEvent
|
89
|
+
object: testRunner
|
90
|
+
arguments:
|
91
|
+
event: PoolClearedEvent
|
92
|
+
count: 1
|
93
|
+
# Perform an operation to ensure the node is rediscovered.
|
94
|
+
- name: insertOne
|
95
|
+
object: collection
|
96
|
+
arguments:
|
97
|
+
document:
|
98
|
+
_id: 4
|
99
|
+
# Assert the server was marked Unknown and pool was cleared exactly once.
|
100
|
+
- name: assertEventCount
|
101
|
+
object: testRunner
|
102
|
+
arguments:
|
103
|
+
event: ServerMarkedUnknownEvent
|
104
|
+
count: 1
|
105
|
+
- name: assertEventCount
|
106
|
+
object: testRunner
|
107
|
+
arguments:
|
108
|
+
event: PoolClearedEvent
|
109
|
+
count: 1
|
110
|
+
|
111
|
+
# Order of operations is non-deterministic so we cannot check events.
|
112
|
+
outcome:
|
113
|
+
collection:
|
114
|
+
data:
|
115
|
+
- {_id: 1}
|
116
|
+
- {_id: 4}
|