mongoid 7.0.6 → 7.0.12

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 (91) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +1 -1
  5. data/Rakefile +14 -5
  6. data/lib/mongoid.rb +1 -1
  7. data/lib/mongoid/association/embedded/embeds_many.rb +2 -1
  8. data/lib/mongoid/association/embedded/embeds_one.rb +2 -1
  9. data/lib/mongoid/association/proxy.rb +1 -1
  10. data/lib/mongoid/atomic.rb +13 -3
  11. data/lib/mongoid/clients/sessions.rb +20 -4
  12. data/lib/mongoid/criteria.rb +7 -1
  13. data/lib/mongoid/criteria/modifiable.rb +2 -1
  14. data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
  15. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +3 -3
  16. data/lib/mongoid/criteria/queryable/extensions/time.rb +1 -1
  17. data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
  18. data/lib/mongoid/document.rb +3 -2
  19. data/lib/mongoid/extensions/hash.rb +4 -2
  20. data/lib/mongoid/extensions/regexp.rb +1 -1
  21. data/lib/mongoid/fields.rb +2 -1
  22. data/lib/mongoid/interceptable.rb +3 -1
  23. data/lib/mongoid/matchable/regexp.rb +2 -2
  24. data/lib/mongoid/persistable/pushable.rb +11 -2
  25. data/lib/mongoid/persistence_context.rb +6 -6
  26. data/lib/mongoid/query_cache.rb +61 -18
  27. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  28. data/lib/mongoid/version.rb +1 -1
  29. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
  30. data/spec/app/models/customer.rb +11 -0
  31. data/spec/app/models/customer_address.rb +12 -0
  32. data/spec/app/models/delegating_patient.rb +16 -0
  33. data/spec/integration/app_spec.rb +192 -0
  34. data/spec/integration/associations/embedded_spec.rb +62 -0
  35. data/spec/integration/callbacks_models.rb +49 -0
  36. data/spec/integration/callbacks_spec.rb +216 -0
  37. data/spec/integration/criteria/date_field_spec.rb +41 -0
  38. data/spec/integration/document_spec.rb +22 -0
  39. data/spec/lite_spec_helper.rb +12 -4
  40. data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +50 -0
  41. data/spec/mongoid/association/embedded/embeds_many_models.rb +53 -0
  42. data/spec/mongoid/association/embedded/embeds_many_spec.rb +10 -0
  43. data/spec/mongoid/association/embedded/embeds_one_spec.rb +0 -2
  44. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +140 -1
  45. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +105 -0
  46. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +2 -1
  47. data/spec/mongoid/atomic/paths_spec.rb +41 -0
  48. data/spec/mongoid/clients/options_spec.rb +4 -4
  49. data/spec/mongoid/clients/sessions_spec.rb +8 -4
  50. data/spec/mongoid/clients/transactions_spec.rb +20 -8
  51. data/spec/mongoid/clients_spec.rb +2 -2
  52. data/spec/mongoid/contextual/atomic_spec.rb +20 -10
  53. data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
  54. data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
  55. data/spec/mongoid/contextual/mongo_spec.rb +76 -53
  56. data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
  57. data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +1 -1
  58. data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
  59. data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
  60. data/spec/mongoid/criteria_spec.rb +4 -2
  61. data/spec/mongoid/document_persistence_context_spec.rb +33 -0
  62. data/spec/mongoid/indexable_spec.rb +6 -4
  63. data/spec/mongoid/matchable/default_spec.rb +1 -1
  64. data/spec/mongoid/matchable/regexp_spec.rb +2 -2
  65. data/spec/mongoid/matchable_spec.rb +2 -2
  66. data/spec/mongoid/persistable/pushable_spec.rb +55 -1
  67. data/spec/mongoid/query_cache_spec.rb +77 -9
  68. data/spec/mongoid/relations/proxy_spec.rb +1 -1
  69. data/spec/mongoid/scopable_spec.rb +2 -1
  70. data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
  71. data/spec/mongoid/tasks/database_spec.rb +1 -1
  72. data/spec/shared/LICENSE +20 -0
  73. data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
  74. data/spec/shared/lib/mrss/cluster_config.rb +211 -0
  75. data/spec/shared/lib/mrss/constraints.rb +330 -0
  76. data/spec/shared/lib/mrss/docker_runner.rb +262 -0
  77. data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
  78. data/spec/shared/lib/mrss/server_version_registry.rb +69 -0
  79. data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
  80. data/spec/shared/share/Dockerfile.erb +229 -0
  81. data/spec/shared/shlib/distro.sh +73 -0
  82. data/spec/shared/shlib/server.sh +270 -0
  83. data/spec/shared/shlib/set_env.sh +128 -0
  84. data/spec/spec_helper.rb +0 -31
  85. data/spec/support/child_process_helper.rb +76 -0
  86. data/spec/support/cluster_config.rb +3 -3
  87. data/spec/support/constraints.rb +201 -30
  88. data/spec/support/session_registry.rb +50 -0
  89. data/spec/support/spec_config.rb +12 -4
  90. metadata +510 -461
  91. metadata.gz.sig +2 -2
