mongo 2.10.5 → 2.11.0.rc0

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.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/lib/mongo.rb +2 -0
  6. data/lib/mongo/address.rb +4 -0
  7. data/lib/mongo/address/validator.rb +99 -0
  8. data/lib/mongo/auth.rb +7 -2
  9. data/lib/mongo/auth/user.rb +1 -7
  10. data/lib/mongo/background_thread.rb +135 -0
  11. data/lib/mongo/bulk_write/transformable.rb +3 -3
  12. data/lib/mongo/client.rb +74 -16
  13. data/lib/mongo/cluster.rb +193 -41
  14. data/lib/mongo/cluster/periodic_executor.rb +31 -43
  15. data/lib/mongo/cluster/sdam_flow.rb +26 -3
  16. data/lib/mongo/cluster/srv_monitor.rb +127 -0
  17. data/lib/mongo/collection/view/readable.rb +3 -5
  18. data/lib/mongo/collection/view/writable.rb +3 -3
  19. data/lib/mongo/cursor/builder/get_more_command.rb +1 -4
  20. data/lib/mongo/cursor/builder/kill_cursors_command.rb +5 -23
  21. data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
  22. data/lib/mongo/cursor/builder/op_kill_cursors.rb +5 -24
  23. data/lib/mongo/error.rb +1 -0
  24. data/lib/mongo/error/auth_error.rb +1 -1
  25. data/lib/mongo/error/connection_check_out_timeout.rb +7 -8
  26. data/lib/mongo/error/invalid_address.rb +24 -0
  27. data/lib/mongo/error/notable.rb +2 -2
  28. data/lib/mongo/error/operation_failure.rb +3 -3
  29. data/lib/mongo/error/pool_closed_error.rb +11 -4
  30. data/lib/mongo/event.rb +1 -1
  31. data/lib/mongo/grid/file.rb +0 -5
  32. data/lib/mongo/grid/file/chunk.rb +0 -2
  33. data/lib/mongo/grid/fs_bucket.rb +13 -15
  34. data/lib/mongo/grid/stream/write.rb +3 -9
  35. data/lib/mongo/loggable.rb +5 -1
  36. data/lib/mongo/monitoring.rb +1 -0
  37. data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +7 -0
  38. data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +11 -3
  39. data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +11 -3
  40. data/lib/mongo/monitoring/event/cmap/pool_closed.rb +11 -3
  41. data/lib/mongo/monitoring/event/cmap/pool_created.rb +12 -3
  42. data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +62 -0
  43. data/lib/mongo/operation/shared/executable.rb +5 -10
  44. data/lib/mongo/operation/shared/sessions_supported.rb +1 -5
  45. data/lib/mongo/protocol/get_more.rb +1 -2
  46. data/lib/mongo/protocol/kill_cursors.rb +13 -6
  47. data/lib/mongo/protocol/serializers.rb +4 -20
  48. data/lib/mongo/retryable.rb +9 -34
  49. data/lib/mongo/semaphore.rb +1 -1
  50. data/lib/mongo/server.rb +113 -42
  51. data/lib/mongo/server/connection.rb +12 -5
  52. data/lib/mongo/server/connection_pool.rb +250 -40
  53. data/lib/mongo/server/connection_pool/populator.rb +58 -0
  54. data/lib/mongo/server/description.rb +9 -2
  55. data/lib/mongo/server/monitor.rb +68 -93
  56. data/lib/mongo/server/monitor/connection.rb +2 -0
  57. data/lib/mongo/server_selector/selectable.rb +13 -5
  58. data/lib/mongo/session.rb +0 -13
  59. data/lib/mongo/srv.rb +17 -0
  60. data/lib/mongo/srv/monitor.rb +96 -0
  61. data/lib/mongo/srv/resolver.rb +130 -0
  62. data/lib/mongo/srv/result.rb +126 -0
  63. data/lib/mongo/srv/warning_result.rb +35 -0
  64. data/lib/mongo/uri.rb +45 -55
  65. data/lib/mongo/uri/srv_protocol.rb +89 -42
  66. data/lib/mongo/version.rb +1 -1
  67. data/mongo.gemspec +3 -4
  68. data/spec/README.md +6 -1
  69. data/spec/enterprise_auth/kerberos_spec.rb +7 -6
  70. data/spec/integration/change_stream_examples_spec.rb +0 -4
  71. data/spec/integration/client_construction_spec.rb +14 -2
  72. data/spec/integration/connect_single_rs_name_spec.rb +2 -2
  73. data/spec/integration/connection_pool_populator_spec.rb +296 -0
  74. data/spec/integration/connection_spec.rb +31 -22
  75. data/spec/integration/cursor_reaping_spec.rb +1 -2
  76. data/spec/integration/docs_examples_spec.rb +0 -4
  77. data/spec/integration/heartbeat_events_spec.rb +17 -15
  78. data/spec/integration/reconnect_spec.rb +144 -1
  79. data/spec/integration/retryable_writes_errors_spec.rb +0 -4
  80. data/spec/integration/retryable_writes_spec.rb +36 -36
  81. data/spec/integration/sdam_error_handling_spec.rb +31 -25
  82. data/spec/integration/sdam_events_spec.rb +2 -6
  83. data/spec/integration/server_monitor_spec.rb +28 -0
  84. data/spec/integration/server_selector_spec.rb +7 -5
  85. data/spec/integration/srv_monitoring_spec.rb +360 -0
  86. data/spec/integration/step_down_spec.rb +4 -6
  87. data/spec/lite_spec_helper.rb +22 -0
  88. data/spec/mongo/address/validator_spec.rb +51 -0
  89. data/spec/mongo/auth/cr_spec.rb +1 -29
  90. data/spec/mongo/auth/ldap_spec.rb +1 -29
  91. data/spec/mongo/auth/scram/conversation_spec.rb +0 -2
  92. data/spec/mongo/auth/scram/negotiation_spec.rb +1 -1
  93. data/spec/mongo/auth/scram_spec.rb +1 -29
  94. data/spec/mongo/auth/user/view_spec.rb +1 -36
  95. data/spec/mongo/auth/user_spec.rb +0 -12
  96. data/spec/mongo/auth/x509_spec.rb +1 -29
  97. data/spec/mongo/bulk_write_spec.rb +2 -2
  98. data/spec/mongo/client_construction_spec.rb +56 -15
  99. data/spec/mongo/client_spec.rb +31 -27
  100. data/spec/mongo/cluster/periodic_executor_spec.rb +16 -0
  101. data/spec/mongo/cluster/srv_monitor_spec.rb +214 -0
  102. data/spec/mongo/cluster/topology/replica_set_spec.rb +16 -11
  103. data/spec/mongo/cluster/topology/sharded_spec.rb +12 -9
  104. data/spec/mongo/cluster/topology/single_spec.rb +20 -11
  105. data/spec/mongo/cluster_spec.rb +45 -29
  106. data/spec/mongo/collection/view/map_reduce_spec.rb +14 -9
  107. data/spec/mongo/collection/view/readable_spec.rb +0 -16
  108. data/spec/mongo/collection_spec.rb +0 -44
  109. data/spec/mongo/cursor/builder/get_more_command_spec.rb +2 -4
  110. data/spec/mongo/cursor/builder/op_get_more_spec.rb +2 -4
  111. data/spec/mongo/cursor_spec.rb +27 -7
  112. data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +10 -3
  113. data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +10 -3
  114. data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +10 -3
  115. data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +10 -3
  116. data/spec/mongo/operation/delete/op_msg_spec.rb +17 -8
  117. data/spec/mongo/operation/insert/op_msg_spec.rb +50 -35
  118. data/spec/mongo/operation/update/op_msg_spec.rb +14 -7
  119. data/spec/mongo/retryable_spec.rb +52 -31
  120. data/spec/mongo/server/app_metadata_spec.rb +0 -8
  121. data/spec/mongo/server/connection_auth_spec.rb +5 -2
  122. data/spec/mongo/server/connection_pool/populator_spec.rb +101 -0
  123. data/spec/mongo/server/connection_pool_spec.rb +256 -107
  124. data/spec/mongo/server/connection_spec.rb +22 -33
  125. data/spec/mongo/server/description_spec.rb +42 -4
  126. data/spec/mongo/server/monitor/connection_spec.rb +22 -11
  127. data/spec/mongo/server/monitor_spec.rb +66 -107
  128. data/spec/mongo/server_spec.rb +82 -60
  129. data/spec/mongo/session/session_pool_spec.rb +1 -5
  130. data/spec/mongo/session_spec.rb +0 -4
  131. data/spec/mongo/socket/ssl_spec.rb +2 -2
  132. data/spec/mongo/srv/monitor_spec.rb +211 -0
  133. data/spec/mongo/srv/result_spec.rb +54 -0
  134. data/spec/mongo/uri/srv_protocol_spec.rb +30 -15
  135. data/spec/mongo/uri_spec.rb +125 -4
  136. data/spec/spec_helper.rb +6 -0
  137. data/spec/spec_tests/auth_spec.rb +39 -0
  138. data/spec/spec_tests/cmap_spec.rb +55 -8
  139. data/spec/spec_tests/connection_string_spec.rb +6 -31
  140. data/spec/spec_tests/data/auth/connection-string.yml +297 -0
  141. data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +4 -1
  142. data/spec/spec_tests/data/cmap/pool-create-with-options.yml +1 -0
  143. data/spec/spec_tests/data/command_monitoring/insertMany.yml +1 -1
  144. data/spec/spec_tests/data/connection_string/invalid-uris.yml +20 -0
  145. data/spec/spec_tests/data/connection_string/valid-auth.yml +16 -0
  146. data/spec/spec_tests/data/connection_string/valid-warnings.yml +26 -30
  147. data/spec/spec_tests/data/transactions/abort.yml +3 -3
  148. data/spec/spec_tests/data/transactions/error-labels.yml +3 -3
  149. data/spec/spec_tests/data/transactions_api/callback-retry.yml +3 -3
  150. data/spec/spec_tests/data/uri_options/auth-options.yml +1 -1
  151. data/spec/spec_tests/max_staleness_spec.rb +7 -2
  152. data/spec/spec_tests/retryable_reads_spec.rb +0 -31
  153. data/spec/spec_tests/sdam_monitoring_spec.rb +12 -12
  154. data/spec/spec_tests/sdam_spec.rb +4 -7
  155. data/spec/spec_tests/server_selection_spec.rb +6 -2
  156. data/spec/spec_tests/transactions_spec.rb +0 -2
  157. data/spec/spec_tests/uri_options_spec.rb +4 -2
  158. data/spec/stress/connection_pool_stress_spec.rb +203 -0
  159. data/spec/stress/connection_pool_timing_spec.rb +181 -0
  160. data/spec/support/auth.rb +113 -0
  161. data/spec/support/background_thread_registry.rb +63 -0
  162. data/spec/support/client_registry.rb +11 -2
  163. data/spec/support/cluster_config.rb +65 -46
  164. data/spec/support/cluster_tools.rb +2 -2
  165. data/spec/support/cmap.rb +13 -14
  166. data/spec/support/cmap/verifier.rb +4 -5
  167. data/spec/support/command_monitoring.rb +0 -5
  168. data/spec/support/common_shortcuts.rb +101 -1
  169. data/spec/support/constraints.rb +25 -0
  170. data/spec/support/dns.rb +13 -0
  171. data/spec/support/event_subscriber.rb +0 -7
  172. data/spec/support/json_ext_formatter.rb +5 -1
  173. data/spec/support/lite_constraints.rb +22 -6
  174. data/spec/support/local_resource_registry.rb +34 -0
  175. data/spec/support/sdam_monitoring.rb +115 -0
  176. data/spec/support/spec_config.rb +20 -6
  177. data/spec/support/spec_setup.rb +2 -2
  178. data/spec/support/transactions.rb +1 -1
  179. data/spec/support/transactions/test.rb +1 -1
  180. data/spec/support/utils.rb +1 -16
  181. metadata +685 -659
  182. metadata.gz.sig +0 -0
  183. data/lib/mongo/event/description_changed.rb +0 -52
  184. data/spec/integration/bson_symbol_spec.rb +0 -34
  185. data/spec/integration/crud_spec.rb +0 -45
  186. data/spec/integration/get_more_spec.rb +0 -32
  187. data/spec/integration/grid_fs_bucket_spec.rb +0 -48
  188. data/spec/integration/retryable_errors_spec.rb +0 -265
  189. data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +0 -98
  190. data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -56
  191. data/spec/runners/sdam/verifier.rb +0 -88
