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
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
 
6
6
  describe Mongo::Collection do
7
7
 
8
- let(:subscriber) { EventSubscriber.new }
8
+ let(:subscriber) { Mrss::EventSubscriber.new }
9
9
 
10
10
  let(:client) do
11
11
  authorized_client.tap do |client|
@@ -1894,6 +1894,11 @@ describe Mongo::Collection do
1894
1894
  context 'when a session supporting causal consistency is used' do
1895
1895
  require_wired_tiger
1896
1896
 
1897
+ before do
1898
+ collection.drop
1899
+ collection.create
1900
+ end
1901
+
1897
1902
  let(:cursors) do
1898
1903
  collection.parallel_scan(2, session: session)
1899
1904
  end
@@ -4352,7 +4357,7 @@ describe Mongo::Collection do
4352
4357
  expect(command[:writeConcern]).to_not be_nil
4353
4358
  expect(command[:writeConcern][:w]).to eq(1)
4354
4359
  expect(command[:upsert]).to be(true)
4355
- expect(command[:bypassDocumentValidation]).to be_nil
4360
+ expect(command[:bypassDocumentValidation]).to be false
4356
4361
  expect(command[:maxTimeMS]).to eq(200)
4357
4362
  end
4358
4363
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
 
6
6
  describe Mongo::Collection do
7
7
 
8
- let(:subscriber) { EventSubscriber.new }
8
+ let(:subscriber) { Mrss::EventSubscriber.new }
9
9
 
10
10
  let(:client) do
11
11
  authorized_client.tap do |client|
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
 
6
6
  describe Mongo::Collection do
7
7
 
8
- let(:subscriber) { EventSubscriber.new }
8
+ let(:subscriber) { Mrss::EventSubscriber.new }
9
9
 
10
10
  let(:client) do
11
11
  authorized_client.tap do |client|
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
+ # TODO convert, move or delete these tests as part of RUBY-2706.
5
+
6
+ =begin
4
7
  require 'spec_helper'
5
8
 
6
9
  describe Mongo::Cursor::Builder::GetMoreCommand do
@@ -189,3 +192,4 @@ describe Mongo::Cursor::Builder::GetMoreCommand do
189
192
  end
190
193
  end
191
194
  end
195
+ =end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
+ # TODO convert, move or delete these tests as part of RUBY-2706.
5
+
6
+ =begin
4
7
  require 'spec_helper'
5
8
 
6
9
  describe Mongo::Cursor::Builder::OpGetMore do
@@ -62,3 +65,4 @@ describe Mongo::Cursor::Builder::OpGetMore do
62
65
  end
63
66
  end
64
67
  end
68
+ =end
@@ -80,6 +80,8 @@ describe Mongo::Cursor do
80
80
  end
81
81
 
82
82
  context 'server is unknown' do
83
+ require_topology :single, :replica_set, :sharded
84
+
83
85
  let(:server) do
84
86
  view.send(:server_selector).select_server(authorized_client.cluster).tap do |server|
85
87
  authorized_client.cluster.disconnect!
@@ -329,8 +331,7 @@ describe Mongo::Cursor do
329
331
 
330
332
  before do
331
333
  authorized_collection.insert_many(documents)
332
- cluster.schedule_kill_cursor(cursor.id,
333
- cursor.send(:kill_cursors_op_spec),
334
+ cluster.schedule_kill_cursor(cursor.kill_spec,
334
335
  cursor.instance_variable_get(:@server))
335
336
  end
336
337
 
@@ -429,7 +430,7 @@ describe Mongo::Cursor do
429
430
 
430
431
  it 'removes the cursor id from the active cursors tracked by the cluster cursor manager' do
431
432
  enum.next
432
- expect(cursor_reaper.instance_variable_get(:@active_cursors)).not_to include(cursor_id)
433
+ expect(cursor_reaper.instance_variable_get(:@active_cursor_ids)).not_to include(cursor_id)
433
434
  end
434
435
  end
435
436
  end
@@ -437,7 +438,7 @@ describe Mongo::Cursor do
437
438
  context 'when an implicit session is used' do
438
439
  min_server_fcv '3.6'
439
440
 
440
- let(:subscriber) { EventSubscriber.new }
441
+ let(:subscriber) { Mrss::EventSubscriber.new }
441
442
 
442
443
  let(:subscribed_client) do
443
444
  authorized_client.tap do |client|
@@ -555,8 +556,17 @@ describe Mongo::Cursor do
555
556
  db_name: SpecConfig.instance.test_db, coll_name: TEST_COLL }