@@ -0,0 +1,330 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ module Mrss
5
+ module Constraints
6
+ def min_server_version(version)
7
+ unless version =~ /\A\d+\.\d+\z/
8
+ raise ArgumentError, "Version can only be major.minor: #{version}"
9
+ end
10
+
11
+ before(:all) do
12
+ if version > ClusterConfig.instance.server_version
13
+ skip "Server version #{version} or higher required, we have #{ClusterConfig.instance.server_version}"
14
+ end
15
+ end
16
+ end
17
+
18
+ def max_server_version(version)
19
+ unless version =~ /\A\d+\.\d+\z/
20
+ raise ArgumentError, "Version can only be major.minor: #{version}"
21
+ end
22
+
23
+ before(:all) do
24
+ if version < ClusterConfig.instance.short_server_version
25
+ skip "Server version #{version} or lower required, we have #{ClusterConfig.instance.server_version}"
26
+ end
27
+ end
28
+ end
29
+
30
+ def min_server_fcv(version)
31
+ unless version =~ /\A\d+\.\d+\z/
32
+ raise ArgumentError, "FCV can only be major.minor: #{version}"
33
+ end
34
+
35
+ before(:all) do
36
+ unless ClusterConfig.instance.fcv_ish >= version
37
+ skip "FCV #{version} or higher required, we have #{ClusterConfig.instance.fcv_ish} (server #{ClusterConfig.instance.server_version})"
38
+ end
39
+ end
40
+ end
41
+
42
+ def max_server_fcv(version)
43
+ unless version =~ /\A\d+\.\d+\z/
44
+ raise ArgumentError, "Version can only be major.minor: #{version}"
45
+ end
46
+
47
+ before(:all) do
48
+ if version < ClusterConfig.instance.fcv_ish
49
+ skip "FCV #{version} or lower required, we have #{ClusterConfig.instance.fcv_ish} (server #{ClusterConfig.instance.server_version})"
50
+ end
51
+ end
52
+ end
53
+
54
+ def require_topology(*topologies)
55
+ invalid_topologies = topologies - [:single, :replica_set, :sharded]
56
+
57
+ unless invalid_topologies.empty?
58
+ raise ArgumentError, "Invalid topologies requested: #{invalid_topologies.join(', ')}"
59
+ end
60
+
61
+ before(:all) do
62
+ unless topologies.include?(topology = ClusterConfig.instance.topology)
63
+ skip "Topology #{topologies.join(' or ')} required, we have #{topology}"
64
+ end
65
+ end
66
+ end
67
+
68
+ def max_example_run_time(timeout)
69
+ around do |example|
70
+ TimeoutInterrupt.timeout(timeout, TimeoutInterrupt::Error.new("Test execution terminated after #{timeout} seconds")) do
71
+ example.run
72
+ end
73
+ end
74
+ end
75
+
76
+ def require_transaction_support
77
+ before(:all) do
78
+ case ClusterConfig.instance.topology
79
+ when :single
80
+ skip 'Transactions tests require a replica set (4.0+) or a sharded cluster (4.2+)'
81
+ when :replica_set
82
+ unless ClusterConfig.instance.server_version >= '4.0'
83
+ skip 'Transactions tests in a replica set topology require server 4.0+'
84
+ end
85
+ when :sharded
86
+ unless ClusterConfig.instance.server_version >= '4.2'
87
+ skip 'Transactions tests in a sharded cluster topology require server 4.2+'
88
+ end
89
+ else
90
+ raise NotImplementedError
91
+ end
92
+ end
93
+ end
94
+
95
+ # Fail command fail point was added to mongod in 4.0 and to mongos in 4.2.
96
+ def require_fail_command
97
+ require_transaction_support
98
+ end
99
+
100
+ def require_tls
101
+ before(:all) do
102
+ unless SpecConfig.instance.ssl?
103
+ skip "SSL not enabled"
104
+ end
105
+ end
106
+ end
107
+
108
+ def require_no_tls
109
+ before(:all) do
110
+ if SpecConfig.instance.ssl?
111
+ skip "SSL enabled"
112
+ end
113
+ end
114
+ end
115
+
116
+ def require_no_retry_writes
117
+ before(:all) do
118
+ if SpecConfig.instance.retry_writes?
119
+ skip "Retry writes is enabled"
120
+ end
121
+ end
122
+ end
123
+
124
+ def require_compression
125
+ before(:all) do
126
+ if SpecConfig.instance.compressors.nil?
127
+ skip "Compression is not enabled"
128
+ end
129
+ end
130
+ end
131
+
132
+ def require_zlib_compression
133
+ before(:all) do
134
+ compressors = SpecConfig.instance.compressors
135
+ unless compressors && compressors.include?('zlib')
136
+ skip "Zlib compression is not enabled"
137
+ end
138
+ end
139
+ end
140
+
141
+ def require_snappy_compression
142
+ before(:all) do
143
+ compressors = SpecConfig.instance.compressors
144
+ unless compressors && compressors.include?('snappy')
145
+ skip "Snappy compression is not enabled"
146
+ end
147
+ end
148
+ end
149
+
150
+ def require_no_snappy_compression
151
+ before(:all) do
152
+ compressors = SpecConfig.instance.compressors
153
+ if compressors && compressors.include?('snappy')
154
+ skip "Snappy compression is enabled"
155
+ end
156
+ end
157
+ end
158
+
159
+ def require_zstd_compression
160
+ before(:all) do
161
+ compressors = SpecConfig.instance.compressors
162
+ unless compressors && compressors.include?('zstd')
163
+ skip "Zstd compression is not enabled"
164
+ end
165
+ end
166
+ end
167
+
168
+ def require_no_zstd_compression
169
+ before(:all) do
170
+ compressors = SpecConfig.instance.compressors
171
+ if compressors && compressors.include?('zstd')
172
+ skip "Zstd compression is enabled"
173
+ end
174
+ end
175
+ end
176
+
177
+ def require_no_compression
178
+ before(:all) do
179
+ if SpecConfig.instance.compressors
180
+ skip "Compression is enabled"
181
+ end
182
+ end
183
+ end
184
+
185
+ def ruby_version_gte(version)
186
+ before(:all) do
187
+ if RUBY_VERSION < version
188
+ skip "Ruby version #{version} or higher required"
189
+ end
190
+ end
191
+ end
192
+
193
+ def ruby_version_lt(version)
194
+ before(:all) do
195
+ if RUBY_VERSION >= version
196
+ skip "Ruby version less than #{version} required"
197
+ end
198
+ end
199
+ end
200
+
201
+ def require_auth(*values)
202
+ before(:all) do
203
+ if values.any?
204
+ unless values.include?(ENV['AUTH'])
205
+ msg = values.map { |v| "AUTH=#{v}" }.join(' or ')
206
+ skip "This test requires #{msg}"
207
+ end
208
+ else
209
+ unless ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
210
+ skip "Auth required"
211
+ end
212
+ end
213
+ end
214
+ end
215
+
216
+ def require_no_auth
217
+ before(:all) do
218
+ if (ENV['AUTH'] && ENV['AUTH'] != 'noauth') || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
219
+ skip "Auth not allowed"
220
+ end
221
+ end
222
+ end
223
+
224
+ def require_x509_auth
225
+ before(:all) do
226
+ unless SpecConfig.instance.x509_auth?
227
+ skip "X.509 auth required"
228
+ end
229
+ end
230
+ end
231
+
232
+ def require_no_external_user
233
+ before(:all) do
234
+ if SpecConfig.instance.external_user?
235
+ skip "External user configurations are not compatible with this test"
236
+ end
237
+ end
238
+ end
239
+
240
+ # Can the driver specify a write concern that won't be overridden?
241
+ # (mongos 4.0+ overrides the write concern)
242
+ def require_set_write_concern
243
+ before(:all) do
244
+ if ClusterConfig.instance.topology == :sharded && ClusterConfig.instance.short_server_version >= '4.0'
245
+ skip "mongos 4.0+ overrides write concern"
246
+ end
247
+ end
248
+ end
249
+
250
+ def require_multi_shard
251
+ before(:all) do
252
+ if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length == 1
253
+ skip 'Test requires a minimum of two shards if run in sharded topology'
254
+ end
255
+ end
256
+ end
257
+
258
+ def require_no_multi_shard
259
+ before(:all) do
260
+ if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length > 1
261
+ skip 'Test requires a single shard if run in sharded topology'
262
+ end
263
+ end
264
+ end
265
+
266
+ def require_wired_tiger
267
+ before(:all) do
268
+ if ClusterConfig.instance.storage_engine != :wired_tiger
269
+ skip 'Test requires WiredTiger storage engine'
270
+ end
271
+ end
272
+ end
273
+
274
+ def require_wired_tiger_on_36
275
+ before(:all) do
276
+ if ClusterConfig.instance.short_server_version >= '3.6'
277
+ if ClusterConfig.instance.storage_engine != :wired_tiger
278
+ skip 'Test requires WiredTiger storage engine on 3.6+ servers'
279
+ end
280
+ end
281
+ end
282
+ end
283
+
284
+ def require_mmapv1
285
+ before(:all) do
286
+ if ClusterConfig.instance.storage_engine != :mmapv1
287
+ skip 'Test requires MMAPv1 storage engine'
288
+ end
289
+ end
290
+ end
291
+
292
+ def require_enterprise
293
+ before(:all) do
294
+ unless ClusterConfig.instance.enterprise?
295
+ skip 'Test requires enterprise build of MongoDB'
296
+ end
297
+ end
298
+ end
299
+
300
+ # Integration tests for SRV polling require internet connectivity to
301
+ # look up SRV records and a sharded cluster configured on default port on
302
+ # localhost (localhost:27017, localhost:27018).
303
+ def require_default_port_deployment
304
+ # Because the DNS records at test1.test.build.10gen.cc point to
305
+ # localhost:27017 & localhost:27018, the test suite must have been
306
+ # configured to use these addresses
307
+ before(:all) do
308
+ have_default_port = SpecConfig.instance.addresses.any? do |address|
309
+ %w(127.0.0.1 127.0.0.1:27017 localhost localhost:27017).include?(address)
310
+ end
311
+ unless have_default_port
312
+ skip 'This test requires the test suite to be configured for localhost:27017'
313
+ end
314
+ end
315
+ end
316
+
317
+ # Some tests perform assertions on what the driver is logging.
318
+ # Some test configurations, for example OCSP with unknown response,
319
+ # produce warnings due to optional checks failing.
320
+ # This constraint skips tests that issue logging assertions on configurations
321
+ # that may produce non-test-originated log entries.
322
+ def require_warning_clean
323
+ before(:all) do
324
+ if ENV['OCSP_STATUS'] == 'unknown'
325
+ skip 'Unknown OCSP status is not global warning-clean'
326
+ end
327
+ end
328
+ end
329
+ end
330
+ end
@@ -0,0 +1,262 @@
1
+ require 'optparse'
2
+ require 'erb'
3
+ autoload :Dotenv, 'dotenv'
4
+
5
+ module Mrss
6
+ autoload :ServerVersionRegistry, 'mrss/server_version_registry'
7
+
8
+ class DockerRunner
9
+ def initialize(**opts)
10
+ # These options are required:
11
+ opts.fetch(:image_tag)
12
+ opts.fetch(:dockerfile_path)
13
+ opts.fetch(:default_script)
14
+ opts.fetch(:project_lib_subdir)
15
+
16
+ @options = opts
17
+ end
18
+
19
+ attr_reader :options
20
+
21
+ def run
22
+ process_arguments
23
+ unless @options[:exec_only]
24
+ create_dockerfile
25
+ create_image
26
+ end
27
+ if @options[:mongo_only]
28
+ run_deployment
29
+ else
30
+ run_tests
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def process_arguments
37
+ #@options = {}
38
+ OptionParser.new do |opts|
39
+ opts.banner = "Usage: test-on-docker [-d distro] [evergreen_key=value ...]"
40
+
41
+ opts.on("-a", "--add-env=PATH", "Load environment variables from PATH in .env format") do |path|
42
+ @options[:extra_env] ||= {}
43
+ unless File.exist?(path)
44
+ raise "-a option references nonexistent file #{path}"
45
+ end
46
+ Dotenv.parse(path).each do |k, v|
47
+ @options[:extra_env][k] = v
48
+ end
49
+ end
50
+
51
+ opts.on("-d", "--distro=DISTRO", "Distro to use") do |v|
52
+ @options[:distro] = v
53
+ end
54
+
55
+ opts.on('-e', '--exec-only', 'Execute tests using existing Dockerfile (for offline user)') do |v|
56
+ @options[:exec_only] = v
57
+ end
58
+
59
+ opts.on('-m', '--mongo-only=PORT', 'Start the MongoDB deployment and expose it to host on ports starting with PORT') do |v|
60
+ @options[:mongo_only] = v.to_i
61
+ end
62
+
63
+ opts.on('-p', '--preload', 'Preload Ruby toolchain and server binaries in docker') do |v|
64
+ @options[:preload] = v
65
+ end
66
+
67
+ opts.on('-s', '--script=SCRIPT', 'Test script to invoke') do |v|
68
+ @options[:script] = v
69
+ end
70
+
71
+ opts.on('-i', '--interactive', 'Interactive mode - disable per-test timeouts') do |v|
72
+ @options[:interactive] = v
73
+ end
74
+ end.parse!
75
+
76
+ @env = Hash[ARGV.map do |arg|
77
+ arg.split('=', 2)
78
+ end]
79
+
80
+ @env['RVM_RUBY'] ||= 'ruby-2.7'
81
+ unless ruby =~ /^j?ruby-/
82
+ raise "RVM_RUBY option is not in expected format: #{ruby}"
83
+ end
84
+
85
+ @env['MONGODB_VERSION'] ||= '4.4'
86
+ end
87
+
88
+ def create_dockerfile
89
+ template_path = File.join(File.dirname(__FILE__), '../../share/Dockerfile.erb')
90
+ result = ERB.new(File.read(template_path)).result(binding)
91
+ File.open(dockerfile_path, 'w') do |f|
92
+ f << result
93
+ end
94
+ end
95
+
96
+ def image_tag
97
+ options.fetch(:image_tag)
98
+ end
99
+
100
+ def dockerfile_path
101
+ options.fetch(:dockerfile_path)
102
+ end
103
+
104
+ def create_image
105
+ run_command(['docker', 'build',
106
+ '-t', image_tag,
107
+ '-f', dockerfile_path,
108
+ '.'])
109
+ end
110
+
111
+ BASE_TEST_COMMAND = %w(docker run -i --tmpfs /tmpfs:exec).freeze
112
+
113
+ def run_tests
114
+ run_command(BASE_TEST_COMMAND + tty_arg + extra_env + [image_tag] +
115
+ script.split(/\s+/))
116
+ end
117
+
118
+ def run_deployment
119
+ run_command(BASE_TEST_COMMAND + tty_arg + extra_env + [
120
+ '-e', %q`TEST_CMD=watch -x bash -c "ps awwxu |egrep 'mongo|ocsp'"`,
121
+ '-e', 'BIND_ALL=true',
122
+ ] + port_forwards + [image_tag] + script.split(/\s+/))
123
+ end
124
+
125
+ def tty_arg
126
+ tty = File.open('/dev/stdin') do |f|
127
+ f.isatty
128
+ end
129
+ if tty
130
+ %w(-t --init)
131
+ else
132
+ []
133
+ end
134
+ end
135
+
136
+ def extra_env
137
+ if @options[:extra_env]
138
+ @options[:extra_env].map do |k, v|
139
+ # Here the value must not be escaped
140
+ ['-e', "#{k}=#{v}"]
141
+ end.flatten
142
+ else
143
+ []
144
+ end
145
+ end
146
+
147
+ def port_forwards
148
+ args = (0...num_exposed_ports).map do |i|
149
+ host_port = @options[:mongo_only] + i
150
+ container_port = 27017 + i
151
+ ['-p', "#{host_port}:#{container_port}"]
152
+ end.flatten
153
+
154
+ if @env['OCSP_ALGORITHM'] && !@env['OCSP_VERIFIER']
155
+ args += %w(-p 8100:8100)
156
+ end
157
+
158
+ args
159
+ end
160
+
161
+ def run_command(cmd)
162
+ if pid = fork
163
+ Process.wait(pid)
164
+ unless $?.exitstatus == 0
165
+ raise "Process exited with code #{$?.exitstatus}"
166
+ end
167
+ else
168
+ exec(*cmd)
169
+ end
170
+ end
171
+
172
+ def distro
173
+ @options[:distro] || 'ubuntu1604'
174
+ end
175
+
176
+ BASE_IMAGES = {
177
+ 'debian81' => 'debian:jessie',
178
+ 'debian92' => 'debian:stretch',
179
+ 'ubuntu1404' => 'ubuntu:trusty',
180
+ 'ubuntu1604' => 'ubuntu:xenial',
181
+ 'ubuntu1804' => 'ubuntu:bionic',
182
+ 'rhel62' => 'centos:6',
183
+ 'rhel70' => 'centos:7',
184
+ }.freeze
185
+
186
+ def base_image
187
+ BASE_IMAGES[distro] or raise "Unknown distro: #{distro}"
188
+ end
189
+
190
+ def ruby
191
+ @env['RVM_RUBY']
192
+ end
193
+
194
+ def ruby_head?
195
+ ruby == 'ruby-head'
196
+ end
197
+
198
+ def server_version
199
+ @env['MONGODB_VERSION']
200
+ end
201
+
202
+ def script
203
+ @options[:script] || options.fetch(:default_script)
204
+ end
205
+
206
+ def debian?
207
+ distro =~ /debian|ubuntu/
208
+ end
209
+
210
+ def preload?
211
+ !!@options[:preload]
212
+ end
213
+
214
+ def interactive?
215
+ !!@options[:interactive]
216
+ end
217
+
218
+ def project_lib_subdir
219
+ options.fetch(:project_lib_subdir)
220
+ end
221
+
222
+ def server_download_url
223
+ @server_download_url ||= ServerVersionRegistry.new(server_version, distro).download_url
224
+ end
225
+
226
+ def libmongocrypt_path
227
+ case distro
228
+ when /ubuntu1604/
229
+ "./ubuntu1604/nocrypto/lib64/libmongocrypt.so"
230
+ when /ubuntu1804/
231
+ "./ubuntu1804-64/nocrypto/lib64/libmongocrypt.so"
232
+ when /debian92/
233
+ "./debian92/nocrypto/lib64/libmongocrypt.so"
234
+ else
235
+ raise "This script does not support running FLE tests on #{distro}. Use ubuntu1604, ubuntu1804 or debian92 instead"
236
+ end
237
+ end
238
+
239
+ def expose?
240
+ !!@options[:mongo_only]
241
+ end
242
+
243
+ def fle?
244
+ %w(1 true yes).include?(@env['FLE']&.downcase)
245
+ end
246
+
247
+ def num_exposed_ports
248
+ case @env['TOPOLOGY'] || 'standalone'
249
+ when 'standalone'
250
+ 1
251
+ when 'replica-set'
252
+ 3
253
+ when 'sharded-cluster'
254
+ if @env['SINGLE_MONGOS']
255
+ 1
256
+ else
257
+ 2
258
+ end
259
+ end
260
+ end
261
+ end
262
+ end