mongoid 7.1.6 → 7.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) 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 +31 -0
  6. data/lib/mongoid.rb +1 -0
  7. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +1 -1
  8. data/lib/mongoid/association/proxy.rb +1 -1
  9. data/lib/mongoid/association/referenced/has_many/enumerable.rb +1 -1
  10. data/lib/mongoid/association/referenced/has_many/proxy.rb +1 -1
  11. data/lib/mongoid/attributes.rb +8 -1
  12. data/lib/mongoid/criteria.rb +1 -1
  13. data/lib/mongoid/criteria/queryable/selector.rb +0 -4
  14. data/lib/mongoid/document.rb +3 -2
  15. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  16. data/lib/mongoid/interceptable.rb +4 -2
  17. data/lib/mongoid/reloadable.rb +5 -0
  18. data/lib/mongoid/validatable/associated.rb +1 -1
  19. data/lib/mongoid/validatable/presence.rb +3 -3
  20. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  21. data/lib/mongoid/version.rb +1 -1
  22. data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
  23. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  24. data/spec/app/models/address.rb +4 -0
  25. data/spec/app/models/customer.rb +11 -0
  26. data/spec/app/models/customer_address.rb +12 -0
  27. data/spec/app/models/dictionary.rb +6 -0
  28. data/spec/app/models/person.rb +9 -0
  29. data/spec/integration/app_spec.rb +178 -88
  30. data/spec/integration/callbacks_models.rb +49 -0
  31. data/spec/integration/callbacks_spec.rb +216 -0
  32. data/spec/integration/document_spec.rb +21 -0
  33. data/spec/lite_spec_helper.rb +6 -6
  34. data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +50 -0
  35. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +17 -4
  36. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +17 -0
  37. data/spec/mongoid/atomic/paths_spec.rb +41 -0
  38. data/spec/mongoid/attributes_spec.rb +241 -0
  39. data/spec/mongoid/clients/options_spec.rb +2 -0
  40. data/spec/mongoid/contextual/atomic_spec.rb +17 -4
  41. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +36 -0
  42. data/spec/mongoid/criteria_spec.rb +4 -0
  43. data/spec/mongoid/document_query_spec.rb +51 -0
  44. data/spec/mongoid/errors/mongoid_error_spec.rb +20 -8
  45. data/spec/mongoid/factory_spec.rb +2 -2
  46. data/spec/mongoid/persistable/savable_spec.rb +4 -4
  47. data/spec/mongoid/persistable/settable_spec.rb +30 -0
  48. data/spec/mongoid/persistable_spec.rb +2 -2
  49. data/spec/shared/bin/get-mongodb-download-url +17 -0
  50. data/spec/shared/bin/s3-copy +45 -0
  51. data/spec/shared/bin/s3-upload +69 -0
  52. data/spec/shared/lib/mrss/cluster_config.rb +19 -4
  53. data/spec/shared/lib/mrss/constraints.rb +62 -6
  54. data/spec/shared/lib/mrss/docker_runner.rb +271 -0
  55. data/spec/shared/lib/mrss/lite_constraints.rb +16 -0
  56. data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
  57. data/spec/shared/lib/mrss/spec_organizer.rb +32 -2
  58. data/spec/shared/lib/mrss/utils.rb +15 -0
  59. data/spec/shared/share/Dockerfile.erb +322 -0
  60. data/spec/shared/share/haproxy-1.conf +16 -0
  61. data/spec/shared/share/haproxy-2.conf +17 -0
  62. data/spec/shared/shlib/distro.sh +73 -0
  63. data/spec/shared/shlib/server.sh +317 -0
  64. data/spec/shared/shlib/set_env.sh +131 -0
  65. data/spec/spec_helper.rb +3 -1
  66. data/spec/support/constraints.rb +0 -226
  67. data/spec/support/spec_config.rb +8 -0
  68. metadata +542 -480
  69. metadata.gz.sig +0 -0
  70. data/spec/support/child_process_helper.rb +0 -76
  71. data/spec/support/lite_constraints.rb +0 -22
@@ -171,5 +171,21 @@ module Mrss
171
171
  end
172
172
  end
173
173
  end