556
557
  end
557
558
 
559
+ let(:conn_desc) do
560
+ double('connection description').tap do |cd|
561
+ allow(cd).to receive(:service_id).and_return(nil)
562
+ end
563
+ end
564
+
558
565
  let(:reply) do
559
- Mongo::Operation::Find.new(query_spec).tap do |reply|
566
+ double('reply').tap do |reply|
567
+ allow(reply).to receive(:is_a?).with(Mongo::Operation::Result).and_return(true)
568
+ allow(reply).to receive(:namespace)
569
+ allow(reply).to receive(:connection_description).and_return(conn_desc)
560
570
  allow(reply).to receive(:cursor_id).and_return(42)
561
571
  end
562
572
  end
@@ -218,7 +218,7 @@ describe Mongo::Database do
218
218
  described_class.new(client, SpecConfig.instance.test_db)
219
219
  end
220
220
 
221
- let(:subscriber) { EventSubscriber.new }
221
+ let(:subscriber) { Mrss::EventSubscriber.new }
222
222
 
223
223
  let(:client) do
224
224
  authorized_client.tap do |client|
@@ -391,7 +391,7 @@ describe Mongo::Database do
391
391
  described_class.new(client, SpecConfig.instance.test_db)
392
392
  end
393
393
 
394
- let(:subscriber) { EventSubscriber.new }
394
+ let(:subscriber) { Mrss::EventSubscriber.new }
395
395
 
396
396
  let(:client) do
397
397
  authorized_client.tap do |client|
@@ -583,7 +583,7 @@ describe Mongo::Database do
583
583
  described_class.new(client, SpecConfig.instance.test_db)
584
584
  end
585
585
 
586
- let(:subscriber) { EventSubscriber.new }
586
+ let(:subscriber) { Mrss::EventSubscriber.new }
587
587
 
588
588
  let(:client) do
589
589
  authorized_client.tap do |client|
@@ -678,7 +678,7 @@ describe Mongo::Database do
678
678
  client.start_session
679
679
  end
680
680
 
681
- let(:subscriber) { EventSubscriber.new }
681
+ let(:subscriber) { Mrss::EventSubscriber.new }
682
682
 
683
683
  let(:client) do
684
684
  authorized_client.tap do |client|
@@ -732,12 +732,12 @@ describe Mongo::Database do
732
732
  database.cluster.next_primary
733
733
  end
734
734
 
735
- before do
736
- expect(primary_server).to receive(:with_connection).at_least(:once).and_call_original
737
- end
738
-
739
735
  it 'uses read preference of primary' do
740
- expect(database.command(ping: 1)).to be_successful
736
+ RSpec::Mocks.with_temporary_scope do
737
+ expect(primary_server).to receive(:with_connection).with(any_args).and_call_original
738
+
739
+ expect(database.command(ping: 1)).to be_successful
740
+ end
741
741
  end
742
742
  end
743
743
 
@@ -760,12 +760,12 @@ describe Mongo::Database do
760
760
  described_class.new(client, SpecConfig.instance.test_db, client.options)
761
761
  end
762
762
 
763
- before do
764
- expect(primary_server).to receive(:with_connection).at_least(:once).and_call_original
765
- end
766
-
767
763
  it 'does not use the client read preference 'do
