mongoid 7.1.7 → 7.1.11

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 (81) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/Rakefile +31 -0
  5. data/lib/config/locales/en.yml +13 -0
  6. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +1 -1
  7. data/lib/mongoid/association/proxy.rb +1 -1
  8. data/lib/mongoid/association/referenced/has_many/enumerable.rb +1 -1
  9. data/lib/mongoid/association/referenced/has_many/proxy.rb +1 -1
  10. data/lib/mongoid/attributes.rb +8 -1
  11. data/lib/mongoid/config/environment.rb +9 -1
  12. data/lib/mongoid/contextual/atomic.rb +7 -2
  13. data/lib/mongoid/contextual/none.rb +3 -0
  14. data/lib/mongoid/criteria/queryable/selectable.rb +2 -2
  15. data/lib/mongoid/criteria/queryable/storable.rb +4 -4
  16. data/lib/mongoid/criteria.rb +1 -1
  17. data/lib/mongoid/document.rb +3 -2
  18. data/lib/mongoid/errors/empty_config_file.rb +26 -0
  19. data/lib/mongoid/errors/invalid_config_file.rb +26 -0
  20. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  21. data/lib/mongoid/errors.rb +2 -0
  22. data/lib/mongoid/interceptable.rb +1 -1
  23. data/lib/mongoid/persistence_context.rb +3 -1
  24. data/lib/mongoid/reloadable.rb +5 -0
  25. data/lib/mongoid/tasks/database.rb +1 -1
  26. data/lib/mongoid/validatable/associated.rb +1 -1
  27. data/lib/mongoid/validatable/presence.rb +3 -3
  28. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  29. data/lib/mongoid/version.rb +1 -1
  30. data/lib/mongoid.rb +1 -0
  31. data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
  32. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  33. data/spec/app/models/address.rb +4 -0
  34. data/spec/app/models/mop.rb +26 -0
  35. data/spec/app/models/person.rb +9 -0
  36. data/spec/integration/app_spec.rb +144 -87
  37. data/spec/integration/contextual/empty_spec.rb +142 -0
  38. data/spec/integration/document_spec.rb +21 -0
  39. data/spec/lite_spec_helper.rb +5 -5
  40. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +17 -4
  41. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +17 -0
  42. data/spec/mongoid/attributes_spec.rb +241 -0
  43. data/spec/mongoid/clients/factory_spec.rb +11 -0
  44. data/spec/mongoid/clients/options_spec.rb +11 -3
  45. data/spec/mongoid/config/environment_spec.rb +86 -8
  46. data/spec/mongoid/contextual/atomic_spec.rb +81 -29
  47. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  48. data/spec/mongoid/criteria_spec.rb +4 -0
  49. data/spec/mongoid/document_query_spec.rb +51 -0
  50. data/spec/mongoid/document_spec.rb +21 -1
  51. data/spec/mongoid/errors/invalid_config_file_spec.rb +32 -0
  52. data/spec/mongoid/errors/mongoid_error_spec.rb +20 -8
  53. data/spec/mongoid/factory_spec.rb +2 -2
  54. data/spec/mongoid/persistable/savable_spec.rb +4 -4
  55. data/spec/mongoid/persistable/settable_spec.rb +30 -0
  56. data/spec/mongoid/persistable/updatable_spec.rb +2 -0
  57. data/spec/mongoid/persistable_spec.rb +2 -2
  58. data/spec/shared/bin/get-mongodb-download-url +17 -0
  59. data/spec/shared/bin/s3-copy +45 -0
  60. data/spec/shared/bin/s3-upload +69 -0
  61. data/spec/shared/lib/mrss/cluster_config.rb +19 -4
  62. data/spec/shared/lib/mrss/constraints.rb +67 -12
  63. data/spec/shared/lib/mrss/docker_runner.rb +10 -1
  64. data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
  65. data/spec/shared/lib/mrss/lite_constraints.rb +16 -0
  66. data/spec/shared/lib/mrss/server_version_registry.rb +84 -33
  67. data/spec/shared/lib/mrss/spec_organizer.rb +32 -2
  68. data/spec/shared/lib/mrss/utils.rb +15 -0
  69. data/spec/shared/share/Dockerfile.erb +126 -32
  70. data/spec/shared/share/haproxy-1.conf +16 -0
  71. data/spec/shared/share/haproxy-2.conf +17 -0
  72. data/spec/shared/shlib/server.sh +123 -26
  73. data/spec/shared/shlib/set_env.sh +4 -1
  74. data/spec/spec_helper.rb +3 -1
  75. data/spec/support/constraints.rb +0 -226
  76. data/spec/support/spec_config.rb +8 -0
  77. data.tar.gz.sig +0 -0
  78. metadata +555 -503
  79. metadata.gz.sig +0 -0
  80. data/spec/support/child_process_helper.rb +0 -76
  81. 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