174
+
175
+ def require_active_support
176
+ before(:all) do
177
+ if !SpecConfig.instance.active_support?
178
+ skip 'This test requires ActiveSupport; set WITH_ACTIVE_SUPPORT=1 in environment'
179
+ end
180
+ end
181
+ end
182
+
183
+ def no_active_support
184
+ before(:all) do
185
+ if SpecConfig.instance.active_support?
186
+ skip 'This test requires no ActiveSupport; unset WITH_ACTIVE_SUPPORT in environment'
187
+ end
188
+ end
189
+ end
174
190
  end
175
191
  end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ autoload :JSON, 'json'
5
+ require 'open-uri'
6
+
7
+ module Mrss
8
+ class ServerVersionRegistry
9
+ class Error < StandardError
10
+ end
11
+
12
+ class UnknownVersion < Error
13
+ end
14
+
15
+ class MissingDownloadUrl < Error
16
+ end
17
+
18
+ class BrokenDownloadUrl < Error
19
+ end
20
+
21
+ def initialize(desired_version, arch)
22
+ @desired_version, @arch = desired_version, arch
23
+ end
24
+
25
+ attr_reader :desired_version, :arch
26
+
27
+ def download_url
28
+ @download_url ||= begin
29
+ version, version_ok = detect_version(current_catalog)
30
+ if version.nil?
31
+ version, full_version_ok = detect_version(full_catalog)
32
+ version_ok ||= full_version_ok
33
+ end
34
+ if version.nil?
35
+ if version_ok
36
+ raise MissingDownloadUrl, "No downloads for version #{desired_version}"
37
+ else
38
+ raise UnknownVersion, "No version #{desired_version}"
39
+ end
40
+ end
41
+ dl = version['downloads'].detect do |dl|
42
+ dl['archive']['url'].index("enterprise-#{arch}") &&
43
+ dl['arch'] == 'x86_64'
44
+ end
45
+ unless dl
46
+ raise MissingDownloadUrl, "No download for #{arch} for #{version['version']}"
47
+ end
48
+ url = dl['archive']['url']
49
+ end
50
+ rescue MissingDownloadUrl
51
+ if %w(4.7 4.7.0).include?(desired_version)
52
+ # 4.7.0 has no advertised downloads but it is downloadable and
53
+ # we do need it. Dirty hack below.
54
+ registry = self.class.new('4.4.3', arch)
55
+ registry.download_url.sub('4.4.3', '4.7.0').tap do |url|
56
+ # Sanity check - ensure the URL we hacked up is a valid one
57
+ io = uri_open(url)
58
+ begin
59
+ io.read(1)
60
+ ensure
61
+ io.close
62
+ end
63
+ end
64
+ else
65
+ raise
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ def uri_open(*args)
72
+ if RUBY_VERSION < '2.5'
73
+ open(*args)
74
+ else
75
+ URI.open(*args)
76
+ end
77
+ end
78
+
79
+ def detect_version(catalog)
80
+ candidate_versions = catalog['versions'].select do |version|
81
+ version['version'].start_with?(desired_version) &&
82
+ !version['version'].include?('-')
83
+ end
84
+ version_ok = !candidate_versions.empty?
85
+ # Sometimes the download situation is borked and there is a release
86
+ # with no downloads... skip those.
87
+ version = candidate_versions.detect do |version|
88
+ !version['downloads'].empty?
89
+ end
90
+ # Allow RC releases if there isn't a GA release.
91
+ if version.nil?
92
+ candidate_versions = catalog['versions'].select do |version|
93
+ version['version'].start_with?(desired_version)
94
+ end
95
+ version_ok ||= !candidate_versions.empty?
96
+ version = candidate_versions.detect do |version|
97
+ !version['downloads'].empty?
98
+ end
99
+ end
100
+ [version, version_ok]
101
+ end
102
+
103
+ def current_catalog
104
+ @current_catalog ||= begin
105
+ JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
106
+ end
107
+ end
108
+
109
+ def full_catalog
110
+ @full_catalog ||= begin
111
+ JSON.load(uri_open('http://downloads.mongodb.org/full.json').read)
112
+ end
113
+ end
114
+ end
115
+ end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  autoload :JSON, 'json'
2
5
  autoload :FileUtils, 'fileutils'
3
6
  autoload :Find, 'find'
@@ -22,18 +25,28 @@ module Mrss
22
25
  end
23
26
 
24
27
  def initialize(root: nil, classifiers:, priority_order:,
25
- spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil
28
+ spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil,
29
+ randomize: false
26
30
  )