768
- expect(database.command(ping: 1)).to be_successful
764
+ RSpec::Mocks.with_temporary_scope do
765
+ expect(primary_server).to receive(:with_connection).with(any_args).and_call_original
766
+
767
+ expect(database.command(ping: 1)).to be_successful
768
+ end
769
769
  end
770
770
  end
771
771
 
@@ -969,7 +969,7 @@ describe Mongo::Database do
969
969
  client.start_session
970
970
  end
971
971
 
972
- let(:subscriber) { EventSubscriber.new }
972
+ let(:subscriber) { Mrss::EventSubscriber.new }
973
973
 
974
974
  let(:client) do
975
975
  root_authorized_client.tap do |client|
@@ -9,7 +9,7 @@ describe Mongo::Error::OperationFailure do
9
9
  # Fail point will work on 4.0 mongod but requires 4.2 for mongos
10
10
  min_server_fcv '4.2'
11
11
  # Fail point must be set on the same server to which the query is sent
12
- require_no_multi_shard
12
+ require_no_multi_mongos
13
13
 
14
14
  # https://github.com/mongodb/specifications/commit/7745234f93039a83ae42589a6c0cdbefcffa32fa
15
15
  let(:fail_point_command) do
@@ -362,7 +362,7 @@ describe Mongo::Grid::FSBucket do
362
362
  fs.database[fs.files_collection.name].indexes
363
363
  end
364
364
 
365
- before do
365
+ let(:operation) do
366
366
  expect(fs.files_collection).to receive(:indexes).and_call_original
367
367
  expect(fs.chunks_collection).to receive(:indexes).and_call_original
368
368
  fs.insert_one(file)
@@ -376,26 +376,36 @@ describe Mongo::Grid::FSBucket do
376
376
  fs.database[fs.files_collection.name].indexes.get(:filename => 1, :uploadDate => 1)
377
377
  end
378
378
 
379
+ it 'tries to create indexes' do
380
+ expect(fs).to receive(:create_index_if_missing!).twice.and_call_original
381
+ operation
382
+ end
383
+
379
384
  it 'creates an index on the files collection' do
385
+ operation
380
386
  expect(files_index[:name]).to eq('filename_1_uploadDate_1')
381
387
  end
382
388
 
383
389
  it 'creates an index on the chunks collection' do
390
+ operation
384
391
  expect(chunks_index[:name]).to eq('files_id_1_n_1')
385
392
  end
386
393
 
387
394
  context 'when a write operation is called more than once' do
388
395
 
389
- before do
390
- expect(fs).not_to receive(:ensure_indexes!)
391
- end
392
-
393
396
  let(:file2) do
394
397
  Mongo::Grid::File.new('Goodbye!', :filename => 'test2.txt')
395
398
  end
396
399
 
397
400
  it 'only creates the indexes the first time' do
398
- expect(fs.insert_one(file2)).to be_a(BSON::ObjectId)
401
+ RSpec::Mocks.with_temporary_scope do
402
+ expect(fs).to receive(:create_index_if_missing!).twice.and_call_original
403
+ operation
404
+ end
405
+ RSpec::Mocks.with_temporary_scope do
406
+ expect(fs).not_to receive(:create_index_if_missing!)
407
+ expect(fs.insert_one(file2)).to be_a(BSON::ObjectId)
408
+ end
399
409
  end
400
410
  end
401
411
  end
@@ -404,14 +414,12 @@ describe Mongo::Grid::FSBucket do
404
414
 
405
415
  before do
406
416
  fs.chunks_collection.indexes.create_one(Mongo::Grid::FSBucket::CHUNKS_INDEX, :unique => false)
407
- expect(fs.chunks_collection).to receive(:indexes).and_call_original
408
- expect(fs.files_collection).not_to receive(:indexes)
409
417
  end
410
418
 
411
- it 'raises the error to the user' do
419
+ it 'should not raise an error to the user' do
412
420
  expect {
413
421
  fs.insert_one(file)
414
- }.to raise_error(Mongo::Error::OperationFailure)
422
+ }.not_to raise_error
415
423
  end