@@ -1,8 +1,23 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
1
4
  autoload :JSON, 'json'
2
5
  require 'open-uri'
3
6
 
4
7
  module Mrss
5
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
+
6
21
  def initialize(desired_version, arch)
7
22
  @desired_version, @arch = desired_version, arch
8
23
  end
@@ -11,39 +26,16 @@ module Mrss
11
26
 
12
27
  def download_url
13
28
  @download_url ||= begin
14
- info = JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
15
- version = info['versions'].detect do |version|
16
- version['version'].start_with?(desired_version) &&
17
- !version['version'].include?('-') &&
18
- # Sometimes the download situation is borked and there is a release
19
- # with no downloads... skip those.
20
- !version['downloads'].empty?
21
- end
22
- # Allow RC releases if there isn't a GA release.
23
- version ||= info['versions'].detect do |version|
24
- version['version'].start_with?(desired_version) &&
25
- # Sometimes the download situation is borked and there is a release
26
- # with no downloads... skip those.
27
- !version['downloads'].empty?
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
28
33
  end
29
34
  if version.nil?
30
- info = JSON.load(URI.parse('http://downloads.mongodb.org/full.json').open.read)
31
- versions = info['versions'].select do |version|
32
- version['version'].start_with?(desired_version) &&
33
- !version['downloads'].empty?
34
- end
35
- # Get rid of rc, beta etc. versions if there is a GA release.
36
- if versions.any? { |version| !version.include?('-') }
37
- versions.delete_if do |version|
38
- version['version'].include?('-')
39
- end
40
- end
41
- # Versions are ordered with newest first, take the first one i.e. the most
42
- # recent one.
43
- version = versions.first
44
- if version.nil?
45
- STDERR.puts "Error: no version #{desired_version}"
46
- exit 2
35
+ if version_ok
36
+ raise MissingDownloadUrl, "No downloads for version #{desired_version}"
37
+ else
38
+ raise UnknownVersion, "No version #{desired_version}"
47
39
  end
48
40
  end
49
41
  dl = version['downloads'].detect do |dl|
@@ -51,13 +43,36 @@ module Mrss
51
43
  dl['arch'] == 'x86_64'
52
44
  end
53
45
  unless dl
54
- STDERR.puts "Error: no download for #{arch} for #{version['version']}"
55
- exit 2
46
+ raise MissingDownloadUrl, "No download for #{arch} for #{version['version']}"
56
47
  end
57
48
  url = dl['archive']['url']
58
49
  end
50
+ rescue MissingDownloadUrl
51
+ if %w(2.6 3.0).include?(desired_version) && arch == 'ubuntu1604'
52
+ # 2.6 and 3.0 are only available for ubuntu1204 and ubuntu1404.
53
+ # Those ubuntus have ancient Pythons that don't work due to not
54
+ # implementing recent TLS protocols.
55
+ # Because of this we test on ubuntu1604 which has a newer Python.
56
+ # But we still need to retrieve ubuntu1404-targeting builds.
57
+ url = self.class.new('3.2', arch).download_url
58
+ unless url.include?('3.2.')
59
+ raise 'URL not in expected format'
60
+ end
61
+ url = case desired_version
62
+ when '2.6'
63
+ url.sub(/\b3\.2\.\d+/, '2.6.12')
64
+ when '3.0'
65
+ url.sub(/\b3\.2\.\d+/, '3.0.15')
66
+ else
67
+ raise NotImplementedError
68
+ end.sub('ubuntu1604', 'ubuntu1404')
69
+ else
70
+ raise
71
+ end
59
72
  end