27
31
  @spec_root = spec_root || File.join(root, 'spec')
28
32
  @classifiers = classifiers
29
33
  @priority_order = priority_order
30
34
  @rspec_json_path = rspec_json_path || File.join(root, 'tmp/rspec.json')
31
35
  @rspec_all_json_path = rspec_all_json_path || File.join(root, 'tmp/rspec-all.json')
36
+ @randomize = !!randomize
32
37
  end
33
38
 
34
39
  attr_reader :spec_root, :classifiers, :priority_order
35
40
  attr_reader :rspec_json_path, :rspec_all_json_path
36
41
 
42
+ def randomize?
43
+ @randomize
44
+ end
45
+
46
+ def seed
47
+ @seed ||= (rand * 100_000).to_i
48
+ end
49
+
37
50
  def buckets
38
51
  @buckets ||= {}.tap do |buckets|
39
52
  Find.find(spec_root) do |path|
@@ -78,10 +91,20 @@ module Mrss
78
91
  end
79
92
 
80
93
  def run
94
+ run_buckets(*buckets.keys)
95
+ end
96
+
97
+ def run_buckets(*buckets)
81
98
  FileUtils.rm_f(rspec_all_json_path)
82
99
 
100
+ buckets.each do |bucket|
101
+ if bucket && !self.buckets[bucket]
102
+ raise "Unknown bucket #{bucket}"
103
+ end
104
+ end
105
+ buckets = Hash[self.buckets.select { |k, v| buckets.include?(k) }]
106
+
83
107
  failed = []
84
- buckets = self.buckets.dup
85
108
 
86
109
  priority_order.each do |category|
87
110
  if files = buckets.delete(category)
@@ -109,8 +132,12 @@ module Mrss
109
132
  puts "Running #{category.to_s.gsub('_', ' ')} tests"
110
133
  FileUtils.rm_f(rspec_json_path)
111
134
  cmd = %w(rspec) + paths
