mongo 2.20.2 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -0
  3. data/Rakefile +11 -11
  4. data/lib/mongo/address.rb +22 -3
  5. data/lib/mongo/auth/aws/credentials_retriever.rb +70 -17
  6. data/lib/mongo/auth/base.rb +1 -1
  7. data/lib/mongo/bulk_write.rb +35 -2
  8. data/lib/mongo/client.rb +38 -6
  9. data/lib/mongo/client_encryption.rb +6 -3
  10. data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -1
  11. data/lib/mongo/cluster/sdam_flow.rb +20 -7
  12. data/lib/mongo/cluster.rb +14 -4
  13. data/lib/mongo/collection/helpers.rb +1 -1
  14. data/lib/mongo/collection/view/aggregation/behavior.rb +131 -0
  15. data/lib/mongo/collection/view/aggregation.rb +33 -99
  16. data/lib/mongo/collection/view/builder/aggregation.rb +1 -7
  17. data/lib/mongo/collection/view/change_stream.rb +80 -27
  18. data/lib/mongo/collection/view/iterable.rb +76 -60
  19. data/lib/mongo/collection/view/map_reduce.rb +25 -8
  20. data/lib/mongo/collection/view/readable.rb +79 -30
  21. data/lib/mongo/collection/view/writable.rb +109 -48
  22. data/lib/mongo/collection/view.rb +43 -3
  23. data/lib/mongo/collection.rb +158 -23
  24. data/lib/mongo/crypt/auto_encrypter.rb +4 -6
  25. data/lib/mongo/crypt/binding.rb +4 -4
  26. data/lib/mongo/crypt/context.rb +20 -14
  27. data/lib/mongo/crypt/encryption_io.rb +56 -26
  28. data/lib/mongo/crypt/explicit_encrypter.rb +49 -20
  29. data/lib/mongo/crypt/explicit_encryption_context.rb +17 -11
  30. data/lib/mongo/crypt/kms/azure/credentials_retriever.rb +22 -6
  31. data/lib/mongo/crypt/kms/gcp/credentials_retriever.rb +29 -4
  32. data/lib/mongo/csot_timeout_holder.rb +119 -0
  33. data/lib/mongo/cursor/kill_spec.rb +5 -2
  34. data/lib/mongo/cursor/nontailable.rb +27 -0
  35. data/lib/mongo/cursor.rb +86 -24
  36. data/lib/mongo/cursor_host.rb +82 -0
  37. data/lib/mongo/database/view.rb +81 -14
  38. data/lib/mongo/database.rb +88 -18
  39. data/lib/mongo/error/operation_failure.rb +209 -204
  40. data/lib/mongo/error/server_timeout_error.rb +12 -0
  41. data/lib/mongo/error/socket_timeout_error.rb +3 -1
  42. data/lib/mongo/error/timeout_error.rb +23 -0
  43. data/lib/mongo/error.rb +2 -0
  44. data/lib/mongo/grid/fs_bucket.rb +45 -12
  45. data/lib/mongo/grid/stream/read.rb +15 -1
  46. data/lib/mongo/grid/stream/write.rb +21 -4
  47. data/lib/mongo/index/view.rb +77 -16
  48. data/lib/mongo/operation/context.rb +40 -2
  49. data/lib/mongo/operation/create_search_indexes/op_msg.rb +2 -2
  50. data/lib/mongo/operation/delete/op_msg.rb +2 -1
  51. data/lib/mongo/operation/drop_search_index/op_msg.rb +2 -2
  52. data/lib/mongo/operation/find/op_msg.rb +45 -0
  53. data/lib/mongo/operation/get_more/op_msg.rb +33 -0
  54. data/lib/mongo/operation/insert/op_msg.rb +3 -2
  55. data/lib/mongo/operation/insert/result.rb +4 -2
  56. data/lib/mongo/operation/list_collections/result.rb +1 -1
  57. data/lib/mongo/operation/map_reduce/result.rb +1 -1
  58. data/lib/mongo/operation/op_msg_base.rb +3 -1
  59. data/lib/mongo/operation/result.rb +26 -5
  60. data/lib/mongo/operation/shared/executable.rb +12 -1
  61. data/lib/mongo/operation/shared/op_msg_executable.rb +4 -1
  62. data/lib/mongo/operation/shared/response_handling.rb +3 -3
  63. data/lib/mongo/operation/shared/sessions_supported.rb +1 -1
  64. data/lib/mongo/operation/shared/timed.rb +52 -0
  65. data/lib/mongo/operation/shared/write.rb +4 -1
  66. data/lib/mongo/operation/update/op_msg.rb +2 -1
  67. data/lib/mongo/operation/update_search_index/op_msg.rb +2 -2
  68. data/lib/mongo/operation.rb +1 -0
  69. data/lib/mongo/protocol/message.rb +1 -4
  70. data/lib/mongo/protocol/msg.rb +2 -2
  71. data/lib/mongo/retryable/read_worker.rb +69 -29
  72. data/lib/mongo/retryable/write_worker.rb +49 -18
  73. data/lib/mongo/retryable.rb +8 -2
  74. data/lib/mongo/server/connection.rb +11 -5
  75. data/lib/mongo/server/connection_base.rb +22 -2
  76. data/lib/mongo/server/connection_pool.rb +32 -14
  77. data/lib/mongo/server/description/features.rb +1 -1
  78. data/lib/mongo/server/description.rb +18 -5
  79. data/lib/mongo/server/monitor.rb +7 -4
  80. data/lib/mongo/server/pending_connection.rb +7 -3
  81. data/lib/mongo/server/{round_trip_time_averager.rb → round_trip_time_calculator.rb} +25 -7
  82. data/lib/mongo/server.rb +11 -6
  83. data/lib/mongo/server_selector/base.rb +25 -9
  84. data/lib/mongo/session.rb +78 -9
  85. data/lib/mongo/socket/ssl.rb +113 -30
  86. data/lib/mongo/socket/tcp.rb +40 -6
  87. data/lib/mongo/socket.rb +154 -25
  88. data/lib/mongo/uri/options_mapper.rb +1 -0
  89. data/lib/mongo/version.rb +15 -4
  90. data/lib/mongo.rb +1 -0
  91. data/spec/atlas/atlas_connectivity_spec.rb +4 -0
  92. data/spec/atlas/operations_spec.rb +4 -0
  93. data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +2 -1
  94. data/spec/integration/client_side_encryption/auto_encryption_spec.rb +494 -487
  95. data/spec/integration/client_side_encryption/on_demand_aws_credentials_spec.rb +1 -1
  96. data/spec/integration/client_side_encryption/range_explicit_encryption_prose_spec.rb +66 -22
  97. data/spec/integration/client_side_operations_timeout/encryption_prose_spec.rb +131 -0
  98. data/spec/integration/connection_pool_populator_spec.rb +2 -0
  99. data/spec/integration/cursor_pinning_spec.rb +15 -60
  100. data/spec/integration/cursor_reaping_spec.rb +1 -1
  101. data/spec/integration/docs_examples_spec.rb +1 -1
  102. data/spec/integration/ocsp_verifier_spec.rb +99 -30
  103. data/spec/integration/operation_failure_code_spec.rb +1 -1
  104. data/spec/integration/operation_failure_message_spec.rb +3 -3
  105. data/spec/integration/reconnect_spec.rb +2 -8
  106. data/spec/integration/retryable_errors_spec.rb +2 -2
  107. data/spec/integration/sdam_error_handling_spec.rb +2 -1
  108. data/spec/integration/search_indexes_prose_spec.rb +4 -0
  109. data/spec/integration/server_spec.rb +4 -3
  110. data/spec/integration/srv_monitoring_spec.rb +3 -2
  111. data/spec/integration/srv_spec.rb +4 -0
  112. data/spec/integration/transactions_api_examples_spec.rb +2 -0
  113. data/spec/kerberos/kerberos_spec.rb +4 -0
  114. data/spec/lite_spec_helper.rb +3 -1
  115. data/spec/mongo/auth/user/view_spec.rb +1 -1
  116. data/spec/mongo/caching_cursor_spec.rb +1 -1
  117. data/spec/mongo/client_encryption_spec.rb +1 -0
  118. data/spec/mongo/client_spec.rb +158 -4
  119. data/spec/mongo/collection/view/aggregation_spec.rb +14 -39
  120. data/spec/mongo/collection/view/change_stream_spec.rb +3 -3
  121. data/spec/mongo/collection_spec.rb +5 -6
  122. data/spec/mongo/crypt/auto_encrypter_spec.rb +14 -12
  123. data/spec/mongo/crypt/data_key_context_spec.rb +3 -1
  124. data/spec/mongo/crypt/explicit_encryption_context_spec.rb +2 -2
  125. data/spec/mongo/crypt/handle_spec.rb +1 -1
  126. data/spec/mongo/cursor_spec.rb +26 -9
  127. data/spec/mongo/error/operation_failure_heavy_spec.rb +2 -2
  128. data/spec/mongo/operation/context_spec.rb +79 -0
  129. data/spec/mongo/operation/create/op_msg_spec.rb +106 -110
  130. data/spec/mongo/operation/delete/op_msg_spec.rb +6 -5
  131. data/spec/mongo/operation/find/op_msg_spec.rb +66 -0
  132. data/spec/mongo/operation/get_more/op_msg_spec.rb +65 -0
  133. data/spec/mongo/operation/insert/op_msg_spec.rb +128 -131
  134. data/spec/mongo/operation/shared/csot/examples.rb +113 -0
  135. data/spec/mongo/query_cache_spec.rb +243 -225
  136. data/spec/mongo/retryable_spec.rb +1 -0
  137. data/spec/mongo/server/round_trip_time_calculator_spec.rb +120 -0
  138. data/spec/mongo/socket/ssl_spec.rb +0 -10
  139. data/spec/runners/change_streams/test.rb +2 -2
  140. data/spec/runners/crud/operation.rb +1 -1
  141. data/spec/runners/crud/verifier.rb +3 -1
  142. data/spec/runners/transactions/operation.rb +4 -6
  143. data/spec/runners/unified/ambiguous_operations.rb +13 -0
  144. data/spec/runners/unified/assertions.rb +4 -0
  145. data/spec/runners/unified/change_stream_operations.rb +14 -24
  146. data/spec/runners/unified/crud_operations.rb +82 -59
  147. data/spec/runners/unified/ddl_operations.rb +38 -7
  148. data/spec/runners/unified/grid_fs_operations.rb +37 -2
  149. data/spec/runners/unified/support_operations.rb +43 -4
  150. data/spec/runners/unified/test.rb +22 -10
  151. data/spec/runners/unified.rb +1 -1
  152. data/spec/solo/clean_exit_spec.rb +2 -0
  153. data/spec/spec_tests/client_side_operations_timeout_spec.rb +15 -0
  154. data/spec/spec_tests/data/change_streams_unified/change-streams-clusterTime.yml +3 -1
  155. data/spec/spec_tests/data/change_streams_unified/change-streams-disambiguatedPaths.yml +3 -1
  156. data/spec/spec_tests/data/change_streams_unified/change-streams-errors.yml +3 -1
  157. data/spec/spec_tests/data/change_streams_unified/change-streams-pre_and_post_images.yml +1 -1
  158. data/spec/spec_tests/data/change_streams_unified/change-streams-resume-allowlist.yml +1 -1
  159. data/spec/spec_tests/data/change_streams_unified/change-streams-resume-errorLabels.yml +1 -1
  160. data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +1 -1
  161. data/spec/spec_tests/data/client_side_encryption/badQueries.yml +2 -1
  162. data/spec/spec_tests/data/client_side_encryption/timeoutMS.yml +67 -0
  163. data/spec/spec_tests/data/client_side_operations_timeout/bulkWrite.yml +87 -0
  164. data/spec/spec_tests/data/client_side_operations_timeout/change-streams.yml +358 -0
  165. data/spec/spec_tests/data/client_side_operations_timeout/close-cursors.yml +129 -0
  166. data/spec/spec_tests/data/client_side_operations_timeout/command-execution.yml +250 -0
  167. data/spec/spec_tests/data/client_side_operations_timeout/convenient-transactions.yml +113 -0
  168. data/spec/spec_tests/data/client_side_operations_timeout/cursors.yml +70 -0
  169. data/spec/spec_tests/data/client_side_operations_timeout/deprecated-options.yml +3982 -0
  170. data/spec/spec_tests/data/client_side_operations_timeout/error-transformations.yml +96 -0
  171. data/spec/spec_tests/data/client_side_operations_timeout/global-timeoutMS.yml +3236 -0
  172. data/spec/spec_tests/data/client_side_operations_timeout/gridfs-advanced.yml +207 -0
  173. data/spec/spec_tests/data/client_side_operations_timeout/gridfs-delete.yml +152 -0
  174. data/spec/spec_tests/data/client_side_operations_timeout/gridfs-download.yml +182 -0
  175. data/spec/spec_tests/data/client_side_operations_timeout/gridfs-find.yml +100 -0
  176. data/spec/spec_tests/data/client_side_operations_timeout/gridfs-upload.yml +249 -0
  177. data/spec/spec_tests/data/client_side_operations_timeout/legacy-timeouts.yml +204 -0
  178. data/spec/spec_tests/data/client_side_operations_timeout/non-tailable-cursors.yml +307 -0
  179. data/spec/spec_tests/data/client_side_operations_timeout/override-collection-timeoutMS.yml +1877 -0
  180. data/spec/spec_tests/data/client_side_operations_timeout/override-operation-timeoutMS.yml +1918 -0
  181. data/spec/spec_tests/data/client_side_operations_timeout/retryability-legacy-timeouts.yml +1676 -0
  182. data/spec/spec_tests/data/client_side_operations_timeout/retryability-timeoutMS.yml +2824 -0
  183. data/spec/spec_tests/data/client_side_operations_timeout/sessions-inherit-timeoutMS.yml +168 -0
  184. data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-operation-timeoutMS.yml +171 -0
  185. data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-timeoutMS.yml +168 -0
  186. data/spec/spec_tests/data/client_side_operations_timeout/tailable-awaitData.yml +247 -0
  187. data/spec/spec_tests/data/client_side_operations_timeout/tailable-non-awaitData.yml +181 -0
  188. data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +4 -0
  189. data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +4 -0
  190. data/spec/spec_tests/data/crud_unified/find-test-all-options.yml +29 -0
  191. data/spec/spec_tests/server_selection_rtt_spec.rb +6 -6
  192. data/spec/support/certificates/atlas-ocsp-ca.crt +81 -83
  193. data/spec/support/certificates/atlas-ocsp.crt +107 -107
  194. data/spec/support/cluster_tools.rb +3 -3
  195. data/spec/support/common_shortcuts.rb +39 -21
  196. data/spec/support/constraints.rb +0 -10
  197. data/spec/support/crypt/encrypted_fields/range-encryptedFields-Date.json +1 -1
  198. data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalNoPrecision.json +1 -1
  199. data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalPrecision.json +1 -1
  200. data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoubleNoPrecision.json +1 -1
  201. data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoublePrecision.json +1 -1
  202. data/spec/support/crypt/encrypted_fields/range-encryptedFields-Int.json +1 -1
  203. data/spec/support/crypt/encrypted_fields/range-encryptedFields-Long.json +1 -1
  204. data/spec/support/dns.rb +16 -0
  205. data/spec/support/shared/session.rb +2 -2
  206. data/spec/support/spec_setup.rb +2 -2
  207. data/spec/support/utils.rb +3 -1
  208. metadata +91 -153
  209. data/spec/mongo/server/round_trip_time_averager_spec.rb +0 -48
  210. data/spec/shared/CANDIDATE.md +0 -28
  211. data/spec/shared/LICENSE +0 -20
  212. data/spec/shared/bin/get-mongodb-download-url +0 -17
  213. data/spec/shared/bin/s3-copy +0 -45
  214. data/spec/shared/bin/s3-upload +0 -69
  215. data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
  216. data/spec/shared/lib/mrss/cluster_config.rb +0 -231
  217. data/spec/shared/lib/mrss/constraints.rb +0 -378
  218. data/spec/shared/lib/mrss/docker_runner.rb +0 -298
  219. data/spec/shared/lib/mrss/eg_config_utils.rb +0 -51
  220. data/spec/shared/lib/mrss/event_subscriber.rb +0 -210
  221. data/spec/shared/lib/mrss/lite_constraints.rb +0 -238
  222. data/spec/shared/lib/mrss/release/candidate.rb +0 -281
  223. data/spec/shared/lib/mrss/release/product_data.rb +0 -144
  224. data/spec/shared/lib/mrss/server_version_registry.rb +0 -113
  225. data/spec/shared/lib/mrss/session_registry.rb +0 -69
  226. data/spec/shared/lib/mrss/session_registry_legacy.rb +0 -60
  227. data/spec/shared/lib/mrss/spec_organizer.rb +0 -179
  228. data/spec/shared/lib/mrss/utils.rb +0 -37
  229. data/spec/shared/lib/tasks/candidate.rake +0 -64
  230. data/spec/shared/share/Dockerfile.erb +0 -251
  231. data/spec/shared/share/haproxy-1.conf +0 -16
  232. data/spec/shared/share/haproxy-2.conf +0 -17
  233. data/spec/shared/shlib/config.sh +0 -27
  234. data/spec/shared/shlib/distro.sh +0 -84
  235. data/spec/shared/shlib/server.sh +0 -423
  236. data/spec/shared/shlib/set_env.sh +0 -110
  237. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Aggregate.yml +0 -242
  238. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Correctness.yml +0 -423
  239. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Delete.yml +0 -183
  240. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-FindOneAndUpdate.yml +0 -240
  241. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-InsertFind.yml +0 -236
  242. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Update.yml +0 -253
  243. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Aggregate.yml +0 -1688
  244. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Correctness.yml +0 -294
  245. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Delete.yml +0 -906
  246. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-FindOneAndUpdate.yml +0 -1685
  247. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-InsertFind.yml +0 -1681
  248. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Update.yml +0 -1698
  249. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Aggregate.yml +0 -330
  250. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Correctness.yml +0 -425
  251. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Delete.yml +0 -227
  252. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.yml +0 -328
  253. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-InsertFind.yml +0 -320
  254. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Update.yml +0 -337
  255. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Aggregate.yml +0 -914
  256. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Correctness.yml +0 -293
  257. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Delete.yml +0 -519
  258. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-FindOneAndUpdate.yml +0 -912
  259. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-InsertFind.yml +0 -908
  260. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Update.yml +0 -925
  261. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Aggregate.yml +0 -326
  262. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Correctness.yml +0 -425
  263. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Delete.yml +0 -225
  264. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-FindOneAndUpdate.yml +0 -324
  265. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-InsertFind.yml +0 -320
  266. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Update.yml +0 -339
  267. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Aggregate.yml +0 -242
  268. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Correctness.yml +0 -424
  269. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Delete.yml +0 -183
  270. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-FindOneAndUpdate.yml +0 -240
  271. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-InsertFind.yml +0 -236
  272. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Update.yml +0 -255
  273. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Aggregate.yml +0 -242
  274. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Correctness.yml +0 -423
  275. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Delete.yml +0 -183
  276. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-FindOneAndUpdate.yml +0 -240
  277. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-InsertFind.yml +0 -236
  278. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Update.yml +0 -255
  279. data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-WrongType.yml +0 -44