416
424
  end
417
425
 
@@ -419,8 +427,6 @@ describe Mongo::Grid::FSBucket do
419
427
 
420
428
  before do
421
429
  support_fs.insert_one(support_file)
422
- expect(fs.files_collection).not_to receive(:indexes)
423
- expect(fs.chunks_collection).not_to receive(:indexes)
424
430
  fs.insert_one(file)
425
431
  end
426
432
 
@@ -259,8 +259,6 @@ describe Mongo::Grid::FSBucket::Stream::Write do
259
259
  context 'when the files collection is empty' do
260
260
 
261
261
  before do
262
- expect(fs.files_collection).to receive(:indexes).and_call_original
263
- expect(fs.chunks_collection).to receive(:indexes).and_call_original
264
262
  stream.write(file)
265
263
  end
266
264
 
@@ -329,8 +327,6 @@ describe Mongo::Grid::FSBucket::Stream::Write do
329
327
  before do
330
328
  support_fs.send(:ensure_indexes!)
331
329
  support_fs.files_collection.insert_one(a: 1)
332
- expect(fs.files_collection).not_to receive(:indexes)
333
- expect(fs.chunks_collection).not_to receive(:indexes)
334
330
  stream.write(file)
335
331
  end
336
332
 
@@ -343,18 +339,16 @@ describe Mongo::Grid::FSBucket::Stream::Write do
343
339
  end
344
340
  end
345
341
 
346
- context 'when the index creation encounters an error' do
342
+ context 'when the index creation is done explicitely' do
347
343
 
348
344
  before do
349
345
  fs.chunks_collection.indexes.create_one(Mongo::Grid::FSBucket::CHUNKS_INDEX, :unique => false)
350
- expect(fs.chunks_collection).to receive(:indexes).and_call_original
351
- expect(fs.files_collection).not_to receive(:indexes)
352
346
  end
353
347
 
354
- it 'raises the error to the user' do
348
+ it 'should not raise an error to the user' do
355
349
  expect {
356
350
  stream.write(file)
357
- }.to raise_error(Mongo::Error::OperationFailure)
351
+ }.not_to raise_error
358
352
  end
359
353
  end
360
354
  end
@@ -48,4 +48,4 @@ describe Mongo::Grid::FSBucket::Stream do
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end
@@ -266,7 +266,7 @@ describe Mongo::Index::View do
266
266
  context 'on server versions >= 4.4' do
267
267
  min_server_fcv '4.4'
268
268
 
269
- let(:subscriber) { EventSubscriber.new }
269
+ let(:subscriber) { Mrss::EventSubscriber.new }
270
270
 
271
271
  let(:client) do
272
272
  authorized_client.tap do |client|
@@ -932,7 +932,7 @@ describe Mongo::Index::View do
932
932
  context 'on server versions >= 4.4' do
933
933
  min_server_fcv '4.4'
934
934
 
935
- let(:subscriber) { EventSubscriber.new }
935
+ let(:subscriber) { Mrss::EventSubscriber.new }
936
936
 
937
937
  let(:client) do
938
938
  authorized_client.tap do |client|
@@ -95,7 +95,7 @@ describe Mongo::Operation::Delete::OpMsg do
95
95
  context 'when write concern is specified' do
96
96
 
97
97
  it 'includes write concern in the selector' do
98
- expect(op.send(:command, connection)[:writeConcern]).to eq(write_concern.options)
98
+ expect(op.send(:command, connection)[:writeConcern]).to eq(BSON::Document.new(write_concern.options))
99
99
  end
100
100
  end
101
101
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
- require 'spec_helper'
4
+ require 'lite_spec_helper'
5
5
 
6
- describe Mongo::Collection::View::Builder::Flags do
6
+ describe Mongo::Operation::Find::Builder::Flags do
7
7
 
8
8
  describe '.map_flags' do
9
9
 
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
- require 'spec_helper'
4
+ require 'lite_spec_helper'
5
5
 