60
73
 
74
+ private
75
+
61
76
  def uri_open(*args)
62
77
  if RUBY_VERSION < '2.5'
63
78
  open(*args)
@@ -65,5 +80,41 @@ module Mrss
65
80
  URI.open(*args)
66
81
  end
67
82
  end
83
+
84
+ def detect_version(catalog)
85
+ candidate_versions = catalog['versions'].select do |version|
86
+ version['version'].start_with?(desired_version) &&
87
+ !version['version'].include?('-')
88
+ end
89
+ version_ok = !candidate_versions.empty?
90
+ # Sometimes the download situation is borked and there is a release
91
+ # with no downloads... skip those.
92
+ version = candidate_versions.detect do |version|
93
+ !version['downloads'].empty?
94
+ end
95
+ # Allow RC releases if there isn't a GA release.
96
+ if version.nil?
97
+ candidate_versions = catalog['versions'].select do |version|
98
+ version['version'].start_with?(desired_version)
99
+ end
100
+ version_ok ||= !candidate_versions.empty?
101
+ version = candidate_versions.detect do |version|
102
+ !version['downloads'].empty?
103
+ end
104
+ end
105
+ [version, version_ok]
106
+ end
107
+
108
+ def current_catalog
109
+ @current_catalog ||= begin
110
+ JSON.load(uri_open('http://downloads.mongodb.org/current.json').read)
111
+ end
112
+ end
113
+
114
+ def full_catalog
115
+ @full_catalog ||= begin
116
+ JSON.load(uri_open('http://downloads.mongodb.org/full.json').read)
117
+ end
118
+ end
68
119
  end
69
120
  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
@@ -55,9 +55,10 @@ FROM <%= base_image %>
55
55
  # Ruby runtime dependencies: libyaml-0-2
56
56
  # Compiling ruby libraries: gcc make
57
57
  # Compiling pyhton packages: python2.7-dev
58
- # JRuby: openjdk-8-jre-headless
58
+ # JRuby: openjdk-8-jdk-headless
59
59
  # Server dependencies: libsnmp30 libcurl3/libcurl4
60
60
  # Determining OS we are running on: lsb-release
61
+ # Load balancer testing: haproxy
61
62
  # Kerberos testing: krb5-user
62
63
  # Local Kerberos server: krb5-kdc krb5-admin-server
63
64
  # Installing mlaunch from git: git
@@ -65,8 +66,9 @@ FROM <%= base_image %>
65
66
  # nio4r on JRuby: libgmp-dev
66
67
  # Snappy compression: libsnappy-dev
67
68
  # nokogiri: zlib1g-dev
68
- # Mongoid testing: tzdata
69
+ # Mongoid testing: tzdata shared-mime-info
69
70
  # Mongoid application testing: nodejs (8.x or newer)
71
+ # Test suite: procps for ps (to kill JRubies)
70
72
  #
71
73
  # We currently use Python 2-compatible version of mtools, which
72
74
  # is installable via pip (which uses Python 2). All of the MongoDB
@@ -74,22 +76,44 @@ FROM <%= base_image %>
74
76
  # therefore install python-pip in all configurations here.
75
77
 
76
78
  <% packages = %w(
77
- lsb-release bzip2 curl zsh
79
+ procps lsb-release bzip2 curl zsh
78
80
  git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
79
- libsnmp30
80
81
  krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
81
- python-pip python2.7-dev python3-pip
82
- tzdata
82
+ haproxy
83
+ python3-pip
84
+ tzdata shared-mime-info
83
85
  ) %>
84
86
 