135
+ if randomize?
136
+ cmd += %W(--order rand:#{seed})
137
+ end
112
138
 
113
139
  begin
140
+ puts "Running #{cmd.join(' ')}"
114
141
  ChildProcessHelper.check_call(cmd)
115
142
  ensure
116
143
  if File.exist?(rspec_json_path)
@@ -136,6 +163,9 @@ module Mrss
136
163
  end
137
164
  new.delete('version')
138
165
  new.delete('summary_line')
166
+ # The spec organizer runs all buckets with the same seed, hence
167
+ # we can drop the seed from new results.
168
+ new.delete('seed')
139
169
  unless new.empty?
140
170
  raise "Unhandled rspec results keys: #{new.keys.join(', ')}"
141
171
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ module Mrss
5
+ module Utils
6
+
7
+ module_function def print_backtrace(dest=STDERR)
8
+ begin
9
+ hello world
10
+ rescue => e
11
+ dest.puts e.backtrace.join("\n")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,322 @@
1
+ # Python toolchain as of this writing is available on rhel62, debian92 and
2
+ # ubuntu1604.
3
+ #
4
+ # To run rhel62 in docker, host system must be configured to emulate syscalls:
5
+ # https://github.com/CentOS/sig-cloud-instance-images/issues/103
6
+
7
+ <%
8
+
9
+ python_toolchain_url = "https://s3.amazonaws.com//mciuploads/mongo-python-driver-toolchain/#{distro}/ba92de2700c04ee2d4f82c3ffdfc33105140cb04/mongo_python_driver_toolchain_#{distro.gsub('-', '_')}_ba92de2700c04ee2d4f82c3ffdfc33105140cb04_19_11_14_15_33_33.tar.gz"
10
+ server_version = '4.3.3'
11
+ server_url = "http://downloads.10gen.com/linux/mongodb-linux-x86_64-enterprise-#{distro}-#{server_version}.tgz"
12
+ server_archive_basename = File.basename(server_url)
13
+ server_extracted_dir = server_archive_basename.sub(/\.(tar\.gz|tgz)$/, '')
14
+
15
+ toolchain_upper='291ba4a4e8297f142796e70eee71b99f333e35e1'
16
+
17
+ ruby_toolchain_url = "http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/ruby-toolchain-#{distro}-#{toolchain_upper}.tar.xz"
18
+ #ruby_toolchain_url = "https://s3.amazonaws.com//mciuploads/mongo-ruby-toolchain/#{distro}/#{toolchain_upper}/mongo_ruby_driver_toolchain_#{distro.gsub('-', '_')}_patch_#{toolchain_upper}_#{toolchain_lower}.tar.gz"
19
+
20
+ %>
21
+
22
+ FROM <%= base_image %>
23
+
24
+ <% if debian? %>
25
+
26
+ ENV DEBIAN_FRONTEND=noninteractive
27
+
28
+ <% else %>
29
+
30
+ RUN echo assumeyes=1 |tee -a /etc/yum.conf
31
+
32
+ <% end %>
33
+
34
+ <% if ruby_head? %>
35
+
36
+ # To use current versions of mlaunch, Python 3.6+ is required.
37
+ # Most distros ship with older Pythons, therefore we need to install
38
+ # a newer Python from somewhere. This section installs the Python
39
+ # toolhcain which comes with recent Pythons.
40
+ # Alternatively, Ruby toolchain compiles its own copy of Python 3 but
41
+ # this is currently incomplete in that on older distros with old OpenSSL,
42
+ # the built Python has no ssl module and hence practically is unusable.
43
+ # Currently Ruby driver uses mtools-legacy which supports Python 2,
44
+ # avoiding this entire issue for the time being.
45
+
46
+ #RUN curl --retry 3 -fL <%= python_toolchain_url %> -o python-toolchain.tar.gz
47
+ #RUN tar -xC /opt -zf python-toolchain.tar.gz
48
+
49
+ <% end %>
50
+
51
+ <% if debian? %>
52
+
53
+ # zsh is not required for any scripts but it is a better interactive shell
54
+ # than bash.
55
+ # Ruby runtime dependencies: libyaml-0-2
56
+ # Compiling ruby libraries: gcc make
57
+ # Compiling pyhton packages: python2.7-dev
58
+ # JRuby: openjdk-8-jre-headless
59
+ # Server dependencies: libsnmp30 libcurl3/libcurl4
60
+ # Determining OS we are running on: lsb-release
61
+ # Load balancer testing: haproxy
62
+ # Kerberos testing: krb5-user
63
+ # Local Kerberos server: krb5-kdc krb5-admin-server
64
+ # Installing mlaunch from git: git
65
+ # ruby-head archive: bzip2
66
+ # nio4r on JRuby: libgmp-dev
67
+ # Snappy compression: libsnappy-dev
68
+ # nokogiri: zlib1g-dev
69
+ # Mongoid testing: tzdata shared-mime-info
70
+ # Mongoid application testing: nodejs (8.x or newer)
71
+ #
72
+ # We currently use Python 2-compatible version of mtools, which
73
+ # is installable via pip (which uses Python 2). All of the MongoDB
74
+ # distros have pip installed (but none as of this writing have pip3)
75
+ # therefore install python-pip in all configurations here.
76
+
77
+ <% packages = %w(
78
+ lsb-release bzip2 curl zsh
79
+ git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
80
+ krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
81
+ haproxy
82
+ python3-pip
83
+ tzdata shared-mime-info
84
+ ) %>
85
+
86
+ <% if distro =~ /ubuntu1404/ %>
87
+ # For building python & setuptools
88
+ <% packages += %w(libssl-dev unzip) %>
89
+ <% end %>
90
+
91
+ <% if distro !~ /ubuntu2004/ %>
92
+ <% packages += %w(python2.7-dev) %>
93
+ <% end %>
94
+
95
+ <% if distro =~ /ubuntu2004/ %>
96
+ <% packages << 'libsnmp35' %>
97
+ <% else %>
98
+ <% packages << 'libsnmp30' %>
99
+ <% end %>
100
+
101
+ <% if distro !~ /ubuntu2004/ %>
102
+ <% packages << 'python-pip' %>
103
+ <% end %>
104
+
105
+ <% if distro =~ /debian10/ %>
106
+ <% packages << 'openjdk-11-jre-headless' %>
107
+ <% elsif distro =~ /ubuntu1404/ %>
108
+ # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
109
+ <% else %>
110
+ <% packages << 'openjdk-8-jre-headless' %>
111
+ <% end %>
112
+
113
+ # ubuntu1404, ubuntu1604: libcurl3
114
+ # ubuntu1804, ubuntu2004, debian10: libcurl4
115
+ <% if distro =~ /ubuntu1804|ubuntu2004|debian10/ %>
116
+ <% packages << 'libcurl4' %>
117
+ <% else %>
118
+ <% packages << 'libcurl3' %>
119
+ <% end %>
120
+
121
+ <% if distro =~ /ubuntu1804/ %>
122
+ <% packages << 'nodejs' %>
123
+ <% end %>
124
+
125
+ <% if distro =~ /ubuntu2004/ %>
126
+ <% packages += %w(ruby ruby2.7 bundler python2 python2-dev) %>
127
+ <% end %>
128
+
129
+ RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
130
+ <% else %>
131
+
132
+ <% if distro =~ /rhel6/ %>
133
+
134
+ # CentOS 6 is dead - to use it retrieve the packages from vault:
135
+ # https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
136
+
137
+ <%
138
+
139
+ cfg = <<-CFG
140
+ [base]
141
+ name=CentOS-$releasever - Base
142
+ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
143
+ #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
144
+ baseurl=http://vault.centos.org/6.10/os/x86_64/
145
+ gpgcheck=1
146
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
147
+ CFG
148
+
149
+ %>
150
+
151
+ RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
152
+
153
+ <% end %>
154
+
155
+ # Enterprise server: net-snmp
156
+ # lsb_release: redhat-lsb-core
157
+ # our runner scripts: which
158
+ # Ruby dependency: libyaml
159
+ # compiling python packages: gcc python-devel
160
+ # Kerberos tests: krb5-workstation + cyrus-sasl-devel to build the
161
+ # mongo_kerberos gem + cyrus-sasl-gssapi for authentication to work
162
+ # Local Kerberos server: krb5-server
163
+ # JRuby: java-1.8.0-openjdk
164
+ #
165
+ # Note: lacking cyrus-sasl-gssapi produces a cryptic message
166
+ # "SASL(-4): no mechanism available: No worthy mechs found"
167
+ # https://github.com/farorm/python-ad/issues/10
168
+
169
+ RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
170
+ krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
171
+ net-snmp python3
172
+
173
+ <% if distro =~ /rhel6/ %>
174
+
175
+ # RHEL 6 ships with Python 2.6.
176
+
177
+ RUN yum install -y centos-release-scl && \
178
+ yum install -y python27-python python27-python-devel
179
+ ENV PATH=/opt/rh/python27/root/usr/bin:$PATH \
180
+ LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
181
+
182
+ <% else %>
183
+
184
+ RUN yum install -y python-devel
185
+
186
+ <% end %>
187
+
188
+ <% end %>
189
+
190
+ <% if preload? %>
191
+
192
+ <% if distro =~ /ubuntu1404/ %>
193
+
194
+ # I couldn't find a prebuilt package of anything more recent than 2.7.6
195
+ # for 14.04.
196
+ RUN curl --retry 3 -fL https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tar.xz | \
197
+ tar xfJ - && \
198
+ cd Python-2.7.16 && \
199
+ ./configure && \
200
+ nice make -j4 && \
201
+ make install && \
202
+ cd .. && rm -rf Python-2.7.16
203
+
204
+ ENV PATH=/usr/local/bin:$PATH
205
+
206
+ RUN curl --retry 3 -fL -o setuptools-44.1.1.zip https://files.pythonhosted.org/packages/b2/40/4e00501c204b457f10fe410da0c97537214b2265247bc9a5bc6edd55b9e4/setuptools-44.1.1.zip && \
207
+ unzip setuptools-44.1.1.zip && \
208
+ cd setuptools-44.1.1 && \
209
+ python setup.py install && \
210
+ cd .. && rm -rf setuptools-44.1.1
211
+
212
+ <% end%>
213
+
214
+ <% if true || distro =~ /rhel|ubuntu1604/ %>
215
+
216
+ # Ubuntu 12.04 ships pip 1.0 which is ancient and does not work.
217
+ #
218
+ # Ubuntu 16.04 apparently also ships a pip that does not work:
219
+ # https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry
220
+ # Potentially this only affects environments with less than ideal
221
+ # connectivity (or, perhaps, when python package registry is experiencing
222
+ # availability issues) when pip must retry to install packages.
223
+ #
224
+ # rhel apparently does not package pip at all in core repoitories,
225
+ # therefore install it the manual way.
226
+ #
227
+ # https://pip.pypa.io/en/stable/installing/
228
+ RUN curl --retry 3 -fL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
229
+
230
+ <% end %>
231
+
232
+ # Current virtualenv fails with
233
+ # https://github.com/pypa/virtualenv/issues/1630
234
+ <% if distro =~ /ubuntu2004/ %>
235
+ RUN python3 -m pip install 'virtualenv<20' 'mtools-legacy[mlaunch]'
236
+ <% else %>
237
+ RUN python2 -m pip install 'virtualenv<20' 'mtools-legacy[mlaunch]'
238
+ <% end %>
239
+
240
+ RUN pip --version && \
241
+ pip install mtools-legacy[mlaunch]
242
+
243
+ <% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
244
+ # ubuntu1604 installs MarkupSafe 0.0.0 here instead of 2.0.0+
245
+ # as specified by dependencies, causing OCSP mock to not work.
246
+ RUN python3 -mpip install asn1crypto oscrypto flask --upgrade
247
+ <% end %>
248
+
249
+ <% unless ruby_head? || system_ruby? %>
250
+
251
+ RUN curl --retry 3 -fL <%= ruby_toolchain_url %> |tar -xC /opt -Jf -
252
+ ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
253
+ USE_OPT_TOOLCHAIN=1
254
+ #ENV PATH=/opt/rubies/python/3/bin:$PATH
255
+
256
+ <% end %>
257
+
258
+ RUN curl --retry 3 -fL <%= server_download_url %> |tar xzf - && \
259
+ mv mongo*/ /opt/mongodb
260
+ ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
261
+
262
+ <% end %>
263
+
264
+ <% if distro =~ /debian|ubuntu/ %>
265
+ # mkdir was moved from /usr/bin to /bin and MongoDB's distros
266
+ # apparently keep using the old location.
267
+ # This definitely affects debian10.
268
+ # https://stackoverflow.com/questions/64653051/make-usr-bin-mkdir-command-not-found-during-gem-install-nokogiri-in-ubuntu
269
+ RUN test -f /usr/bin/mkdir || ln -s /bin/mkdir /usr/bin/mkdir
270
+ <% end %>
271
+
272
+ WORKDIR /app
273
+
274
+ <% if preload? && !ruby_head? %>
275
+
276
+ COPY Gemfile .
277
+ COPY gemfiles gemfiles
278
+ COPY *.gemspec .
279
+ COPY lib/<%= project_lib_subdir %>/version.rb lib/<%= project_lib_subdir %>/version.rb
280
+ RUN bundle install
281
+ COPY .evergreen/patch-debuggers .evergreen/patch-debuggers
282
+ <% if system_ruby? %>
283
+ # Running under docker with root access
284
+ RUN .evergreen/patch-debuggers /var/lib/gems
285
+ <% else %>
286
+ RUN .evergreen/patch-debuggers /opt/rubies
287
+ <% end %>
288
+
289
+ <% end %>
290
+
291
+ <% if fle? %>
292
+ RUN curl --retry 3 -fLo libmongocrypt-all.tar.gz "https://s3.amazonaws.com/mciuploads/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz"
293
+ RUN tar xf libmongocrypt-all.tar.gz
294
+
295
+ <%= "ENV LIBMONGOCRYPT_PATH #{libmongocrypt_path}" %>
296
+ <% end %>
297
+
298
+ ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
299
+ PROJECT_DIRECTORY=/app \
300
+ <%= @env.map { |k, v| %Q`#{k}="#{v.gsub('$', "\\$").gsub('"', "\\\"")}"` }.join(" \\\n ") %>
301
+
302
+ <% if interactive? %>
303
+ ENV INTERACTIVE=1
304
+ <% end %>
305
+
306
+ COPY . .
307
+
308
+ <% if expose? %>
309
+
310
+ <% ports = [] %>
311
+
312
+ <% 0.upto(num_exposed_ports-1) do |i| %>
313
+ <% ports << 27017 + i %>
314
+ <% end %>
315
+
316
+ <% if @env['OCSP_ALGORITHM'] %>
317
+ <% ports << 8100 %>
318
+ <% end %>
319
+
320
+ EXPOSE <%= ports.map(&:to_s).join(' ') %>
321
+
322
+ <% end %>