mongo 2.15.0.alpha → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1108) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -1
  3. data.tar.gz.sig +0 -0
  4. data/README.md +1 -1
  5. data/lib/mongo.rb +3 -0
  6. data/lib/mongo/active_support.rb +3 -0
  7. data/lib/mongo/address.rb +3 -0
  8. data/lib/mongo/address/ipv4.rb +3 -0
  9. data/lib/mongo/address/ipv6.rb +3 -0
  10. data/lib/mongo/address/unix.rb +3 -0
  11. data/lib/mongo/address/validator.rb +3 -0
  12. data/lib/mongo/auth.rb +4 -1
  13. data/lib/mongo/auth/aws.rb +3 -0
  14. data/lib/mongo/auth/aws/conversation.rb +3 -0
  15. data/lib/mongo/auth/aws/credentials_retriever.rb +3 -0
  16. data/lib/mongo/auth/aws/request.rb +3 -0
  17. data/lib/mongo/auth/base.rb +4 -1
  18. data/lib/mongo/auth/conversation_base.rb +3 -0
  19. data/lib/mongo/auth/cr.rb +3 -0
  20. data/lib/mongo/auth/cr/conversation.rb +3 -0
  21. data/lib/mongo/auth/credential_cache.rb +3 -0
  22. data/lib/mongo/auth/gssapi.rb +3 -0
  23. data/lib/mongo/auth/gssapi/conversation.rb +3 -0
  24. data/lib/mongo/auth/ldap.rb +3 -0
  25. data/lib/mongo/auth/ldap/conversation.rb +3 -0
  26. data/lib/mongo/auth/roles.rb +3 -0
  27. data/lib/mongo/auth/sasl_conversation_base.rb +3 -0
  28. data/lib/mongo/auth/scram.rb +5 -2
  29. data/lib/mongo/auth/scram/conversation.rb +3 -0
  30. data/lib/mongo/auth/scram256.rb +3 -0
  31. data/lib/mongo/auth/scram256/conversation.rb +3 -0
  32. data/lib/mongo/auth/scram_conversation_base.rb +3 -0
  33. data/lib/mongo/auth/stringprep.rb +4 -1
  34. data/lib/mongo/auth/stringprep/profiles/sasl.rb +3 -0
  35. data/lib/mongo/auth/stringprep/tables.rb +3 -0
  36. data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +2 -2
  37. data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1 -1
  38. data/lib/mongo/auth/user.rb +3 -0
  39. data/lib/mongo/auth/user/view.rb +3 -0
  40. data/lib/mongo/auth/x509.rb +3 -0
  41. data/lib/mongo/auth/x509/conversation.rb +3 -0
  42. data/lib/mongo/background_thread.rb +5 -2
  43. data/lib/mongo/bson.rb +3 -0
  44. data/lib/mongo/bulk_write.rb +3 -0
  45. data/lib/mongo/bulk_write/combineable.rb +3 -0
  46. data/lib/mongo/bulk_write/ordered_combiner.rb +3 -0
  47. data/lib/mongo/bulk_write/result.rb +3 -0
  48. data/lib/mongo/bulk_write/result_combiner.rb +3 -0
  49. data/lib/mongo/bulk_write/transformable.rb +3 -0
  50. data/lib/mongo/bulk_write/unordered_combiner.rb +3 -0
  51. data/lib/mongo/bulk_write/validatable.rb +3 -0
  52. data/lib/mongo/caching_cursor.rb +3 -0
  53. data/lib/mongo/client.rb +4 -1
  54. data/lib/mongo/client_encryption.rb +3 -0
  55. data/lib/mongo/cluster.rb +10 -7
  56. data/lib/mongo/cluster/periodic_executor.rb +3 -0
  57. data/lib/mongo/cluster/reapers/cursor_reaper.rb +3 -0
  58. data/lib/mongo/cluster/reapers/socket_reaper.rb +3 -0
  59. data/lib/mongo/cluster/sdam_flow.rb +3 -0
  60. data/lib/mongo/cluster/topology.rb +3 -0
  61. data/lib/mongo/cluster/topology/base.rb +3 -0
  62. data/lib/mongo/cluster/topology/no_replica_set_options.rb +3 -0
  63. data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -0
  64. data/lib/mongo/cluster/topology/replica_set_with_primary.rb +3 -0
  65. data/lib/mongo/cluster/topology/sharded.rb +3 -0
  66. data/lib/mongo/cluster/topology/single.rb +3 -0
  67. data/lib/mongo/cluster/topology/unknown.rb +3 -0
  68. data/lib/mongo/cluster_time.rb +3 -0
  69. data/lib/mongo/collection.rb +35 -11
  70. data/lib/mongo/collection/view.rb +3 -0
  71. data/lib/mongo/collection/view/aggregation.rb +3 -0
  72. data/lib/mongo/collection/view/builder.rb +3 -0
  73. data/lib/mongo/collection/view/builder/aggregation.rb +3 -0
  74. data/lib/mongo/collection/view/builder/find_command.rb +3 -0
  75. data/lib/mongo/collection/view/builder/flags.rb +3 -0
  76. data/lib/mongo/collection/view/builder/map_reduce.rb +3 -0
  77. data/lib/mongo/collection/view/builder/modifiers.rb +3 -0
  78. data/lib/mongo/collection/view/builder/op_query.rb +3 -0
  79. data/lib/mongo/collection/view/change_stream.rb +4 -1
  80. data/lib/mongo/collection/view/change_stream/retryable.rb +3 -0
  81. data/lib/mongo/collection/view/explainable.rb +3 -0
  82. data/lib/mongo/collection/view/immutable.rb +3 -0
  83. data/lib/mongo/collection/view/iterable.rb +3 -0
  84. data/lib/mongo/collection/view/map_reduce.rb +3 -0
  85. data/lib/mongo/collection/view/readable.rb +11 -2
  86. data/lib/mongo/collection/view/writable.rb +3 -0
  87. data/lib/mongo/crypt.rb +3 -0
  88. data/lib/mongo/crypt/auto_decryption_context.rb +3 -0
  89. data/lib/mongo/crypt/auto_encrypter.rb +4 -1
  90. data/lib/mongo/crypt/auto_encryption_context.rb +3 -0
  91. data/lib/mongo/crypt/binary.rb +3 -0
  92. data/lib/mongo/crypt/binding.rb +4 -1
  93. data/lib/mongo/crypt/context.rb +3 -0
  94. data/lib/mongo/crypt/data_key_context.rb +3 -0
  95. data/lib/mongo/crypt/encryption_io.rb +3 -0
  96. data/lib/mongo/crypt/explicit_decryption_context.rb +3 -0
  97. data/lib/mongo/crypt/explicit_encrypter.rb +3 -0
  98. data/lib/mongo/crypt/explicit_encryption_context.rb +3 -0
  99. data/lib/mongo/crypt/handle.rb +3 -0
  100. data/lib/mongo/crypt/hooks.rb +3 -0
  101. data/lib/mongo/crypt/kms_context.rb +3 -0
  102. data/lib/mongo/crypt/status.rb +3 -0
  103. data/lib/mongo/cursor.rb +4 -0
  104. data/lib/mongo/cursor/builder.rb +3 -0
  105. data/lib/mongo/cursor/builder/get_more_command.rb +3 -0
  106. data/lib/mongo/cursor/builder/kill_cursors_command.rb +3 -0
  107. data/lib/mongo/cursor/builder/op_get_more.rb +3 -0
  108. data/lib/mongo/cursor/builder/op_kill_cursors.rb +3 -0
  109. data/lib/mongo/database.rb +4 -1
  110. data/lib/mongo/database/view.rb +3 -0
  111. data/lib/mongo/dbref.rb +3 -0
  112. data/lib/mongo/distinguishing_semaphore.rb +3 -0
  113. data/lib/mongo/error.rb +3 -0
  114. data/lib/mongo/error/auth_error.rb +3 -0
  115. data/lib/mongo/error/bulk_write_error.rb +3 -0
  116. data/lib/mongo/error/change_stream_resumable.rb +3 -0
  117. data/lib/mongo/error/closed_stream.rb +3 -0
  118. data/lib/mongo/error/connection_check_out_timeout.rb +3 -0
  119. data/lib/mongo/error/connection_perished.rb +3 -0
  120. data/lib/mongo/error/credential_check_error.rb +3 -0
  121. data/lib/mongo/error/crypt_error.rb +3 -0
  122. data/lib/mongo/error/extra_file_chunk.rb +3 -0
  123. data/lib/mongo/error/failed_string_prep_validation.rb +3 -0
  124. data/lib/mongo/error/file_not_found.rb +3 -0
  125. data/lib/mongo/error/handshake_error.rb +3 -0
  126. data/lib/mongo/error/insufficient_iteration_count.rb +3 -0
  127. data/lib/mongo/error/internal_driver_error.rb +3 -0
  128. data/lib/mongo/error/invalid_address.rb +3 -0
  129. data/lib/mongo/error/invalid_application_name.rb +3 -0
  130. data/lib/mongo/error/invalid_bulk_operation.rb +3 -0
  131. data/lib/mongo/error/invalid_bulk_operation_type.rb +3 -0
  132. data/lib/mongo/error/invalid_collection_name.rb +3 -0
  133. data/lib/mongo/error/invalid_cursor_operation.rb +3 -0
  134. data/lib/mongo/error/invalid_database_name.rb +3 -0
  135. data/lib/mongo/error/invalid_document.rb +3 -0
  136. data/lib/mongo/error/invalid_file.rb +3 -0
  137. data/lib/mongo/error/invalid_file_revision.rb +3 -0
  138. data/lib/mongo/error/invalid_min_pool_size.rb +3 -0
  139. data/lib/mongo/error/invalid_nonce.rb +3 -0
  140. data/lib/mongo/error/invalid_read_concern.rb +3 -0
  141. data/lib/mongo/error/invalid_read_option.rb +3 -0
  142. data/lib/mongo/error/invalid_replacement_document.rb +3 -0
  143. data/lib/mongo/error/invalid_server_auth_host.rb +3 -0
  144. data/lib/mongo/error/invalid_server_auth_response.rb +3 -0
  145. data/lib/mongo/error/invalid_server_preference.rb +3 -0
  146. data/lib/mongo/error/invalid_session.rb +3 -0
  147. data/lib/mongo/error/invalid_signature.rb +3 -0
  148. data/lib/mongo/error/invalid_transaction_operation.rb +3 -0
  149. data/lib/mongo/error/invalid_txt_record.rb +3 -0
  150. data/lib/mongo/error/invalid_update_document.rb +3 -0
  151. data/lib/mongo/error/invalid_uri.rb +3 -0
  152. data/lib/mongo/error/invalid_write_concern.rb +3 -0
  153. data/lib/mongo/error/kms_error.rb +3 -0
  154. data/lib/mongo/error/lint_error.rb +3 -0
  155. data/lib/mongo/error/max_bson_size.rb +3 -0
  156. data/lib/mongo/error/max_message_size.rb +3 -0
  157. data/lib/mongo/error/mismatched_domain.rb +3 -0
  158. data/lib/mongo/error/missing_file_chunk.rb +3 -0
  159. data/lib/mongo/error/missing_password.rb +3 -0
  160. data/lib/mongo/error/missing_resume_token.rb +3 -0
  161. data/lib/mongo/error/missing_scram_server_signature.rb +3 -0
  162. data/lib/mongo/error/mongocryptd_spawn_error.rb +3 -0
  163. data/lib/mongo/error/multi_index_drop.rb +3 -0
  164. data/lib/mongo/error/need_primary_server.rb +3 -0
  165. data/lib/mongo/error/no_server_available.rb +3 -0
  166. data/lib/mongo/error/no_srv_records.rb +3 -0
  167. data/lib/mongo/error/notable.rb +3 -0
  168. data/lib/mongo/error/operation_failure.rb +5 -2
  169. data/lib/mongo/error/parser.rb +4 -1
  170. data/lib/mongo/error/pool_closed_error.rb +3 -0
  171. data/lib/mongo/error/raise_original_error.rb +3 -0
  172. data/lib/mongo/error/sdam_error_detection.rb +16 -5
  173. data/lib/mongo/error/server_api_conflict.rb +3 -0
  174. data/lib/mongo/error/server_api_not_supported.rb +3 -0
  175. data/lib/mongo/error/server_certificate_revoked.rb +3 -0
  176. data/lib/mongo/error/session_ended.rb +3 -0
  177. data/lib/mongo/error/sessions_not_supported.rb +3 -0
  178. data/lib/mongo/error/socket_error.rb +3 -0
  179. data/lib/mongo/error/socket_timeout_error.rb +3 -0
  180. data/lib/mongo/error/unchangeable_collection_option.rb +3 -0
  181. data/lib/mongo/error/unexpected_chunk_length.rb +3 -0
  182. data/lib/mongo/error/unexpected_response.rb +3 -0
  183. data/lib/mongo/error/unknown_payload_type.rb +3 -0
  184. data/lib/mongo/error/unmet_dependency.rb +3 -0
  185. data/lib/mongo/error/unsupported_array_filters.rb +3 -0
  186. data/lib/mongo/error/unsupported_collation.rb +3 -0
  187. data/lib/mongo/error/unsupported_features.rb +3 -0
  188. data/lib/mongo/error/unsupported_message_type.rb +3 -0
  189. data/lib/mongo/error/unsupported_option.rb +3 -0
  190. data/lib/mongo/error/write_retryable.rb +3 -0
  191. data/lib/mongo/event.rb +3 -0
  192. data/lib/mongo/event/base.rb +3 -0
  193. data/lib/mongo/event/listeners.rb +3 -0
  194. data/lib/mongo/event/publisher.rb +3 -0
  195. data/lib/mongo/event/subscriber.rb +3 -0
  196. data/lib/mongo/grid.rb +3 -0
  197. data/lib/mongo/grid/file.rb +3 -0
  198. data/lib/mongo/grid/file/chunk.rb +4 -1
  199. data/lib/mongo/grid/file/info.rb +3 -0
  200. data/lib/mongo/grid/fs_bucket.rb +29 -8
  201. data/lib/mongo/grid/stream.rb +3 -0
  202. data/lib/mongo/grid/stream/read.rb +22 -7
  203. data/lib/mongo/grid/stream/write.rb +3 -0
  204. data/lib/mongo/id.rb +3 -0
  205. data/lib/mongo/index.rb +3 -0
  206. data/lib/mongo/index/view.rb +3 -0
  207. data/lib/mongo/lint.rb +3 -0
  208. data/lib/mongo/loggable.rb +3 -0
  209. data/lib/mongo/logger.rb +3 -0
  210. data/lib/mongo/monitoring.rb +9 -6
  211. data/lib/mongo/monitoring/cmap_log_subscriber.rb +3 -0
  212. data/lib/mongo/monitoring/command_log_subscriber.rb +3 -0
  213. data/lib/mongo/monitoring/event.rb +3 -0
  214. data/lib/mongo/monitoring/event/cmap.rb +3 -0
  215. data/lib/mongo/monitoring/event/cmap/base.rb +3 -0
  216. data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +3 -0
  217. data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +3 -0
  218. data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +3 -0
  219. data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +3 -0
  220. data/lib/mongo/monitoring/event/cmap/connection_closed.rb +3 -0
  221. data/lib/mongo/monitoring/event/cmap/connection_created.rb +3 -0
  222. data/lib/mongo/monitoring/event/cmap/connection_ready.rb +3 -0
  223. data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +3 -0
  224. data/lib/mongo/monitoring/event/cmap/pool_closed.rb +3 -0
  225. data/lib/mongo/monitoring/event/cmap/pool_created.rb +3 -0
  226. data/lib/mongo/monitoring/event/command_failed.rb +32 -5
  227. data/lib/mongo/monitoring/event/command_started.rb +20 -2
  228. data/lib/mongo/monitoring/event/command_succeeded.rb +29 -3
  229. data/lib/mongo/monitoring/event/secure.rb +39 -5
  230. data/lib/mongo/monitoring/event/server_closed.rb +3 -0
  231. data/lib/mongo/monitoring/event/server_description_changed.rb +4 -1
  232. data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +6 -3
  233. data/lib/mongo/monitoring/event/server_heartbeat_started.rb +3 -0
  234. data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +5 -2
  235. data/lib/mongo/monitoring/event/server_opening.rb +3 -0
  236. data/lib/mongo/monitoring/event/topology_changed.rb +3 -0
  237. data/lib/mongo/monitoring/event/topology_closed.rb +3 -0
  238. data/lib/mongo/monitoring/event/topology_opening.rb +3 -0
  239. data/lib/mongo/monitoring/publishable.rb +32 -10
  240. data/lib/mongo/monitoring/sdam_log_subscriber.rb +3 -0
  241. data/lib/mongo/monitoring/server_closed_log_subscriber.rb +3 -0
  242. data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +3 -0
  243. data/lib/mongo/monitoring/server_opening_log_subscriber.rb +3 -0
  244. data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +3 -0
  245. data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +3 -0
  246. data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +3 -0
  247. data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +3 -0
  248. data/lib/mongo/operation.rb +3 -0
  249. data/lib/mongo/operation/aggregate.rb +3 -0
  250. data/lib/mongo/operation/aggregate/command.rb +3 -0
  251. data/lib/mongo/operation/aggregate/op_msg.rb +3 -0
  252. data/lib/mongo/operation/aggregate/result.rb +3 -0
  253. data/lib/mongo/operation/collections_info.rb +3 -0
  254. data/lib/mongo/operation/collections_info/command.rb +3 -0
  255. data/lib/mongo/operation/collections_info/result.rb +3 -0
  256. data/lib/mongo/operation/command.rb +3 -0
  257. data/lib/mongo/operation/command/command.rb +3 -0
  258. data/lib/mongo/operation/command/op_msg.rb +3 -0
  259. data/lib/mongo/operation/context.rb +3 -0
  260. data/lib/mongo/operation/count.rb +3 -0
  261. data/lib/mongo/operation/count/command.rb +3 -0
  262. data/lib/mongo/operation/count/op_msg.rb +3 -0
  263. data/lib/mongo/operation/create.rb +3 -0
  264. data/lib/mongo/operation/create/command.rb +3 -0
  265. data/lib/mongo/operation/create/op_msg.rb +3 -0
  266. data/lib/mongo/operation/create_index.rb +3 -0
  267. data/lib/mongo/operation/create_index/command.rb +3 -0
  268. data/lib/mongo/operation/create_index/op_msg.rb +3 -0
  269. data/lib/mongo/operation/create_user.rb +3 -0
  270. data/lib/mongo/operation/create_user/command.rb +3 -0
  271. data/lib/mongo/operation/create_user/op_msg.rb +3 -0
  272. data/lib/mongo/operation/delete.rb +3 -0
  273. data/lib/mongo/operation/delete/bulk_result.rb +3 -0
  274. data/lib/mongo/operation/delete/command.rb +3 -0
  275. data/lib/mongo/operation/delete/legacy.rb +3 -0
  276. data/lib/mongo/operation/delete/op_msg.rb +3 -0
  277. data/lib/mongo/operation/delete/result.rb +3 -0
  278. data/lib/mongo/operation/distinct.rb +3 -0
  279. data/lib/mongo/operation/distinct/command.rb +3 -0
  280. data/lib/mongo/operation/distinct/op_msg.rb +3 -0
  281. data/lib/mongo/operation/drop.rb +3 -0
  282. data/lib/mongo/operation/drop/command.rb +3 -0
  283. data/lib/mongo/operation/drop/op_msg.rb +3 -0
  284. data/lib/mongo/operation/drop_database.rb +3 -0
  285. data/lib/mongo/operation/drop_database/command.rb +3 -0
  286. data/lib/mongo/operation/drop_database/op_msg.rb +3 -0
  287. data/lib/mongo/operation/drop_index.rb +3 -0
  288. data/lib/mongo/operation/drop_index/command.rb +3 -0
  289. data/lib/mongo/operation/drop_index/op_msg.rb +3 -0
  290. data/lib/mongo/operation/explain.rb +3 -0
  291. data/lib/mongo/operation/explain/command.rb +3 -0
  292. data/lib/mongo/operation/explain/legacy.rb +3 -0
  293. data/lib/mongo/operation/explain/op_msg.rb +3 -0
  294. data/lib/mongo/operation/explain/result.rb +3 -0
  295. data/lib/mongo/operation/find.rb +3 -0
  296. data/lib/mongo/operation/find/command.rb +3 -0
  297. data/lib/mongo/operation/find/legacy.rb +3 -0
  298. data/lib/mongo/operation/find/legacy/result.rb +3 -0
  299. data/lib/mongo/operation/find/op_msg.rb +3 -0
  300. data/lib/mongo/operation/find/result.rb +3 -0
  301. data/lib/mongo/operation/get_more.rb +3 -0
  302. data/lib/mongo/operation/get_more/command.rb +3 -0
  303. data/lib/mongo/operation/get_more/legacy.rb +3 -0
  304. data/lib/mongo/operation/get_more/op_msg.rb +3 -0
  305. data/lib/mongo/operation/get_more/result.rb +3 -0
  306. data/lib/mongo/operation/indexes.rb +3 -0
  307. data/lib/mongo/operation/indexes/command.rb +3 -0
  308. data/lib/mongo/operation/indexes/legacy.rb +3 -0
  309. data/lib/mongo/operation/indexes/op_msg.rb +3 -0
  310. data/lib/mongo/operation/indexes/result.rb +3 -0
  311. data/lib/mongo/operation/insert.rb +3 -0
  312. data/lib/mongo/operation/insert/bulk_result.rb +3 -0
  313. data/lib/mongo/operation/insert/command.rb +3 -0
  314. data/lib/mongo/operation/insert/legacy.rb +3 -0
  315. data/lib/mongo/operation/insert/op_msg.rb +3 -0
  316. data/lib/mongo/operation/insert/result.rb +3 -0
  317. data/lib/mongo/operation/kill_cursors.rb +3 -0
  318. data/lib/mongo/operation/kill_cursors/command.rb +3 -0
  319. data/lib/mongo/operation/kill_cursors/legacy.rb +3 -0
  320. data/lib/mongo/operation/kill_cursors/op_msg.rb +3 -0
  321. data/lib/mongo/operation/list_collections.rb +3 -0
  322. data/lib/mongo/operation/list_collections/command.rb +3 -0
  323. data/lib/mongo/operation/list_collections/op_msg.rb +3 -0
  324. data/lib/mongo/operation/list_collections/result.rb +3 -0
  325. data/lib/mongo/operation/map_reduce.rb +3 -0
  326. data/lib/mongo/operation/map_reduce/command.rb +3 -0
  327. data/lib/mongo/operation/map_reduce/op_msg.rb +3 -0
  328. data/lib/mongo/operation/map_reduce/result.rb +3 -0
  329. data/lib/mongo/operation/op_msg_base.rb +3 -0
  330. data/lib/mongo/operation/parallel_scan.rb +3 -0
  331. data/lib/mongo/operation/parallel_scan/command.rb +4 -2
  332. data/lib/mongo/operation/parallel_scan/op_msg.rb +3 -0
  333. data/lib/mongo/operation/parallel_scan/result.rb +3 -0
  334. data/lib/mongo/operation/remove_user.rb +3 -0
  335. data/lib/mongo/operation/remove_user/command.rb +3 -0
  336. data/lib/mongo/operation/remove_user/op_msg.rb +3 -0
  337. data/lib/mongo/operation/result.rb +3 -0
  338. data/lib/mongo/operation/shared/bypass_document_validation.rb +3 -0
  339. data/lib/mongo/operation/shared/causal_consistency_supported.rb +3 -0
  340. data/lib/mongo/operation/shared/executable.rb +4 -4
  341. data/lib/mongo/operation/shared/executable_no_validate.rb +3 -0
  342. data/lib/mongo/operation/shared/executable_transaction_label.rb +3 -0
  343. data/lib/mongo/operation/shared/idable.rb +3 -0
  344. data/lib/mongo/operation/shared/limited.rb +3 -0
  345. data/lib/mongo/operation/shared/object_id_generator.rb +3 -0
  346. data/lib/mongo/operation/shared/op_msg_or_command.rb +3 -0
  347. data/lib/mongo/operation/shared/op_msg_or_find_command.rb +3 -0
  348. data/lib/mongo/operation/shared/polymorphic_lookup.rb +3 -0
  349. data/lib/mongo/operation/shared/polymorphic_operation.rb +3 -0
  350. data/lib/mongo/operation/shared/polymorphic_result.rb +3 -0
  351. data/lib/mongo/operation/shared/read_preference_supported.rb +41 -36
  352. data/lib/mongo/operation/shared/response_handling.rb +3 -0
  353. data/lib/mongo/operation/shared/result/aggregatable.rb +3 -0
  354. data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +3 -0
  355. data/lib/mongo/operation/shared/sessions_supported.rb +6 -2
  356. data/lib/mongo/operation/shared/specifiable.rb +3 -0
  357. data/lib/mongo/operation/shared/write.rb +3 -0
  358. data/lib/mongo/operation/shared/write_concern_supported.rb +3 -0
  359. data/lib/mongo/operation/update.rb +3 -0
  360. data/lib/mongo/operation/update/bulk_result.rb +3 -0
  361. data/lib/mongo/operation/update/command.rb +3 -0
  362. data/lib/mongo/operation/update/legacy.rb +3 -0
  363. data/lib/mongo/operation/update/legacy/result.rb +3 -0
  364. data/lib/mongo/operation/update/op_msg.rb +3 -0
  365. data/lib/mongo/operation/update/result.rb +3 -0
  366. data/lib/mongo/operation/update_user.rb +3 -0
  367. data/lib/mongo/operation/update_user/command.rb +3 -0
  368. data/lib/mongo/operation/update_user/op_msg.rb +3 -0
  369. data/lib/mongo/operation/users_info.rb +3 -0
  370. data/lib/mongo/operation/users_info/command.rb +3 -0
  371. data/lib/mongo/operation/users_info/op_msg.rb +3 -0
  372. data/lib/mongo/operation/users_info/result.rb +3 -0
  373. data/lib/mongo/options.rb +3 -0
  374. data/lib/mongo/options/mapper.rb +3 -0
  375. data/lib/mongo/options/redacted.rb +3 -0
  376. data/lib/mongo/protocol.rb +3 -0
  377. data/lib/mongo/protocol/bit_vector.rb +3 -0
  378. data/lib/mongo/protocol/compressed.rb +3 -0
  379. data/lib/mongo/protocol/delete.rb +3 -0
  380. data/lib/mongo/protocol/get_more.rb +3 -0
  381. data/lib/mongo/protocol/insert.rb +3 -0
  382. data/lib/mongo/protocol/kill_cursors.rb +3 -0
  383. data/lib/mongo/protocol/message.rb +3 -0
  384. data/lib/mongo/protocol/msg.rb +8 -10
  385. data/lib/mongo/protocol/query.rb +18 -14
  386. data/lib/mongo/protocol/registry.rb +3 -0
  387. data/lib/mongo/protocol/reply.rb +3 -0
  388. data/lib/mongo/protocol/serializers.rb +3 -0
  389. data/lib/mongo/protocol/update.rb +3 -0
  390. data/lib/mongo/query_cache.rb +3 -0
  391. data/lib/mongo/retryable.rb +3 -0
  392. data/lib/mongo/semaphore.rb +3 -0
  393. data/lib/mongo/server.rb +17 -0
  394. data/lib/mongo/server/app_metadata.rb +40 -18
  395. data/lib/mongo/server/connection.rb +4 -1
  396. data/lib/mongo/server/connection_base.rb +22 -10
  397. data/lib/mongo/server/connection_common.rb +34 -1
  398. data/lib/mongo/server/connection_pool.rb +5 -2
  399. data/lib/mongo/server/connection_pool/populator.rb +3 -0
  400. data/lib/mongo/server/context.rb +3 -0
  401. data/lib/mongo/server/description.rb +23 -10
  402. data/lib/mongo/server/description/features.rb +5 -2
  403. data/lib/mongo/server/monitor.rb +15 -21
  404. data/lib/mongo/server/monitor/app_metadata.rb +3 -0
  405. data/lib/mongo/server/monitor/connection.rb +50 -39
  406. data/lib/mongo/server/pending_connection.rb +19 -20
  407. data/lib/mongo/server/push_monitor.rb +26 -21
  408. data/lib/mongo/server/push_monitor/connection.rb +3 -0
  409. data/lib/mongo/server/round_trip_time_averager.rb +6 -3
  410. data/lib/mongo/server_selector.rb +3 -0
  411. data/lib/mongo/server_selector/base.rb +6 -3
  412. data/lib/mongo/server_selector/nearest.rb +6 -4
  413. data/lib/mongo/server_selector/primary.rb +6 -4
  414. data/lib/mongo/server_selector/primary_preferred.rb +6 -4
  415. data/lib/mongo/server_selector/secondary.rb +6 -4
  416. data/lib/mongo/server_selector/secondary_preferred.rb +8 -11
  417. data/lib/mongo/session.rb +17 -10
  418. data/lib/mongo/session/server_session.rb +3 -0
  419. data/lib/mongo/session/session_pool.rb +3 -0
  420. data/lib/mongo/socket.rb +8 -3
  421. data/lib/mongo/socket/ocsp_cache.rb +3 -0
  422. data/lib/mongo/socket/ocsp_verifier.rb +9 -1
  423. data/lib/mongo/socket/ssl.rb +3 -0
  424. data/lib/mongo/socket/tcp.rb +3 -0
  425. data/lib/mongo/socket/unix.rb +3 -0
  426. data/lib/mongo/srv.rb +3 -0
  427. data/lib/mongo/srv/monitor.rb +3 -0
  428. data/lib/mongo/srv/resolver.rb +3 -0
  429. data/lib/mongo/srv/result.rb +3 -0
  430. data/lib/mongo/timeout.rb +3 -0
  431. data/lib/mongo/topology_version.rb +4 -1
  432. data/lib/mongo/uri.rb +3 -0
  433. data/lib/mongo/uri/options_mapper.rb +3 -0
  434. data/lib/mongo/uri/srv_protocol.rb +3 -0
  435. data/lib/mongo/utils.rb +30 -0
  436. data/lib/mongo/version.rb +4 -1
  437. data/lib/mongo/write_concern.rb +3 -0
  438. data/lib/mongo/write_concern/acknowledged.rb +3 -0
  439. data/lib/mongo/write_concern/base.rb +3 -0
  440. data/lib/mongo/write_concern/unacknowledged.rb +3 -0
  441. data/spec/atlas/atlas_connectivity_spec.rb +3 -0
  442. data/spec/atlas/operations_spec.rb +3 -0
  443. data/spec/integration/auth_spec.rb +3 -0
  444. data/spec/integration/awaited_ismaster_spec.rb +8 -5
  445. data/spec/integration/aws_auth_request_spec.rb +3 -0
  446. data/spec/integration/aws_credentials_retriever_spec.rb +3 -0
  447. data/spec/integration/bson_symbol_spec.rb +4 -1
  448. data/spec/integration/bulk_insert_spec.rb +3 -0
  449. data/spec/integration/bulk_write_spec.rb +3 -0
  450. data/spec/integration/change_stream_examples_spec.rb +3 -0
  451. data/spec/integration/change_stream_spec.rb +3 -0
  452. data/spec/integration/check_clean_slate_spec.rb +3 -0
  453. data/spec/integration/client_authentication_options_spec.rb +21 -8
  454. data/spec/integration/client_connectivity_spec.rb +4 -1
  455. data/spec/integration/client_construction_aws_auth_spec.rb +3 -0
  456. data/spec/integration/client_construction_spec.rb +3 -0
  457. data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +3 -0
  458. data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +3 -0
  459. data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +3 -0
  460. data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +3 -0
  461. data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +3 -0
  462. data/spec/integration/client_side_encryption/auto_encryption_spec.rb +3 -0
  463. data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +3 -0
  464. data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +4 -1
  465. data/spec/integration/client_side_encryption/client_close_spec.rb +3 -0
  466. data/spec/integration/client_side_encryption/corpus_spec.rb +3 -0
  467. data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +3 -0
  468. data/spec/integration/client_side_encryption/data_key_spec.rb +3 -0
  469. data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +3 -0
  470. data/spec/integration/client_side_encryption/external_key_vault_spec.rb +3 -0
  471. data/spec/integration/client_side_encryption/views_spec.rb +3 -0
  472. data/spec/integration/client_spec.rb +5 -2
  473. data/spec/integration/client_update_spec.rb +3 -0
  474. data/spec/integration/collection_indexes_prose_spec.rb +3 -0
  475. data/spec/integration/command_monitoring_spec.rb +61 -23
  476. data/spec/integration/command_spec.rb +3 -0
  477. data/spec/integration/connect_single_rs_name_spec.rb +6 -3
  478. data/spec/integration/connection_pool_populator_spec.rb +3 -0
  479. data/spec/integration/connection_spec.rb +10 -7
  480. data/spec/integration/crud_spec.rb +31 -0
  481. data/spec/integration/cursor_reaping_spec.rb +3 -0
  482. data/spec/integration/docs_examples_spec.rb +3 -0
  483. data/spec/integration/error_detection_spec.rb +3 -0
  484. data/spec/integration/fork_reconnect_spec.rb +4 -1
  485. data/spec/integration/get_more_spec.rb +3 -0
  486. data/spec/integration/grid_fs_bucket_spec.rb +4 -1
  487. data/spec/integration/heartbeat_events_spec.rb +7 -4
  488. data/spec/integration/mmapv1_spec.rb +3 -0
  489. data/spec/integration/mongos_pinning_spec.rb +3 -0
  490. data/spec/integration/ocsp_connectivity_spec.rb +3 -0
  491. data/spec/integration/ocsp_verifier_cache_spec.rb +3 -0
  492. data/spec/integration/ocsp_verifier_spec.rb +16 -1
  493. data/spec/integration/operation_failure_code_spec.rb +3 -0
  494. data/spec/integration/query_cache_spec.rb +3 -0
  495. data/spec/integration/query_cache_transactions_spec.rb +3 -0
  496. data/spec/integration/read_concern_spec.rb +3 -0
  497. data/spec/integration/read_preference_spec.rb +3 -0
  498. data/spec/integration/reconnect_spec.rb +3 -0
  499. data/spec/integration/retryable_errors_spec.rb +3 -0
  500. data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +3 -0
  501. data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +3 -0
  502. data/spec/integration/retryable_writes/shared/adds_diagnostics.rb +3 -0
  503. data/spec/integration/retryable_writes/shared/does_not_support_retries.rb +3 -0
  504. data/spec/integration/retryable_writes/shared/only_supports_legacy_retries.rb +3 -0
  505. data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +3 -0
  506. data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -0
  507. data/spec/integration/retryable_writes/shared/performs_no_retries.rb +3 -0
  508. data/spec/integration/retryable_writes/shared/supports_legacy_retries.rb +3 -0
  509. data/spec/integration/retryable_writes/shared/supports_modern_retries.rb +3 -0
  510. data/spec/integration/retryable_writes/shared/supports_retries.rb +3 -0
  511. data/spec/integration/retryable_writes_errors_spec.rb +3 -0
  512. data/spec/integration/sdam_error_handling_spec.rb +5 -2
  513. data/spec/integration/sdam_events_spec.rb +11 -5
  514. data/spec/integration/sdam_prose_spec.rb +4 -1
  515. data/spec/integration/secondary_reads_spec.rb +102 -0
  516. data/spec/integration/server_description_spec.rb +3 -0
  517. data/spec/integration/server_monitor_spec.rb +4 -1
  518. data/spec/integration/server_selection_spec.rb +3 -0
  519. data/spec/integration/server_selector_spec.rb +3 -0
  520. data/spec/integration/server_spec.rb +3 -0
  521. data/spec/integration/shell_examples_spec.rb +3 -0
  522. data/spec/integration/size_limit_spec.rb +3 -0
  523. data/spec/integration/snappy_compression_spec.rb +3 -0
  524. data/spec/integration/srv_monitoring_spec.rb +3 -0
  525. data/spec/integration/srv_spec.rb +3 -0
  526. data/spec/integration/ssl_uri_options_spec.rb +3 -0
  527. data/spec/integration/step_down_spec.rb +3 -0
  528. data/spec/integration/time_zone_querying_spec.rb +3 -0
  529. data/spec/integration/transactions_api_examples_spec.rb +3 -0
  530. data/spec/integration/transactions_examples_spec.rb +3 -0
  531. data/spec/integration/truncated_utf8_spec.rb +26 -0
  532. data/spec/integration/versioned_api_examples_spec.rb +69 -0
  533. data/spec/integration/x509_auth_spec.rb +4 -1
  534. data/spec/integration/zlib_compression_spec.rb +3 -0
  535. data/spec/integration/zstd_compression_spec.rb +3 -0
  536. data/spec/kerberos/kerberos_spec.rb +3 -0
  537. data/spec/lite_spec_helper.rb +4 -0
  538. data/spec/mongo/address/ipv4_spec.rb +3 -0
  539. data/spec/mongo/address/ipv6_spec.rb +3 -0
  540. data/spec/mongo/address/unix_spec.rb +3 -0
  541. data/spec/mongo/address/validator_spec.rb +3 -0
  542. data/spec/mongo/address_spec.rb +3 -0
  543. data/spec/mongo/auth/aws/request_region_spec.rb +3 -0
  544. data/spec/mongo/auth/aws/request_spec.rb +3 -0
  545. data/spec/mongo/auth/cr_spec.rb +3 -0
  546. data/spec/mongo/auth/gssapi/conversation_spec.rb +3 -0
  547. data/spec/mongo/auth/invalid_mechanism_spec.rb +3 -0
  548. data/spec/mongo/auth/ldap/conversation_spec.rb +3 -0
  549. data/spec/mongo/auth/ldap_spec.rb +3 -0
  550. data/spec/mongo/auth/scram/conversation_spec.rb +3 -0
  551. data/spec/mongo/auth/scram256/conversation_spec.rb +3 -0
  552. data/spec/mongo/auth/scram_negotiation_spec.rb +3 -0
  553. data/spec/mongo/auth/scram_spec.rb +3 -0
  554. data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +3 -0
  555. data/spec/mongo/auth/stringprep_spec.rb +3 -0
  556. data/spec/mongo/auth/user/view_spec.rb +3 -0
  557. data/spec/mongo/auth/user_spec.rb +3 -0
  558. data/spec/mongo/auth/x509/conversation_spec.rb +3 -0
  559. data/spec/mongo/auth/x509_spec.rb +3 -0
  560. data/spec/mongo/auth_spec.rb +3 -0
  561. data/spec/mongo/bson_spec.rb +3 -0
  562. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +3 -0
  563. data/spec/mongo/bulk_write/result_spec.rb +3 -0
  564. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +3 -0
  565. data/spec/mongo/bulk_write_spec.rb +3 -0
  566. data/spec/mongo/caching_cursor_spec.rb +3 -0
  567. data/spec/mongo/client_construction_spec.rb +10 -5
  568. data/spec/mongo/client_encryption_spec.rb +3 -0
  569. data/spec/mongo/client_spec.rb +3 -0
  570. data/spec/mongo/cluster/cursor_reaper_spec.rb +3 -0
  571. data/spec/mongo/cluster/periodic_executor_spec.rb +3 -0
  572. data/spec/mongo/cluster/socket_reaper_spec.rb +3 -0
  573. data/spec/mongo/cluster/topology/replica_set_spec.rb +12 -9
  574. data/spec/mongo/cluster/topology/sharded_spec.rb +5 -2
  575. data/spec/mongo/cluster/topology/single_spec.rb +5 -2
  576. data/spec/mongo/cluster/topology/unknown_spec.rb +3 -0
  577. data/spec/mongo/cluster/topology_spec.rb +3 -0
  578. data/spec/mongo/cluster_spec.rb +4 -0
  579. data/spec/mongo/cluster_time_spec.rb +3 -0
  580. data/spec/mongo/collection/view/aggregation_spec.rb +3 -0
  581. data/spec/mongo/collection/view/builder/find_command_spec.rb +3 -0
  582. data/spec/mongo/collection/view/builder/flags_spec.rb +3 -0
  583. data/spec/mongo/collection/view/builder/modifiers_spec.rb +3 -0
  584. data/spec/mongo/collection/view/builder/op_query_spec.rb +3 -0
  585. data/spec/mongo/collection/view/change_stream_resume_spec.rb +7 -2
  586. data/spec/mongo/collection/view/change_stream_spec.rb +16 -0
  587. data/spec/mongo/collection/view/explainable_spec.rb +3 -0
  588. data/spec/mongo/collection/view/immutable_spec.rb +3 -0
  589. data/spec/mongo/collection/view/iterable_spec.rb +3 -0
  590. data/spec/mongo/collection/view/map_reduce_spec.rb +3 -0
  591. data/spec/mongo/collection/view/readable_spec.rb +19 -0
  592. data/spec/mongo/collection/view/writable_spec.rb +3 -0
  593. data/spec/mongo/collection/view_spec.rb +3 -0
  594. data/spec/mongo/collection_crud_spec.rb +3 -0
  595. data/spec/mongo/collection_ddl_spec.rb +3 -0
  596. data/spec/mongo/collection_spec.rb +3 -0
  597. data/spec/mongo/crypt/auto_decryption_context_spec.rb +3 -0
  598. data/spec/mongo/crypt/auto_encrypter_spec.rb +3 -0
  599. data/spec/mongo/crypt/auto_encryption_context_spec.rb +3 -0
  600. data/spec/mongo/crypt/binary_spec.rb +3 -0
  601. data/spec/mongo/crypt/binding/binary_spec.rb +3 -0
  602. data/spec/mongo/crypt/binding/context_spec.rb +3 -0
  603. data/spec/mongo/crypt/binding/helpers_spec.rb +3 -0
  604. data/spec/mongo/crypt/binding/mongocrypt_spec.rb +3 -0
  605. data/spec/mongo/crypt/binding/status_spec.rb +3 -0
  606. data/spec/mongo/crypt/binding/version_spec.rb +3 -0
  607. data/spec/mongo/crypt/binding_unloaded_spec.rb +3 -0
  608. data/spec/mongo/crypt/data_key_context_spec.rb +3 -0
  609. data/spec/mongo/crypt/encryption_io_spec.rb +3 -0
  610. data/spec/mongo/crypt/explicit_decryption_context_spec.rb +3 -0
  611. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +3 -0
  612. data/spec/mongo/crypt/handle_spec.rb +3 -0
  613. data/spec/mongo/crypt/helpers/mongo_crypt_spec_helper.rb +3 -0
  614. data/spec/mongo/crypt/status_spec.rb +3 -0
  615. data/spec/mongo/cursor/builder/get_more_command_spec.rb +7 -2
  616. data/spec/mongo/cursor/builder/op_get_more_spec.rb +7 -2
  617. data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +7 -2
  618. data/spec/mongo/cursor_spec.rb +74 -7
  619. data/spec/mongo/database_spec.rb +9 -6
  620. data/spec/mongo/dbref_spec.rb +3 -0
  621. data/spec/mongo/distinguishing_semaphore_spec.rb +3 -0
  622. data/spec/mongo/error/bulk_write_error_spec.rb +3 -0
  623. data/spec/mongo/error/crypt_error_spec.rb +3 -0
  624. data/spec/mongo/error/max_bson_size_spec.rb +3 -0
  625. data/spec/mongo/error/no_server_available_spec.rb +3 -0
  626. data/spec/mongo/error/notable_spec.rb +3 -0
  627. data/spec/mongo/error/operation_failure_heavy_spec.rb +3 -0
  628. data/spec/mongo/error/operation_failure_spec.rb +94 -31
  629. data/spec/mongo/error/parser_spec.rb +3 -0
  630. data/spec/mongo/error/unsupported_option_spec.rb +3 -0
  631. data/spec/mongo/event/publisher_spec.rb +3 -0
  632. data/spec/mongo/event/subscriber_spec.rb +3 -0
  633. data/spec/mongo/grid/file/chunk_spec.rb +7 -4
  634. data/spec/mongo/grid/file/info_spec.rb +3 -0
  635. data/spec/mongo/grid/file_spec.rb +4 -1
  636. data/spec/mongo/grid/fs_bucket_spec.rb +22 -5
  637. data/spec/mongo/grid/stream/read_spec.rb +33 -10
  638. data/spec/mongo/grid/stream/write_spec.rb +3 -0
  639. data/spec/mongo/grid/stream_spec.rb +3 -0
  640. data/spec/mongo/id_spec.rb +3 -0
  641. data/spec/mongo/index/view_spec.rb +3 -0
  642. data/spec/mongo/lint_spec.rb +3 -0
  643. data/spec/mongo/logger_spec.rb +3 -0
  644. data/spec/mongo/monitoring/command_log_subscriber_spec.rb +3 -0
  645. data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +3 -0
  646. data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +3 -0
  647. data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +3 -0
  648. data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +3 -0
  649. data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +3 -0
  650. data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +3 -0
  651. data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +3 -0
  652. data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +3 -0
  653. data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +3 -0
  654. data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +3 -0
  655. data/spec/mongo/monitoring/event/command_failed_spec.rb +59 -2
  656. data/spec/mongo/monitoring/event/command_started_spec.rb +3 -0
  657. data/spec/mongo/monitoring/event/command_succeeded_spec.rb +46 -6
  658. data/spec/mongo/monitoring/event/secure_spec.rb +28 -4
  659. data/spec/mongo/monitoring/event/server_closed_spec.rb +3 -0
  660. data/spec/mongo/monitoring/event/server_description_changed_spec.rb +3 -0
  661. data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +3 -0
  662. data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +3 -0
  663. data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +3 -0
  664. data/spec/mongo/monitoring/event/server_opening_spec.rb +3 -0
  665. data/spec/mongo/monitoring/event/topology_changed_spec.rb +3 -0
  666. data/spec/mongo/monitoring/event/topology_closed_spec.rb +3 -0
  667. data/spec/mongo/monitoring/event/topology_opening_spec.rb +3 -0
  668. data/spec/mongo/monitoring_spec.rb +3 -0
  669. data/spec/mongo/operation/aggregate/result_spec.rb +7 -2
  670. data/spec/mongo/operation/aggregate_spec.rb +3 -0
  671. data/spec/mongo/operation/collections_info_spec.rb +3 -0
  672. data/spec/mongo/operation/command_spec.rb +5 -2
  673. data/spec/mongo/operation/create_index_spec.rb +3 -0
  674. data/spec/mongo/operation/create_user_spec.rb +3 -0
  675. data/spec/mongo/operation/delete/bulk_spec.rb +3 -0
  676. data/spec/mongo/operation/delete/command_spec.rb +3 -0
  677. data/spec/mongo/operation/delete/op_msg_spec.rb +3 -0
  678. data/spec/mongo/operation/delete_spec.rb +3 -0
  679. data/spec/mongo/operation/drop_index_spec.rb +3 -0
  680. data/spec/mongo/operation/find/legacy_spec.rb +4 -1
  681. data/spec/mongo/operation/get_more_spec.rb +3 -0
  682. data/spec/mongo/operation/indexes_spec.rb +3 -0
  683. data/spec/mongo/operation/insert/bulk_spec.rb +3 -0
  684. data/spec/mongo/operation/insert/command_spec.rb +3 -0
  685. data/spec/mongo/operation/insert/op_msg_spec.rb +3 -0
  686. data/spec/mongo/operation/insert_spec.rb +3 -0
  687. data/spec/mongo/operation/kill_cursors_spec.rb +3 -0
  688. data/spec/mongo/operation/limited_spec.rb +3 -0
  689. data/spec/mongo/operation/map_reduce_spec.rb +3 -0
  690. data/spec/mongo/operation/read_preference_legacy_spec.rb +35 -42
  691. data/spec/mongo/operation/read_preference_op_msg_spec.rb +6 -3
  692. data/spec/mongo/operation/remove_user_spec.rb +3 -0
  693. data/spec/mongo/operation/result_spec.rb +9 -4
  694. data/spec/mongo/operation/specifiable_spec.rb +3 -0
  695. data/spec/mongo/operation/update/bulk_spec.rb +3 -0
  696. data/spec/mongo/operation/update/command_spec.rb +3 -0
  697. data/spec/mongo/operation/update/op_msg_spec.rb +3 -0
  698. data/spec/mongo/operation/update_spec.rb +3 -0
  699. data/spec/mongo/operation/update_user_spec.rb +3 -0
  700. data/spec/mongo/options/redacted_spec.rb +3 -0
  701. data/spec/mongo/protocol/compressed_spec.rb +3 -0
  702. data/spec/mongo/protocol/delete_spec.rb +3 -0
  703. data/spec/mongo/protocol/get_more_spec.rb +3 -0
  704. data/spec/mongo/protocol/insert_spec.rb +3 -0
  705. data/spec/mongo/protocol/kill_cursors_spec.rb +3 -0
  706. data/spec/mongo/protocol/msg_spec.rb +4 -1
  707. data/spec/mongo/protocol/query_spec.rb +6 -3
  708. data/spec/mongo/protocol/registry_spec.rb +3 -0
  709. data/spec/mongo/protocol/reply_spec.rb +3 -0
  710. data/spec/mongo/protocol/update_spec.rb +3 -0
  711. data/spec/mongo/query_cache_spec.rb +3 -0
  712. data/spec/mongo/retryable_spec.rb +3 -0
  713. data/spec/mongo/semaphore_spec.rb +3 -0
  714. data/spec/mongo/server/app_metadata_spec.rb +44 -21
  715. data/spec/mongo/server/connection_auth_spec.rb +6 -9
  716. data/spec/mongo/server/connection_common_spec.rb +24 -0
  717. data/spec/mongo/server/connection_pool/populator_spec.rb +3 -0
  718. data/spec/mongo/server/connection_pool_spec.rb +3 -0
  719. data/spec/mongo/server/connection_spec.rb +9 -0
  720. data/spec/mongo/server/description/features_spec.rb +3 -0
  721. data/spec/mongo/server/description_query_methods_spec.rb +4 -1
  722. data/spec/mongo/server/description_spec.rb +624 -611
  723. data/spec/mongo/server/monitor/app_metadata_spec.rb +3 -1
  724. data/spec/mongo/server/monitor/connection_spec.rb +40 -0
  725. data/spec/mongo/server/monitor_spec.rb +13 -10
  726. data/spec/mongo/server/round_trip_time_averager_spec.rb +3 -0
  727. data/spec/mongo/server_selector/nearest_spec.rb +8 -2
  728. data/spec/mongo/server_selector/primary_preferred_spec.rb +8 -2
  729. data/spec/mongo/server_selector/primary_spec.rb +8 -2
  730. data/spec/mongo/server_selector/secondary_preferred_spec.rb +14 -8
  731. data/spec/mongo/server_selector/secondary_spec.rb +8 -2
  732. data/spec/mongo/server_selector_spec.rb +5 -1
  733. data/spec/mongo/server_spec.rb +3 -0
  734. data/spec/mongo/session/server_session_spec.rb +3 -0
  735. data/spec/mongo/session/session_pool_spec.rb +3 -0
  736. data/spec/mongo/session_spec.rb +3 -0
  737. data/spec/mongo/session_transaction_spec.rb +7 -12
  738. data/spec/mongo/socket/ssl_spec.rb +3 -0
  739. data/spec/mongo/socket/tcp_spec.rb +3 -0
  740. data/spec/mongo/socket/unix_spec.rb +3 -0
  741. data/spec/mongo/socket_spec.rb +3 -0
  742. data/spec/mongo/srv/monitor_spec.rb +3 -0
  743. data/spec/mongo/srv/result_spec.rb +3 -0
  744. data/spec/mongo/timeout_spec.rb +3 -0
  745. data/spec/mongo/tls_context_hooks_spec.rb +3 -0
  746. data/spec/mongo/uri/srv_protocol_spec.rb +4 -0
  747. data/spec/mongo/uri_option_parsing_spec.rb +3 -0
  748. data/spec/mongo/uri_spec.rb +3 -0
  749. data/spec/mongo/utils_spec.rb +17 -0
  750. data/spec/mongo/write_concern/acknowledged_spec.rb +3 -0
  751. data/spec/mongo/write_concern/unacknowledged_spec.rb +3 -0
  752. data/spec/mongo/write_concern_spec.rb +3 -0
  753. data/spec/runners/auth.rb +22 -1
  754. data/spec/runners/change_streams/outcome.rb +3 -0
  755. data/spec/runners/change_streams/spec.rb +3 -0
  756. data/spec/runners/change_streams/test.rb +3 -0
  757. data/spec/runners/cmap.rb +3 -0
  758. data/spec/runners/cmap/verifier.rb +3 -0
  759. data/spec/runners/command_monitoring.rb +3 -0
  760. data/spec/runners/connection_string.rb +3 -0
  761. data/spec/runners/crud.rb +22 -0
  762. data/spec/runners/crud/context.rb +3 -0
  763. data/spec/runners/crud/operation.rb +3 -0
  764. data/spec/runners/crud/outcome.rb +3 -0
  765. data/spec/runners/crud/requirement.rb +28 -1
  766. data/spec/runners/crud/spec.rb +3 -0
  767. data/spec/runners/crud/test.rb +3 -0
  768. data/spec/runners/crud/test_base.rb +3 -0
  769. data/spec/runners/crud/verifier.rb +3 -0
  770. data/spec/runners/gridfs.rb +3 -0
  771. data/spec/runners/read_write_concern_document.rb +3 -0
  772. data/spec/runners/sdam.rb +6 -3
  773. data/spec/runners/sdam/verifier.rb +3 -0
  774. data/spec/runners/server_selection.rb +3 -0
  775. data/spec/runners/server_selection_rtt.rb +4 -1
  776. data/spec/runners/transactions.rb +3 -0
  777. data/spec/runners/transactions/operation.rb +3 -0
  778. data/spec/runners/transactions/spec.rb +3 -0
  779. data/spec/runners/transactions/test.rb +3 -0
  780. data/spec/runners/unified.rb +3 -0
  781. data/spec/runners/unified/assertions.rb +43 -10
  782. data/spec/runners/unified/change_stream_operations.rb +3 -0
  783. data/spec/runners/unified/crud_operations.rb +8 -1
  784. data/spec/runners/unified/ddl_operations.rb +11 -1
  785. data/spec/runners/unified/entity_map.rb +3 -0
  786. data/spec/runners/unified/error.rb +3 -0
  787. data/spec/runners/unified/event_subscriber.rb +24 -11
  788. data/spec/runners/unified/exceptions.rb +3 -0
  789. data/spec/runners/unified/grid_fs_operations.rb +3 -0
  790. data/spec/runners/unified/support_operations.rb +3 -0
  791. data/spec/runners/unified/test.rb +53 -23
  792. data/spec/runners/unified/test_group.rb +3 -0
  793. data/spec/runners/unified/using_hash.rb +3 -0
  794. data/spec/shared/bin/s3-copy +45 -0
  795. data/spec/shared/bin/s3-upload +69 -0
  796. data/spec/shared/lib/mrss/cluster_config.rb +11 -3
  797. data/spec/shared/lib/mrss/constraints.rb +39 -6
  798. data/spec/shared/lib/mrss/docker_runner.rb +10 -1
  799. data/spec/shared/lib/mrss/lite_constraints.rb +16 -0
  800. data/spec/shared/lib/mrss/server_version_registry.rb +3 -0
  801. data/spec/shared/lib/mrss/spec_organizer.rb +32 -2
  802. data/spec/shared/share/Dockerfile.erb +123 -32
  803. data/spec/shared/share/haproxy-1.conf +16 -0
  804. data/spec/shared/share/haproxy-2.conf +17 -0
  805. data/spec/shared/shlib/server.sh +31 -4
  806. data/spec/shared/shlib/set_env.sh +4 -1
  807. data/spec/solo/clean_exit_spec.rb +3 -0
  808. data/spec/spec_helper.rb +4 -2
  809. data/spec/spec_tests/auth_spec.rb +30 -13
  810. data/spec/spec_tests/change_streams_spec.rb +3 -0
  811. data/spec/spec_tests/change_streams_unified_spec.rb +13 -0
  812. data/spec/spec_tests/client_side_encryption_spec.rb +3 -0
  813. data/spec/spec_tests/cmap_spec.rb +3 -0
  814. data/spec/spec_tests/collection_management_spec.rb +13 -0
  815. data/spec/spec_tests/command_monitoring_spec.rb +31 -26
  816. data/spec/spec_tests/command_monitoring_unified_spec.rb +13 -0
  817. data/spec/spec_tests/connection_string_spec.rb +3 -0
  818. data/spec/spec_tests/crud_spec.rb +3 -0
  819. data/spec/spec_tests/crud_unified_spec.rb +3 -0
  820. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +5 -5
  821. data/spec/spec_tests/data/change_streams/{change-streams-resume-whitelist.yml → change-streams-resume-allowlist.yml} +58 -58
  822. data/spec/spec_tests/data/change_streams/change-streams-resume-errorLabels.yml +46 -46
  823. data/spec/spec_tests/data/change_streams_unified/change-streams.yml +72 -0
  824. data/spec/spec_tests/data/collection_management/timeseries-collection.yml +129 -0
  825. data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +340 -0
  826. data/spec/spec_tests/data/crud/write/bulkWrite.yml +26 -22
  827. data/spec/spec_tests/data/crud/write/insertMany.yml +26 -22
  828. data/spec/spec_tests/data/crud_unified/updateWithPipelines.yml +305 -0
  829. data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +1 -0
  830. data/spec/spec_tests/data/crud_v2/db-aggregate.yml +1 -0
  831. data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +1 -1
  832. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +6 -5
  833. data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -0
  834. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +6 -5
  835. data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -0
  836. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +6 -5
  837. data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -0
  838. data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +1 -1
  839. data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +1 -1
  840. data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +1 -1
  841. data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +1 -1
  842. data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-pre4.9.yml +1 -1
  843. data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +1 -1
  844. data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +1 -1
  845. data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +1 -1
  846. data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +1 -1
  847. data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +1 -1
  848. data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +1 -1
  849. data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +1 -1
  850. data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +1 -1
  851. data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +1 -1
  852. data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +1 -1
  853. data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +1 -1
  854. data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +1 -1
  855. data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +30 -24
  856. data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +5 -4
  857. data/spec/spec_tests/data/sdam/errors/error_handling_handshake.yml +2 -1
  858. data/spec/spec_tests/data/sdam/errors/non-stale-network-error.yml +2 -1
  859. data/spec/spec_tests/data/sdam/errors/non-stale-network-timeout-error.yml +2 -1
  860. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedAtShutdown.yml +2 -1
  861. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedDueToReplStateChange.yml +2 -1
  862. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-LegacyNotPrimary.yml +61 -0
  863. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-greater-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-greater-NotPrimaryNoSecondaryOk.yml} +5 -4
  864. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-greater-NotMasterOrSecondary.yml → non-stale-topologyVersion-greater-NotPrimaryOrSecondary.yml} +5 -4
  865. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-greater-NotMaster.yml → non-stale-topologyVersion-greater-NotWritablePrimary.yml} +5 -4
  866. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-PrimarySteppedDown.yml +2 -1
  867. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-ShutdownInProgress.yml +2 -1
  868. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedAtShutdown.yml +2 -1
  869. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedDueToReplStateChange.yml +2 -1
  870. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-LegacyNotPrimary.yml +52 -0
  871. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-missing-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-missing-NotPrimaryNoSecondaryOk.yml} +5 -4
  872. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-missing-NotMasterOrSecondary.yml → non-stale-topologyVersion-missing-NotPrimaryOrSecondary.yml} +5 -4
  873. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-missing-NotMaster.yml → non-stale-topologyVersion-missing-NotWritablePrimary.yml} +5 -4
  874. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-PrimarySteppedDown.yml +2 -1
  875. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-ShutdownInProgress.yml +2 -1
  876. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedAtShutdown.yml +2 -1
  877. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedDueToReplStateChange.yml +2 -1
  878. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-LegacyNotPrimary.yml +61 -0
  879. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-proccessId-changed-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-proccessId-changed-NotPrimaryNoSecondaryOk.yml} +5 -4
  880. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-proccessId-changed-NotMasterOrSecondary.yml → non-stale-topologyVersion-proccessId-changed-NotPrimaryOrSecondary.yml} +5 -4
  881. data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-proccessId-changed-NotMaster.yml → non-stale-topologyVersion-proccessId-changed-NotWritablePrimary.yml} +5 -4
  882. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-PrimarySteppedDown.yml +2 -1
  883. data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-ShutdownInProgress.yml +2 -1
  884. data/spec/spec_tests/data/sdam/errors/post-42-InterruptedAtShutdown.yml +2 -1
  885. data/spec/spec_tests/data/sdam/errors/post-42-InterruptedDueToReplStateChange.yml +2 -1
  886. data/spec/spec_tests/data/sdam/errors/post-42-LegacyNotPrimary.yml +47 -0
  887. data/spec/spec_tests/data/sdam/errors/{post-42-NotMasterNoSlaveOk.yml → post-42-NotPrimaryNoSecondaryOk.yml} +5 -4
  888. data/spec/spec_tests/data/sdam/errors/{post-42-NotMasterOrSecondary.yml → post-42-NotPrimaryOrSecondary.yml} +5 -4
  889. data/spec/spec_tests/data/sdam/errors/{post-42-NotMaster.yml → post-42-NotWritablePrimary.yml} +5 -4
  890. data/spec/spec_tests/data/sdam/errors/post-42-PrimarySteppedDown.yml +2 -1
  891. data/spec/spec_tests/data/sdam/errors/post-42-ShutdownInProgress.yml +2 -1
  892. data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedAtShutdown.yml +2 -1
  893. data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedDueToReplStateChange.yml +2 -1
  894. data/spec/spec_tests/data/sdam/errors/{pre-42-NotMaster.yml → pre-42-LegacyNotPrimary.yml} +6 -5
  895. data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryNoSecondaryOk.yml +47 -0
  896. data/spec/spec_tests/data/sdam/errors/{pre-42-NotMasterOrSecondary.yml → pre-42-NotPrimaryOrSecondary.yml} +5 -4
  897. data/spec/spec_tests/data/sdam/errors/{pre-42-NotMasterNoSlaveOk.yml → pre-42-NotWritablePrimary.yml} +6 -5
  898. data/spec/spec_tests/data/sdam/errors/pre-42-PrimarySteppedDown.yml +2 -1
  899. data/spec/spec_tests/data/sdam/errors/pre-42-ShutdownInProgress.yml +2 -1
  900. data/spec/spec_tests/data/sdam/errors/prefer-error-code.yml +54 -0
  901. data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedAtShutdown.yml +4 -2
  902. data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedDueToReplStateChange.yml +4 -2
  903. data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMasterNoSlaveOk.yml → stale-generation-NotPrimaryNoSecondaryOk.yml} +7 -5
  904. data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMasterOrSecondary.yml → stale-generation-NotPrimaryOrSecondary.yml} +7 -5
  905. data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMaster.yml → stale-generation-NotWritablePrimary.yml} +7 -5
  906. data/spec/spec_tests/data/sdam/errors/stale-generation-PrimarySteppedDown.yml +4 -2
  907. data/spec/spec_tests/data/sdam/errors/stale-generation-ShutdownInProgress.yml +4 -2
  908. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedAtShutdown.yml +4 -2
  909. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedDueToReplStateChange.yml +4 -2
  910. data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMaster.yml → stale-generation-afterHandshakeCompletes-LegacyNotPrimary.yml} +8 -6
  911. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
  912. data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMasterOrSecondary.yml → stale-generation-afterHandshakeCompletes-NotPrimaryOrSecondary.yml} +7 -5
  913. data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMasterNoSlaveOk.yml → stale-generation-afterHandshakeCompletes-NotWritablePrimary.yml} +8 -6
  914. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-PrimarySteppedDown.yml +4 -2
  915. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-ShutdownInProgress.yml +4 -2
  916. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-network.yml +6 -4
  917. data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-timeout.yml +6 -4
  918. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedAtShutdown.yml +4 -2
  919. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedDueToReplStateChange.yml +4 -2
  920. data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMaster.yml → stale-generation-beforeHandshakeCompletes-LegacyNotPrimary.yml} +8 -6
  921. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
  922. data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMasterOrSecondary.yml → stale-generation-beforeHandshakeCompletes-NotPrimaryOrSecondary.yml} +7 -5
  923. data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMasterNoSlaveOk.yml → stale-generation-beforeHandshakeCompletes-NotWritablePrimary.yml} +8 -6
  924. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-PrimarySteppedDown.yml +4 -2
  925. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-ShutdownInProgress.yml +4 -2
  926. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-network.yml +6 -4
  927. data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-timeout.yml +6 -4
  928. data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedAtShutdown.yml +2 -1
  929. data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedDueToReplStateChange.yml +2 -1
  930. data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-LegacyNotPrimary.yml +65 -0
  931. data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMasterNoSlaveOk.yml → stale-topologyVersion-NotPrimaryNoSecondaryOk.yml} +7 -6
  932. data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMasterOrSecondary.yml → stale-topologyVersion-NotPrimaryOrSecondary.yml} +7 -6
  933. data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMaster.yml → stale-topologyVersion-NotWritablePrimary.yml} +7 -6
  934. data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-PrimarySteppedDown.yml +2 -1
  935. data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-ShutdownInProgress.yml +2 -1
  936. data/spec/spec_tests/data/sdam/errors/write_errors_ignored.yml +42 -0
  937. data/spec/spec_tests/data/sdam/rs/compatible.yml +4 -2
  938. data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +2 -1
  939. data/spec/spec_tests/data/sdam/rs/discover_arbiters.yml +2 -1
  940. data/spec/spec_tests/data/sdam/rs/discover_arbiters_replicaset.yml +2 -1
  941. data/spec/spec_tests/data/sdam/rs/discover_ghost.yml +2 -1
  942. data/spec/spec_tests/data/sdam/rs/discover_ghost_replicaset.yml +2 -1
  943. data/spec/spec_tests/data/sdam/rs/discover_hidden.yml +2 -1
  944. data/spec/spec_tests/data/sdam/rs/discover_hidden_replicaset.yml +2 -1
  945. data/spec/spec_tests/data/sdam/rs/discover_passives.yml +4 -2
  946. data/spec/spec_tests/data/sdam/rs/discover_passives_replicaset.yml +4 -2
  947. data/spec/spec_tests/data/sdam/rs/discover_primary.yml +2 -1
  948. data/spec/spec_tests/data/sdam/rs/discover_primary_replicaset.yml +2 -1
  949. data/spec/spec_tests/data/sdam/rs/discover_rsother.yml +2 -1
  950. data/spec/spec_tests/data/sdam/rs/discover_rsother_replicaset.yml +4 -2
  951. data/spec/spec_tests/data/sdam/rs/discover_secondary.yml +2 -1
  952. data/spec/spec_tests/data/sdam/rs/discover_secondary_replicaset.yml +2 -1
  953. data/spec/spec_tests/data/sdam/rs/discovery.yml +8 -4
  954. data/spec/spec_tests/data/sdam/rs/equal_electionids.yml +4 -2
  955. data/spec/spec_tests/data/sdam/rs/hosts_differ_from_seeds.yml +2 -1
  956. data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +3 -1
  957. data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +3 -1
  958. data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +3 -1
  959. data/spec/spec_tests/data/sdam/rs/ls_timeout.yml +12 -6
  960. data/spec/spec_tests/data/sdam/rs/member_reconfig.yml +4 -2
  961. data/spec/spec_tests/data/sdam/rs/member_standalone.yml +4 -2
  962. data/spec/spec_tests/data/sdam/rs/new_primary.yml +4 -2
  963. data/spec/spec_tests/data/sdam/rs/new_primary_new_electionid.yml +6 -3
  964. data/spec/spec_tests/data/sdam/rs/new_primary_new_setversion.yml +6 -3
  965. data/spec/spec_tests/data/sdam/rs/new_primary_wrong_set_name.yml +4 -2
  966. data/spec/spec_tests/data/sdam/rs/non_rs_member.yml +1 -0
  967. data/spec/spec_tests/data/sdam/rs/normalize_case.yml +2 -1
  968. data/spec/spec_tests/data/sdam/rs/normalize_case_me.yml +4 -2
  969. data/spec/spec_tests/data/sdam/rs/null_election_id.yml +8 -4
  970. data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +4 -2
  971. data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +4 -2
  972. data/spec/spec_tests/data/sdam/rs/primary_becomes_standalone.yml +2 -1
  973. data/spec/spec_tests/data/sdam/rs/primary_changes_set_name.yml +4 -2
  974. data/spec/spec_tests/data/sdam/rs/primary_disconnect.yml +2 -1
  975. data/spec/spec_tests/data/sdam/rs/primary_disconnect_electionid.yml +10 -5
  976. data/spec/spec_tests/data/sdam/rs/primary_disconnect_setversion.yml +10 -5
  977. data/spec/spec_tests/data/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +4 -2
  978. data/spec/spec_tests/data/sdam/rs/primary_mismatched_me.yml +2 -1
  979. data/spec/spec_tests/data/sdam/rs/primary_mismatched_me_not_removed.yml +5 -3
  980. data/spec/spec_tests/data/sdam/rs/primary_reports_new_member.yml +8 -4
  981. data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +4 -2
  982. data/spec/spec_tests/data/sdam/rs/primary_wrong_set_name.yml +2 -1
  983. data/spec/spec_tests/data/sdam/rs/repeated.yml +9 -5
  984. data/spec/spec_tests/data/sdam/rs/replicaset_rsnp.yml +2 -1
  985. data/spec/spec_tests/data/sdam/rs/response_from_removed.yml +4 -2
  986. data/spec/spec_tests/data/sdam/rs/sec_not_auth.yml +4 -2
  987. data/spec/spec_tests/data/sdam/rs/secondary_ignore_ok_0.yml +4 -2
  988. data/spec/spec_tests/data/sdam/rs/secondary_mismatched_me.yml +2 -1
  989. data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name.yml +2 -1
  990. data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary.yml +4 -2
  991. data/spec/spec_tests/data/sdam/rs/setversion_without_electionid.yml +4 -2
  992. data/spec/spec_tests/data/sdam/rs/stepdown_change_set_name.yml +4 -2
  993. data/spec/spec_tests/data/sdam/rs/too_new.yml +4 -2
  994. data/spec/spec_tests/data/sdam/rs/too_old.yml +4 -2
  995. data/spec/spec_tests/data/sdam/rs/topology_version_equal.yml +4 -2
  996. data/spec/spec_tests/data/sdam/rs/topology_version_greater.yml +10 -5
  997. data/spec/spec_tests/data/sdam/rs/topology_version_less.yml +4 -2
  998. data/spec/spec_tests/data/sdam/rs/unexpected_mongos.yml +2 -1
  999. data/spec/spec_tests/data/sdam/rs/use_setversion_without_electionid.yml +6 -3
  1000. data/spec/spec_tests/data/sdam/rs/wrong_set_name.yml +2 -1
  1001. data/spec/spec_tests/data/sdam/sharded/compatible.yml +4 -2
  1002. data/spec/spec_tests/data/sdam/sharded/discover_single_mongos.yml +2 -1
  1003. data/spec/spec_tests/data/sdam/sharded/ls_timeout_mongos.yml +9 -5
  1004. data/spec/spec_tests/data/sdam/sharded/mongos_disconnect.yml +6 -3
  1005. data/spec/spec_tests/data/sdam/sharded/multiple_mongoses.yml +4 -2
  1006. data/spec/spec_tests/data/sdam/sharded/non_mongos_removed.yml +4 -2
  1007. data/spec/spec_tests/data/sdam/sharded/too_new.yml +4 -2
  1008. data/spec/spec_tests/data/sdam/sharded/too_old.yml +4 -2
  1009. data/spec/spec_tests/data/sdam/single/compatible.yml +2 -1
  1010. data/spec/spec_tests/data/sdam/single/direct_connection_external_ip.yml +2 -1
  1011. data/spec/spec_tests/data/sdam/single/direct_connection_mongos.yml +2 -1
  1012. data/spec/spec_tests/data/sdam/single/direct_connection_replicaset.yml +2 -1
  1013. data/spec/spec_tests/data/sdam/single/direct_connection_rsarbiter.yml +2 -1
  1014. data/spec/spec_tests/data/sdam/single/direct_connection_rsprimary.yml +2 -1
  1015. data/spec/spec_tests/data/sdam/single/direct_connection_rssecondary.yml +2 -1
  1016. data/spec/spec_tests/data/sdam/single/direct_connection_standalone.yml +2 -1
  1017. data/spec/spec_tests/data/sdam/single/direct_connection_wrong_set_name.yml +4 -2
  1018. data/spec/spec_tests/data/sdam/single/discover_standalone.yml +2 -1
  1019. data/spec/spec_tests/data/sdam/single/ls_timeout_standalone.yml +2 -1
  1020. data/spec/spec_tests/data/sdam/single/not_ok_response.yml +5 -3
  1021. data/spec/spec_tests/data/sdam/single/standalone_removed.yml +2 -1
  1022. data/spec/spec_tests/data/sdam/single/{direct_connection_slave.yml → standalone_using_legacy_hello.yml} +3 -3
  1023. data/spec/spec_tests/data/sdam/single/too_new.yml +2 -1
  1024. data/spec/spec_tests/data/sdam/single/too_old.yml +2 -1
  1025. data/spec/spec_tests/data/sdam/single/too_old_then_upgraded.yml +4 -2
  1026. data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +1 -1
  1027. data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +2 -2
  1028. data/spec/spec_tests/data/sdam_integration/{isMaster-command-error.yml → hello-command-error.yml} +19 -29
  1029. data/spec/spec_tests/data/sdam_integration/{isMaster-network-error.yml → hello-network-error.yml} +9 -15
  1030. data/spec/spec_tests/data/sdam_integration/{isMaster-timeout.yml → hello-timeout.yml} +7 -13
  1031. data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +14 -3
  1032. data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -1
  1033. data/spec/spec_tests/data/sdam_monitoring/replica_set_with_no_primary.yml +2 -1
  1034. data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary.yml +2 -1
  1035. data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +3 -2
  1036. data/spec/spec_tests/data/sdam_monitoring/required_replica_set.yml +2 -1
  1037. data/spec/spec_tests/data/sdam_monitoring/standalone.yml +1 -1
  1038. data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
  1039. data/spec/spec_tests/data/transactions/error-labels.yml +3 -0
  1040. data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +3 -0
  1041. data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +2 -0
  1042. data/spec/spec_tests/data/transactions/pin-mongos.yml +6 -3
  1043. data/spec/spec_tests/data/transactions_unified/mongos-unpin.yml +172 -0
  1044. data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +7 -6
  1045. data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +7 -5
  1046. data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +9 -1
  1047. data/spec/spec_tests/data/versioned_api/test-commands-deprecation-errors.yml +1 -1
  1048. data/spec/spec_tests/data/versioned_api/test-commands-strict-mode.yml +3 -1
  1049. data/spec/spec_tests/data/versioned_api/transaction-handling.yml +5 -57
  1050. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +3 -0
  1051. data/spec/spec_tests/gridfs_spec.rb +3 -0
  1052. data/spec/spec_tests/max_staleness_spec.rb +3 -0
  1053. data/spec/spec_tests/read_write_concern_connection_string_spec.rb +3 -0
  1054. data/spec/spec_tests/read_write_concern_document_spec.rb +3 -0
  1055. data/spec/spec_tests/read_write_concern_operaton_spec.rb +3 -0
  1056. data/spec/spec_tests/retryable_reads_spec.rb +3 -0
  1057. data/spec/spec_tests/retryable_writes_spec.rb +9 -6
  1058. data/spec/spec_tests/sdam_integration_spec.rb +3 -0
  1059. data/spec/spec_tests/sdam_monitoring_spec.rb +4 -1
  1060. data/spec/spec_tests/sdam_spec.rb +4 -1
  1061. data/spec/spec_tests/server_selection_rtt_spec.rb +3 -0
  1062. data/spec/spec_tests/server_selection_spec.rb +3 -0
  1063. data/spec/spec_tests/transactions_api_spec.rb +3 -0
  1064. data/spec/spec_tests/transactions_spec.rb +3 -0
  1065. data/spec/spec_tests/transactions_unified_spec.rb +13 -0
  1066. data/spec/spec_tests/unified_spec.rb +3 -0
  1067. data/spec/spec_tests/uri_options_spec.rb +3 -0
  1068. data/spec/spec_tests/versioned_api_spec.rb +3 -0
  1069. data/spec/stress/cleanup_spec.rb +3 -0
  1070. data/spec/stress/connection_pool_stress_spec.rb +3 -0
  1071. data/spec/stress/connection_pool_timing_spec.rb +3 -0
  1072. data/spec/stress/fork_reconnect_stress_spec.rb +6 -3
  1073. data/spec/support/authorization.rb +3 -0
  1074. data/spec/support/aws_utils.rb +3 -0
  1075. data/spec/support/aws_utils/base.rb +3 -0
  1076. data/spec/support/aws_utils/inspector.rb +3 -0
  1077. data/spec/support/aws_utils/orchestrator.rb +3 -0
  1078. data/spec/support/aws_utils/provisioner.rb +3 -0
  1079. data/spec/support/background_thread_registry.rb +4 -1
  1080. data/spec/support/certificates/README.md +3 -2
  1081. data/spec/support/certificates/atlas-ocsp-ca.crt +116 -26
  1082. data/spec/support/certificates/atlas-ocsp.crt +150 -39
  1083. data/spec/support/client_registry.rb +12 -5
  1084. data/spec/support/client_registry_macros.rb +7 -4
  1085. data/spec/support/cluster_tools.rb +4 -1
  1086. data/spec/support/common_shortcuts.rb +25 -6
  1087. data/spec/support/constraints.rb +3 -0
  1088. data/spec/support/crypt.rb +3 -0
  1089. data/spec/support/dns.rb +3 -0
  1090. data/spec/support/event_subscriber.rb +9 -0
  1091. data/spec/support/json_ext_formatter.rb +3 -0
  1092. data/spec/support/keyword_struct.rb +3 -0
  1093. data/spec/support/local_resource_registry.rb +3 -0
  1094. data/spec/support/matchers.rb +4 -1
  1095. data/spec/support/monitoring_ext.rb +3 -0
  1096. data/spec/support/primary_socket.rb +3 -0
  1097. data/spec/support/sdam_formatter_integration.rb +3 -0
  1098. data/spec/support/session_registry.rb +3 -0
  1099. data/spec/{mongo/server/app_metadata_shared.rb → support/shared/app_metadata.rb} +38 -7
  1100. data/spec/support/shared/protocol.rb +3 -0
  1101. data/spec/support/shared/scram_conversation.rb +3 -0
  1102. data/spec/support/shared/server_selector.rb +6 -3
  1103. data/spec/support/shared/session.rb +3 -0
  1104. data/spec/support/spec_config.rb +43 -9
  1105. data/spec/support/spec_setup.rb +3 -0
  1106. data/spec/support/utils.rb +4 -1
  1107. metadata +1031 -977
  1108. metadata.gz.sig +0 -0
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,8 +52,38 @@ module Mongo
49
52
  # @api private
