mongo 2.15.1 → 2.16.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (326) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/lib/mongo/bulk_write.rb +2 -2
  5. data/lib/mongo/client.rb +45 -5
  6. data/lib/mongo/cluster/periodic_executor.rb +4 -3
  7. data/lib/mongo/cluster/reapers/cursor_reaper.rb +76 -43
  8. data/lib/mongo/cluster/sdam_flow.rb +9 -3
  9. data/lib/mongo/cluster/topology/base.rb +13 -9
  10. data/lib/mongo/cluster/topology/load_balanced.rb +102 -0
  11. data/lib/mongo/cluster/topology.rb +28 -8
  12. data/lib/mongo/cluster.rb +136 -51
  13. data/lib/mongo/collection/view/aggregation.rb +5 -10
  14. data/lib/mongo/collection/view/builder/aggregation.rb +6 -5
  15. data/lib/mongo/collection/view/builder/map_reduce.rb +12 -49
  16. data/lib/mongo/collection/view/builder.rb +0 -4
  17. data/lib/mongo/collection/view/iterable.rb +42 -18
  18. data/lib/mongo/collection/view/map_reduce.rb +39 -15
  19. data/lib/mongo/collection/view/readable.rb +60 -51
  20. data/lib/mongo/collection/view/writable.rb +178 -175
  21. data/lib/mongo/collection/view.rb +15 -21
  22. data/lib/mongo/collection.rb +13 -13
  23. data/lib/mongo/cursor/kill_spec.rb +38 -0
  24. data/lib/mongo/cursor.rb +62 -31
  25. data/lib/mongo/database/view.rb +1 -1
  26. data/lib/mongo/error/bad_load_balancer_target.rb +26 -0
  27. data/lib/mongo/error/missing_service_id.rb +26 -0
  28. data/lib/mongo/error/no_service_connection_available.rb +49 -0
  29. data/lib/mongo/error/notable.rb +7 -0
  30. data/lib/mongo/error.rb +3 -0
  31. data/lib/mongo/grid/fs_bucket.rb +21 -2
  32. data/lib/mongo/id.rb +7 -5
  33. data/lib/mongo/index/view.rb +22 -41
  34. data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +7 -4
  35. data/lib/mongo/monitoring/event/command_failed.rb +1 -1
  36. data/lib/mongo/monitoring/event/command_started.rb +2 -0
  37. data/lib/mongo/monitoring/publishable.rb +2 -2
  38. data/lib/mongo/operation/aggregate/command.rb +8 -0
  39. data/lib/mongo/operation/context.rb +19 -1
  40. data/lib/mongo/operation/count/command.rb +6 -0
  41. data/lib/mongo/operation/count/op_msg.rb +6 -0
  42. data/lib/mongo/operation/create/command.rb +7 -1
  43. data/lib/mongo/operation/create/op_msg.rb +7 -0
  44. data/lib/mongo/operation/create_index/command.rb +17 -1
  45. data/lib/mongo/operation/create_index/op_msg.rb +17 -4
  46. data/lib/mongo/operation/delete/command.rb +6 -3
  47. data/lib/mongo/operation/delete/legacy.rb +9 -2
  48. data/lib/mongo/operation/delete/op_msg.rb +8 -1
  49. data/lib/mongo/operation/distinct/command.rb +6 -0
  50. data/lib/mongo/operation/distinct/op_msg.rb +7 -0
  51. data/lib/mongo/operation/explain/command.rb +13 -1
  52. data/lib/mongo/operation/explain/legacy.rb +12 -5
  53. data/lib/mongo/operation/explain/op_msg.rb +9 -1
  54. data/lib/mongo/operation/find/builder/command.rb +110 -0
  55. data/lib/mongo/{collection/view → operation/find}/builder/flags.rb +10 -14
  56. data/lib/mongo/operation/find/builder/legacy.rb +123 -0
  57. data/lib/mongo/{collection/view → operation/find}/builder/modifiers.rb +31 -25
  58. data/lib/mongo/{cursor → operation/find}/builder.rb +4 -4
  59. data/lib/mongo/operation/find/command.rb +9 -0
  60. data/lib/mongo/operation/find/legacy.rb +10 -1
  61. data/lib/mongo/operation/find/op_msg.rb +12 -0
  62. data/lib/mongo/operation/find.rb +1 -0
  63. data/lib/mongo/operation/get_more/command.rb +1 -0
  64. data/lib/mongo/operation/get_more/command_builder.rb +38 -0
  65. data/lib/mongo/operation/get_more/op_msg.rb +1 -0
  66. data/lib/mongo/operation/get_more.rb +1 -0
  67. data/lib/mongo/operation/kill_cursors/command.rb +8 -0
  68. data/lib/mongo/operation/kill_cursors/command_builder.rb +35 -0
  69. data/lib/mongo/operation/kill_cursors/legacy.rb +2 -1
  70. data/lib/mongo/operation/kill_cursors/op_msg.rb +10 -0
  71. data/lib/mongo/operation/kill_cursors.rb +1 -0
  72. data/lib/mongo/operation/map_reduce/command.rb +8 -0
  73. data/lib/mongo/operation/map_reduce/op_msg.rb +1 -1
  74. data/lib/mongo/operation/shared/executable.rb +15 -1
  75. data/lib/mongo/operation/shared/polymorphic_operation.rb +1 -1
  76. data/lib/mongo/operation/shared/read_preference_supported.rb +3 -1
  77. data/lib/mongo/operation/shared/response_handling.rb +1 -0
  78. data/lib/mongo/operation/shared/sessions_supported.rb +12 -12
  79. data/lib/mongo/operation/shared/specifiable.rb +11 -29
  80. data/lib/mongo/operation/shared/validatable.rb +87 -0
  81. data/lib/mongo/operation/shared/write.rb +1 -1
  82. data/lib/mongo/operation/update/command.rb +6 -3
  83. data/lib/mongo/operation/update/legacy.rb +19 -11
  84. data/lib/mongo/operation/update/op_msg.rb +7 -4
  85. data/lib/mongo/operation/write_command/command.rb +51 -0
  86. data/lib/mongo/operation/write_command/op_msg.rb +43 -0
  87. data/lib/mongo/operation/write_command.rb +32 -0
  88. data/lib/mongo/operation.rb +10 -0
  89. data/lib/mongo/protocol/query.rb +35 -18
  90. data/lib/mongo/server/connection.rb +25 -3
  91. data/lib/mongo/server/connection_base.rb +12 -1
  92. data/lib/mongo/server/connection_common.rb +38 -1
  93. data/lib/mongo/server/connection_pool/generation_manager.rb +71 -0
  94. data/lib/mongo/server/connection_pool.rb +100 -27
  95. data/lib/mongo/server/description/features.rb +17 -16
  96. data/lib/mongo/server/description/load_balancer.rb +33 -0
  97. data/lib/mongo/server/description.rb +85 -6
  98. data/lib/mongo/server/monitor/connection.rb +5 -6
  99. data/lib/mongo/server/monitor.rb +2 -1
  100. data/lib/mongo/server/pending_connection.rb +47 -31
  101. data/lib/mongo/server.rb +73 -26
  102. data/lib/mongo/server_selector/base.rb +5 -1
  103. data/lib/mongo/session/session_pool.rb +11 -0
  104. data/lib/mongo/session.rb +21 -1
  105. data/lib/mongo/socket/ocsp_verifier.rb +6 -37
  106. data/lib/mongo/uri/options_mapper.rb +1 -0
  107. data/lib/mongo/uri/srv_protocol.rb +6 -8
  108. data/lib/mongo/uri.rb +18 -0
  109. data/lib/mongo/utils.rb +0 -7
  110. data/lib/mongo/version.rb +1 -1
  111. data/mongo.gemspec +1 -1
  112. data/spec/integration/auth_spec.rb +31 -1
  113. data/spec/integration/awaited_ismaster_spec.rb +1 -1
  114. data/spec/integration/bulk_write_spec.rb +1 -1
  115. data/spec/integration/change_stream_spec.rb +3 -3
  116. data/spec/integration/client_construction_spec.rb +54 -0
  117. data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +1 -1
  118. data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +1 -1
  119. data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +1 -1
  120. data/spec/integration/client_side_encryption/data_key_spec.rb +1 -1
  121. data/spec/integration/client_spec.rb +2 -0
  122. data/spec/integration/command_monitoring_spec.rb +1 -1
  123. data/spec/integration/command_spec.rb +1 -1
  124. data/spec/integration/connection_spec.rb +52 -35
  125. data/spec/integration/crud_spec.rb +174 -1
  126. data/spec/integration/cursor_pinning_spec.rb +121 -0
  127. data/spec/integration/cursor_reaping_spec.rb +8 -4
  128. data/spec/integration/fork_reconnect_spec.rb +1 -5
  129. data/spec/integration/get_more_spec.rb +1 -1
  130. data/spec/integration/heartbeat_events_spec.rb +1 -1
  131. data/spec/integration/map_reduce_spec.rb +77 -0
  132. data/spec/integration/query_cache_spec.rb +2 -2
  133. data/spec/integration/query_cache_transactions_spec.rb +1 -1
  134. data/spec/integration/read_concern_spec.rb +1 -1
  135. data/spec/integration/read_preference_spec.rb +1 -1
  136. data/spec/integration/reconnect_spec.rb +30 -12
  137. data/spec/integration/retryable_errors_spec.rb +1 -1
  138. data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +1 -1
  139. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -1
  140. data/spec/integration/sdam_error_handling_spec.rb +5 -3
  141. data/spec/integration/sdam_events_spec.rb +35 -19
  142. data/spec/integration/sdam_prose_spec.rb +1 -1
  143. data/spec/integration/server_monitor_spec.rb +1 -0
  144. data/spec/integration/server_selector_spec.rb +22 -5
  145. data/spec/integration/server_spec.rb +2 -0
  146. data/spec/integration/srv_monitoring_spec.rb +1 -1
  147. data/spec/integration/step_down_spec.rb +1 -1
  148. data/spec/integration/transaction_pinning_spec.rb +120 -0
  149. data/spec/integration/versioned_api_examples_spec.rb +45 -0
  150. data/spec/integration/x509_auth_spec.rb +1 -1
  151. data/spec/lite_spec_helper.rb +1 -2
  152. data/spec/mongo/address/unix_spec.rb +1 -0
  153. data/spec/mongo/auth/cr_spec.rb +2 -3
  154. data/spec/mongo/auth/ldap_spec.rb +2 -3
  155. data/spec/mongo/auth/scram_spec.rb +2 -3
  156. data/spec/mongo/auth/user/view_spec.rb +1 -1
  157. data/spec/mongo/auth/x509_spec.rb +2 -3
  158. data/spec/mongo/bulk_write_spec.rb +3 -3
  159. data/spec/mongo/client_construction_spec.rb +259 -28
  160. data/spec/mongo/client_spec.rb +6 -4
  161. data/spec/mongo/cluster/cursor_reaper_spec.rb +36 -21
  162. data/spec/mongo/cluster/periodic_executor_spec.rb +3 -1
  163. data/spec/mongo/cluster_spec.rb +44 -3
  164. data/spec/mongo/collection/view/aggregation_spec.rb +1 -1
  165. data/spec/mongo/collection/view/builder/find_command_spec.rb +4 -0
  166. data/spec/mongo/collection/view/builder/op_query_spec.rb +4 -0
  167. data/spec/mongo/collection/view/map_reduce_spec.rb +1 -1
  168. data/spec/mongo/collection_crud_spec.rb +7 -2
  169. data/spec/mongo/collection_ddl_spec.rb +1 -1
  170. data/spec/mongo/collection_spec.rb +1 -1
  171. data/spec/mongo/cursor/builder/get_more_command_spec.rb +4 -0
  172. data/spec/mongo/cursor/builder/op_get_more_spec.rb +4 -0
  173. data/spec/mongo/cursor_spec.rb +15 -5
  174. data/spec/mongo/database_spec.rb +15 -15
  175. data/spec/mongo/error/operation_failure_heavy_spec.rb +1 -1
  176. data/spec/mongo/grid/fs_bucket_spec.rb +18 -12
  177. data/spec/mongo/grid/stream/write_spec.rb +3 -9
  178. data/spec/mongo/grid/stream_spec.rb +1 -1
  179. data/spec/mongo/index/view_spec.rb +2 -2
  180. data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
  181. data/spec/mongo/{collection/view → operation/find}/builder/flags_spec.rb +2 -2
  182. data/spec/mongo/{collection/view → operation/find}/builder/modifiers_spec.rb +2 -2
  183. data/spec/mongo/operation/find/legacy_spec.rb +1 -0
  184. data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
  185. data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
  186. data/spec/mongo/operation/kill_cursors_spec.rb +4 -1
  187. data/spec/mongo/operation/read_preference_legacy_spec.rb +4 -0
  188. data/spec/mongo/operation/read_preference_op_msg_spec.rb +2 -0
  189. data/spec/mongo/operation/update/bulk_spec.rb +1 -1
  190. data/spec/mongo/operation/update/op_msg_spec.rb +1 -1
  191. data/spec/mongo/query_cache_spec.rb +6 -2
  192. data/spec/mongo/server/connection_common_spec.rb +62 -11
  193. data/spec/mongo/server/connection_pool_spec.rb +73 -7
  194. data/spec/mongo/server/connection_spec.rb +138 -43
  195. data/spec/mongo/server/description_spec.rb +1 -1
  196. data/spec/mongo/server/monitor_spec.rb +4 -3
  197. data/spec/mongo/session/session_pool_spec.rb +42 -10
  198. data/spec/mongo/session_transaction_spec.rb +15 -30
  199. data/spec/mongo/socket/unix_spec.rb +1 -0
  200. data/spec/mongo/uri_option_parsing_spec.rb +38 -5
  201. data/spec/runners/change_streams/test.rb +1 -1
  202. data/spec/runners/cmap.rb +1 -1
  203. data/spec/runners/connection_string.rb +7 -3
  204. data/spec/runners/crud/operation.rb +5 -3
  205. data/spec/runners/crud/requirement.rb +1 -0
  206. data/spec/runners/crud.rb +1 -1
  207. data/spec/runners/sdam.rb +2 -1
  208. data/spec/runners/transactions/test.rb +2 -2
  209. data/spec/runners/unified/assertions.rb +2 -3
  210. data/spec/runners/unified/event_subscriber.rb +2 -2
  211. data/spec/runners/unified/test.rb +3 -0
  212. data/spec/runners/unified.rb +1 -1
  213. data/spec/shared/lib/mrss/constraints.rb +11 -5
  214. data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
  215. data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
  216. data/spec/shared/share/Dockerfile.erb +2 -1
  217. data/spec/shared/shlib/server.sh +70 -20
  218. data/spec/spec_tests/change_streams_spec.rb +1 -1
  219. data/spec/spec_tests/cmap_spec.rb +4 -1
  220. data/spec/spec_tests/command_monitoring_spec.rb +2 -2
  221. data/spec/spec_tests/data/command_monitoring/find.yml +9 -9
  222. data/spec/spec_tests/data/crud/read/aggregate-collation.yml +2 -1
  223. data/spec/spec_tests/data/crud/read/aggregate-out.yml +1 -0
  224. data/spec/spec_tests/data/crud/read/count-collation.yml +2 -1
  225. data/spec/spec_tests/data/crud/read/distinct-collation.yml +2 -1
  226. data/spec/spec_tests/data/crud/read/find-collation.yml +2 -1
  227. data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +2 -1
  228. data/spec/spec_tests/data/crud/write/deleteMany-collation.yml +2 -1
  229. data/spec/spec_tests/data/crud/write/deleteOne-collation.yml +2 -1
  230. data/spec/spec_tests/data/crud/write/findOneAndDelete-collation.yml +3 -2
  231. data/spec/spec_tests/data/crud/write/findOneAndReplace-collation.yml +2 -1
  232. data/spec/spec_tests/data/crud/write/findOneAndUpdate-collation.yml +3 -2
  233. data/spec/spec_tests/data/crud/write/replaceOne-collation.yml +3 -2
  234. data/spec/spec_tests/data/crud/write/updateMany-collation.yml +2 -1
  235. data/spec/spec_tests/data/crud/write/updateOne-collation.yml +2 -1
  236. data/spec/spec_tests/data/load_balancers/event-monitoring.yml +99 -0
  237. data/spec/spec_tests/data/load_balancers/lb-connection-establishment.yml +36 -0
  238. data/spec/spec_tests/data/load_balancers/non-lb-connection-establishment.yml +56 -0
  239. data/spec/spec_tests/data/load_balancers/server-selection.yml +50 -0
  240. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +1 -1
  241. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -1
  242. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +1 -1
  243. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -1
  244. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +1 -1
  245. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -1
  246. data/spec/spec_tests/data/retryable_reads/mapReduce.yml +3 -1
  247. data/spec/spec_tests/data/sdam/load-balanced/discover_load_balancer.yml +25 -0
  248. data/spec/spec_tests/data/sdam_integration/find-network-error.yml +2 -0
  249. data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +2 -0
  250. data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +3 -1
  251. data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +3 -1
  252. data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +2 -0
  253. data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +2 -0
  254. data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +2 -0
  255. data/spec/spec_tests/data/sdam_monitoring/load_balancer.yml +65 -0
  256. data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-directConnection.yml +13 -0
  257. data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-replicaSet-errors.yml +6 -0
  258. data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-multiple-hosts.yml +5 -0
  259. data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-txt.yml +10 -0
  260. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-false.yml +0 -0
  261. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-true.yml +0 -0
  262. data/spec/spec_tests/data/seed_list_discovery/replica-set/encoded-userinfo-and-db.yml +15 -0
  263. data/spec/spec_tests/data/seed_list_discovery/replica-set/loadBalanced-false-txt.yml +10 -0
  264. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/longer-parent-in-return.yml +0 -0
  265. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/misformatted-option.yml +0 -0
  266. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/no-results.yml +0 -0
  267. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/not-enough-parts.yml +0 -0
  268. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-result-default-port.yml +0 -0
  269. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record-multiple-strings.yml +0 -0
  270. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record.yml +0 -0
  271. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch1.yml +0 -0
  272. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch2.yml +0 -0
  273. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch3.yml +0 -0
  274. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch4.yml +0 -0
  275. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch5.yml +0 -0
  276. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-too-short.yml +0 -0
  277. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-wrong.yml +0 -0
  278. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-default-port.yml +0 -0
  279. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-nonstandard-port.yml +0 -0
  280. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-txt-records.yml +0 -0
  281. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-not-allowed-option.yml +0 -0
  282. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-ssl-option.yml +0 -0
  283. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-uri-option.yml +0 -0
  284. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-unallowed-option.yml +0 -0
  285. data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-admin-database.yml +13 -0
  286. data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-auth.yml +12 -0
  287. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-port.yml +0 -0
  288. data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-two-hosts.yml +0 -0
  289. data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +2 -0
  290. data/spec/spec_tests/data/transactions/retryable-abort.yml +2 -0
  291. data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +2 -0
  292. data/spec/spec_tests/data/transactions/retryable-commit.yml +2 -0
  293. data/spec/spec_tests/data/transactions/retryable-writes.yml +2 -0
  294. data/spec/spec_tests/data/uri_options/connection-options.yml +60 -0
  295. data/spec/spec_tests/load_balancers_spec.rb +15 -0
  296. data/spec/spec_tests/retryable_reads_spec.rb +2 -2
  297. data/spec/spec_tests/retryable_writes_spec.rb +1 -1
  298. data/spec/spec_tests/sdam_integration_spec.rb +1 -1
  299. data/spec/spec_tests/sdam_monitoring_spec.rb +10 -5
  300. data/spec/spec_tests/sdam_spec.rb +1 -1
  301. data/spec/spec_tests/seed_list_discovery_spec.rb +118 -0
  302. data/spec/spec_tests/uri_options_spec.rb +4 -4
  303. data/spec/stress/fork_reconnect_stress_spec.rb +1 -5
  304. data/spec/support/certificates/atlas-ocsp-ca.crt +82 -90
  305. data/spec/support/certificates/atlas-ocsp.crt +127 -122
  306. data/spec/support/common_shortcuts.rb +2 -3
  307. data/spec/support/matchers.rb +13 -0
  308. data/spec/support/shared/auth_context.rb +16 -0
  309. data/spec/support/shared/session.rb +2 -2
  310. data/spec/support/spec_config.rb +9 -10
  311. data/spec/support/using_hash.rb +31 -0
  312. data/spec/support/utils.rb +1 -1
  313. data.tar.gz.sig +0 -0
  314. metadata +120 -76
  315. metadata.gz.sig +0 -0
  316. data/lib/mongo/collection/view/builder/find_command.rb +0 -173
  317. data/lib/mongo/collection/view/builder/op_query.rb +0 -94
  318. data/lib/mongo/cursor/builder/get_more_command.rb +0 -80
  319. data/lib/mongo/cursor/builder/kill_cursors_command.rb +0 -111
  320. data/lib/mongo/cursor/builder/op_get_more.rb +0 -64
  321. data/lib/mongo/cursor/builder/op_kill_cursors.rb +0 -106
  322. data/lib/mongo/server/context.rb +0 -72
  323. data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -66
  324. data/spec/runners/unified/using_hash.rb +0 -34
  325. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +0 -79
  326. data/spec/support/event_subscriber.rb +0 -221