6
- describe Mongo::Collection::View::Builder::Modifiers do
6
+ describe Mongo::Operation::Find::Builder::Modifiers do
7
7
 
8
8
  describe '.map_driver_options' do
9
9
 
@@ -78,6 +78,7 @@ describe Mongo::Operation::Find::Legacy do
78
78
  double('description').tap do |description|
79
79
  expect(description).to receive(:mongos?) { false }
80
80
  expect(description).to receive(:standalone?) { false }
81
+ #expect(description).to receive(:load_balancer?) { false }
81
82
  end
82
83
  end
83
84
 
@@ -4,7 +4,7 @@
4
4
  require 'spec_helper'
5
5
 
6
6
  describe Mongo::Operation::Insert do
7
- require_no_multi_shard
7
+ require_no_multi_mongos
8
8
  require_no_required_api_version
9
9
 
10
10
  let(:context) { Mongo::Operation::Context.new }
@@ -95,7 +95,7 @@ describe Mongo::Operation::Insert::OpMsg do
95
95
  context 'when write concern is specified' do
96
96
 
97
97
  it 'includes write concern in the selector' do
98
- expect(op.send(:command, connection)[:writeConcern]).to eq(write_concern.options)
98
+ expect(op.send(:command, connection)[:writeConcern]).to eq(BSON::Document.new(write_concern.options))
99
99
  end
100
100
  end
101
101
  end
@@ -35,9 +35,12 @@ describe Mongo::Operation::KillCursors::Legacy do
35
35
  end
36
36
 
37
37
  describe '#message' do
38
+ let(:expected_cursor_ids) do
39
+ spec[:cursor_ids].map { |v| BSON::Int64.new(v) }
40
+ end
38
41
 
39
42
  it 'creates a kill cursors wire protocol message with correct specs' do
40
- expect(Mongo::Protocol::KillCursors).to receive(:new).with(TEST_COLL, SpecConfig.instance.test_db, spec[:cursor_ids])
43
+ expect(Mongo::Protocol::KillCursors).to receive(:new).with(TEST_COLL, SpecConfig.instance.test_db, expected_cursor_ids)
41
44
  op.send(:message, double('server'))
42
45
  end
43
46
  end
@@ -33,12 +33,16 @@ describe Mongo::Operation::ReadPreferenceSupported do
33
33
  double('description').tap do |description|
34
34
  allow(description).to receive(:mongos?).and_return(mongos?)
35
35
  allow(description).to receive(:standalone?).and_return(standalone?)
36
+ # TODO consider adding tests for load-balanced topologies also
37
+ allow(description).to receive(:load_balancer?).and_return(false)
36
38
  end
37
39
  end
38
40
 
39
41
  let(:server) do
40
42
  double('server').tap do |server|
41
43
  allow(server).to receive(:cluster).and_return(cluster)
44
+ # TODO consider adding tests for load-balanced topologies also
45
+ allow(server).to receive(:load_balancer?).and_return(false)
42
46
  end
43
47
  end
44
48
 
@@ -41,6 +41,8 @@ describe Mongo::Operation::SessionsSupported do
41
41
  let(:server) do
42
42
  double('server').tap do |server|
43
43
  allow(server).to receive(:cluster).and_return(cluster)
44
+ # TODO consider adding tests for load-balanced topologies also
45
+ allow(server).to receive(:load_balancer?).and_return(false)
44
46
  end
45
47
  end
46
48
 
@@ -4,7 +4,7 @@
4
4
  require 'spec_helper'
5
5
 
6
6
  describe Mongo::Operation::Update do
7
- require_no_multi_shard
7
+ require_no_multi_mongos
8
8
  require_no_required_api_version
9
9
 
10
10
  let(:context) { Mongo::Operation::Context.new }
@@ -101,7 +101,7 @@ describe Mongo::Operation::Update::OpMsg do
101
101
  context 'when write concern is specified' do
102
102
 
103
103
  it 'includes write concern in the selector' do