50
53
  attr_reader :pid
51
54
 
55
+ # Build a document that should be used for connection handshake.
56
+ #
57
+ # @param [ Server::AppMetadata ] app_metadata Application metadata
58
+ # @param [ BSON::Document ] speculative_auth_doc The speculative
59
+ # authentication document, if any.
60
+ # @param server_api [ Hash | nil ] server_api Server API version.
61
+ #
62
+ # @return [BSON::Document] Document that should be sent to a server
63
+ # for handshake purposes.
64
+ #
65
+ # @api private
66
+ def handshake_document(app_metadata, speculative_auth_doc: nil, server_api: nil)
67
+ serv_api = app_metadata.server_api || server_api
68
+ document = if serv_api
69
+ HELLO_DOC.merge(Utils.transform_server_api(serv_api))
70
+ else
71
+ LEGACY_HELLO_DOC
72
+ end
73
+ document.merge(app_metadata.validated_document).tap do |doc|
74
+ if speculative_auth_doc
75
+ doc.update(speculativeAuthenticate: speculative_auth_doc)
76
+ end
77
+ end
78
+ end
79
+
80
+
52
81
  private
53
82
 
83
+ HELLO_DOC = BSON::Document.new({ hello: 1 }).freeze
84
+
85
+ LEGACY_HELLO_DOC = BSON::Document.new({ isMaster: 1, helloOk: true }).freeze
86
+
54
87
  attr_reader :socket
