Skip to content

Commit ec010c1

Browse files
saghmp
authored andcommitted
RUBY-1559 Implement uri option spec tests (mongodb#1170)
1 parent 90340ab commit ec010c1

12 files changed

+794
-70
lines changed

docs/tutorials/ruby-driver-create-client.txt

Lines changed: 101 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ Since the URI options are required in camel case, which is not the Ruby standard
7676
following table shows the option in the URI and its corresponding option if passed
7777
to the constructor in Ruby.
7878

79-
.. note::
80-
79+
.. note::
80+
8181
The options passed directly should be symbols.
8282

8383
The options are explained in detail in the :manual:`Connection URI reference
84-
</reference/connection-string/>`.
84+
</reference/connection-string/>`.
8585

8686
.. note::
8787
Options that are set in **milliseconds** in the URI are
@@ -97,8 +97,29 @@ URI Options Conversions
9797
* - URI Option
9898
- Ruby Option
9999

100-
* - replicaSet=String
101-
- ``:replica_set => String``
100+
* - appName=String
101+
- ``:app_name => String``
102+
103+
* - authMechanism=String
104+
- ``:auth_mech => Symbol``
105+
106+
* - authMechanismProperties=Strings
107+
- ``{ :auth_mech_properties => { :service_realm => String, :canonicalize_host_name => true|false, :service_name => String } }``
108+
109+
Specified as comma-separated key:value pairs, e.g. ``"SERVICE_REALM:foo,CANONICALIZE_HOSTNAME:TRUE"``.
110+
111+
* - authSource=String
112+
- ``:auth_source => String``
113+
114+
* - compressors=Strings
115+
- ``:compressors => Array<String>``
116+
117+
Specified as a comma-separated list. Note that the Ruby driver only supports zlib
118+
compression; however, other drivers may support snappy. For maximum compatibility with
119+
drivers, specify ``"snappy,zlib"``; if compatibility with other drivers is not a concern,
120+
specify ``"zlib".`` Compression is not enabled by default and when using MongoDB 4.0 and
121+
earlier, so zlib compression must be manually enabled on the server in order for the Ruby
122+
driver to compress wire protocol data.
102123

103124
* - connect=String
104125
- ``:connect => Symbol``
@@ -109,56 +130,81 @@ URI Options Conversions
109130
* - connectTimeoutMS=Integer
110131
- ``:connect_timeout => Float``
111132

112-
* - socketTimeoutMS=Integer
113-
- ``:socket_timeout => Float``
133+
* - fsync=Boolean
134+
- ``{ :write => { :fsync => true|false }}``
114135

115-
* - serverSelectionTimeoutMS=Integer
116-
- ``:server_selection_timeout => Float``
136+
* - heartbeatFrequencyMS=Integer
137+
- ``:heartbeat_frequency => Float``
138+
139+
* - journal=Boolean
140+
- ``{ :write => { :j => true|false }}``
117141

118142
* - localThresholdMS=Integer
119143
- ``:local_threshold => Float``
120144

145+
* - maxIdleTimeMS=Integer
146+
- ``:max_idle_time => Float``
147+
121148
* - maxPoolSize=Integer
122149
- ``:max_pool_size => Integer``
123150

124151
* - minPoolSize=Integer
125152
- ``:min_pool_size => Integer``
126153

127-
* - waitQueueTimeoutMS=Integer
128-
- ``:wait_queue_timeout => Float``
154+
* - readPreference=String
155+
- ``{ :read => { :mode => Symbol }}``
129156

130-
* - w=Integer|String
131-
- ``{ :write => { :w => Integer|String }}``
157+
* - readPreferenceTags=Strings
158+
- ``{ :read => { :tag_sets => Array<Hash> }}``
132159

133-
* - wtimeoutMS=Integer
134-
- ``{ :write => { :wtimeout => Float }}``
160+
Each instance of the readPreferenceTags field is a comma-separated key:value pair which will appear in the :tag_sets array in the order they are specified. For instance, ``"readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny"`` will be converted to ``[ { 'dc' => 'ny', 'rack' => '1' }, { 'dc' => 'ny' }]``.
135161

136-
* - journal=Boolean
137-
- ``{ :write => { :j => true|false }}``
162+
* - replicaSet=String
163+
- ``:replica_set => String``
138164

139-
* - fsync=Boolean
140-
- ``{ :write => { :fsync => true|false }}``
165+
* - serverSelectionTimeoutMS=Integer
166+
- ``:server_selection_timeout => Float``
141167

142-
* - readPreference=String
143-
- ``{ :read => { :mode => Symbol }}``
168+
* - socketTimeoutMS=Integer
169+
- ``:socket_timeout => Float``
144170

145-
* - readPreferenceTags=Strings
146-
- ``{ :read => { :tag_sets => Array<String> }}``
171+
* - tls=Boolean
172+
- ``:ssl => boolean``
147173

148-
* - authSource=String
149-
- ``:auth_source => String``
174+
* - tlsAllowInvalidCertificates=Boolean
175+
- ``:ssl_verify => boolean``
150176

151-
* - authMechanism=String
152-
- ``:auth_mech => Symbol``
177+
Because ``tlsAllowInvalidCertificates`` uses ``true`` to signify that verification
178+
should be disabled and ``ssl_verify`` uses ``false`` to signify that verification should be
179+
disabled, the boolean is inverted before being used to set ``ssl_verify``.
153180

154-
* - authMechanismProperties=Strings
155-
- ``{ :auth_mech_properties => { :service_realm => String, :canonicalize_host_name => true|false, :service_name => String } }``
181+
* - tlsCAFile=String
182+
- ``:ssl_ca_cert => String``
156183

157-
* - appName=String
158-
- ``:app_name => String``
184+
* - tlsClientCertFile=String
185+
- ``:ssl_cert => String``
159186

160-
* - compressors=Strings
161-
- ``:compressors => Array<String>``
187+
* - tlsClientKeyFile=String
188+
- ``:ssl_key => String``
189+
190+
* - tlsClientKeyPassword=String
191+
- ``:ssl_key_pass_phrase => String``
192+
193+
* - tlsInsecure=Boolean
194+
- ``:ssl_verify => boolean``
195+
196+
Because tlsInsecure uses ``true`` to signify that verification should be disabled and
197+
``ssl_verify`` uses ``false`` to signify that verification should be disabled, the boolean
198+
is inverted before being used to set ``ssl_verify``.
199+
200+
* - w=Integer|String
201+
- ``{ :write => { :w => Integer|String }}``
202+
203+
* - waitQueueTimeoutMS=Integer
204+
- ``:wait_queue_timeout => Float``
205+
206+
* - wtimeoutMS=Integer
207+
- ``{ :write => { :wtimeout => Float }}``
162208

163209
* - zlibCompressionLevel=Integer
164210
- ``:zlib_compression_level => Integer``
@@ -178,12 +224,12 @@ Ruby Options
178224

179225
* - ``:replica_set``
180226
- When connecting to a replica set, this is the name of the set to
181-
filter servers by.
227+
filter servers by.
182228
- ``String``
183229
- none
184230

185231
* - ``:ssl``
186-
- Tell the client to connect to the servers via SSL.
232+
- Tell the client to connect to the servers via SSL.
187233
- ``Boolean``
188234
- false
189235

@@ -255,30 +301,30 @@ Ruby Options
255301

256302
* - ``:connect_timeout``
257303
- The number of seconds to wait to establish a socket connection
258-
before raising an exception.
304+
before raising an exception.
259305
- ``Float``
260306
- 10 seconds
261307

262308
* - ``:socket_timeout``
263309
- The number of seconds to wait for an operation to execute on a
264-
socket before raising an exception.
310+
socket before raising an exception.
265311
- ``Float``
266312
- 5 seconds
267313

268314
* - ``:max_pool_size``
269-
- The maximum size of the connection pool for each server.
315+
- The maximum size of the connection pool for each server.
270316
- ``Integer``
271317
- 5
272318

273319
* - ``:min_pool_size``
274320
- The minimum number of connections in the connection pool for each
275-
server.
321+
server.
276322
- ``Integer``
277323
- 1
278324

279325
* - ``:wait_queue_timeout``
280326
- The number of seconds to wait for a connection in the connection
281-
pool to become available.
327+
pool to become available.
282328
- ``Float``
283329
- 1
284330

@@ -291,22 +337,22 @@ Ruby Options
291337
{ :write => { :w => 2 } }
292338
- ``Hash``
293339
- ``{ :w => 1 }``
294-
340+
295341
* - ``:read``
296342
- Specifies the read preference mode and tag sets for selecting servers as a ``Hash``.
297343
Keys in the hash are ``:mode`` and ``:tag_sets``.
298344

299345
.. code-block:: ruby
300346

301-
{ :read =>
302-
{ :mode => :secondary,
303-
:tag_sets => [ "berlin" ]
304-
}
347+
{ :read =>
348+
{ :mode => :secondary,
349+
:tag_sets => [ "berlin" ]
350+
}
305351
}
306352

307353
- ``Hash``
308354
- ``{ :mode => :primary }``
309-
355+
310356
* - ``:auth_source``
311357
- Specifies the authentication source.
312358
- ``String``
@@ -316,7 +362,7 @@ Ruby Options
316362

317363
* - ``:auth_mech``
318364
- Specifies the authenticaion mechanism to use. Can be one of:
319-
``:mongodb_cr``, ``:mongodb_x509``, ``:plain``, ``:scram``.
365+
``:mongodb_cr``, ``:mongodb_x509``, ``:plain``, ``:scram``.
320366
- ``Symbol``
321367
- MongoDB 3.0 and later: ``:scram`` if user credentials
322368
are supplied but an ``:auth_mech`` is not. 2.6 and earlier:
@@ -343,7 +389,7 @@ Ruby Options
343389
``:replica_set`` or ``:sharded``.
344390
- ``Symbol``
345391
- none
346-
392+
347393
* - ``:heartbeat_frequency``
348394
- The number of seconds for the server monitors to refresh
349395
server states asynchronously.
@@ -437,9 +483,9 @@ Details on Timeout Options
437483

438484
``connect_timeout``
439485
On initialization of a connection to a server, this setting is the
440-
number of seconds to wait to connect before raising an exception.
486+
number of seconds to wait to connect before raising an exception.
441487
This timeout is also used when monitor threads ping their servers.
442-
The default is 10 seconds. See the `socket timeout for monitoring
488+
The default is 10 seconds. See the `socket timeout for monitoring
443489
specification <https://github.com/mongodb/specifications/blob/
444490
master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#socket-timeout-for-monitoring
445491
-is-connecttimeoutms>`_ for further explanation.
@@ -457,7 +503,7 @@ Details on Timeout Options
457503
The number of seconds to wait for the driver to find an appropriate server to
458504
which an operation can be sent before raising an exception. Defaults to 30.
459505
It should take the speed of :manual:`elections</core/replica-set-elections/>`
460-
during a failover into account. See the
506+
during a failover into account. See the
461507
`serverSelectionTimeoutMS specification
462508
<https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#serverselectiontimeoutms>`_
463509
for further information.
@@ -466,10 +512,10 @@ Details on Timeout Options
466512
The maximum latency in seconds between the nearest server and the servers that can be considered available to send an
467513
operation to. Defaults to 0.015.
468514

469-
.. note::
515+
.. note::
470516
This is not the latency window between the driver and a server, but
471517
rather the latency between the nearest server and other servers. See
472-
`the localThresholdMS specification
518+
`the localThresholdMS specification
473519
<https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst#localthresholdms>`_.
474520

475521
``wait_queue_timeout``
@@ -483,7 +529,7 @@ Details on Timeout Options
483529

484530
``min_pool_size``
485531
Minimum number of connections in the connection pool for each server.
486-
Increase this number to create connections when the pool is
532+
Increase this number to create connections when the pool is
487533
initialized and to reduce the overhead of creating new connections
488534
later on. Defaults to 1.
489535

@@ -669,7 +715,7 @@ You can either use the default global driver logger or set your own. To set your
669715
Mongo::Logger.logger = other_logger
670716

671717
See the `Ruby Logger documentation <http://ruby-doc.org/stdlib-2.2.0/libdoc/logger/rdoc/Logger.html>`_
672-
for more information on the default logger API and available levels.
718+
for more information on the default logger API and available levels.
673719

674720
Changing the Logger Level
675721
`````````````````````````

0 commit comments

Comments
 (0)