metadata.gz.sig CHANGED
Binary file
@@ -1,52 +0,0 @@
1
- # Copyright (C) 2014-2019 MongoDB, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- module Mongo
16
- module Event
17
-
18
- # This handles a change in description.
19
- #
20
- # @since 2.0.6
21
- class DescriptionChanged < Base
22
-
23
- # @return [ Mongo::Cluster ] cluster The cluster.
24
- attr_reader :cluster
25
-
26
- # Initialize the new host added event handler.
27
- #
28
- # @example Create the new handler.
29
- # ServerAdded.new(cluster)
30
- #
31
- # @param [ Mongo::Cluster ] cluster The cluster to publish from.
32
- #
33
- # @since 2.0.0
34
- def initialize(cluster)
35
- @cluster = cluster
36
- end
37
-
38
- # This event publishes an event to add the cluster and logs the
39
- # configuration change.
40
- #
41
- # @param [ Server::Description ] previous_desc Previous server description.
42
- # @param [ Server::Description ] updated_desc The changed description.
43
- #
44
- # @since 2.0.0
45
- def handle(previous_desc, updated_desc)
46
- cluster.sdam_flow_lock.synchronize do
47
- Mongo::Cluster::SdamFlow.new(cluster, previous_desc, updated_desc).server_description_changed
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Symbol encoding to BSON' do
4
- let(:value) { :foo }
5
-
6
- let(:hash) do
7
- {'foo' => value}
8
- end
9
-
10
- let(:serialized) do
11
- hash.to_bson.to_s
12
- end
13
-
14
- let(:expected) do
15
- "\x12\x00\x00\x00\x0Efoo\x00\x04\x00\x00\x00foo\x00\x00".force_encoding('binary')
16
- end
17
-
18
- it 'encodes symbol to BSON symbol' do
19
- serialized.should == expected
20
- end
21
-
22
- it 'round-trips symbol values' do
23
- buffer = BSON::ByteBuffer.new(serialized)
24
- Hash.from_bson(buffer).should == hash
25
- end
26
-
27
- it 'round-trips symbol values using the same byte buffer' do
28
- if BSON::Environment.jruby?
29
- pending 'https://jira.mongodb.org/browse/RUBY-2128'
30
- end
31
-
32
- Hash.from_bson(hash.to_bson).should == hash
33
- end
34
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'CRUD operations' do
4
- let(:collection) { authorized_client['crud_integration'] }
5
-
6
- before do
7
- collection.delete_many
8
- end
9
-
10
- describe 'upsert' do
11
- context 'with default write concern' do
12
- it 'upserts' do
13
- collection.count_documents({}).should == 0
14
-
15
- res = collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true)
16
-
17
- res.documents.first['upserted'].length.should == 1
18
-
19
- collection.count_documents({}).should == 1
20
- end
21
- end
22
-
23
- context 'unacknowledged write' do
24
- let(:unack_collection) do
25
- collection.with(write_concern: {w: 0})
26
- end
27
-
28
- before do
29
- unack_collection.write_concern.acknowledged?.should be false
30
- end
31
-
32
- it 'upserts' do
33
- unack_collection.count_documents({}).should == 0
34
-
35
- res = unack_collection.find(_id: 'foo').update_one({'$set' => {foo: 'bar'}}, upsert: true)
36
-
37
- # since write concern is unacknowledged, wait for the data to be
38
- # persisted (hopefully)
39
- sleep 0.25
40
-
41
- unack_collection.count_documents({}).should == 1
42
- end
43
- end
44
- end
45
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'getMore operation' do
4
- # https://jira.mongodb.org/browse/RUBY-1987
5
- min_server_fcv '3.2'
6
-
7
- let(:collection) do
8
- subscribed_client['get_more_spec']
9
- end
10
-
11
- let(:scope) do
12
- collection.find.batch_size(1).each
13
- end
14
-
15
- before do
16
- collection.delete_many
17
- collection.insert_one(a: 1)
18
- #collection.insert_one(a: 2)
19
- EventSubscriber.clear_events!
20
- end
21
-
22
- let(:get_more_command) do
23
- event = EventSubscriber.single_command_started_event('getMore')
24
- event.command['getMore']
25
- end
26
-
27
- it 'sends cursor id as int64' do
28
- scope.to_a
29
-
30
- expect(get_more_command).to be_a(BSON::Int64)
31
- end
32
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'GridFS bucket integration' do
4
- let(:fs) do
5
- authorized_client.database.fs
6
- end
7
-
8
- describe 'UTF-8 string write' do
9
- let(:data) { "hello\u2210" }
10
-
11
- before do
12
- data.length.should_not == data.bytesize
13
- end
14
-
15
- shared_examples 'round-trips' do
16
- it 'round-trips' do
17
- stream = fs.open_upload_stream('test') do |stream|
18
- stream.write(data_to_write)
19
- end
20
-
21
- actual = nil
22
- fs.open_download_stream(stream.file_id) do |stream|
23
- actual = stream.read
24
- end
25
-
26
- actual.encoding.name.should == 'ASCII-8BIT'
27
- actual.should == data.dup.force_encoding('binary')
28
- end
29
- end
30
-
31
- context 'in binary encoding' do
32
- let(:data_to_write) do
33
- data.force_encoding('binary').freeze
34
- end
35
-
36
- it_behaves_like 'round-trips'
37
- end
38
-
39
- context 'in UTF-8 encoding' do
40
- let(:data_to_write) do
41
- data.encoding.name.should == 'UTF-8'
42
- data.freeze
43
- end
44
-
45
- it_behaves_like 'round-trips'
46
- end
47
- end
48
- end
@@ -1,265 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Failing retryable operations' do
4
- # Requirement for fail point
5
- min_server_fcv '4.0'
6
-
7
- let(:client) do
8
- subscribed_client
9
- end
10
-
11
- let(:collection) do
12
- client['retryable-errors-spec']
13
- end
14
-
15
- context 'when operation fails' do
16
- require_topology :replica_set
17
-
18
-
19
- let(:clear_fail_point_command) do
20
- {
21
- configureFailPoint: 'failCommand',
22
- mode: 'off',
23
- }
24
- end
25
-
26
- after do
27
- ClusterTools.instance.direct_client_for_each_server do |client|
28
- client.use(:admin).database.command(clear_fail_point_command)
29
- end
30
- end
31
-
32
- let(:collection) do
33
- client['retryable-errors-spec', read: {mode: :secondary_preferred}]
34
- end
35
-
36
- let(:first_server) do
37
- client.cluster.servers_list.detect do |server|
38
- server.address.seed == events.first.address.seed
39
- end
40
- end
41
-
42
- let(:second_server) do
43
- client.cluster.servers_list.detect do |server|
44
- server.address.seed == events.last.address.seed
45
- end
46
- end
47
-
48
- shared_context 'read operation' do
49
- let(:fail_point_command) do
50
- {
51
- configureFailPoint: 'failCommand',
52
- mode: {times: 1},
53
- data: {
54
- failCommands: ['find'],
55
- errorCode: 11600,
56
- },
57
- }
58
- end
59
-
60
- let(:set_fail_point) do
61
- client.cluster.servers_list.each do |server|
62
- server.scan!
63
- server.monitor.stop!
64
- end
65
-
66
- ClusterTools.instance.direct_client_for_each_server do |client|
67
- client.use(:admin).database.command(fail_point_command)
68
- end
69
- end
70
-
71
- let(:operation_exception) do
72
- set_fail_point
73
-
74
- begin
75
- collection.find(a: 1).to_a
76
- rescue Mongo::Error::OperationFailure => exception
77
- else
78
- fail('Expected operation to fail')
79
- end
80
-
81
- puts exception.message
82
-
83
- exception
84
- end
85
-
86
- let(:events) do
87
- EventSubscriber.command_started_events('find')
88
- end
89
- end
90
-
91
- shared_context 'write operation' do
92
- let(:fail_point_command) do
93
- {
94
- configureFailPoint: 'failCommand',
95
- mode: {times: 2},
96
- data: {
97
- failCommands: ['insert'],
98
- errorCode: 11600,
99
- },
100
- }
101
- end
102
-
103
- let(:set_fail_point) do
104
- client.use(:admin).database.command(fail_point_command)
105
- end
106
-
107
- let(:operation_exception) do
108
- set_fail_point
109
-
110
- begin
111
- collection.insert_one(a: 1)
112
- rescue Mongo::Error::OperationFailure => exception
113
- else
114
- fail('Expected operation to fail')
115
- end
116
-
117
- #puts exception.message
118
-
119
- exception
120
- end
121
-
122
- let(:events) do
123
- EventSubscriber.command_started_events('insert')
124
- end
125
- end
126
-
127
- shared_examples_for 'failing retry' do
128
-
129
- it 'indicates second attempt' do
130
- expect(operation_exception.message).to include('attempt 2')
131
- expect(operation_exception.message).not_to include('attempt 1')
132
- expect(operation_exception.message).not_to include('attempt 3')
133
- end
134
-
135
- it 'publishes two events' do
136
-
137
- expect(events.length).to eq(2)
138
- end
139
- end
140
-
141
- shared_examples_for 'failing single attempt' do
142
-
143
- it 'does not indicate attempt' do
144
- expect(operation_exception.message).not_to include('attempt 1')
145
- expect(operation_exception.message).not_to include('attempt 2')
146
- expect(operation_exception.message).not_to include('attempt 3')
147
- end
148
-
149
- it 'publishes one event' do
150
-
151
- expect(events.length).to eq(1)
152
- end
153
- end
154
-
155
- shared_examples_for 'failing retry on the same server' do
156
- it 'is reported on the server of the second attempt' do
157
- expect(operation_exception.message).to include(second_server.address.seed)
158
- end
159
- end
160
-
161
- shared_examples_for 'failing retry on a different server' do
162
- it 'is reported on the server of the second attempt' do
163
- expect(operation_exception.message).not_to include(first_server.address.seed)
164
- expect(operation_exception.message).to include(second_server.address.seed)
165
- end
166
-
167
- it 'marks servers used in both attempts unknown' do
168
- operation_exception
169
-
170
- expect(first_server).to be_unknown
171
-
172
- expect(second_server).to be_unknown
173
- end
174
-
175
- it 'publishes events for the different server addresses' do
176
-
177
- expect(events.length).to eq(2)
178
- expect(events.first.address.seed).not_to eq(events.last.address.seed)
179
- end
180
- end
181
-
182
- shared_examples_for 'modern retry' do
183
- it 'indicates modern retry' do
184
- expect(operation_exception.message).to include('modern retry')
185
- expect(operation_exception.message).not_to include('legacy retry')
186
- expect(operation_exception.message).not_to include('retries disabled')
187
- end
188
- end
189
-
190
- shared_examples_for 'legacy retry' do
191
- it 'indicates legacy retry' do
192
- expect(operation_exception.message).to include('legacy retry')
193
- expect(operation_exception.message).not_to include('modern retry')
194
- expect(operation_exception.message).not_to include('retries disabled')
195
- end
196
- end
197
-
198
- shared_examples_for 'disabled retry' do
199
- it 'indicates retries are disabled' do
200
- expect(operation_exception.message).to include('retries disabled')
201
- expect(operation_exception.message).not_to include('legacy retry')
202
- expect(operation_exception.message).not_to include('modern retry')
203
- end
204
- end
205
-
206
- context 'when read is retried and retry fails' do
207
- include_context 'read operation'
208
-
209
- context 'modern read retries' do
210
- require_wired_tiger_on_36
211
-
212
- let(:client) do
213
- subscribed_client.with(retry_reads: true)
214
- end
215
-
216
- it_behaves_like 'failing retry'
217
- it_behaves_like 'modern retry'
218
- end
219
-
220
- context 'legacy read retries' do
221
- let(:client) do
222
- subscribed_client.with(retry_reads: false, read_retry_interval: 0)
223
- end
224
-
225
- it_behaves_like 'failing retry'
226
- it_behaves_like 'legacy retry'
227
- end
228
- end
229
-
230
- context 'when read retries are disabled' do
231
- let(:client) do
232
- subscribed_client.with(retry_reads: false, max_read_retries: 0)
233
- end
234
-
235
- include_context 'read operation'
236
-
237
- it_behaves_like 'failing single attempt'
238
- it_behaves_like 'disabled retry'
239
- end
240
-
241
- context 'when write is retried and retry fails' do
242
- include_context 'write operation'
243
-
244
- context 'modern write retries' do
245
- require_wired_tiger_on_36
246
-
247
- let(:client) do
248
- subscribed_client.with(retry_writes: true)
249
- end
250
-
251
- it_behaves_like 'failing retry'
252
- it_behaves_like 'modern retry'
253
- end
254
-
255
- context 'legacy write' do
256
- let(:client) do
257
- subscribed_client.with(retry_writes: false)
258
- end
259
-
260
- it_behaves_like 'failing retry'
261
- it_behaves_like 'legacy retry'
262
- end
263
- end
264
- end
265
- end