55
88
 
56
89
  def set_compressor!(reply)
@@ -88,7 +121,7 @@ module Mongo
88
121
  # Server::Monitor::Connection does not reference its server, but
89
122
  # knows its address. Server::Connection delegates the address to its
90
123
  # server.
91
- note = "on #{address.seed}"
124
+ note = +"on #{address.seed}"
92
125
  if respond_to?(:id)
93
126
  note << ", connection #{generation}:#{id}"
94
127
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2014-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -291,7 +294,7 @@ module Mongo
291
294
  raise Error::PoolClosedError.new(@server.address, self)
292
295
  end
293
296
 
294
- deadline = Time.now + wait_timeout
297
+ deadline = Utils.monotonic_time + wait_timeout
295
298
  pid = Process.pid
296
299
  connection = nil
297
300
  # It seems that synchronize sets up its own loop, thus a simple break
@@ -341,7 +344,7 @@ module Mongo
341
344
  end
342
345
  end
343
346
 
344
- wait = deadline - Time.now
347
+ wait = deadline - Utils.monotonic_time
345
348
  if wait <= 0
346
349
  publish_cmap_event(
347
350
  Monitoring::Event::Cmap::ConnectionCheckOutFailed.new(
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2019-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2014-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the 'License');
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2014-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the 'License');
@@ -18,7 +21,7 @@ module Mongo
18
21
  class Server