@@ -1,423 +0,0 @@
1
- # This file contains functions pertaining to downloading, starting and
2
- # configuring a MongoDB server.
3
-
4
- # Note that mlaunch is executed with (and therefore installed with) Python 2.
5
- # The reason for this is that in the past, some of the distros we tested on
6
- # had an ancient version of Python 3 that was unusable (e.g. it couldn't
7
- # install anything from PyPI due to outdated TLS/SSL implementation).
8
- # It is likely that all of the current distros we use have a recent enough
9
- # and working Python 3 implementation, such that we could use Python 3 for
10
- # everything.
11
- #
12
- # Note that some distros (e.g. ubuntu2004) do not contain a `python' binary
13
- # at all, thus python2 or python3 must be explicitly specified depending on
14
- # the desired version.
15
-
16
- set_fcv() {
17
- if test -n "$FCV"; then
18
- mongo --eval 'assert.commandWorked(db.adminCommand( { setFeatureCompatibilityVersion: "'"$FCV"'" } ));' "$MONGODB_URI"
19
- mongo --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' |grep "version.*$FCV"
20
- fi
21
- }
22
-
23
- add_uri_option() {
24
- opt=$1
25
-
26
- if ! echo $MONGODB_URI |sed -e s,//,, |grep -q /; then
27
- MONGODB_URI="$MONGODB_URI/"
28
- fi
29
-
30
- if ! echo $MONGODB_URI |grep -q '?'; then
31
- MONGODB_URI="$MONGODB_URI?"
32
- fi
33
-
34
- MONGODB_URI="$MONGODB_URI&$opt"
35
- }
36
-
37
- prepare_server() {
38
- if test -n "$USE_OPT_MONGODB"; then
39
- export BINDIR=/opt/mongodb/bin
40
- export PATH=$BINDIR:$PATH
41
- return
42
- fi
43
-
44
- . $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
45
-
46
- get_distro
47
- arch="${1:-$DISTRO}"
48
-
49
- get_mongodb_download_url_for "$arch" "$MONGODB_VERSION"
50
- prepare_server_from_url "$MONGODB_DOWNLOAD_URL" "$MONGOSH_DOWNLOAD_URL"
51
- }
52
-
53
- prepare_server_from_url() {
54
- server_url=$1
55
- mongosh_url=$2
56
-
57
- dirname=`basename $server_url |sed -e s/.tgz//`
58
- mongodb_dir="$MONGO_ORCHESTRATION_HOME"/mdb/"$dirname"
59
- mkdir -p "$mongodb_dir"
60
- curl --retry 3 $server_url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
61
-
62
- if test -n "$mongosh_url"; then
63
- curl --retry 3 $mongosh_url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
64
- fi
65
-
66
- BINDIR="$mongodb_dir"/bin
67
- export PATH="$BINDIR":$PATH
68
- }
69
-
70
- install_mlaunch_venv() {
71
- python3 -V || true
72
- if ! python3 -m venv -h >/dev/null; then
73
- # Current virtualenv fails with
74
- # https://github.com/pypa/virtualenv/issues/1630
75
- python3 -m pip install venv --user
76
- fi
77
- if ! python3 -m ensurepip -h > /dev/null; then
78
- # Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
79
- # the python3-venv package is also installed (it lacks the ensurepip
80
- # module).
81
- sudo apt-get update && sudo apt-get install --yes python3-venv
82
- fi
83
- if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
84
- python3 -m pip list |grep mtools
85
- then
86
- # Use the existing mtools-legacy
87
- :
88
- else
89
- # Spawn a virtual environment, but only if one is not already
90
- # active...
91
- if test -z "$VIRTUAL_ENV"; then
92
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
93
- python3 -m venv $venvpath
94
- . $venvpath/bin/activate
95
- fi
96
-
97
- # [mlaunch] does not work:
98
- # https://github.com/rueckstiess/mtools/issues/856
99
- # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
100
- #pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
101
-
102
- # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
103
- pip install --upgrade setuptools
104
- pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
105
- fi
106
- }
107
-
108
- install_mlaunch_pip() {
109
- if test -n "$USE_OPT_MONGODB" && which mlaunch >/dev/null 2>&1; then
110
- # mlaunch is preinstalled in the docker image, do not install it here
111
- return
112
- fi
113
-
114
- python -V || true
115
- python3 -V || true
116
- pythonpath="$MONGO_ORCHESTRATION_HOME"/python
117
- # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
118
- pip install -t "$pythonpath" 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
119
- export PATH="$pythonpath/bin":$PATH
120
- export PYTHONPATH="$pythonpath"
121
- }
122
-
123
- install_mlaunch_git() {
124
- repo=$1
125
- branch=$2
126
- python -V || true
127
- python3 -V || true
128
- which pip || true
129
- which pip3 || true
130
-
131
- if false; then
132
- if ! virtualenv --version; then
133
- python3 `which pip3` install --user virtualenv
134
- export PATH=$HOME/.local/bin:$PATH
135
- virtualenv --version
136
- fi
137
-
138
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
139
- virtualenv -p python3 $venvpath
140
- . $venvpath/bin/activate
141
-
142
- # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
143
- pip3 install psutil pymongo python-dateutil
144
-
145
- git clone $repo mlaunch
146
- cd mlaunch
147
- git checkout origin/$branch
148
- python3 setup.py install
149
- cd ..
150
- else
151
- pip install --user 'virtualenv==13'
152
- export PATH=$HOME/.local/bin:$PATH
153
-
154
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
155
- virtualenv $venvpath
156
- . $venvpath/bin/activate
157
-
158
- # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
159
- pip install psutil pymongo python-dateutil
160
-
161
- git clone $repo mlaunch
162
- (cd mlaunch &&
163
- git checkout origin/$branch &&
164
- python2 setup.py install
165
- )
166
- fi
167
- }
168
-
169
- install_haproxy() {
170
- if ! command -v haproxy &> /dev/null; then
171
- if ! command -v apt-get &> /dev/null; then
172
- # no apt-get; assume RHEL
173
- sudo yum -y install haproxy
174
- else
175
- sudo apt-get update && sudo apt-get install --yes haproxy
176
- fi
177
- else
178
- echo 'haproxy is present'
179
- fi
180
- }
181
-
182
- install_cmake() {
183
- if ! command -v cmake &> /dev/null; then
184
- if ! command -v apt-get &> /dev/null; then
185
- # no apt-get; assume RHEL
186
- sudo yum -y install cmake libarchive
187
- else
188
- sudo apt-get update && sudo apt-get install --yes cmake
189
- fi
190
- else
191
- echo 'cmake is present'
192
- fi
193
- }
194
-
195
- # This function sets followong global variables:
196
- # server_cert_path
197
- # server_ca_path
198
- # server_client_cert_path
199
- #
200
- # These variables are used later to connect to processes via mongo client.
201
- calculate_server_args() {
202
- local mongo_version=`echo $MONGODB_VERSION |tr -d .`
203
-
204
- if test -z "$mongo_version"; then
205
- echo "$MONGODB_VERSION must be set and not contain only dots" 1>&2
206
- exit 3
207
- fi
208
-
209
- if test $mongo_version = latest; then
210
- mongo_version=70
211
- fi
212
-
213
- local args="--setParameter enableTestCommands=1"
214
-
215
- if test $mongo_version -ge 50; then
216
- args="$args --setParameter acceptApiVersion2=1"
217
- elif test $mongo_version -ge 47; then
218
- args="$args --setParameter acceptAPIVersion2=1"
219
- fi
220
-
221
- args="$args --setParameter diagnosticDataCollectionEnabled=false"
222
-
223
- local uri_options=
224
- if test "$TOPOLOGY" = replica-set; then
225
- args="$args --replicaset --name test-rs --nodes 2 --arbiter"
226
- export HAVE_ARBITER=1
227
- elif test "$TOPOLOGY" = replica-set-single-node; then
228
- args="$args --replicaset --name test-rs --nodes 1"
229
- elif test "$TOPOLOGY" = sharded-cluster; then
230
- args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
231
- if test -z "$SINGLE_MONGOS"; then
232
- args="$args --mongos 2"
233
- fi
234
- elif test "$TOPOLOGY" = standalone; then
235
- args="$args --single"
236
- elif test "$TOPOLOGY" = load-balanced; then
237
- args="$args --replicaset --nodes 2 --sharded 1 --name test-rs --port 27117"
238
- if test -z "$MRSS_ROOT"; then
239
- echo "Please set MRSS_ROOT" 1>&2
240
- exit 2
241
- fi
242
- if test -n "$SINGLE_MONGOS"; then
243
- haproxy_config=$MRSS_ROOT/share/haproxy-1.conf
244
- else
245
- args="$args --mongos 2"
246
- haproxy_config=$MRSS_ROOT/share/haproxy-2.conf
247
- fi
248
- uri_options="$uri_options&loadBalanced=true"
249
- else
250
- echo "Unknown topology: $TOPOLOGY" 1>&2
251
- exit 1
252
- fi
253
- if test -n "$MMAPV1"; then
254
- args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
255
- uri_options="$uri_options&retryReads=false&retryWrites=false"
256
- fi
257
- if test "$AUTH" = auth; then
258
- args="$args --auth --username bob --password pwd123"
259
- elif test "$AUTH" = x509; then
260
- args="$args --auth --username bootstrap --password bootstrap"
261
- elif echo "$AUTH" |grep -q ^aws; then
262
- args="$args --auth --username bootstrap --password bootstrap"
263
- args="$args --setParameter authenticationMechanisms=MONGODB-AWS,SCRAM-SHA-1,SCRAM-SHA-256"
264
- uri_options="$uri_options&authMechanism=MONGODB-AWS&authSource=\$external"
265
- fi
266
-
267
- if test -n "$OCSP"; then
268
- if test -z "$OCSP_ALGORITHM"; then
269
- echo "OCSP_ALGORITHM must be set if OCSP is set" 1>&2
270
- exit 1
271
- fi
272
- fi
273
-
274
- if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
275
- if test -n "$OCSP_ALGORITHM"; then
276
- if test "$OCSP_MUST_STAPLE" = 1; then
277
- server_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server-mustStaple.pem
278
- else
279
- server_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
280
- fi
281
- server_ca_path=spec/support/ocsp/$OCSP_ALGORITHM/ca.crt
282
- server_client_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
283
- else
284
- server_cert_path=spec/support/certificates/server-second-level-bundle.pem
285
- server_ca_path=spec/support/certificates/ca.crt
286
- server_client_cert_path=spec/support/certificates/client.pem
287
- fi
288
-
289
- if test -n "$OCSP_ALGORITHM"; then
290
- client_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
291
- elif test "$AUTH" = x509; then
292
- client_cert_path=spec/support/certificates/client-x509.pem
293
-
294
- uri_options="$uri_options&authMechanism=MONGODB-X509"
295
- elif echo $RVM_RUBY |grep -q jruby; then
296
- # JRuby does not grok chained certificate bundles -
297
- # https://github.com/jruby/jruby-openssl/issues/181
298
- client_cert_path=spec/support/certificates/client.pem
299
- else
300
- client_cert_path=spec/support/certificates/client-second-level-bundle.pem
301
- fi
302
-
303
- uri_options="$uri_options&tls=true&"\
304
- "tlsCAFile=$server_ca_path&"\
305
- "tlsCertificateKeyFile=$client_cert_path"
306
-
307
- args="$args --sslMode requireSSL"\
308
- " --sslPEMKeyFile $server_cert_path"\
309
- " --sslCAFile $server_ca_path"\
310
- " --sslClientCertificate $server_client_cert_path"
311
- fi
312
-
313
- # Docker forwards ports to the external interface, not to the loopback.
314
- # Hence we must bind to all interfaces here.
315
- if test -n "$BIND_ALL"; then
316
- args="$args --bind_ip_all"
317
- fi
318
-
319
- # MongoDB servers pre-4.2 do not enable zlib compression by default
320
- if test "$COMPRESSOR" = snappy; then
321
- args="$args --networkMessageCompressors snappy"
322
- elif test "$COMPRESSOR" = zlib; then
323
- args="$args --networkMessageCompressors zlib"
324
- fi
325
-
326
- if test -n "$OCSP_ALGORITHM" || test -n "$OCSP_VERIFIER"; then
327
- python3 -m pip install asn1crypto oscrypto flask
328
- fi
329
-
330
- local ocsp_args=
331
- if test -n "$OCSP_ALGORITHM"; then
332
- if test -z "$server_ca_path"; then
333
- echo "server_ca_path must have been set" 1>&2
334
- exit 1
335
- fi
336
- ocsp_args="--ca_file $server_ca_path"
337
- if test "$OCSP_DELEGATE" = 1; then
338
- ocsp_args="$ocsp_args \
339
- --ocsp_responder_cert spec/support/ocsp/$OCSP_ALGORITHM/ocsp-responder.crt \
340
- --ocsp_responder_key spec/support/ocsp/$OCSP_ALGORITHM/ocsp-responder.key \
341
- "
342
- else
343
- ocsp_args="$ocsp_args \
344
- --ocsp_responder_cert spec/support/ocsp/$OCSP_ALGORITHM/ca.crt \
345
- --ocsp_responder_key spec/support/ocsp/$OCSP_ALGORITHM/ca.key \
346
- "
347
- fi
348
- if test -n "$OCSP_STATUS"; then
349
- ocsp_args="$ocsp_args --fault $OCSP_STATUS"
350
- fi
351
- fi
352
-
353
- OCSP_ARGS="$ocsp_args"
354
- SERVER_ARGS="$args"
355
- URI_OPTIONS="$uri_options"
356
- }
357
-
358
- launch_ocsp_mock() {
359
- if test -n "$OCSP_ARGS"; then
360
- # Bind to 0.0.0.0 for Docker
361
- python3 spec/support/ocsp/ocsp_mock.py $OCSP_ARGS -b 0.0.0.0 -p 8100 &
362
- OCSP_MOCK_PID=$!
363
- fi
364
- }
365
-
366
- launch_server() {
367
- local dbdir="$1"
368
- python3 -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
369
-
370
- if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
371
- # On 3.6 server the sessions collection is not immediately available,
372
- # so we run the refreshLogicalSessionCacheNow command on the config server
373
- # and again on each mongos in order for the mongoses
374
- # to correctly report logicalSessionTimeoutMinutes.
375
- mongos_regex="\s*mongos\s+([0-9]+)\s+running\s+[0-9]+"
376
- config_server_regex="\s*config\sserver\s+([0-9]+)\s+running\s+[0-9]+"
377
- config_server=""
378
- mongoses=()
379
- if test "$AUTH" = auth
380
- then
381
- base_url="mongodb://bob:pwd123@localhost"
382
- else
383
- base_url="mongodb://localhost"
384
- fi
385
- if test "$SSL" = "ssl"
386
- then
387
- mongo_command="${BINDIR}/mongo --ssl --sslPEMKeyFile $server_cert_path --sslCAFile $server_ca_path"
388
- else
389
- mongo_command="${BINDIR}/mongo"
390
- fi
391
-
392
- while read -r line
393
- do
394
- if [[ $line =~ $config_server_regex ]]
395
- then
396
- port="${BASH_REMATCH[1]}"
397
- config_server="${base_url}:${port}"
398
- fi
399
- if [[ $line =~ $mongos_regex ]]
400
- then
401
- port="${BASH_REMATCH[1]}"
402
- mongoses+=("${base_url}:${port}")
403
- fi
404
- done < <(python2 -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
405
-
406
- if [ -n "$config_server" ]; then
407
- ${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
408
- for mongos in ${mongoses[*]}
409
- do
410
- ${mongo_command} "$mongos" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
411
- done
412
- fi
413
- fi
414
-
415
- if test "$TOPOLOGY" = load-balanced; then
416
- if test -z "$haproxy_config"; then
417
- echo haproxy_config should have been set 1>&2
418
- exit 3
419
- fi
420
-
421
- haproxy -D -f $haproxy_config -p $mongodb_dir/haproxy.pid
422
- fi
423
- }
@@ -1,110 +0,0 @@
1
- # When changing, also update the hash in share/Dockerfile.
2
- JDK_VERSION=jdk21
3
-
4
- set_env_java() {
5
- ls -l /opt || true
6
- ls -l /usr/lib/jvm || true
7
-
8
- # Use toolchain java if it exists
9
- if [ -f /opt/java/$JDK_VERSION/bin/java ]; then
10
- export JAVACMD=/opt/java/$JDK_VERSION/bin/java
11
- else
12
- echo Could not find $JDK_VERSION in /opt/java
13
- fi
14
-
15
- if test -n "$JAVACMD"; then
16
- eval $JAVACMD -version
17
- elif which java 2>/dev/null; then
18
- java -version
19
- else
20
- echo No java runtime found
21
- fi
22
- }
23
-
24
- set_env_python() {
25
- if test "$DOCKER_PRELOAD" != 1; then
26
- if test -n "$DOCKER"; then
27
- # If we are running in Docker and not preloading, we need to fetch the
28
- # Python binary.
29
- curl -fL --retry 3 https://github.com/p-mongodb/deps/raw/main/"$arch"-python37.tar.xz | \
30
- tar xfJ - -C /opt
31
- fi
32
-
33
- if test -d /opt/python/3.7/bin; then
34
- # Most Evergreen configurations.
35
- export PATH=/opt/python/3.7/bin:$PATH
36
- elif test -d /opt/python37/bin; then
37
- # Configurations that use Docker in Evergreen - these don't preload.
38
- export PATH=/opt/python37/bin:$PATH
39
- fi
40
-
41
- python3 -V
42
- fi
43
- }
44
-
45
- set_env_node() {
46
- if test "$DOCKER_PRELOAD" != 1; then
47
- dir=`ls -d /opt/nodejs/node-v12* |head -1`
48
- if test -z "$dir"; then
49
- echo "Node 12 missing" 1>&2
50
- exit 2
51
- fi
52
- export PATH="$dir/bin:$PATH"
53
- elif test -d /opt/node/bin; then
54
- # Node from toolchain in Evergreen
55
- export PATH=/opt/node/bin:$PATH
56
- fi
57
-
58
- node -v
59
- }
60
-
61
- set_env_ruby() {
62
- if test -z "$RVM_RUBY"; then
63
- echo "Empty RVM_RUBY, aborting"
64
- exit 2
65
- fi
66
-
67
- #ls -l /opt
68
-
69
- # Necessary for jruby
70
- set_env_java
71
-
72
- if [ "$RVM_RUBY" == "ruby-head" ]; then
73
- # When we use ruby-head, we do not install the Ruby toolchain.
74
- # But we still need Python 3.6+ to run mlaunch.
75
- # Since the ruby-head tests are run on ubuntu1604, we can use the
76
- # globally installed Python toolchain.
77
- #export PATH=/opt/python/3.7/bin:$PATH
78
-
79
- # 12.04, 14.04 and 16.04 are good
80
- curl --retry 3 -fL http://rubies.travis-ci.org/ubuntu/`lsb_release -rs`/x86_64/ruby-head.tar.bz2 |tar xfj -
81
- # TODO adjust gem path?
82
- export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
83
- ruby --version
84
- ruby --version |grep dev
85
- elif test "$SYSTEM_RUBY" = 1; then
86
- # Nothing
87
- :
88
- else
89
- if test "$USE_OPT_TOOLCHAIN" = 1; then
90
- # Nothing, also PATH is already set
91
- :
92
- else
93
- # For testing unpublished builds:
94
- #build_url=https://s3.amazonaws.com/mciuploads/mongo-ruby-toolchain/library/`host_distro`/$RVM_RUBY.tar.xz
95
-
96
- build_url=http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-toolchain/library/`host_distro`/$RVM_RUBY.tar.xz
97
- curl --retry 3 -fL $build_url |tar Jxf -
98
- export PATH=`pwd`/rubies/$RVM_RUBY/bin:$PATH
99
- fi
100
-
101
- ruby --version
102
-
103
- # Ensure we're using the right ruby
104
- ruby_name=`echo $RVM_RUBY |awk -F- '{print $1}'`
105
- ruby_version=`echo $RVM_RUBY |awk -F- '{print $2}' |cut -c 1-3`
106
-
107
- ruby -v |fgrep $ruby_name
108
- ruby -v |fgrep $ruby_version
109
- fi
110
- }