mongo 2.13.0.beta1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -5
  4. data/Rakefile +50 -9
  5. data/lib/mongo.rb +13 -2
  6. data/lib/mongo/address.rb +1 -1
  7. data/lib/mongo/address/ipv4.rb +1 -1
  8. data/lib/mongo/address/ipv6.rb +1 -1
  9. data/lib/mongo/auth/aws/request.rb +31 -5
  10. data/lib/mongo/bulk_write.rb +18 -0
  11. data/lib/mongo/caching_cursor.rb +74 -0
  12. data/lib/mongo/client.rb +238 -31
  13. data/lib/mongo/cluster.rb +56 -20
  14. data/lib/mongo/cluster/sdam_flow.rb +13 -10
  15. data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -2
  16. data/lib/mongo/cluster/topology/sharded.rb +1 -1
  17. data/lib/mongo/cluster/topology/single.rb +2 -2
  18. data/lib/mongo/collection.rb +66 -24
  19. data/lib/mongo/collection/view.rb +24 -20
  20. data/lib/mongo/collection/view/aggregation.rb +25 -4
  21. data/lib/mongo/collection/view/builder/find_command.rb +38 -18
  22. data/lib/mongo/collection/view/explainable.rb +27 -8
  23. data/lib/mongo/collection/view/iterable.rb +72 -12
  24. data/lib/mongo/collection/view/readable.rb +19 -3
  25. data/lib/mongo/collection/view/writable.rb +55 -5
  26. data/lib/mongo/crypt/encryption_io.rb +6 -6
  27. data/lib/mongo/cursor.rb +16 -3
  28. data/lib/mongo/database.rb +37 -4
  29. data/lib/mongo/database/view.rb +18 -3
  30. data/lib/mongo/distinguishing_semaphore.rb +55 -0
  31. data/lib/mongo/error.rb +5 -0
  32. data/lib/mongo/error/invalid_read_concern.rb +28 -0
  33. data/lib/mongo/error/invalid_server_auth_host.rb +22 -0
  34. data/lib/mongo/error/invalid_session.rb +2 -1
  35. data/lib/mongo/error/operation_failure.rb +11 -5
  36. data/lib/mongo/error/server_certificate_revoked.rb +22 -0
  37. data/lib/mongo/error/sessions_not_supported.rb +35 -0
  38. data/lib/mongo/error/unsupported_option.rb +14 -12
  39. data/lib/mongo/event/base.rb +6 -0
  40. data/lib/mongo/grid/file.rb +5 -0
  41. data/lib/mongo/grid/file/chunk.rb +2 -0
  42. data/lib/mongo/grid/fs_bucket.rb +15 -13
  43. data/lib/mongo/grid/stream/write.rb +9 -3
  44. data/lib/mongo/index/view.rb +3 -0
  45. data/lib/mongo/lint.rb +2 -1
  46. data/lib/mongo/logger.rb +3 -3
  47. data/lib/mongo/monitoring.rb +38 -0
  48. data/lib/mongo/monitoring/command_log_subscriber.rb +10 -2
  49. data/lib/mongo/monitoring/event/command_failed.rb +11 -0
  50. data/lib/mongo/monitoring/event/command_started.rb +37 -2
  51. data/lib/mongo/monitoring/event/command_succeeded.rb +11 -0
  52. data/lib/mongo/monitoring/event/server_closed.rb +1 -1
  53. data/lib/mongo/monitoring/event/server_description_changed.rb +27 -4
  54. data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +9 -2
  55. data/lib/mongo/monitoring/event/server_heartbeat_started.rb +9 -2
  56. data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +9 -2
  57. data/lib/mongo/monitoring/event/server_opening.rb +1 -1
  58. data/lib/mongo/monitoring/event/topology_changed.rb +1 -1
  59. data/lib/mongo/monitoring/event/topology_closed.rb +1 -1
  60. data/lib/mongo/monitoring/event/topology_opening.rb +1 -1
  61. data/lib/mongo/monitoring/publishable.rb +6 -3
  62. data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +9 -1
  63. data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +1 -1
  64. data/lib/mongo/operation.rb +2 -0
  65. data/lib/mongo/operation/aggregate/result.rb +9 -8
  66. data/lib/mongo/operation/collections_info/command.rb +5 -0
  67. data/lib/mongo/operation/collections_info/result.rb +18 -1
  68. data/lib/mongo/operation/delete/bulk_result.rb +2 -0
  69. data/lib/mongo/operation/delete/result.rb +3 -0
  70. data/lib/mongo/operation/explain/command.rb +4 -0
  71. data/lib/mongo/operation/explain/legacy.rb +4 -0
  72. data/lib/mongo/operation/explain/op_msg.rb +6 -0
  73. data/lib/mongo/operation/explain/result.rb +3 -0
  74. data/lib/mongo/operation/find/legacy/result.rb +2 -0
  75. data/lib/mongo/operation/find/result.rb +13 -0
  76. data/lib/mongo/operation/get_more/result.rb +3 -0
  77. data/lib/mongo/operation/indexes/result.rb +5 -0
  78. data/lib/mongo/operation/insert/bulk_result.rb +5 -0
  79. data/lib/mongo/operation/insert/result.rb +5 -0
  80. data/lib/mongo/operation/list_collections/result.rb +5 -0
  81. data/lib/mongo/operation/map_reduce/result.rb +10 -0
  82. data/lib/mongo/operation/parallel_scan/result.rb +4 -0
  83. data/lib/mongo/operation/result.rb +35 -6
  84. data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
  85. data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
  86. data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
  87. data/lib/mongo/operation/shared/executable.rb +1 -0
  88. data/lib/mongo/operation/shared/idable.rb +2 -1
  89. data/lib/mongo/operation/shared/limited.rb +1 -0
  90. data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
  91. data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
  92. data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
  93. data/lib/mongo/operation/shared/specifiable.rb +1 -0
  94. data/lib/mongo/operation/shared/write.rb +1 -0
  95. data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
  96. data/lib/mongo/operation/update/legacy/result.rb +7 -0
  97. data/lib/mongo/operation/update/result.rb +8 -0
  98. data/lib/mongo/operation/users_info/result.rb +3 -0
  99. data/lib/mongo/protocol/message.rb +47 -10
  100. data/lib/mongo/protocol/msg.rb +34 -1
  101. data/lib/mongo/protocol/query.rb +36 -0
  102. data/lib/mongo/protocol/serializers.rb +5 -2
  103. data/lib/mongo/query_cache.rb +242 -0
  104. data/lib/mongo/retryable.rb +8 -1
  105. data/lib/mongo/server.rb +15 -4
  106. data/lib/mongo/server/app_metadata.rb +27 -3
  107. data/lib/mongo/server/connection.rb +4 -4
  108. data/lib/mongo/server/connection_base.rb +38 -12
  109. data/lib/mongo/server/connection_common.rb +2 -2
  110. data/lib/mongo/server/connection_pool.rb +3 -0
  111. data/lib/mongo/server/description.rb +13 -1
  112. data/lib/mongo/server/monitor.rb +76 -44
  113. data/lib/mongo/server/monitor/connection.rb +57 -9
  114. data/lib/mongo/server/pending_connection.rb +14 -4
  115. data/lib/mongo/server/push_monitor.rb +173 -0
  116. data/{spec/runners/transactions/context.rb → lib/mongo/server/push_monitor/connection.rb} +9 -14
  117. data/lib/mongo/server_selector.rb +0 -1
  118. data/lib/mongo/server_selector/base.rb +583 -1
  119. data/lib/mongo/server_selector/nearest.rb +1 -6
  120. data/lib/mongo/server_selector/primary.rb +1 -6
  121. data/lib/mongo/server_selector/primary_preferred.rb +7 -10
  122. data/lib/mongo/server_selector/secondary.rb +1 -6
  123. data/lib/mongo/server_selector/secondary_preferred.rb +1 -7
  124. data/lib/mongo/session.rb +7 -1
  125. data/lib/mongo/socket.rb +26 -12
  126. data/lib/mongo/socket/ocsp_cache.rb +97 -0
  127. data/lib/mongo/socket/ocsp_verifier.rb +368 -0
  128. data/lib/mongo/socket/ssl.rb +46 -25
  129. data/lib/mongo/socket/tcp.rb +1 -1
  130. data/lib/mongo/srv/monitor.rb +7 -13
  131. data/lib/mongo/srv/resolver.rb +14 -10
  132. data/lib/mongo/timeout.rb +2 -0
  133. data/lib/mongo/topology_version.rb +9 -0
  134. data/lib/mongo/uri.rb +21 -390
  135. data/lib/mongo/uri/options_mapper.rb +582 -0
  136. data/lib/mongo/uri/srv_protocol.rb +3 -2
  137. data/lib/mongo/utils.rb +73 -0
  138. data/lib/mongo/version.rb +1 -1
  139. data/spec/NOTES.aws-auth.md +12 -7
  140. data/spec/README.aws-auth.md +2 -2
  141. data/spec/README.md +63 -1
  142. data/spec/integration/awaited_ismaster_spec.rb +28 -0
  143. data/spec/integration/bson_symbol_spec.rb +4 -2
  144. data/spec/integration/bulk_write_spec.rb +67 -0
  145. data/spec/integration/change_stream_examples_spec.rb +6 -2
  146. data/spec/integration/change_stream_spec.rb +1 -1
  147. data/spec/integration/check_clean_slate_spec.rb +16 -0
  148. data/spec/integration/client_authentication_options_spec.rb +92 -28
  149. data/spec/integration/client_construction_spec.rb +1 -0
  150. data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +9 -5
  151. data/spec/integration/connect_single_rs_name_spec.rb +5 -2
  152. data/spec/integration/connection_pool_populator_spec.rb +4 -2
  153. data/spec/integration/connection_spec.rb +7 -4
  154. data/spec/integration/crud_spec.rb +4 -4
  155. data/spec/integration/cursor_reaping_spec.rb +54 -18
  156. data/spec/integration/docs_examples_spec.rb +6 -0
  157. data/spec/integration/fork_reconnect_spec.rb +56 -1
  158. data/spec/integration/grid_fs_bucket_spec.rb +48 -0
  159. data/spec/integration/heartbeat_events_spec.rb +4 -23
  160. data/spec/integration/ocsp_connectivity_spec.rb +26 -0
  161. data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
  162. data/spec/integration/ocsp_verifier_spec.rb +334 -0
  163. data/spec/integration/query_cache_spec.rb +1045 -0
  164. data/spec/integration/query_cache_transactions_spec.rb +190 -0
  165. data/spec/integration/read_concern_spec.rb +1 -1
  166. data/spec/integration/retryable_errors_spec.rb +1 -1
  167. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
  168. data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +4 -2
  169. data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -3
  170. data/spec/integration/retryable_writes/shared/performs_no_retries.rb +2 -2
  171. data/spec/integration/sdam_error_handling_spec.rb +122 -15
  172. data/spec/integration/sdam_events_spec.rb +80 -6
  173. data/spec/integration/sdam_prose_spec.rb +64 -0
  174. data/spec/integration/server_monitor_spec.rb +25 -1
  175. data/spec/integration/server_selection_spec.rb +36 -0
  176. data/spec/integration/size_limit_spec.rb +23 -5
  177. data/spec/integration/srv_monitoring_spec.rb +38 -3
  178. data/spec/integration/srv_spec.rb +56 -0
  179. data/spec/integration/ssl_uri_options_spec.rb +2 -2
  180. data/spec/integration/transactions_examples_spec.rb +17 -7
  181. data/spec/integration/zlib_compression_spec.rb +25 -0
  182. data/spec/lite_spec_helper.rb +20 -9
  183. data/spec/mongo/address_spec.rb +1 -1
  184. data/spec/mongo/auth/aws/request_region_spec.rb +42 -0
  185. data/spec/mongo/auth/aws/request_spec.rb +76 -0
  186. data/spec/mongo/auth/scram_spec.rb +1 -1
  187. data/spec/mongo/auth/user_spec.rb +1 -1
  188. data/spec/mongo/bulk_write_spec.rb +2 -2
  189. data/spec/mongo/caching_cursor_spec.rb +70 -0
  190. data/spec/mongo/client_construction_spec.rb +386 -3
  191. data/spec/mongo/client_encryption_spec.rb +16 -10
  192. data/spec/mongo/client_spec.rb +85 -3
  193. data/spec/mongo/cluster/topology/replica_set_spec.rb +53 -10
  194. data/spec/mongo/cluster/topology/sharded_spec.rb +1 -1
  195. data/spec/mongo/cluster/topology/single_spec.rb +19 -8
  196. data/spec/mongo/cluster/topology/unknown_spec.rb +1 -1
  197. data/spec/mongo/cluster/topology_spec.rb +1 -1
  198. data/spec/mongo/cluster_spec.rb +37 -35
  199. data/spec/mongo/collection/view/change_stream_resume_spec.rb +7 -7
  200. data/spec/mongo/collection/view/explainable_spec.rb +87 -4
  201. data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
  202. data/spec/mongo/collection/view/readable_spec.rb +36 -0
  203. data/spec/mongo/collection_spec.rb +572 -0
  204. data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
  205. data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
  206. data/spec/mongo/crypt/binary_spec.rb +1 -6
  207. data/spec/mongo/crypt/binding/binary_spec.rb +1 -6
  208. data/spec/mongo/crypt/binding/context_spec.rb +2 -7
  209. data/spec/mongo/crypt/binding/helpers_spec.rb +1 -6
  210. data/spec/mongo/crypt/binding/mongocrypt_spec.rb +2 -7
  211. data/spec/mongo/crypt/binding/status_spec.rb +1 -6
  212. data/spec/mongo/crypt/binding/version_spec.rb +1 -6
  213. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  214. data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
  215. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
  216. data/spec/mongo/crypt/status_spec.rb +1 -6
  217. data/spec/mongo/database_spec.rb +353 -8
  218. data/spec/mongo/distinguishing_semaphore_spec.rb +63 -0
  219. data/spec/mongo/error/no_server_available_spec.rb +1 -1
  220. data/spec/mongo/error/operation_failure_spec.rb +40 -0
  221. data/spec/mongo/index/view_spec.rb +148 -2
  222. data/spec/mongo/logger_spec.rb +13 -11
  223. data/spec/mongo/monitoring/event/server_closed_spec.rb +1 -1
  224. data/spec/mongo/monitoring/event/server_description_changed_spec.rb +1 -4
  225. data/spec/mongo/monitoring/event/server_opening_spec.rb +1 -1
  226. data/spec/mongo/monitoring/event/topology_changed_spec.rb +1 -1
  227. data/spec/mongo/monitoring/event/topology_closed_spec.rb +1 -1
  228. data/spec/mongo/monitoring/event/topology_opening_spec.rb +1 -1
  229. data/spec/mongo/operation/delete/op_msg_spec.rb +3 -3
  230. data/spec/mongo/operation/insert/command_spec.rb +2 -2
  231. data/spec/mongo/operation/insert/op_msg_spec.rb +3 -3
  232. data/spec/mongo/operation/read_preference_op_msg_spec.rb +1 -1
  233. data/spec/mongo/operation/update/command_spec.rb +2 -2
  234. data/spec/mongo/operation/update/op_msg_spec.rb +3 -3
  235. data/spec/mongo/protocol/msg_spec.rb +10 -0
  236. data/spec/mongo/query_cache_spec.rb +280 -0
  237. data/spec/mongo/semaphore_spec.rb +51 -0
  238. data/spec/mongo/server/app_metadata_shared.rb +82 -2
  239. data/spec/mongo/server/connection_auth_spec.rb +2 -2
  240. data/spec/mongo/server/connection_pool_spec.rb +7 -3
  241. data/spec/mongo/server/connection_spec.rb +15 -8
  242. data/spec/mongo/server/description_spec.rb +18 -0
  243. data/spec/mongo/server_selector/nearest_spec.rb +23 -23
  244. data/spec/mongo/server_selector/primary_preferred_spec.rb +26 -26
  245. data/spec/mongo/server_selector/primary_spec.rb +9 -9
  246. data/spec/mongo/server_selector/secondary_preferred_spec.rb +22 -22
  247. data/spec/mongo/server_selector/secondary_spec.rb +18 -18
  248. data/spec/mongo/server_selector_spec.rb +6 -6
  249. data/spec/mongo/session_spec.rb +35 -0
  250. data/spec/mongo/socket/ssl_spec.rb +4 -4
  251. data/spec/mongo/socket_spec.rb +1 -1
  252. data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
  253. data/spec/mongo/uri_option_parsing_spec.rb +11 -11
  254. data/spec/mongo/uri_spec.rb +68 -41
  255. data/spec/mongo/utils_spec.rb +39 -0
  256. data/spec/runners/auth.rb +3 -0
  257. data/spec/runners/change_streams/test.rb +3 -3
  258. data/spec/runners/cmap.rb +1 -1
  259. data/spec/runners/command_monitoring.rb +3 -34
  260. data/spec/runners/connection_string.rb +35 -124
  261. data/spec/runners/crud/context.rb +9 -5
  262. data/spec/runners/crud/operation.rb +59 -27
  263. data/spec/runners/crud/spec.rb +0 -8
  264. data/spec/runners/crud/test.rb +1 -1
  265. data/spec/runners/crud/test_base.rb +0 -19
  266. data/spec/runners/sdam.rb +2 -2
  267. data/spec/runners/server_selection.rb +242 -28
  268. data/spec/runners/transactions.rb +12 -12
  269. data/spec/runners/transactions/operation.rb +151 -25
  270. data/spec/runners/transactions/test.rb +62 -18
  271. data/spec/shared/LICENSE +20 -0
  272. data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
  273. data/spec/shared/lib/mrss/constraints.rb +303 -0
  274. data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
  275. data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
  276. data/spec/spec_helper.rb +3 -1
  277. data/spec/spec_tests/cmap_spec.rb +7 -3
  278. data/spec/spec_tests/command_monitoring_spec.rb +22 -12
  279. data/spec/spec_tests/crud_spec.rb +1 -1
  280. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +4 -9
  281. data/spec/spec_tests/data/change_streams/change-streams-resume-whitelist.yml +66 -0
  282. data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
  283. data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
  284. data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
  285. data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
  286. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
  287. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +4 -3
  288. data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -0
  289. data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
  290. data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
  291. data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
  292. data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
  293. data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
  294. data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
  295. data/spec/spec_tests/data/sdam_integration/isMaster-command-error.yml +168 -0
  296. data/spec/spec_tests/data/sdam_integration/isMaster-network-error.yml +162 -0
  297. data/spec/spec_tests/data/sdam_integration/isMaster-timeout.yml +229 -0
  298. data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +87 -0
  299. data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
  300. data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
  301. data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
  302. data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
  303. data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
  304. data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
  305. data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
  306. data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
  307. data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
  308. data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
  309. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
  310. data/spec/spec_tests/max_staleness_spec.rb +4 -142
  311. data/spec/spec_tests/retryable_reads_spec.rb +2 -2
  312. data/spec/spec_tests/sdam_integration_spec.rb +13 -0
  313. data/spec/spec_tests/sdam_monitoring_spec.rb +1 -2
  314. data/spec/spec_tests/server_selection_spec.rb +4 -116
  315. data/spec/spec_tests/uri_options_spec.rb +31 -33
  316. data/spec/stress/cleanup_spec.rb +17 -2
  317. data/spec/stress/connection_pool_stress_spec.rb +10 -8
  318. data/spec/stress/fork_reconnect_stress_spec.rb +1 -1
  319. data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
  320. data/spec/support/certificates/atlas-ocsp.crt +41 -0
  321. data/spec/support/client_registry.rb +1 -0
  322. data/spec/support/client_registry_macros.rb +11 -2
  323. data/spec/support/cluster_config.rb +4 -0
  324. data/spec/support/common_shortcuts.rb +45 -0
  325. data/spec/support/constraints.rb +6 -253
  326. data/spec/support/event_subscriber.rb +123 -33
  327. data/spec/support/keyword_struct.rb +26 -0
  328. data/spec/support/matchers.rb +16 -0
  329. data/spec/support/ocsp +1 -0
  330. data/spec/support/session_registry.rb +52 -0
  331. data/spec/support/shared/server_selector.rb +13 -1
  332. data/spec/support/spec_config.rb +60 -13
  333. data/spec/support/spec_setup.rb +1 -1
  334. data/spec/support/utils.rb +84 -1
  335. metadata +1027 -937
  336. metadata.gz.sig +0 -0
  337. data/lib/mongo/server_selector/selectable.rb +0 -560
  338. data/spec/runners/sdam_monitoring.rb +0 -89
  339. data/spec/support/lite_constraints.rb +0 -141