19
22
 
20
23
  # Represents a description of the server, populated by the result of the
21
- # ismaster command.
24
+ # hello command.
22
25
  #
23
26
  # Note: Unknown servers do not have wire versions, but for legacy reasons
24
27
  # we return 0 for min_wire_version and max_wire_version of any server that does
@@ -197,15 +200,15 @@ module Mongo
197
200
  CONNECTION_ID,
198
201
  ].freeze
199
202
 
200
- # Instantiate the new server description from the result of the ismaster
203
+ # Instantiate the new server description from the result of the hello
201
204
  # command.
202
205
  #
203
206
  # @example Instantiate the new description.
204
- # Description.new(address, { 'ismaster' => true }, 0.5)
207
+ # Description.new(address, { 'isWritablePrimary' => true }, 0.5)
205
208
  #
206
209
  # @param [ Address ] address The server address.
207
- # @param [ Hash ] config The result of the ismaster command.
208
- # @param [ Float ] average_round_trip_time The moving average time (sec) the ismaster
210
+ # @param [ Hash ] config The result of the hello command.
211
+ # @param [ Float ] average_round_trip_time The moving average time (sec) the hello
209
212
  # call took to complete.
210
213
  #
211
214
  # @since 2.0.0
@@ -214,7 +217,8 @@ module Mongo
214
217
  @config = config