85
- # ubuntu1404 only has openjdk-7-jre-headless
86
- <% if distro !~ /ubuntu1404/ %>
87
- <% packages << 'openjdk-8-jre-headless' %>
87
+ <% if distro =~ /ubuntu1404/ %>
88
+ # For building python & setuptools
89
+ <% packages += %w(libssl-dev unzip) %>
90
+ <% end %>
91
+
92
+ <% if distro !~ /ubuntu2004/ %>
93
+ <% packages += %w(python2.7-dev) %>
94
+ <% end %>
95
+
96
+ <% if distro =~ /ubuntu2004/ %>
97
+ <% packages << 'libsnmp35' %>
98
+ <% else %>
99
+ <% packages << 'libsnmp30' %>
100
+ <% end %>
101
+
102
+ <% if distro !~ /ubuntu2004/ %>
103
+ <% packages << 'python-pip' %>
104
+ <% end %>
105
+
106
+ <% if distro =~ /debian10/ %>
107
+ <% packages << 'openjdk-11-jdk-headless' %>
108
+ <% elsif distro =~ /ubuntu1404/ %>
109
+ # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
110
+ <% else %>
111
+ <% packages << 'openjdk-8-jdk-headless' %>
88
112
  <% end %>
89
113
 
90
114
  # ubuntu1404, ubuntu1604: libcurl3
91
- # ubuntu1804: libcurl4
92
- <% if distro =~ /ubuntu1804/ %>
115
+ # ubuntu1804, ubuntu2004, debian10: libcurl4
116
+ <% if distro =~ /ubuntu1804|ubuntu2004|debian10/ %>
93
117
  <% packages << 'libcurl4' %>
94
118
  <% else %>
95
119
  <% packages << 'libcurl3' %>
@@ -99,9 +123,36 @@ FROM <%= base_image %>
99
123
  <% packages << 'nodejs' %>
100
124
  <% end %>
101
125
 
126
+ <% if distro =~ /ubuntu2004/ %>
127
+ <% packages += %w(ruby ruby2.7 bundler python2 python2-dev) %>
128
+ <% end %>
129
+
102
130
  RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
103
131
  <% else %>
104
132
 
133
+ <% if distro =~ /rhel6/ %>
134
+
135
+ # CentOS 6 is dead - to use it retrieve the packages from vault:
136
+ # https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
137
+
138
+ <%
139
+
140
+ cfg = <<-CFG
141
+ [base]
142
+ name=CentOS-$releasever - Base
143
+ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
144
+ #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
145
+ baseurl=http://vault.centos.org/6.10/os/x86_64/
146
+ gpgcheck=1
147
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
148
+ CFG
149
+
150
+ %>
151
+
152
+ RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
153
+
154
+ <% end %>
155
+
105
156
  # Enterprise server: net-snmp
106
157
  # lsb_release: redhat-lsb-core
107
158
  # our runner scripts: which
@@ -118,7 +169,7 @@ FROM <%= base_image %>
118
169
 
119
170
  RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
120
171
  krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
121
- net-snmp
172
+ net-snmp python3
122
173
 
123
174
  <% if distro =~ /rhel6/ %>
124
175
 
@@ -134,27 +185,34 @@ FROM <%= base_image %>
134
185
  RUN yum install -y python-devel
135
186
 
136
187
  <% end %>
137
-
188
+
138
189
  <% end %>
139
190
 
140
191
  <% if preload? %>
141
192
 
142
- WORKDIR /app
143
-
144
- RUN curl --retry 3 -fL <%= server_download_url %> |tar xzf - && \
145
- mv mongo*/ /opt/mongodb
146
- ENV USE_OPT_MONGODB=1
147
-
148
- <% unless ruby_head? %>
149
-
150
- RUN curl --retry 3 -fL <%= ruby_toolchain_url %> |tar -xC /opt -Jf -
151
- ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
152
- USE_OPT_TOOLCHAIN=1
153
- #ENV PATH=/opt/rubies/python/3/bin:$PATH
154
-
155
- <% end %>
156
-
157
- <% if distro =~ /rhel|ubuntu1604/ %>
193
+ <% if distro =~ /ubuntu1404/ %>
194
+
195
+ # I couldn't find a prebuilt package of anything more recent than 2.7.6
196
+ # for 14.04.
197
+ RUN curl --retry 3 -fL https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tar.xz | \
198
+ tar xfJ - && \
199
+ cd Python-2.7.16 && \
200
+ ./configure && \
201
+ nice make -j4 && \
202
+ make install && \
203
+ cd .. && rm -rf Python-2.7.16
204
+
205
+ ENV PATH=/usr/local/bin:$PATH
206
+
207
+ RUN curl --retry 3 -fL -o setuptools-44.1.1.zip https://files.pythonhosted.org/packages/b2/40/4e00501c204b457f10fe410da0c97537214b2265247bc9a5bc6edd55b9e4/setuptools-44.1.1.zip && \
208
+ unzip setuptools-44.1.1.zip && \
209
+ cd setuptools-44.1.1 && \
210
+ python setup.py install && \
211
+ cd .. && rm -rf setuptools-44.1.1
212
+
213
+ <% end%>
214
+
215
+ <% if true || distro =~ /rhel|ubuntu1604/ %>
158
216
 