@@ -36,6 +36,7 @@ tests:
36
36
  options:
37
37
  directConnection: false
38
38
  connect: replica_set
39
+ replicaSet: foo
39
40
 
40
41
  -
41
42
  description: directConnection=true and connect=sharded
@@ -149,7 +149,8 @@ tests:
149
149
  warning: false
150
150
  hosts: ~
151
151
  auth: ~
152
- options: {}
152
+ # https://jira.mongodb.org/browse/DRIVERS-1368
153
+ options: ~
153
154
  -
154
155
  description: "tls=false and ssl=false doesn't warn"
155
156
  uri: "mongodb://example.com/?tls=false&ssl=false"
@@ -157,7 +158,8 @@ tests:
157
158
  warning: false
158
159
  hosts: ~
159
160
  auth: ~
160
- options: {}
161
+ # https://jira.mongodb.org/browse/DRIVERS-1368
162
+ options: ~
161
163
  -
162
164
  description: "ssl=true and tls=true doesn't warn"
163
165
  uri: "mongodb://example.com/?ssl=true&tls=true"
@@ -165,7 +167,8 @@ tests:
165
167
  warning: false
166
168
  hosts: ~
167
169
  auth: ~
168
- options: {}
170
+ # https://jira.mongodb.org/browse/DRIVERS-1368
171
+ options: ~
169
172
  -