215
218
  @features = Features.new(wire_versions, me || @address.to_s)
216
219
  @average_round_trip_time = average_round_trip_time
217
- @last_update_time = Time.now.dup.freeze
220
+ @last_update_time = Time.now.freeze
221
+ @last_update_monotime = Utils.monotonic_time
218
222
 
219
223
  if Mongo::Lint.enabled?
220
224
  # prepopulate cache instance variables
@@ -230,7 +234,7 @@ module Mongo
230
234
  # @return [ Address ] address The server's address.
231
235
  attr_reader :address
232
236
 
233
- # @return [ Hash ] The actual result from the ismaster command.
237
+ # @return [ Hash ] The actual result from the hello command.
234
238
  attr_reader :config
235
239
 
236
240
  # @return [ Features ] features The features for the server.
@@ -238,7 +242,7 @@ module Mongo
238
242
  @features
239
243
  end
240
244
 
241
- # @return [ Float ] The moving average time the ismaster call took to complete.
245
+ # @return [ Float ] The moving average time the hello call took to complete.
242
246
  attr_reader :average_round_trip_time
243
247
 
244
248
  # Returns whether this server is an arbiter, per the SDAM spec.
@@ -569,7 +573,7 @@ module Mongo
569
573
  # @since 2.0.0
570
574
  def primary?