@@ -0,0 +1,56 @@
1
+ description: connection establishment if loadBalanced is specified for non-load balanced clusters
2
+
3
+ schemaVersion: '1.3'
4
+
5
+ runOnRequirements:
6
+ # Don't run on replica sets because the URI used to configure the clients will contain multiple hosts and the
7
+ # replicaSet option, which will cause an error when constructing the lbTrueClient entity.
8
+ - topologies: [ single, sharded ]
9
+
10
+ createEntities:
11
+ - client:
12
+ id: &lbTrueClient lbTrueClient
13
+ # Restrict to a single mongos to ensure there are not multiple hosts in the URI, which would conflict with
14
+ # loadBalanced=true.
15
+ useMultipleMongoses: false
16
+ uriOptions:
17
+ loadBalanced: true
18
+ - database:
19
+ id: &lbTrueDatabase lbTrueDatabase
20
+ client: *lbTrueClient
21
+ databaseName: &lbTrueDatabaseName lbTrueDb
22
+ - client:
23
+ id: &lbFalseClient lbFalseClient
24
+ uriOptions:
25
+ loadBalanced: false
26
+ - database:
27
+ id: &lbFalseDatabase lbFalseDatabase
28
+ client: *lbFalseClient
29
+ databaseName: &lbFalseDatabaseName lbFalseDb
30
+
31
+ _yamlAnchors:
32
+ runCommandArguments:
33
+ - &pingArguments
34
+ arguments:
35
+ commandName: ping
36
+ command: { ping: 1 }
37
+
38
+ tests:
39
+ # These tests assert that drivers behave correctly if loadBalanced=true/false for non-load balanced clusters. Existing
40
+ # spec tests should cover the case where loadBalanced is unset.
41
+
42
+ # If the server is not configured to be behind a load balancer and the URI contains loadBalanced=true, the driver
43
+ # should error during the connection handshake because the server's hello response does not contain a serviceId field.
44
+ - description: operations against non-load balanced clusters fail if URI contains loadBalanced=true
45
+ operations:
46
+ - name: runCommand
47
+ object: *lbTrueDatabase
48
+ <<: *pingArguments
49
+ expectError:
50
+ errorContains: Driver attempted to initialize in load balancing mode, but the server does not support this mode
51
+
52
+ - description: operations against non-load balanced clusters succeed if URI contains loadBalanced=false
53
+ operations:
54
+ - name: runCommand
55
+ object: *lbFalseDatabase
56
+ <<: *pingArguments
@@ -0,0 +1,50 @@
1
+ description: server selection for load-balanced clusters
2
+
3
+ schemaVersion: '1.3'
4
+
5
+ runOnRequirements:
6
+ - topologies: [ load-balanced ]
7
+
8
+ createEntities:
9
+ - client:
10
+ id: &client0 client0
11
+ useMultipleMongoses: true
12
+ observeEvents:
13
+ - commandStartedEvent
14
+ - database:
15
+ id: &database0 database0
16
+ client: *client0
17
+ databaseName: &database0Name database0Name
18
+ - collection:
19
+ id: &collection0 collection0
20
+ database: *database0
21
+ collectionName: &collection0Name coll0
22
+ collectionOptions:
23
+ readPreference:
24
+ # Use secondaryPreferred to ensure that operations can succeed even if the shards are only comprised of one
25
+ # server.
26
+ mode: &readPrefMode secondaryPreferred
27
+
28
+ initialData:
29
+ - collectionName: *collection0Name
30
+ databaseName: *database0Name
31
+ documents: []
32
+
33
+ tests:
34
+ - description: $readPreference is sent for load-balanced clusters
35
+ operations:
36
+ - name: find
37
+ object: *collection0
38
+ arguments:
39
+ filter: {}
40
+ expectEvents:
41
+ - client: *client0
42
+ events:
43
+ - commandStartedEvent:
44
+ command:
45
+ find: *collection0Name
46
+ filter: {}
47
+ $readPreference:
48
+ mode: *readPrefMode
49
+ commandName: find
50
+ databaseName: *database0Name
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,7 @@ runOn:
4
4
  topology: ["replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
8
  serverless: "forbid"
9
9
 
10
10
  database_name: &database_name "retryable-reads-tests"
@@ -4,7 +4,9 @@ runOn:
4
4
  topology: ["single", "replicaset"]
5
5
  -
6
6
  minServerVersion: "4.1.7"
7
- topology: ["sharded"]
7
+ topology: ["sharded", "load-balanced"]
8
+ # serverless proxy does not support mapReduce operation
9
+ serverless: "forbid"
8
10
 
9
11
  database_name: &database_name "retryable-reads-tests"
10
12
  collection_name: &collection_name "coll"
@@ -0,0 +1,25 @@
1
+ description: "Load balancer can be discovered and only has the address property set"
2
+
3
+ uri: "mongodb://a/?loadBalanced=true"
4
+
5
+ phases:
6
+
7
+ # There should be no monitoring in LoadBalanced mode, so no responses are necessary to get the topology into the
8
+ # correct state.
9
+ - outcome:
10
+ servers:
11
+ a:27017:
12
+ type: LoadBalancer
13
+ setName: null
14
+ setVersion: null
15
+ electionId: null
16
+ logicalSessionTimeoutMinutes: null
17
+ minWireVersion: null
18
+ maxWireVersion: null
19
+ topologyVersion: null
20
+ topologyType: LoadBalanced
21
+ setName: null
22
+ logicalSessionTimeoutMinutes: null
23
+ maxSetVersion: null
24
+ maxElectionId: null
25
+ compatible: true
@@ -2,6 +2,8 @@
2
2
  runOn:
3
3
  # failCommand appName requirements
4
4
  - minServerVersion: "4.4"
5
+ # TODO Remove the line below when load balancer is ready
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "find-network-error"
@@ -2,6 +2,8 @@
2
2
  runOn:
3
3
  # failCommand appName requirements
4
4
  - minServerVersion: "4.4"
5
+ # TODO Remove the line below when load balancer is ready
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "find-shutdown-error"
@@ -1,7 +1,9 @@
1
1
  # Test SDAM error handling.
2
2
  runOn:
3
3
  # failCommand appName requirements
4
- - minServerVersion: "4.4"
4
+ - minServerVersion: "4.9"
5
+ # TODO Remove the line below when load balancer is completed.
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "hello-command-error"
@@ -1,7 +1,9 @@
1
1
  #hello Test SDAM error handling.
2
2
  runOn:
3
3
  # failCommand appName requirements
4
- - minServerVersion: "4.4"
4
+ - minServerVersion: "4.9"
5
+ # TODO Uncomment the line below when load balancer is ready.
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "hello-network-error"
@@ -2,6 +2,8 @@
2
2
  runOn:
3
3
  # failCommand appName requirements
4
4
  - minServerVersion: "4.4"
5
+ # It seems this spec should not run against LB.
6
+ topology: ["single", "replicaset", "sharded"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "hello-timeout"
@@ -2,6 +2,8 @@
2
2
  runOn:
3
3
  # failCommand appName requirements
4
4
  - minServerVersion: "4.4"
5
+ # TODO Remove the line below when load balancer is ready
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "insert-network-error"
@@ -2,6 +2,8 @@
2
2
  runOn:
3
3
  # failCommand appName requirements
4
4
  - minServerVersion: "4.4"
5
+ # TODO Remove the line below when load balancer is ready
6
+ topology: ["replicaset","sharded","single"]
5
7
 
6
8
  database_name: &database_name "sdam-tests"
7
9
  collection_name: &collection_name "insert-shutdown-error"
@@ -0,0 +1,65 @@
1
+ description: "Monitoring a load balancer"
2
+ uri: "mongodb://a:27017/?loadBalanced=true"
3
+ phases:
4
+ -
5
+ outcome:
6
+ events:
7
+ -
8
+ topology_opening_event:
9
+ topologyId: "42"
10
+ -
11
+ topology_description_changed_event:
12
+ topologyId: "42"
13
+ previousDescription:
14
+ topologyType: "Unknown"
15
+ servers: []
16
+ newDescription:
17
+ topologyType: "LoadBalanced"
18
+ servers:
19
+ -
20
+ address: "a:27017"
21
+ arbiters: []
22
+ hosts: []
23
+ passives: []
24
+ type: "Unknown"
25
+ -
26
+ server_opening_event:
27
+ topologyId: "42"
28
+ address: "a:27017"
29
+ -
30
+ server_description_changed_event:
31
+ topologyId: "42"
32
+ address: "a:27017"
33
+ previousDescription:
34
+ address: "a:27017"
35
+ arbiters: []
36
+ hosts: []
37
+ passives: []
38
+ type: "Unknown"
39
+ newDescription:
40
+ address: "a:27017"
41
+ arbiters: []
42
+ hosts: []
43
+ passives: []
44
+ type: "LoadBalancer"
45
+ -
46
+ topology_description_changed_event:
47
+ topologyId: "42"
48
+ previousDescription:
49
+ topologyType: "LoadBalanced"
50
+ servers:
51
+ -
52
+ address: "a:27017"
53
+ arbiters: []
54
+ hosts: []
55
+ passives: []
56
+ type: "Unknown"
57
+ newDescription:
58
+ topologyType: "LoadBalanced"
59
+ servers:
60
+ -
61
+ address: "a:27017"
62
+ arbiters: []
63
+ hosts: []
64
+ passives: []
65
+ type: "LoadBalancer"
@@ -0,0 +1,13 @@
1
+ # The TXT record for test20.test.build.10gen.cc contains loadBalanced=true.
2
+ # DRIVERS-1721 introduced this test as passing.
3
+ uri: "mongodb+srv://test20.test.build.10gen.cc/?directConnection=false"
4
+ seeds:
5
+ - localhost.test.build.10gen.cc:27017
6
+ hosts:
7
+ # In LB mode, the driver does not do server discovery, so the hostname does
8
+ # not get resolved to localhost:27017.
9
+ - localhost.test.build.10gen.cc:27017
10
+ options:
11
+ loadBalanced: true
12
+ ssl: true
13
+ directConnection: false
@@ -0,0 +1,6 @@
1
+ # The TXT record for test20.test.build.10gen.cc contains loadBalanced=true.
2
+ uri: "mongodb+srv://test20.test.build.10gen.cc/?replicaSet=replset"
3
+ seeds: []
4
+ hosts: []
5
+ error: true
6
+ comment: Should fail because loadBalanced=true is incompatible with replicaSet
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test1.test.build.10gen.cc/?loadBalanced=true"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because loadBalanced is true but the SRV record resolves to multiple hosts
@@ -0,0 +1,10 @@
1
+ uri: "mongodb+srv://test20.test.build.10gen.cc/"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ # In LB mode, the driver does not do server discovery, so the hostname does
6
+ # not get resolved to localhost:27017.
7
+ - localhost.test.build.10gen.cc:27017
8
+ options:
9
+ loadBalanced: true
10
+ ssl: true
@@ -0,0 +1,15 @@
1
+ uri: "mongodb+srv://b*b%40f3tt%3D:%244to%40L8%3DMC@test3.test.build.10gen.cc/mydb%3F?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ ssl: true
11
+ parsed_options:
12
+ user: "b*b@f3tt="
13
+ password: "$4to@L8=MC"
14
+ db: "mydb?"
15
+ comment: Encoded user, pass, and DB parse correctly
@@ -0,0 +1,10 @@
1
+ uri: "mongodb+srv://test21.test.build.10gen.cc/"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ loadBalanced: false
10
+ ssl: true
@@ -0,0 +1,13 @@
1
+ uri: "mongodb+srv://test1.test.build.10gen.cc/adminDB?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ - localhost.test.build.10gen.cc:27018
5
+ hosts:
6
+ - localhost:27017
7
+ - localhost:27018
8
+ - localhost:27019
9
+ options:
10
+ replicaSet: repl0
11
+ ssl: true
12
+ parsed_options:
13
+ auth_database: adminDB
@@ -0,0 +1,12 @@
1
+ uri: "mongodb+srv://auser:apass@test1.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ - localhost.test.build.10gen.cc:27018
5
+ hosts:
6
+ - localhost:27017
7
+ - localhost:27018
8
+ - localhost:27019
9
+ parsed_options:
10
+ user: auser
11
+ password: apass
12
+ comment: Should preserve auth credentials
@@ -2,6 +2,8 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.3.1"
4
4
  topology: ["replicaset", "sharded"]
5
+ # https://jira.mongodb.org/browse/RUBY-2776
6
+ serverless: forbid
5
7
 
6
8
  database_name: &database_name "transaction-tests"
7
9
  collection_name: &collection_name "test"
@@ -5,6 +5,8 @@ runOn:
5
5
  -
6
6
  minServerVersion: "4.1.8"
7
7
  topology: ["sharded"]
8
+ # https://jira.mongodb.org/browse/RUBY-2776
9
+ serverless: forbid
8
10
 
9
11
  database_name: &database_name "transaction-tests"
10
12
  collection_name: &collection_name "test"
@@ -2,6 +2,8 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.3.1"
4
4
  topology: ["replicaset", "sharded"]
5
+ # https://jira.mongodb.org/browse/RUBY-2776
6
+ serverless: forbid
5
7
 
6
8
  database_name: &database_name "transaction-tests"
7
9
  collection_name: &collection_name "test"
@@ -5,6 +5,8 @@ runOn:
5
5
  -
6
6
  minServerVersion: "4.1.8"
7
7
  topology: ["sharded"]
8
+ # https://jira.mongodb.org/browse/RUBY-2776
9
+ serverless: forbid
8
10
 
9
11
  database_name: &database_name "transaction-tests"
10
12
  collection_name: &collection_name "test"
@@ -5,6 +5,8 @@ runOn:
5
5
  -
6
6
  minServerVersion: "4.1.8"
7
7
  topology: ["sharded"]
8
+ # https://jira.mongodb.org/browse/RUBY-2776
9
+ serverless: forbid
8
10
 
9
11
  database_name: &database_name "transaction-tests"
10
12
  collection_name: &collection_name "test"
@@ -147,3 +147,63 @@ tests:
147
147
  hosts: ~
148
148
  auth: ~
149
149
  options: {}
150
+ -
151
+ description: loadBalanced=true
152
+ uri: "mongodb://example.com/?loadBalanced=true"
153
+ valid: true
154
+ warning: false
155
+ hosts: ~
156
+ auth: ~
157
+ options:
158
+ loadBalanced: true
159
+ -
160
+ description: loadBalanced=true with directConnection=false
161
+ uri: "mongodb://example.com/?loadBalanced=true&directConnection=false"
162
+ valid: true
163
+ warning: false
164
+ hosts: ~
165
+ auth: ~
166
+ options:
167
+ loadBalanced: true
168
+ directConnection: false
169
+ -
170
+ description: loadBalanced=false
171
+ uri: "mongodb://example.com/?loadBalanced=false"
172
+ valid: true
173
+ warning: false
174
+ hosts: ~
175
+ auth: ~
176
+ options:
177
+ loadBalanced: false
178
+ -
179
+ description: Invalid loadBalanced value
180
+ uri: "mongodb://example.com/?loadBalanced=1"
181
+ valid: true
182
+ warning: true
183
+ hosts: ~
184
+ auth: ~
185
+ options: {}
186
+ -
187
+ description: loadBalanced=true with multiple hosts causes an error
188
+ uri: "mongodb://example1,example2/?loadBalanced=true"
189
+ valid: false
190
+ warning: false
191
+ hosts: ~
192
+ auth: ~
193
+ options: {}
194
+ -
195
+ description: loadBalanced=true with directConnection=true causes an error
196
+ uri: "mongodb://example.com/?loadBalanced=true&directConnection=true"
197
+ valid: false
198
+ warning: false
199
+ hosts: ~
200
+ auth: ~
201
+ options: {}
202
+ -
203
+ description: loadBalanced=true with replicaSet causes an error
204
+ uri: "mongodb://example.com/?loadBalanced=true&replicaSet=replset"
205
+ valid: false
206
+ warning: false
207
+ hosts: ~
208
+ auth: ~
209
+ options: {}
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ require 'spec_helper'
5
+
6
+ require 'runners/unified'
7
+
8
+ base = "#{CURRENT_PATH}/spec_tests/data/load_balancers"
9
+ LOAD_BALANCER_TESTS = Dir.glob("#{base}/**/*.yml").sort
10
+
11
+ describe 'Load balancer spec tests' do
12
+ require_topology :load_balanced
13
+
14
+ define_unified_spec_tests(base, LOAD_BALANCER_TESTS)
15
+ end