170
173
  description: "ssl=false and tls=false doesn't warn"
171
174
  uri: "mongodb://example.com/?ssl=false&tls=false"
@@ -173,7 +176,8 @@ tests:
173
176
  warning: false
174
177
  hosts: ~
175
178
  auth: ~
176
- options: {}
179
+ # https://jira.mongodb.org/browse/DRIVERS-1368
180
+ options: ~
177
181
  -
178
182
  description: "tls=false and ssl=true raises error"
179
183
  uri: "mongodb://example.com/?tls=false&ssl=true"
@@ -206,3 +210,155 @@ tests:
206
210
  hosts: ~
207
211
  auth: ~
208
212
  options: {}
213
+ -
214
+ description: "tlsDisableOCSPEndpointCheck can be set to true"
215
+ uri: "mongodb://example.com/?tls=true&tlsDisableOCSPEndpointCheck=true"
216
+ valid: true
217
+ warning: false
218
+ hosts: ~
219
+ auth: ~
220
+ options:
221
+ tls: true
222
+ tlsDisableOCSPEndpointCheck: true
223
+ -
224
+ description: "tlsDisableOCSPEndpointCheck can be set to false"
225
+ uri: "mongodb://example.com/?tls=true&tlsDisableOCSPEndpointCheck=false"
226
+ valid: true
227
+ warning: false
228
+ hosts: ~
229
+ auth: ~
230
+ options:
231
+ tls: true
232
+ tlsDisableOCSPEndpointCheck: false
233
+ # 4 permutations of [tlsInsecure=true/false, tlsDisableOCSPEndpointCheck=true/false]
234
+ -
235
+ description: "tlsInsecure and tlsDisableOCSPEndpointCheck both present (and true) raises an error"
236
+ uri: "mongodb://example.com/?tlsInsecure=true&tlsDisableOCSPEndpointCheck=true"
237
+ valid: false
238
+ warning: false
239
+ hosts: ~
240
+ auth: ~
241
+ options: {}
242
+ -
243
+ description: "tlsInsecure=true and tlsDisableOCSPEndpointCheck=false raises an error"
244
+ uri: "mongodb://example.com/?tlsInsecure=true&tlsDisableOCSPEndpointCheck=false"
245
+ valid: false
246
+ warning: false
247
+ hosts: ~
248
+ auth: ~
249
+ options: {}
250
+ -
251
+ description: "tlsInsecure=false and tlsDisableOCSPEndpointCheck=true raises an error"
252
+ uri: "mongodb://example.com/?tlsInsecure=false&tlsDisableOCSPEndpointCheck=true"
253
+ valid: false
254
+ warning: false
255
+ hosts: ~
256
+ auth: ~
257
+ options: {}
258
+ -
259
+ description: "tlsInsecure and tlsDisableOCSPEndpointCheck both present (and false) raises an error"
260
+ uri: "mongodb://example.com/?tlsInsecure=false&tlsDisableOCSPEndpointCheck=false"
261
+ valid: false
262
+ warning: false
263
+ hosts: ~
264
+ auth: ~
265
+ options: {}
266
+ # 4 permutations of [tlsDisableOCSPEndpointCheck=true/false, tlsInsecure=true/false]
267
+ -
268
+ description: "tlsDisableOCSPEndpointCheck and tlsInsecure both present (and true) raises an error"
269
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=true&tlsInsecure=true"
270
+ valid: false
271
+ warning: false
272
+ hosts: ~
273
+ auth: ~
274
+ options: {}
275
+ -
276
+ description: "tlsDisableOCSPEndpointCheck=true and tlsInsecure=false raises an error"
277
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=true&tlsInsecure=false"
278
+ valid: false
279
+ warning: false
280
+ hosts: ~
281
+ auth: ~
282
+ options: {}
283
+ -
284
+ description: "tlsDisableOCSPEndpointCheck=false and tlsInsecure=true raises an error"
285
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=false&tlsInsecure=true"
286
+ valid: false
287
+ warning: false
288
+ hosts: ~
289
+ auth: ~
290
+ options: {}
291
+ -
292
+ description: "tlsDisableOCSPEndpointCheck and tlsInsecure both present (and false) raises an error"
293
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=false&tlsInsecure=false"
294
+ valid: false
295
+ warning: false
296
+ hosts: ~
297
+ auth: ~
298
+ options: {}
299
+ # 4 permutations of [tlsAllowInvalidCertificates=true/false, tlsDisableOCSPEndpointCheck=true/false]
300
+ -
301
+ description: "tlsAllowInvalidCertificates and tlsDisableOCSPEndpointCheck both present (and true) raises an error"
302
+ uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true&tlsDisableOCSPEndpointCheck=true"
303
+ valid: false
304
+ warning: false
305
+ hosts: ~
306
+ auth: ~
307
+ options: {}
308
+ -
309
+ description: "tlsAllowInvalidCertificates=true and tlsDisableOCSPEndpointCheck=false raises an error"
310
+ uri: "mongodb://example.com/?tlsAllowInvalidCertificates=true&tlsDisableOCSPEndpointCheck=false"
311
+ valid: false
312
+ warning: false
313
+ hosts: ~
314
+ auth: ~
315
+ options: {}
316
+ -
317
+ description: "tlsAllowInvalidCertificates=false and tlsDisableOCSPEndpointCheck=true raises an error"
318
+ uri: "mongodb://example.com/?tlsAllowInvalidCertificates=false&tlsDisableOCSPEndpointCheck=true"
319
+ valid: false
320
+ warning: false
321
+ hosts: ~
322
+ auth: ~
323
+ options: {}
324
+ -
325
+ description: "tlsAllowInvalidCertificates and tlsDisableOCSPEndpointCheck both present (and false) raises an error"
326
+ uri: "mongodb://example.com/?tlsAllowInvalidCertificates=false&tlsDisableOCSPEndpointCheck=false"
327
+ valid: false
328
+ warning: false
329
+ hosts: ~
330
+ auth: ~
331
+ options: {}
332
+ # 4 permutations of [tlsDisableOCSPEndpointCheck=true/false, tlsAllowInvalidCertificates=true/false]
333
+ -
334
+ description: "tlsDisableOCSPEndpointCheck and tlsAllowInvalidCertificates both present (and true) raises an error"
335
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=true&tlsAllowInvalidCertificates=true"
336
+ valid: false
337
+ warning: false
338
+ hosts: ~
339
+ auth: ~
340
+ options: {}
341
+ -
342
+ description: "tlsDisableOCSPEndpointCheck=true and tlsAllowInvalidCertificates=false raises an error"
343
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=true&tlsAllowInvalidCertificates=false"
344
+ valid: false
345
+ warning: false
346
+ hosts: ~
347
+ auth: ~
348
+ options: {}
349
+ -
350
+ description: "tlsDisableOCSPEndpointCheck=false and tlsAllowInvalidCertificates=true raises an error"
351
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=false&tlsAllowInvalidCertificates=true"
352
+ valid: false
353
+ warning: false
354
+ hosts: ~
355
+ auth: ~
356
+ options: {}
357
+ -
358
+ description: "tlsDisableOCSPEndpointCheck and tlsAllowInvalidCertificates both present (and false) raises an error"
359
+ uri: "mongodb://example.com/?tlsDisableOCSPEndpointCheck=false&tlsAllowInvalidCertificates=false"
360
+ valid: false
361
+ warning: false
362
+ hosts: ~
363
+ auth: ~
364
+ options: {}
@@ -60,7 +60,15 @@ describe 'DNS Seedlist Discovery' do
60
60
  end