571
575
  ok? &&
572
- config['ismaster'] == true &&
576
+ (config['ismaster'] == true || config['isWritablePrimary'] == true ) &&
573
577
  !!config['setName']
574
578
  end
575
579
 
@@ -739,7 +743,7 @@ module Mongo
739
743
  !!(address.to_s.downcase != me.downcase if me)
740
744
  end
741
745
 
742
- # opTime in lastWrite subdocument of the ismaster response.
746
+ # opTime in lastWrite subdocument of the hello response.
743
747
  #
744
748
  # @return [ BSON::Timestamp ] The timestamp.
745
749
  #
@@ -762,6 +766,15 @@ module Mongo
762
766
  # @since 2.7.0
763
767
  attr_reader :last_update_time
764
768
 
769
+ # Time when this server description was created according to monotonic clock.
770
+ #
771
+ # @see Description::last_updated_time for more detail
772
+ #
773
+ # @return [ Float ] Server description creation monotonic time.
774
+ #
775
+ # @api private
776
+ attr_reader :last_update_monotime
777
+
765
778
  # @api experimental
766
779
  def server_connection_id
767
780
  config['connectionId']
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2014-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the 'License');
@@ -31,7 +34,7 @@ module Mongo
31
34
  # - 7 => 4.0
32
35
  # - 8 => 4.2