104
- expect(op.send(:command, connection)[:writeConcern]).to eq(write_concern.options)
104
+ expect(op.send(:command, connection)[:writeConcern]).to eq(BSON::Document.new(write_concern.options))
105
105
  end
106
106
  end
107
107
  end
@@ -14,7 +14,7 @@ describe Mongo::QueryCache do
14
14
  authorized_collection.delete_many
15
15
  end
16
16
 
17
- let(:subscriber) { EventSubscriber.new }
17
+ let(:subscriber) { Mrss::EventSubscriber.new }
18
18
 
19
19
  let(:client) do
20
20
  authorized_client.tap do |client|
@@ -139,7 +139,11 @@ describe Mongo::QueryCache do
139
139
 
140
140
  describe '#get' do
141
141
  let(:view) { double("Mongo::Collection::View") }
142
- let(:result) { double("Mongo::Operation::Result") }
142
+ let(:result) do
143
+ double("Mongo::Operation::Result").tap do |result|
144
+ allow(result).to receive(:is_a?).with(Mongo::Operation::Result).and_return(true)
145
+ end
146
+ end
143
147
  let(:server) { double("Mongo::Server") }
144
148
  let(:caching_cursor) { Mongo::CachingCursor.new(view, result, server) }
145
149
 
@@ -1,24 +1,75 @@
1
1
  # frozen_string_literal: true
2
2
  # encoding: utf-8
3
3
 
4
- require 'spec_helper'
4
+ require 'lite_spec_helper'
5
5
 
6
6
  describe Mongo::Server::ConnectionCommon do
7
7
  let(:subject) { described_class.new }
8
8
 
9
+ let(:metadata) do
10
+ Mongo::Server::AppMetadata.new({})
11
+ end
12
+
9
13
  describe '#handshake_document' do
10
- it 'returns hello document with API version' do
11
- meta = Mongo::Server::AppMetadata.new({
12
- server_api: { version: '1' }
13
- })
14
- document = subject.handshake_document(meta)
15
- expect(document['hello']).to eq(1)
14
+ let(:document) do
15
+ subject.handshake_document(metadata)
16
+ end
17
+
18
+ context 'with api version' do
19
+ let(:metadata) do
20
+ Mongo::Server::AppMetadata.new({
21
+ server_api: { version: '1' }
22
+ })
23
+ end
24
+
25
+ it 'returns hello document with API version' do
26
+ expect(document['hello']).to eq(1)
27
+ end
28
+ end
29
+
30
+ context 'without api version' do
31
+ it 'returns legacy hello document without API version' do
32
+ expect(document['isMaster']).to eq(1)
33
+ end
34
+ end
35
+
36
+ context 'when connecting to load balancer' do
37
+
38
+ let(:document) do
39
+ subject.handshake_document(metadata, load_balancer: true)
40
+ end
41
+
42
+ it 'includes loadBalanced: true' do
43
+ document['loadBalanced'].should be true
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#handshake_command' do
49
+ let(:document) do
50
+ subject.handshake_document(metadata)
51
+ end
52
+
53
+ context 'with api version' do
54
+ let(:metadata) do
55
+ Mongo::Server::AppMetadata.new({
56
+ server_api: { version: '1' }
57
+ })
58
+ end
59
+
60
+ it 'returns OP_MSG command' do
61
+ expect(
62
+ subject.handshake_command(document)
63
+ ).to be_a(Mongo::Protocol::Msg)
64
+ end
16
65
  end
17
66
 
18
- it 'returns legacy hello document without API version' do
19
- meta = Mongo::Server::AppMetadata.new({})
20
- document = subject.handshake_document(meta)
21
- expect(document['isMaster']).to eq(1)
67
+ context 'without api version' do
68
+ it 'returns OP_QUERY command' do
69
+ expect(
70
+ subject.handshake_command(document)
71
+ ).to be_a(Mongo::Protocol::Query)
72
+ end
22
73
  end
23
74
  end
24
75
  end