61
61
 
62
62
  it 'creates a client with the correct options' do
63
- expect(test.client).to match_options(test)
63
+ mapped = Mongo::URI::OptionsMapper.new.ruby_to_smc(test.client.options)
64
+ # Connection string spec tests do not use canonical URI option names
65
+ actual = Utils.downcase_keys(mapped)
66
+ expected = Utils.downcase_keys(test.options)
67
+ # SRV tests use ssl URI option instead of tls one
68
+ if expected.key?('ssl') && !expected.key?('tls')
69
+ expected['tls'] = expected.delete('ssl')
70
+ end
71
+ actual.should == expected
64
72
  end
65
73
  end
66
74
  end
@@ -1,147 +1,9 @@
1
- require 'spec_helper'
1
+ require 'lite_spec_helper'
2
2
 
3
3
  require 'runners/server_selection'
4
4
 
5
- describe 'Max Staleness Spec' do
5
+ MAX_STALENESS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/max_staleness/**/*.yml").sort
6
6
 
7
- include Mongo::ServerSelection::Read
8
-
9
- MAX_STALENESS_TESTS.each do |file|
10
-
11
- spec = Mongo::ServerSelection::Read::Spec.new(file)
12
-
13
- context(spec.description) do
14
- # Cluster needs a topology and topology needs a cluster...
15
- # This temporary cluster is used for topology construction.
16
- let(:temp_cluster) do
17
- double('temp cluster').tap do |cluster|
18
- allow(cluster).to receive(:servers_list).and_return([])
19
- end
20
- end
21
-
22
- let(:topology) do
23
- options = if spec.type <= Mongo::Cluster::Topology::ReplicaSetNoPrimary
24
- {replica_set_name: 'foo'}
25
- else
26
- {}
27
- end
28
- spec.type.new(options, monitoring, temp_cluster)
29
- end
30
-
31
- let(:monitoring) do
32
- Mongo::Monitoring.new(monitoring: false)
33
- end
34
-
35
- let(:listeners) do
36
- Mongo::Event::Listeners.new
37
- end
38
-
39
- let(:options) do
40
- if spec.heartbeat_frequency
41
- SpecConfig.instance.test_options.merge(heartbeat_frequency: spec.heartbeat_frequency)
42
- else
43
- SpecConfig.instance.test_options.dup.tap do |opts|
44
- opts.delete(:heartbeat_frequency)
45
- end
46
- end.merge!(server_selection_timeout: 0.2, connect_timeout: 0.1)
47
- end
48
-
49
- let(:cluster) do
50
- double('cluster').tap do |c|
51
- allow(c).to receive(:connected?).and_return(true)
52
- allow(c).to receive(:summary)
53
- allow(c).to receive(:topology).and_return(topology)
54
- allow(c).to receive(:single?).and_return(topology.single?)
55
- allow(c).to receive(:sharded?).and_return(topology.sharded?)
56
- allow(c).to receive(:replica_set?).and_return(topology.replica_set?)
57
- allow(c).to receive(:unknown?).and_return(topology.unknown?)
58
- allow(c).to receive(:options).and_return(options)
59
- allow(c).to receive(:scan!).and_return(true)
60
- allow(c).to receive(:app_metadata).and_return(app_metadata)
61
- allow(c).to receive(:heartbeat_interval).and_return(
62
- spec.heartbeat_frequency || Mongo::Server::Monitor::DEFAULT_HEARTBEAT_INTERVAL)
63
- end
64
- end
65
-
66
- let(:candidate_servers) do
67
- spec.candidate_servers.collect do |server|
68
- features = double('features').tap do |feat|
69
- allow(feat).to receive(:max_staleness_enabled?).and_return(server['maxWireVersion'] && server['maxWireVersion'] >= 5)
70
- allow(feat).to receive(:check_driver_support!).and_return(true)
71
- end
72
- address = Mongo::Address.new(server['address'])
73
- Mongo::Server.new(address, cluster, monitoring, listeners,
74
- {monitoring_io: false}.update(options)
75
- ).tap do |s|
76
- allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'] / 1000.0) if server['avg_rtt_ms']
77
- allow(s).to receive(:tags).and_return(server['tags'])
78
- allow(s).to receive(:secondary?).and_return(server['type'] == 'RSSecondary')
79
- allow(s).to receive(:primary?).and_return(server['type'] == 'RSPrimary')
80
- allow(s).to receive(:connectable?).and_return(true)
81
- allow(s).to receive(:last_write_date).and_return(
82
- Time.at(server['lastWrite']['lastWriteDate']['$numberLong'].to_f / 1000)) if server['lastWrite']
83
- allow(s).to receive(:last_scan).and_return(
84
- Time.at(server['lastUpdateTime'].to_f / 1000))
85
- allow(s).to receive(:features).and_return(features)
86
- end
87
- end
88
- end
89
-
90
- let(:in_latency_window) do
91
- spec.in_latency_window.collect do |server|
92
- Mongo::Server.new(Mongo::Address.new(server['address']), cluster, monitoring, listeners,
93
- options.merge(monitoring_io: false))
94
- end
95
- end
96
-
97
- let(:server_selector_definition) do
98
- { mode: spec.read_preference['mode'] }.tap do |definition|
99
- definition[:tag_sets] = spec.read_preference['tag_sets']
100
- definition[:max_staleness] = spec.max_staleness if spec.max_staleness
101
- end
102
- end
103
-
104
- let(:server_selector) do
105
- Mongo::ServerSelector.get(server_selector_definition)
106
- end
107
-
108
- before do
109
- allow(cluster).to receive(:servers).and_return(candidate_servers)
110
- allow(cluster).to receive(:addresses).and_return(candidate_servers.map(&:address))
111
- end
112
-
113
- context 'when the max staleness is invalid' do
114
-
115
- it 'Raises an InvalidServerPreference exception', if: spec.invalid_max_staleness? do
116
-
117
- expect do
118
- server_selector.select_server(cluster)
119
- end.to raise_exception(Mongo::Error::InvalidServerPreference)
120
- end
121
- end
122
-
123
- context 'when the max staleness is valid' do
124
-
125
- context 'when there are available servers' do
126
-
127
- it 'Finds all suitable servers in the latency window', if: (spec.replica_set? && !spec.invalid_max_staleness? && spec.server_available?) do
128
- expect(server_selector.send(:select, cluster.servers)).to match_array(in_latency_window)
129
- end
130
-
131
- it 'Finds the most suitable server in the latency window', if: (!spec.invalid_max_staleness? && spec.server_available?) do
132
- expect(in_latency_window).to include(server_selector.select_server(cluster))
133
- end
134
- end
135
-
136
- context 'when there are no available servers', if: (!spec.invalid_max_staleness? && !spec.server_available?) do
137
-
138
- it 'Raises a NoServerAvailable Exception' do
139
- expect do
140
- server_selector.select_server(cluster)
141
- end.to raise_exception(Mongo::Error::NoServerAvailable)
142
- end
143
- end
144
- end
145
- end
146
- end
7
+ describe 'Max staleness spec tests' do
8
+ define_server_selection_spec_tests(MAX_STALENESS_TESTS)
147
9
  end
