mongo 2.14.1 → 2.15.0.alpha
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/README.md +4 -1
- data/Rakefile +8 -15
- data/lib/mongo/auth/aws/conversation.rb +1 -4
- data/lib/mongo/auth/base.rb +13 -7
- data/lib/mongo/auth/conversation_base.rb +32 -0
- data/lib/mongo/auth/cr/conversation.rb +6 -29
- data/lib/mongo/auth/gssapi/conversation.rb +4 -15
- data/lib/mongo/auth/ldap/conversation.rb +3 -14
- data/lib/mongo/auth/sasl_conversation_base.rb +1 -13
- data/lib/mongo/auth/scram_conversation_base.rb +7 -34
- data/lib/mongo/auth/user/view.rb +16 -9
- data/lib/mongo/auth/x509/conversation.rb +4 -25
- data/lib/mongo/bulk_write.rb +21 -18
- data/lib/mongo/client.rb +82 -6
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -2
- data/lib/mongo/cluster.rb +19 -2
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +7 -17
- data/lib/mongo/collection/view/map_reduce.rb +2 -2
- data/lib/mongo/collection/view/readable.rb +42 -20
- data/lib/mongo/collection/view/writable.rb +14 -14
- data/lib/mongo/collection.rb +6 -6
- data/lib/mongo/cursor.rb +2 -12
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/database.rb +8 -3
- data/lib/mongo/error/bulk_write_error.rb +17 -3
- data/lib/mongo/error/internal_driver_error.rb +22 -0
- data/lib/mongo/error/operation_failure.rb +21 -2
- data/lib/mongo/error/parser.rb +65 -12
- data/lib/mongo/error/server_api_conflict.rb +23 -0
- data/lib/mongo/error/server_api_not_supported.rb +24 -0
- data/lib/mongo/error/unmet_dependency.rb +21 -0
- data/lib/mongo/error.rb +9 -1
- data/lib/mongo/index/view.rb +21 -11
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +27 -16
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +26 -15
- data/lib/mongo/monitoring.rb +13 -4
- data/lib/mongo/operation/collections_info/command.rb +2 -2
- data/lib/mongo/operation/collections_info.rb +18 -1
- data/lib/mongo/operation/context.rb +99 -0
- data/lib/mongo/operation/indexes.rb +15 -1
- data/lib/mongo/operation/insert/command.rb +2 -2
- data/lib/mongo/operation/insert/legacy.rb +2 -2
- data/lib/mongo/operation/insert/op_msg.rb +2 -2
- data/lib/mongo/operation/list_collections/result.rb +4 -1
- data/lib/mongo/operation/parallel_scan/command.rb +2 -1
- data/lib/mongo/operation/result.rb +2 -0
- data/lib/mongo/operation/shared/executable.rb +24 -14
- data/lib/mongo/operation/shared/executable_no_validate.rb +2 -2
- data/lib/mongo/operation/shared/op_msg_or_command.rb +1 -7
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +1 -7
- data/lib/mongo/operation/shared/polymorphic_operation.rb +39 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +36 -38
- data/lib/mongo/operation/shared/response_handling.rb +23 -23
- data/lib/mongo/operation/shared/sessions_supported.rb +15 -5
- data/lib/mongo/operation/shared/write.rb +8 -18
- data/lib/mongo/operation.rb +2 -2
- data/lib/mongo/protocol/compressed.rb +51 -5
- data/lib/mongo/protocol/message.rb +20 -2
- data/lib/mongo/protocol/msg.rb +38 -13
- data/lib/mongo/protocol/query.rb +11 -11
- data/lib/mongo/query_cache.rb +30 -0
- data/lib/mongo/retryable.rb +1 -1
- data/lib/mongo/server/app_metadata.rb +52 -18
- data/lib/mongo/server/connection.rb +5 -0
- data/lib/mongo/server/connection_base.rb +13 -10
- data/lib/mongo/server/connection_pool.rb +6 -2
- data/lib/mongo/server/description/features.rb +9 -8
- data/lib/mongo/server/description.rb +4 -0
- data/lib/mongo/server/monitor/app_metadata.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +9 -10
- data/lib/mongo/server/monitor.rb +20 -1
- data/lib/mongo/server/pending_connection.rb +24 -6
- data/lib/mongo/server/push_monitor.rb +11 -1
- data/lib/mongo/server.rb +7 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
- data/lib/mongo/session/session_pool.rb +4 -2
- data/lib/mongo/session.rb +2 -2
- data/lib/mongo/socket/ssl.rb +8 -0
- data/lib/mongo/socket.rb +29 -4
- data/lib/mongo/uri/options_mapper.rb +38 -0
- data/lib/mongo/utils.rb +15 -0
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo.rb +23 -0
- data/spec/README.md +24 -1
- data/spec/integration/auth_spec.rb +25 -15
- data/spec/integration/bulk_write_error_message_spec.rb +41 -0
- data/spec/integration/change_stream_spec.rb +4 -4
- data/spec/integration/command_monitoring_spec.rb +2 -2
- data/spec/integration/connection_spec.rb +2 -0
- data/spec/integration/docs_examples_spec.rb +8 -1
- data/spec/integration/fork_reconnect_spec.rb +4 -1
- data/spec/integration/ocsp_verifier_spec.rb +13 -7
- data/spec/integration/operation_failure_code_spec.rb +1 -1
- data/spec/integration/operation_failure_message_spec.rb +90 -0
- data/spec/integration/query_cache_spec.rb +0 -45
- data/spec/integration/reconnect_spec.rb +1 -1
- data/spec/integration/snappy_compression_spec.rb +25 -0
- data/spec/integration/srv_monitoring_spec.rb +1 -1
- data/spec/integration/transactions_examples_spec.rb +6 -0
- data/spec/integration/zlib_compression_spec.rb +1 -1
- data/spec/integration/zstd_compression_spec.rb +26 -0
- data/spec/lite_spec_helper.rb +7 -1
- data/spec/mongo/address_spec.rb +15 -11
- data/spec/mongo/auth/ldap/conversation_spec.rb +1 -1
- data/spec/mongo/auth/ldap_spec.rb +5 -1
- data/spec/mongo/auth/scram_negotiation_spec.rb +1 -1
- data/spec/mongo/auth/scram_spec.rb +1 -1
- data/spec/mongo/auth/x509/conversation_spec.rb +3 -3
- data/spec/mongo/client_construction_spec.rb +207 -33
- data/spec/mongo/client_spec.rb +17 -0
- data/spec/mongo/cluster_spec.rb +1 -0
- data/spec/mongo/collection/view/explainable_spec.rb +1 -1
- data/spec/mongo/collection/view/readable_spec.rb +33 -19
- data/spec/mongo/collection_crud_spec.rb +4357 -0
- data/spec/mongo/collection_ddl_spec.rb +534 -0
- data/spec/mongo/collection_spec.rb +5 -4859
- data/spec/mongo/database_spec.rb +66 -4
- data/spec/mongo/error/bulk_write_error_spec.rb +3 -3
- data/spec/mongo/error/parser_spec.rb +37 -6
- data/spec/mongo/index/view_spec.rb +4 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +1 -1
- data/spec/mongo/operation/aggregate_spec.rb +2 -1
- data/spec/mongo/operation/collections_info_spec.rb +4 -1
- data/spec/mongo/operation/command_spec.rb +6 -3
- data/spec/mongo/operation/create_index_spec.rb +6 -3
- data/spec/mongo/operation/create_user_spec.rb +6 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +9 -6
- data/spec/mongo/operation/delete_spec.rb +11 -7
- data/spec/mongo/operation/drop_index_spec.rb +6 -2
- data/spec/mongo/operation/find/legacy_spec.rb +3 -1
- data/spec/mongo/operation/get_more_spec.rb +3 -1
- data/spec/mongo/operation/indexes_spec.rb +5 -1
- data/spec/mongo/operation/insert/bulk_spec.rb +10 -7
- data/spec/mongo/operation/insert_spec.rb +15 -12
- data/spec/mongo/operation/map_reduce_spec.rb +5 -2
- data/spec/mongo/operation/read_preference_legacy_spec.rb +19 -9
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +3 -3
- data/spec/mongo/operation/remove_user_spec.rb +6 -3
- data/spec/mongo/operation/result_spec.rb +1 -1
- data/spec/mongo/operation/update/bulk_spec.rb +9 -6
- data/spec/mongo/operation/update_spec.rb +10 -7
- data/spec/mongo/operation/update_user_spec.rb +4 -1
- data/spec/mongo/protocol/compressed_spec.rb +26 -12
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/retryable_spec.rb +3 -2
- data/spec/mongo/server/app_metadata_shared.rb +7 -33
- data/spec/mongo/server/app_metadata_spec.rb +2 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +3 -1
- data/spec/mongo/server/connection_pool_spec.rb +1 -1
- data/spec/mongo/server/connection_spec.rb +24 -17
- data/spec/mongo/server/monitor/connection_spec.rb +17 -7
- data/spec/mongo/server/monitor_spec.rb +9 -1
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
- data/spec/mongo/server_spec.rb +15 -2
- data/spec/mongo/socket/ssl_spec.rb +40 -0
- data/spec/mongo/socket_spec.rb +2 -2
- data/spec/mongo/tls_context_hooks_spec.rb +37 -0
- data/spec/runners/connection_string.rb +0 -4
- data/spec/runners/crud/requirement.rb +40 -3
- data/spec/runners/crud/verifier.rb +8 -0
- data/spec/runners/transactions/operation.rb +1 -1
- data/spec/runners/transactions/test.rb +1 -0
- data/spec/runners/unified/assertions.rb +249 -0
- data/spec/runners/unified/change_stream_operations.rb +26 -0
- data/spec/runners/unified/crud_operations.rb +199 -0
- data/spec/runners/unified/ddl_operations.rb +96 -0
- data/spec/runners/unified/entity_map.rb +39 -0
- data/spec/runners/unified/error.rb +25 -0
- data/spec/runners/unified/event_subscriber.rb +91 -0
- data/spec/runners/unified/exceptions.rb +21 -0
- data/spec/runners/unified/grid_fs_operations.rb +55 -0
- data/spec/runners/unified/support_operations.rb +250 -0
- data/spec/runners/unified/test.rb +393 -0
- data/spec/runners/unified/test_group.rb +28 -0
- data/spec/runners/unified/using_hash.rb +31 -0
- data/spec/runners/unified.rb +96 -0
- data/spec/shared/lib/mrss/cluster_config.rb +0 -3
- data/spec/shared/lib/mrss/docker_runner.rb +0 -3
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -16
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -3
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -3
- data/spec/shared/shlib/server.sh +1 -1
- data/spec/spec_helper.rb +4 -1
- data/spec/spec_tests/crud_unified_spec.rb +10 -0
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
- data/spec/spec_tests/data/crud_unified/estimatedDocumentCount.yml +267 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-4.9.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount.yml → estimatedDocumentCount-pre4.9.yml} +2 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +146 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount-serverErrors.yml → estimatedDocumentCount-serverErrors-pre4.9.yml} +2 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +1 -1
- data/spec/spec_tests/data/unified/valid-fail/operation-failure.yml +31 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-change-streams.yml +220 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-command-monitoring.yml +102 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +184 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-gridfs.yml +155 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-reads.yml +193 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +210 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +215 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +235 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +169 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +170 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +1 -1
- data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +416 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +409 -0
- data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +67 -0
- data/spec/spec_tests/data/versioned_api/test-commands-deprecation-errors.yml +47 -0
- data/spec/spec_tests/data/versioned_api/test-commands-strict-mode.yml +44 -0
- data/spec/spec_tests/data/versioned_api/transaction-handling.yml +180 -0
- data/spec/spec_tests/unified_spec.rb +15 -0
- data/spec/spec_tests/uri_options_spec.rb +16 -0
- data/spec/spec_tests/versioned_api_spec.rb +10 -0
- data/spec/support/client_registry.rb +4 -8
- data/spec/support/client_registry_macros.rb +4 -4
- data/spec/support/common_shortcuts.rb +15 -1
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +42 -11
- data/spec/support/utils.rb +64 -3
- data.tar.gz.sig +0 -0
- metadata +1005 -915
- metadata.gz.sig +0 -0
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +0 -58
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +0 -47
- data/spec/integration/secondary_reads_spec.rb +0 -102
- data/spec/support/cluster_config.rb +0 -207
@@ -0,0 +1,193 @@
|
|
1
|
+
description: "poc-retryable-reads"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
runOnRequirements:
|
6
|
+
- minServerVersion: "4.0"
|
7
|
+
topologies: [ single, replicaset ]
|
8
|
+
- minServerVersion: "4.1.7"
|
9
|
+
topologies: [ sharded ]
|
10
|
+
|
11
|
+
createEntities:
|
12
|
+
- client:
|
13
|
+
id: &client0 client0
|
14
|
+
useMultipleMongoses: false
|
15
|
+
observeEvents: [ commandStartedEvent ]
|
16
|
+
- client:
|
17
|
+
id: &client1 client1
|
18
|
+
uriOptions: { retryReads: false }
|
19
|
+
useMultipleMongoses: false
|
20
|
+
observeEvents: [ commandStartedEvent ]
|
21
|
+
- database:
|
22
|
+
id: &database0 database0
|
23
|
+
client: *client0
|
24
|
+
databaseName: &databaseName retryable-reads-tests
|
25
|
+
- database:
|
26
|
+
id: &database1 database1
|
27
|
+
client: *client1
|
28
|
+
databaseName: *databaseName
|
29
|
+
- collection:
|
30
|
+
id: &collection0 collection0
|
31
|
+
database: *database0
|
32
|
+
collectionName: &collectionName coll
|
33
|
+
- collection:
|
34
|
+
id: &collection1 collection1
|
35
|
+
database: *database1
|
36
|
+
collectionName: *collectionName
|
37
|
+
|
38
|
+
initialData:
|
39
|
+
- collectionName: *collectionName
|
40
|
+
databaseName: *databaseName
|
41
|
+
documents:
|
42
|
+
- {_id: 1, x: 11}
|
43
|
+
- {_id: 2, x: 22}
|
44
|
+
- {_id: 3, x: 33}
|
45
|
+
|
46
|
+
tests:
|
47
|
+
- description: "Aggregate succeeds after InterruptedAtShutdown"
|
48
|
+
operations:
|
49
|
+
- name: failPoint
|
50
|
+
object: testRunner
|
51
|
+
arguments:
|
52
|
+
client: *client0
|
53
|
+
failPoint:
|
54
|
+
configureFailPoint: failCommand
|
55
|
+
mode: { times: 1 }
|
56
|
+
data:
|
57
|
+
failCommands: [ aggregate ]
|
58
|
+
errorCode: 11600 # InterruptedAtShutdown
|
59
|
+
- name: aggregate
|
60
|
+
object: *collection0
|
61
|
+
arguments:
|
62
|
+
pipeline: &pipeline
|
63
|
+
- $match: { _id: { $gt: 1 } }
|
64
|
+
- $sort: { x: 1 }
|
65
|
+
expectResult:
|
66
|
+
- { _id: 2, x: 22 }
|
67
|
+
- { _id: 3, x: 33 }
|
68
|
+
expectEvents:
|
69
|
+
- client: *client0
|
70
|
+
events:
|
71
|
+
- commandStartedEvent:
|
72
|
+
command:
|
73
|
+
aggregate: *collectionName
|
74
|
+
pipeline: *pipeline
|
75
|
+
databaseName: *databaseName
|
76
|
+
- commandStartedEvent:
|
77
|
+
command:
|
78
|
+
aggregate: *collectionName
|
79
|
+
pipeline: *pipeline
|
80
|
+
databaseName: *databaseName
|
81
|
+
|
82
|
+
- description: "Find succeeds on second attempt"
|
83
|
+
operations:
|
84
|
+
- name: failPoint
|
85
|
+
object: testRunner
|
86
|
+
arguments:
|
87
|
+
client: *client0
|
88
|
+
failPoint:
|
89
|
+
configureFailPoint: failCommand
|
90
|
+
mode: { times: 1 }
|
91
|
+
data:
|
92
|
+
failCommands: [ find ]
|
93
|
+
closeConnection: true
|
94
|
+
# Find options and expected result changed to use common initialData
|
95
|
+
- name: find
|
96
|
+
object: collection0
|
97
|
+
arguments:
|
98
|
+
filter: {}
|
99
|
+
sort: { _id: 1 }
|
100
|
+
limit: 2
|
101
|
+
expectResult:
|
102
|
+
- { _id: 1, x: 11 }
|
103
|
+
- { _id: 2, x: 22 }
|
104
|
+
expectEvents:
|
105
|
+
- client: *client0
|
106
|
+
events:
|
107
|
+
- &findAttempt
|
108
|
+
commandStartedEvent:
|
109
|
+
command:
|
110
|
+
find: *collectionName
|
111
|
+
filter: {}
|
112
|
+
sort: { _id: 1 }
|
113
|
+
limit: 2
|
114
|
+
databaseName: *databaseName
|
115
|
+
- *findAttempt
|
116
|
+
|
117
|
+
- description: "Find fails on first attempt"
|
118
|
+
operations:
|
119
|
+
- name: failPoint
|
120
|
+
object: testRunner
|
121
|
+
arguments:
|
122
|
+
client: *client0
|
123
|
+
failPoint:
|
124
|
+
configureFailPoint: failCommand
|
125
|
+
mode: { times: 1 }
|
126
|
+
data:
|
127
|
+
failCommands: [ find ]
|
128
|
+
closeConnection: true
|
129
|
+
- name: find
|
130
|
+
object: collection1 # client uses retryReads=false
|
131
|
+
arguments:
|
132
|
+
filter: {}
|
133
|
+
# Other arguments in the original test are not relevant
|
134
|
+
expectError: { isError: true }
|
135
|
+
expectEvents:
|
136
|
+
- client: *client1
|
137
|
+
events:
|
138
|
+
- commandStartedEvent:
|
139
|
+
command:
|
140
|
+
find: *collectionName
|
141
|
+
filter: {}
|
142
|
+
databaseName: *databaseName
|
143
|
+
|
144
|
+
- description: "Find fails on second attempt"
|
145
|
+
operations:
|
146
|
+
- name: failPoint
|
147
|
+
object: testRunner
|
148
|
+
arguments:
|
149
|
+
client: *client0
|
150
|
+
failPoint:
|
151
|
+
configureFailPoint: failCommand
|
152
|
+
mode: { times: 2 }
|
153
|
+
data:
|
154
|
+
failCommands: [ find ]
|
155
|
+
closeConnection: true
|
156
|
+
- name: find
|
157
|
+
object: collection0
|
158
|
+
arguments:
|
159
|
+
filter: {}
|
160
|
+
# Other arguments in the original test are not relevant
|
161
|
+
expectError: { isError: true }
|
162
|
+
expectEvents:
|
163
|
+
- client: *client0
|
164
|
+
events:
|
165
|
+
- &findAttempt
|
166
|
+
commandStartedEvent:
|
167
|
+
command:
|
168
|
+
find: *collectionName
|
169
|
+
filter: {}
|
170
|
+
databaseName: *databaseName
|
171
|
+
- *findAttempt
|
172
|
+
|
173
|
+
- description: "ListDatabases succeeds on second attempt"
|
174
|
+
operations:
|
175
|
+
- name: failPoint
|
176
|
+
object: testRunner
|
177
|
+
arguments:
|
178
|
+
client: *client0
|
179
|
+
failPoint:
|
180
|
+
configureFailPoint: failCommand
|
181
|
+
mode: { times: 1 }
|
182
|
+
data:
|
183
|
+
failCommands: [ listDatabases ]
|
184
|
+
closeConnection: true
|
185
|
+
- name: listDatabases
|
186
|
+
object: *client0
|
187
|
+
expectEvents:
|
188
|
+
- client: *client0
|
189
|
+
events:
|
190
|
+
- commandStartedEvent:
|
191
|
+
command: { listDatabases: 1 }
|
192
|
+
- commandStartedEvent:
|
193
|
+
command: { listDatabases: 1 }
|
@@ -0,0 +1,210 @@
|
|
1
|
+
description: "poc-retryable-writes"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
runOnRequirements:
|
6
|
+
- minServerVersion: "3.6"
|
7
|
+
topologies: [ replicaset ]
|
8
|
+
|
9
|
+
createEntities:
|
10
|
+
- client:
|
11
|
+
id: &client0 client0
|
12
|
+
useMultipleMongoses: false
|
13
|
+
observeEvents: [ commandStartedEvent ]
|
14
|
+
- client:
|
15
|
+
id: &client1 client1
|
16
|
+
uriOptions: { retryWrites: false }
|
17
|
+
useMultipleMongoses: false
|
18
|
+
observeEvents: [ commandStartedEvent ]
|
19
|
+
- database:
|
20
|
+
id: &database0 database0
|
21
|
+
client: *client0
|
22
|
+
databaseName: &databaseName retryable-writes-tests
|
23
|
+
- database:
|
24
|
+
id: &database1 database1
|
25
|
+
client: *client1
|
26
|
+
databaseName: *databaseName
|
27
|
+
- collection:
|
28
|
+
id: &collection0 collection0
|
29
|
+
database: *database0
|
30
|
+
collectionName: &collectionName coll
|
31
|
+
- collection:
|
32
|
+
id: &collection1 collection1
|
33
|
+
database: *database1
|
34
|
+
collectionName: *collectionName
|
35
|
+
|
36
|
+
initialData:
|
37
|
+
- collectionName: *collectionName
|
38
|
+
databaseName: *databaseName
|
39
|
+
documents:
|
40
|
+
- { _id: 1, x: 11 }
|
41
|
+
- { _id: 2, x: 22 }
|
42
|
+
|
43
|
+
tests:
|
44
|
+
- description: "FindOneAndUpdate is committed on first attempt"
|
45
|
+
operations:
|
46
|
+
- name: failPoint
|
47
|
+
object: testRunner
|
48
|
+
arguments:
|
49
|
+
client: *client0
|
50
|
+
failPoint:
|
51
|
+
configureFailPoint: onPrimaryTransactionalWrite
|
52
|
+
mode: { times: 1 }
|
53
|
+
- name: findOneAndUpdate
|
54
|
+
object: *collection0
|
55
|
+
arguments:
|
56
|
+
filter: { _id: 1 }
|
57
|
+
update: { $inc: { x : 1 } }
|
58
|
+
returnDocument: Before
|
59
|
+
expectResult: { _id: 1, x: 11 }
|
60
|
+
outcome:
|
61
|
+
- collectionName: *collectionName
|
62
|
+
databaseName: *databaseName
|
63
|
+
documents:
|
64
|
+
- { _id: 1, x: 12 }
|
65
|
+
- { _id: 2, x: 22 }
|
66
|
+
|
67
|
+
- description: "FindOneAndUpdate is not committed on first attempt"
|
68
|
+
operations:
|
69
|
+
- name: failPoint
|
70
|
+
object: testRunner
|
71
|
+
arguments:
|
72
|
+
client: *client0
|
73
|
+
failPoint:
|
74
|
+
configureFailPoint: onPrimaryTransactionalWrite
|
75
|
+
mode: { times: 1 }
|
76
|
+
data: { failBeforeCommitExceptionCode: 1 }
|
77
|
+
- name: findOneAndUpdate
|
78
|
+
object: *collection0
|
79
|
+
arguments:
|
80
|
+
filter: { _id: 1 }
|
81
|
+
update: { $inc: { x : 1 } }
|
82
|
+
returnDocument: Before
|
83
|
+
expectResult: { _id: 1, x: 11 }
|
84
|
+
outcome:
|
85
|
+
- collectionName: *collectionName
|
86
|
+
databaseName: *databaseName
|
87
|
+
documents:
|
88
|
+
- { _id: 1, x: 12 }
|
89
|
+
- { _id: 2, x: 22 }
|
90
|
+
|
91
|
+
- description: "FindOneAndUpdate is never committed"
|
92
|
+
operations:
|
93
|
+
- name: failPoint
|
94
|
+
object: testRunner
|
95
|
+
arguments:
|
96
|
+
client: *client0
|
97
|
+
failPoint:
|
98
|
+
configureFailPoint: onPrimaryTransactionalWrite
|
99
|
+
mode: { times: 2 }
|
100
|
+
data: { failBeforeCommitExceptionCode: 1 }
|
101
|
+
- name: findOneAndUpdate
|
102
|
+
object: *collection0
|
103
|
+
arguments:
|
104
|
+
filter: { _id: 1 }
|
105
|
+
update: { $inc: { x : 1 } }
|
106
|
+
returnDocument: Before
|
107
|
+
expectError: { isError: true }
|
108
|
+
outcome:
|
109
|
+
- collectionName: *collectionName
|
110
|
+
databaseName: *databaseName
|
111
|
+
documents:
|
112
|
+
- { _id: 1, x: 11 }
|
113
|
+
- { _id: 2, x: 22 }
|
114
|
+
|
115
|
+
- description: "InsertMany succeeds after PrimarySteppedDown"
|
116
|
+
runOnRequirements: &failCommand_requirements
|
117
|
+
- minServerVersion: "4.0"
|
118
|
+
topologies: [ replicaset ]
|
119
|
+
- minServerVersion: "4.1.7"
|
120
|
+
# Original test uses "sharded", but retryable writes requires a sharded
|
121
|
+
# cluster backed by replica sets
|
122
|
+
topologies: [ sharded-replicaset ]
|
123
|
+
operations:
|
124
|
+
- name: failPoint
|
125
|
+
object: testRunner
|
126
|
+
arguments:
|
127
|
+
client: *client0
|
128
|
+
failPoint:
|
129
|
+
configureFailPoint: failCommand
|
130
|
+
mode: { times: 1 }
|
131
|
+
data:
|
132
|
+
failCommands: [ insert ]
|
133
|
+
errorCode: 189 # PrimarySteppedDown
|
134
|
+
errorLabels: [ RetryableWriteError ]
|
135
|
+
- name: insertMany
|
136
|
+
object: *collection0
|
137
|
+
arguments:
|
138
|
+
documents:
|
139
|
+
# Documents are modified from original test for "initialData"
|
140
|
+
- { _id: 3, x: 33 }
|
141
|
+
- { _id: 4, x: 44 }
|
142
|
+
ordered: true
|
143
|
+
expectResult:
|
144
|
+
insertedCount: { $$unsetOrMatches: 2 }
|
145
|
+
insertedIds: { $$unsetOrMatches: { 0: 3, 1: 4 } }
|
146
|
+
outcome:
|
147
|
+
- collectionName: *collectionName
|
148
|
+
databaseName: *databaseName
|
149
|
+
documents:
|
150
|
+
- { _id: 1, x: 11 }
|
151
|
+
- { _id: 2, x: 22 }
|
152
|
+
- { _id: 3, x: 33 }
|
153
|
+
- { _id: 4, x: 44 }
|
154
|
+
|
155
|
+
- description: "InsertOne fails after connection failure when retryWrites option is false"
|
156
|
+
runOnRequirements: *failCommand_requirements
|
157
|
+
operations:
|
158
|
+
- name: failPoint
|
159
|
+
object: testRunner
|
160
|
+
arguments:
|
161
|
+
client: *client1
|
162
|
+
failPoint:
|
163
|
+
configureFailPoint: failCommand
|
164
|
+
mode: { times: 1 }
|
165
|
+
data:
|
166
|
+
failCommands: [ insert ]
|
167
|
+
closeConnection: true
|
168
|
+
- name: insertOne
|
169
|
+
object: *collection1
|
170
|
+
arguments:
|
171
|
+
document: { _id: 3, x: 33 }
|
172
|
+
expectError:
|
173
|
+
# If retryWrites is false, the driver should not add the
|
174
|
+
# RetryableWriteError label to the error.
|
175
|
+
errorLabelsOmit: [ RetryableWriteError ]
|
176
|
+
outcome:
|
177
|
+
- collectionName: *collectionName
|
178
|
+
databaseName: *databaseName
|
179
|
+
documents:
|
180
|
+
- { _id: 1, x: 11 }
|
181
|
+
- { _id: 2, x: 22 }
|
182
|
+
|
183
|
+
- description: "InsertOne fails after multiple retryable writeConcernErrors"
|
184
|
+
runOnRequirements: *failCommand_requirements
|
185
|
+
operations:
|
186
|
+
- name: failPoint
|
187
|
+
object: testRunner
|
188
|
+
arguments:
|
189
|
+
client: *client0
|
190
|
+
failPoint:
|
191
|
+
configureFailPoint: failCommand
|
192
|
+
mode: { times: 2 }
|
193
|
+
data:
|
194
|
+
failCommands: [ insert ]
|
195
|
+
writeConcernError:
|
196
|
+
code: 91 # ShutdownInProgress
|
197
|
+
errmsg: "Replication is being shut down"
|
198
|
+
- name: insertOne
|
199
|
+
object: *collection0
|
200
|
+
arguments:
|
201
|
+
document: { _id: 3, x: 33 }
|
202
|
+
expectError:
|
203
|
+
errorLabelsContain: [ RetryableWriteError ]
|
204
|
+
outcome:
|
205
|
+
- collectionName: *collectionName
|
206
|
+
databaseName: *databaseName
|
207
|
+
documents:
|
208
|
+
- { _id: 1, x: 11 }
|
209
|
+
- { _id: 2, x: 22 }
|
210
|
+
- { _id: 3, x: 33 } # The write was still applied
|
@@ -0,0 +1,215 @@
|
|
1
|
+
description: "poc-sessions"
|
2
|
+
|
3
|
+
schemaVersion: "1.0"
|
4
|
+
|
5
|
+
runOnRequirements:
|
6
|
+
- minServerVersion: "3.6.0"
|
7
|
+
|
8
|
+
createEntities:
|
9
|
+
- client:
|
10
|
+
id: &client0 client0
|
11
|
+
useMultipleMongoses: false
|
12
|
+
observeEvents: [ commandStartedEvent ]
|
13
|
+
- database:
|
14
|
+
id: &database0 database0
|
15
|
+
client: *client0
|
16
|
+
databaseName: &database0Name session-tests
|
17
|
+
- collection:
|
18
|
+
id: &collection0 collection0
|
19
|
+
database: *database0
|
20
|
+
collectionName: &collection0Name test
|
21
|
+
- session:
|
22
|
+
id: &session0 session0
|
23
|
+
client: *client0
|
24
|
+
|
25
|
+
initialData:
|
26
|
+
- collectionName: *collection0Name
|
27
|
+
databaseName: *database0Name
|
28
|
+
documents:
|
29
|
+
- { _id: 1 }
|
30
|
+
|
31
|
+
tests:
|
32
|
+
- description: "Server supports explicit sessions"
|
33
|
+
operations:
|
34
|
+
- name: assertSessionNotDirty
|
35
|
+
object: testRunner
|
36
|
+
arguments:
|
37
|
+
session: *session0
|
38
|
+
- name: insertOne
|
39
|
+
object: *collection0
|
40
|
+
arguments:
|
41
|
+
session: *session0
|
42
|
+
document: { _id: 2 }
|
43
|
+
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
|
44
|
+
- name: assertSessionNotDirty
|
45
|
+
object: testRunner
|
46
|
+
arguments:
|
47
|
+
session: *session0
|
48
|
+
- name: endSession
|
49
|
+
object: *session0
|
50
|
+
- &find_with_implicit_session
|
51
|
+
name: find
|
52
|
+
object: *collection0
|
53
|
+
arguments:
|
54
|
+
filter: { _id: -1 }
|
55
|
+
expectResult: []
|
56
|
+
- name: assertSameLsidOnLastTwoCommands
|
57
|
+
object: testRunner
|
58
|
+
arguments:
|
59
|
+
client: *client0
|
60
|
+
expectEvents:
|
61
|
+
- client: *client0
|
62
|
+
events:
|
63
|
+
- commandStartedEvent:
|
64
|
+
command:
|
65
|
+
insert: *collection0Name
|
66
|
+
documents: [ { _id: 2 } ]
|
67
|
+
ordered: true
|
68
|
+
lsid: { $$sessionLsid: *session0 }
|
69
|
+
commandName: insert
|
70
|
+
databaseName: *database0Name
|
71
|
+
- commandStartedEvent:
|
72
|
+
command:
|
73
|
+
find: *collection0Name
|
74
|
+
filter: { _id: -1 }
|
75
|
+
lsid: { $$sessionLsid: *session0 }
|
76
|
+
commandName: find
|
77
|
+
databaseName: *database0Name
|
78
|
+
outcome:
|
79
|
+
- collectionName: *collection0Name
|
80
|
+
databaseName: *database0Name
|
81
|
+
documents:
|
82
|
+
- { _id: 1 }
|
83
|
+
- { _id: 2 }
|
84
|
+
|
85
|
+
- description: "Server supports implicit sessions"
|
86
|
+
operations:
|
87
|
+
- name: insertOne
|
88
|
+
object: *collection0
|
89
|
+
arguments:
|
90
|
+
document: { _id: 2 }
|
91
|
+
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
|
92
|
+
- *find_with_implicit_session
|
93
|
+
- name: assertSameLsidOnLastTwoCommands
|
94
|
+
object: testRunner
|
95
|
+
arguments:
|
96
|
+
client: *client0
|
97
|
+
expectEvents:
|
98
|
+
- client: *client0
|
99
|
+
events:
|
100
|
+
- commandStartedEvent:
|
101
|
+
command:
|
102
|
+
insert: *collection0Name
|
103
|
+
documents:
|
104
|
+
- { _id: 2 }
|
105
|
+
ordered: true
|
106
|
+
# Original test did not include any assertion, but we can use
|
107
|
+
# $$type to expect an arbitrary lsid document
|
108
|
+
lsid: { $$type: object }
|
109
|
+
commandName: insert
|
110
|
+
databaseName: *database0Name
|
111
|
+
- commandStartedEvent:
|
112
|
+
command:
|
113
|
+
find: *collection0Name
|
114
|
+
filter: { _id: -1 }
|
115
|
+
lsid: { $$type: object }
|
116
|
+
commandName: find
|
117
|
+
databaseName: *database0Name
|
118
|
+
outcome:
|
119
|
+
- collectionName: *collection0Name
|
120
|
+
databaseName: *database0Name
|
121
|
+
documents:
|
122
|
+
- { _id: 1 }
|
123
|
+
- { _id: 2 }
|
124
|
+
|
125
|
+
- description: "Dirty explicit session is discarded"
|
126
|
+
skipReason: RUBY-1813
|
127
|
+
# Original test specified retryWrites=true, but that is now the default.
|
128
|
+
# Retryable writes will require a sharded-replicaset, though.
|
129
|
+
runOnRequirements:
|
130
|
+
- minServerVersion: "4.0"
|
131
|
+
topologies: [ replicaset ]
|
132
|
+
- minServerVersion: "4.1.8"
|
133
|
+
topologies: [ sharded-replicaset ]
|
134
|
+
operations:
|
135
|
+
- name: failPoint
|
136
|
+
object: testRunner
|
137
|
+
arguments:
|
138
|
+
client: *client0
|
139
|
+
failPoint:
|
140
|
+
configureFailPoint: failCommand
|
141
|
+
mode: { times: 1 }
|
142
|
+
data:
|
143
|
+
failCommands: [ insert ]
|
144
|
+
closeConnection: true
|
145
|
+
- name: assertSessionNotDirty
|
146
|
+
object: testRunner
|
147
|
+
arguments:
|
148
|
+
session: *session0
|
149
|
+
- name: insertOne
|
150
|
+
object: *collection0
|
151
|
+
arguments:
|
152
|
+
session: *session0
|
153
|
+
document: { _id: 2 }
|
154
|
+
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
|
155
|
+
- name: assertSessionDirty
|
156
|
+
object: testRunner
|
157
|
+
arguments:
|
158
|
+
session: *session0
|
159
|
+
- name: insertOne
|
160
|
+
object: *collection0
|
161
|
+
arguments:
|
162
|
+
session: *session0
|
163
|
+
document: { _id: 3 }
|
164
|
+
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } }
|
165
|
+
- name: assertSessionDirty
|
166
|
+
object: testRunner
|
167
|
+
arguments:
|
168
|
+
session: *session0
|
169
|
+
- name: endSession
|
170
|
+
object: *session0
|
171
|
+
- *find_with_implicit_session
|
172
|
+
- name: assertDifferentLsidOnLastTwoCommands
|
173
|
+
object: testRunner
|
174
|
+
arguments:
|
175
|
+
client: *client0
|
176
|
+
expectEvents:
|
177
|
+
- client: *client0
|
178
|
+
events:
|
179
|
+
# ajv's YAML parser is unable to handle anchors on array elements, so
|
180
|
+
# we define an anchor on the commandStartedEvent object instead
|
181
|
+
- commandStartedEvent: &insert_attempt
|
182
|
+
command:
|
183
|
+
insert: *collection0Name
|
184
|
+
documents:
|
185
|
+
- { _id: 2 }
|
186
|
+
ordered: true
|
187
|
+
lsid: { $$sessionLsid: *session0 }
|
188
|
+
txnNumber: 1
|
189
|
+
commandName: insert
|
190
|
+
databaseName: *database0Name
|
191
|
+
- commandStartedEvent: *insert_attempt
|
192
|
+
- commandStartedEvent:
|
193
|
+
command:
|
194
|
+
insert: *collection0Name
|
195
|
+
documents:
|
196
|
+
- { _id: 3 }
|
197
|
+
ordered: true
|
198
|
+
lsid: { $$sessionLsid: *session0 }
|
199
|
+
txnNumber: 2
|
200
|
+
commandName: insert
|
201
|
+
databaseName: *database0Name
|
202
|
+
- commandStartedEvent:
|
203
|
+
command:
|
204
|
+
find: *collection0Name
|
205
|
+
filter: { _id: -1 }
|
206
|
+
lsid: { $$type: object }
|
207
|
+
commandName: find
|
208
|
+
databaseName: *database0Name
|
209
|
+
outcome:
|
210
|
+
- collectionName: *collection0Name
|
211
|
+
databaseName: *database0Name
|
212
|
+
documents:
|
213
|
+
- { _id: 1 }
|
214
|
+
- { _id: 2 }
|
215
|
+
- { _id: 3 }
|