33
36
  # - 9 => 4.4
34
- # - 12 => 5.0
37
+ # - 13 => 5.0
35
38
  #
36
39
  # @since 2.0.0
37
40
  MAPPINGS = {
@@ -74,7 +77,7 @@ module Mongo
74
77
  # The wire protocol versions that this version of the driver supports.
75
78
  #
76
79
  # @since 2.0.0
77
- DRIVER_WIRE_VERSIONS = (2..9).freeze
80
+ DRIVER_WIRE_VERSIONS = (2..13).freeze
78
81
 
79
82
  # Create the methods for each mapping to tell if they are supported.
80
83
  #
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2014-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +18,7 @@
15
18
  module Mongo
16
19
  class Server
17
20
 
18
- # Responsible for periodically polling a server via ismaster commands to
21
+ # Responsible for periodically polling a server via hello commands to
19
22
  # keep the server's status up to date.
20
23
  #
21
24
  # Does all work in a background thread so as to not interfere with other
@@ -129,13 +132,7 @@ module Mongo
129
132
  end
130
133
  end
131
134
 
132
- # Runs the server monitor. Refreshing happens on a separate thread per
133
- # server.
134
- #
135
- # @example Run the monitor.
136
- # monitor.run
137
- #
138
- # @return [ Thread ] The thread the monitor runs on.
135
+ # Perform a check of the server.
139
136
  #
140
137
  # @since 2.0.0
141
138
  def do_work
@@ -187,7 +184,7 @@ module Mongo
187
184
  #
188
185
  # If the server was checked less than MIN_SCAN_INTERVAL seconds
189
186
  # ago, sleep until MIN_SCAN_INTERVAL seconds have passed since the last
190
- # check. Then perform the check which involves running isMaster
187
+ # check. Then perform the check which involves running hello
191
188
  # on the server being monitored and updating the server description
192
189
  # as a result.
193
190
  #
@@ -260,10 +257,10 @@ module Mongo
260
257
  def do_scan
261
258
  begin
262
259
  monitoring.publish_heartbeat(server) do
263
- ismaster
260
+ check
264
261
  end
265
262
  rescue => exc
266
- msg = "Error running ismaster on #{server.address}"
263
+ msg = "Error checking #{server.address}"
267
264
  Utils.warn_bg_exception(msg, exc,
268
265
  logger: options[:logger],
269
266
  log_prefix: options[:log_prefix],
@@ -273,7 +270,7 @@ module Mongo
273
270
  end
274
271
  end
275
272
 
276
- def ismaster
273
+ def check
277
274
  if @connection && @connection.pid != Process.pid
278
275
  log_warn("Detected PID change - Mongo client should have been reconnected (old pid #{@connection.pid}, new pid #{Process.pid}")
279
276
  @connection.disconnect!
@@ -283,15 +280,11 @@ module Mongo
283
280
  if @connection
284
281
  result = server.round_trip_time_averager.measure do
285
282
  begin
286
- ismaster_bytes = if server_api = options[:server_api]
287
- ismaster_doc = Monitor::Connection::ISMASTER.merge(
288
- Utils.transform_server_api(server_api)
289
- )
290
- Protocol::Query.new(Database::ADMIN, Database::COMMAND, ismaster_doc, limit: -1).serialize.to_s
291
- else
292
- Monitor::Connection::ISMASTER_BYTES
293
- end
294
- message = @connection.dispatch_bytes(ismaster_bytes)
283
+ doc = @connection.check_document
284
+ cmd = Protocol::Query.new(
285
+ Database::ADMIN, Database::COMMAND, doc, :limit => -1
286
+ )
287
+ message = @connection.dispatch_bytes(cmd.serialize.to_s)
295
288
  message.documents.first
296
289
  rescue Mongo::Error
297
290
  @connection.disconnect!
@@ -316,6 +309,7 @@ module Mongo
316
309
  **Utils.shallow_symbolize_keys(options.merge(
317
310
  socket_timeout: heartbeat_interval + connection.socket_timeout,
318
311
  app_metadata: options[:push_monitor_app_metadata],
312
+ check_document: @connection.check_document
319
313
  )),
320
314
  )
321
315
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2018-2020 MongoDB Inc.
2
5
 
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2015-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,44 +26,6 @@ module Mongo
23
26
  class Connection < Server::ConnectionCommon
24
27
  include Loggable
25
28
 
26
- # The command used for determining server status.
27
- #
28
- # The case matters here for fail points.
29
- #
30
- # @since 2.2.0
31
- ISMASTER = { isMaster: 1 }.freeze
32
-
33
- # The command used for determining server status formatted for an
34
- # OP_MSG (server versions >= 3.6).
35
- #
36
- # The case matters here for fail points.
37
- #
38
- # @since 2.5.0
39
- ISMASTER_OP_MSG = {
40
- isMaster: 1,
41
- '$db' => Database::ADMIN,
42
- }.freeze
43
-
44
- # The constant for the ismaster command.
45
- #
46
- # @since 2.2.0
47
- ISMASTER_MESSAGE = Protocol::Query.new(Database::ADMIN, Database::COMMAND, ISMASTER, limit: -1)
48
-
49
- # The constant for the ismaster command as an OP_MSG (server versions >= 3.6).
50
- #
51
- # @since 2.5.0
52
- ISMASTER_OP_MSG_MESSAGE = Protocol::Msg.new([], {}, ISMASTER_OP_MSG)
53
-
54
- # The raw bytes for the ismaster message.
55
- #
56
- # @since 2.2.0
57
- ISMASTER_BYTES = ISMASTER_MESSAGE.serialize.to_s.freeze
58
-
59
- # The raw bytes for the ismaster OP_MSG message (server versions >= 3.6).
60
- #
61
- # @since 2.5.0
62
- ISMASTER_OP_MSG_BYTES = ISMASTER_OP_MSG_MESSAGE.serialize.to_s.freeze
63
-
64
29
  # Creates a new connection object to the specified target address
65
30
  # with the specified options.
66
31
  #
@@ -99,6 +64,7 @@ module Mongo
99
64
  @socket = nil
100
65
  @pid = Process.pid
101
66
  @compressor = nil
67
+ @hello_ok = false
102
68
  end
103
69
 
104
70
  # @return [ Hash ] options The passed in options.
@@ -222,13 +188,26 @@ module Mongo
222
188
  true
223
189
  end
224
190
 
191
+ # Send handshake command to connected host and validate the response.
192
+ #
193
+ # @return [BSON::Document] Handshake response from server
194
+ #
195
+ # @raise [Mongo::Error] If handshake failed.
225
196
  def handshake!
226
- payload = @app_metadata.ismaster_bytes
197
+ document = handshake_document(
198
+ @app_metadata,
199
+ server_api: options[:server_api]
200
+ )
201
+ # TODO (DR): OP_MSG should be used if api version is declared.
202
+ # See https://github.com/mongodb/specifications/blob/master/source/message/OP_MSG.rst#id5
203
+ command = Protocol::Query.new(Database::ADMIN, Database::COMMAND, document, :limit => -1)
204
+ payload = command.serialize.to_s
227
205
  message = dispatch_bytes(payload)
228
206
  result = Operation::Result.new(message)
229
207
  result.validate!
230
208
  reply = result.documents.first
231
209
  set_compressor!(reply)
210
+ set_hello_ok!(reply)
232
211
  @server_connection_id = reply['connectionId']
233
212
  reply
234
213
  rescue => exc
@@ -241,6 +220,25 @@ module Mongo
241
220
  raise
242
221
  end
243
222
 
223
+ # Build a document that should be used for connection check.
224
+ #
225
+ # @return [BSON::Document] Document that should be sent to a server
226
+ # for connection check.
227
+ #
228
+ # @api private
229
+ def check_document
230
+ server_api = @app_metadata.server_api || options[:server_api]
231
+ if hello_ok? || server_api
232
+ doc = HELLO_DOC
233
+ if server_api
234
+ doc = doc.merge(Utils.transform_server_api(server_api))
235
+ end
236
+ doc
237
+ else
238
+ LEGACY_HELLO_DOC
239
+ end
240
+ end
241
+
244
242
  private
245
243
 
246
244
  def add_server_connection_id
@@ -252,6 +250,19 @@ module Mongo
252
250
  end
253
251
  raise e
254
252
  end
253
+
254
+ # Update @hello_ok flag according to server reply to legacy hello
255
+ # command. The flag will be set to true if connected server supports
256
+ # hello command, otherwise the flag will be set to false.
257
+ #
258
+ # @param [ BSON::Document ] reply Server reply to legacy hello command.
259
+ def set_hello_ok!(reply)
260
+ @hello_ok = !!reply[:helloOk]
261
+ end
262
+
263
+ def hello_ok?
264
+ @hello_ok
265
+ end
255
266
  end
256
267
  end
257
268
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  # Copyright (C) 2019-2020 MongoDB Inc.
2
5
  #
3
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,35 +102,31 @@ module Mongo
99
102
  private
100
103
 
101
104
  # @param [ BSON::Document | nil ] speculative_auth_doc The document to
102
- # provide in speculativeAuthenticate field of ismaster command.
105
+ # provide in speculativeAuthenticate field of handshake command.
103
106
  #
104
- # @return [ BSON::Document ] The document of the ismaster response for
107
+ # @return [ BSON::Document ] The document of the handshake response for
105
108
  # this particular connection.
106
109
  def handshake!(speculative_auth_doc: nil)
107
110
  unless socket
108
111
  raise Error::InternalDriverError, "Cannot handshake because there is no usable socket (for #{address})"
109
112
  end
110
113
 
111
- ismaster_doc = app_metadata.validated_document
112
- if speculative_auth_doc
113
- ismaster_doc = ismaster_doc.merge(speculativeAuthenticate: speculative_auth_doc)
114
- end
115
-
116
- if server_api = options[:server_api]
117
- ismaster_doc = ismaster_doc.merge(
118
- Utils.transform_server_api(server_api)
119
- )
120
- end
114
+ hello_doc = handshake_document(
115
+ app_metadata,
116
+ speculative_auth_doc: speculative_auth_doc,
117
+ server_api: options[:server_api],
118
+ )
121
119
 
122
- ismaster_command = Protocol::Query.new(Database::ADMIN, Database::COMMAND,
123
- ismaster_doc, :limit => -1)
120
+ # TODO (DR): OP_MSG should be used if api version is declared.
121
+ # See https://github.com/mongodb/specifications/blob/master/source/message/OP_MSG.rst#id5
122
+ hello_command = Protocol::Query.new(Database::ADMIN, Database::COMMAND, hello_doc, :limit => -1)
124
123
 
125
124
  doc = nil
126
125
  @server.handle_handshake_failure! do
127
126
  begin
128
127
  response = @server.round_trip_time_averager.measure do
129
128
  add_server_diagnostics do
130
- socket.write(ismaster_command.serialize.to_s)
129
+ socket.write(hello_command.serialize.to_s)
131
130
  Protocol::Message.deserialize(socket, Protocol::Message::MAX_MESSAGE_SIZE)
132
131
  end
133
132
  end
@@ -157,7 +156,7 @@ module Mongo
157
156
  # for speculative auth, if speculative auth succeeded. If speculative
158
157
  # auth was not performed or it failed, this must be nil.
159
158
  # @param [ BSON::Document | nil ] speculative_auth_result The
160
- # value of speculativeAuthenticate field of ismaster response of
159
+ # value of speculativeAuthenticate field of hello response of
161
160
  # the handshake on this connection.
162
161
  def authenticate!(
163
162
  speculative_auth_client_nonce: nil,
@@ -194,12 +193,12 @@ module Mongo
194
193
  # This is a separate method to keep the nesting level down.
195
194
  #
196
195
  # @return [ Server::Description ] The server description calculated from
197
- # ismaster response for this particular connection.
196
+ # hello response for this particular connection.
198
197
  def post_handshake(response, average_rtt)
199
198
  if response["ok"] == 1
200
199
  # Auth mechanism is entirely dependent on the contents of
201
- # ismaster response *for this connection*.
202
- # Ismaster received by the monitoring connection should advertise
200
+ # hello response *for this connection*.
201
+ # Hello received by the monitoring connection should advertise
203
202
  # the same wire protocol, but if it doesn't, we use whatever
204
203
  # the monitoring connection advertised for filling out the
205
204
  # server description and whatever the non-monitoring connection
@@ -233,7 +232,7 @@ module Mongo
233
232
  user_options = Options::Redacted.new(
234
233
  # When speculative auth is performed, we always use SCRAM-SHA-256.
235
234
  # At the same time we perform SCRAM mechanism negotiation in the
236
- # ismaster request.
235
+ # hello request.
237
236
  # If the credentials we are trying to authenticate with do not
238
237
  # map to an existing user, SCRAM mechanism negotiation will not
239
238
  # return anything which would cause the driver to use