@@ -8,7 +8,7 @@ describe 'Retryable reads spec tests' do
8
8
 
9
9
  define_crud_spec_tests(RETRYABLE_READS_TESTS) do |spec, req, test|
10
10
  let(:client) do
11
- authorized_client.with({max_read_retries: 0}.update(test.client_options)).tap do |client|
11
+ authorized_client.use(spec.database_name).with({max_read_retries: 0}.update(test.client_options)).tap do |client|
12
12
  client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
13
13
  end
14
14
  end
@@ -28,7 +28,7 @@ describe 'Retryable reads spec tests - legacy' do
28
28
  end
29
29
 
30
30
  let(:client) do
31
- authorized_client.with(client_options).tap do |client|
31
+ authorized_client.use(spec.database_name).with(client_options).tap do |client|
32
32
  client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
33
33
  end
34
34
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ require 'runners/crud'
4
+ require 'runners/transactions'
5
+
6
+ SDAM_INTEGRATION_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/sdam_integration/*.yml").sort
7
+
8
+ describe 'SDAM integration tests' do
9
+ require_no_multi_shard
10
+ require_wired_tiger
11
+
12
+ define_transactions_spec_tests(SDAM_INTEGRATION_TESTS)
13
+ end
@@ -2,7 +2,6 @@ require 'lite_spec_helper'
2
2
 
3
3
  require 'runners/sdam'
4
4
  require 'runners/sdam/verifier'
5
- require 'runners/sdam_monitoring'
6
5
 
7
6
  describe 'SDAM Monitoring' do
8
7
  include Mongo::SDAM
@@ -14,7 +13,7 @@ describe 'SDAM Monitoring' do
14
13
  context("#{spec.description} (#{file.sub(%r'.*/data/sdam_monitoring/', '')})") do