159
217
  # Ubuntu 12.04 ships pip 1.0 which is ancient and does not work.
160
218
  #
@@ -168,17 +226,48 @@ FROM <%= base_image %>
168
226
  # therefore install it the manual way.
169
227
  #
170
228
  # https://pip.pypa.io/en/stable/installing/
171
- RUN curl --retry 3 -fL https://raw.githubusercontent.com/pypa/get-pip/master/2.7/get-pip.py | python
229
+ RUN curl --retry 3 -fL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
230
+
231
+ <% end %>
172
232
 
233
+ # Current virtualenv fails with
234
+ # https://github.com/pypa/virtualenv/issues/1630
235
+ <% if distro =~ /ubuntu2004/ %>
236
+ RUN python3 -m pip install 'virtualenv<20' 'mtools-legacy[mlaunch]'
237
+ <% else %>
238
+ RUN python2 -m pip install 'virtualenv<20' 'mtools-legacy[mlaunch]'
173
239
  <% end %>
174
240
 
175
241
  RUN pip --version && \
176
242
  pip install mtools-legacy[mlaunch]
177
243
 
178
244
  <% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
179
- RUN python3 -mpip install asn1crypto oscrypto flask
245
+ # ubuntu1604 installs MarkupSafe 0.0.0 here instead of 2.0.0+
246
+ # as specified by dependencies, causing OCSP mock to not work.
247
+ RUN python3 -mpip install asn1crypto oscrypto flask --upgrade
180
248
  <% end %>
181
249
 
250
+ <% unless ruby_head? || system_ruby? %>
251
+
252
+ RUN curl --retry 3 -fL <%= ruby_toolchain_url %> |tar -xC /opt -Jf -
253
+ ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
254
+ USE_OPT_TOOLCHAIN=1
255
+ #ENV PATH=/opt/rubies/python/3/bin:$PATH
256
+
257
+ <% end %>
258
+
259
+ RUN curl --retry 3 -fL <%= server_download_url %> |tar xzf - && \
260
+ mv mongo*/ /opt/mongodb
261
+ ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
262
+
263
+ <% end %>
264
+
265
+ <% if distro =~ /debian|ubuntu/ %>
266
+ # mkdir was moved from /usr/bin to /bin and MongoDB's distros
267
+ # apparently keep using the old location.
268
+ # This definitely affects debian10.
269
+ # https://stackoverflow.com/questions/64653051/make-usr-bin-mkdir-command-not-found-during-gem-install-nokogiri-in-ubuntu
270
+ RUN test -f /usr/bin/mkdir || ln -s /bin/mkdir /usr/bin/mkdir
182
271
  <% end %>
183
272
 
184
273
  WORKDIR /app
@@ -191,7 +280,12 @@ WORKDIR /app
191
280
  COPY lib/<%= project_lib_subdir %>/version.rb lib/<%= project_lib_subdir %>/version.rb
192
281
  RUN bundle install
193
282
  COPY .evergreen/patch-debuggers .evergreen/patch-debuggers
194
- RUN .evergreen/patch-debuggers /opt/rubies
283
+ <% if system_ruby? %>
284
+ # Running under docker with root access
285
+ RUN .evergreen/patch-debuggers /var/lib/gems
286
+ <% else %>
287
+ RUN .evergreen/patch-debuggers /opt/rubies
288
+ <% end %>
195
289
 
196
290
  <% end %>
197
291