15
14
 
16
15
  before(:all) do
17
- @subscriber = Mongo::SDAMMonitoring::PhasedTestSubscriber.new
16
+ @subscriber = PhasedEventSubscriber.new
18
17
  sdam_proc = lambda do |client|
19
18
  client.subscribe(Mongo::Monitoring::SERVER_OPENING, @subscriber)
20
19
  client.subscribe(Mongo::Monitoring::SERVER_CLOSED, @subscriber)
@@ -1,121 +1,9 @@
1
- require 'spec_helper'
1
+ require 'lite_spec_helper'
2
2
 
3
3
  require 'runners/server_selection'
4
4
 
5
- describe 'Server Selection' do
5
+ SERVER_SELECTION_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/server_selection/**/*.yml").sort
6
6
 
7
- include Mongo::ServerSelection::Read
8
-
9
- SERVER_SELECTION_TESTS.each do |file|
10
-
11
- spec = Mongo::ServerSelection::Read::Spec.new(file)
12
-
13
- context(spec.description) do
14
-
15
- let(:monitoring) do
16
- Mongo::Monitoring.new(monitoring: false)
17
- end
18
-
19
- # Cluster needs a topology and topology needs a cluster...
20
- # This temporary cluster is used for topology construction.
21
- let(:temp_cluster) do
22
- double('temp cluster').tap do |cluster|
23
- allow(cluster).to receive(:servers_list).and_return([])
24
- end
25
- end
26
-
27
- let(:topology) do
28
- options = if spec.type <= Mongo::Cluster::Topology::ReplicaSetNoPrimary
29
- {replica_set_name: 'foo'}
30
- else
31
- {}
32
- end
33
- spec.type.new(options, monitoring, temp_cluster)
34
- end
35
-
36
- let(:listeners) do
37
- Mongo::Event::Listeners.new
38
- end
39
-
40
- let(:cluster) do
41
- double('cluster').tap do |c|
42
- allow(c).to receive(:connected?).and_return(true)
43
- allow(c).to receive(:summary)
44
- allow(c).to receive(:topology).and_return(topology)
45
- allow(c).to receive(:single?).and_return(topology.single?)
46
- allow(c).to receive(:sharded?).and_return(topology.sharded?)
47
- allow(c).to receive(:replica_set?).and_return(topology.replica_set?)
48
- allow(c).to receive(:unknown?).and_return(topology.unknown?)
49
- allow(c).to receive(:app_metadata).and_return(app_metadata)
50
- allow(c).to receive(:options).and_return({})
51
- allow(c).to receive(:server_selection_semaphore).and_return(nil)
52
- end
53
- end
54
-
55
- let(:candidate_servers) do
56
- spec.candidate_servers.collect do |server|
57
- address = Mongo::Address.new(server['address'])
58
- Mongo::Server.new(address, cluster, monitoring, listeners,
59
- {monitoring_io: false}.update(SpecConfig.instance.test_options)
60
- ).tap do |s|
61
- allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'] / 1000.0)
62
- allow(s).to receive(:tags).and_return(server['tags'])
63
- allow(s).to receive(:secondary?).and_return(server['type'] == 'RSSecondary')
64
- allow(s).to receive(:primary?).and_return(server['type'] == 'RSPrimary')
65
- allow(s).to receive(:connectable?).and_return(true)
66
- allow(s).to receive(:check_driver_support!).and_return(true)
67
- end
68
- end
69
- end
70
-
71
- let(:in_latency_window) do
72
- spec.in_latency_window.collect do |server|
73
- address = Mongo::Address.new(server['address'])
74
- Mongo::Server.new(address, cluster, monitoring, listeners,
75
- {monitoring_io: false}.update(SpecConfig.instance.test_options)
76
- ).tap do |s|
77
- allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'] / 1000.0)
78
- allow(s).to receive(:tags).and_return(server['tags'])
79
- allow(s).to receive(:connectable?).and_return(true)
80
- allow(s).to receive(:check_driver_support!).and_return(true)
81
- end
82
- end
83
- end
84
-
85
- let(:server_selector) do
86
- Mongo::ServerSelector.get(:mode => spec.read_preference['mode'],
87
- :tag_sets => spec.read_preference['tag_sets'])
88
- end
89
-
90
- before do
91
- allow(cluster).to receive(:servers).and_return(candidate_servers)
92
- allow(cluster).to receive(:servers_list).and_return(candidate_servers)
93
- allow(cluster).to receive(:addresses).and_return(candidate_servers.map(&:address))
94
- allow(cluster).to receive(:options).and_return(server_selection_timeout: 0.2)
95
- allow(cluster).to receive(:scan!).and_return(true)
96
- allow(cluster).to receive(:app_metadata).and_return(app_metadata)
97
- end
98
-
99
- context 'Valid read preference and matching server available', if: spec.server_available? do
100
-
101
- it 'Finds all suitable servers in the latency window', if: spec.replica_set? do
102
- expect(server_selector.send(:select, cluster.servers)).to match_array(in_latency_window)
103
- end
104
-
105
- it 'Finds the most suitable server in the latency window' do
106
- expect(in_latency_window).to include(server_selector.select_server(cluster))
107
- end
108
- end
109
-
110
- context 'No matching server available', if: !spec.server_available? do
111
- skip_if_linting
112
-
113
- it 'Raises exception' do
114
- expect do
115
- server_selector.select_server(cluster)
116
- end.to raise_exception(Mongo::Error::NoServerAvailable)
117
- end
118
- end
119
- end
120
- end
7
+ describe 'Server selection spec tests' do
8
+ define_server_selection_spec_tests(SERVER_SELECTION_TESTS)
121
9
  end