mongoid 8.1.0 → 8.1.2

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.
@@ -559,6 +559,49 @@ describe Mongoid::Fields do
559
559
  end
560
560
  end
561
561
  end
562
+
563
+ context 'when the field is declared as BSON::Decimal128' do
564
+ let(:document) { Mop.create!(decimal128_field: BSON::Decimal128.new(Math::PI.to_s)).reload }
565
+
566
+ shared_context 'BSON::Decimal128 is BigDecimal' do
567
+ it 'should return a BigDecimal' do
568
+ expect(document.decimal128_field).to be_a BigDecimal
569
+ end
570
+ end
571
+
572
+ shared_context 'BSON::Decimal128 is BSON::Decimal128' do
573
+ it 'should return a BSON::Decimal128' do
574
+ expect(document.decimal128_field).to be_a BSON::Decimal128
575
+ end
576
+ end
577
+
578
+ it 'is declared as BSON::Decimal128' do
579
+ expect(Mop.fields['decimal128_field'].type).to be == BSON::Decimal128
580
+ end
581
+
582
+ context 'when BSON version <= 4' do
583
+ max_bson_version '4.99.99'
584
+ it_behaves_like 'BSON::Decimal128 is BSON::Decimal128'
585
+ end
586
+
587
+ context 'when BSON version >= 5' do
588
+ min_bson_version '5.0.0'
589
+
590
+ context 'when allow_bson5_decimal128 is false' do
591
+ config_override :allow_bson5_decimal128, false
592
+ it_behaves_like 'BSON::Decimal128 is BigDecimal'
593
+ end
594
+
595
+ context 'when allow_bson5_decimal128 is true' do
596
+ config_override :allow_bson5_decimal128, true
597
+ it_behaves_like 'BSON::Decimal128 is BSON::Decimal128'
598
+ end
599
+
600
+ context 'when allow_bson5_decimal128 is default' do
601
+ it_behaves_like 'BSON::Decimal128 is BigDecimal'
602
+ end
603
+ end
604
+ end
562
605
  end
563
606
 
564
607
  describe "#getter_before_type_cast" do
@@ -390,6 +390,30 @@ describe Mongoid::Reloadable do
390
390
  end
391
391
  end
392
392
 
393
+ context 'when embeds_many is modified' do
394
+ let(:contractor1) { Contractor.new(name: 'b') }
395
+ let(:contractor2) { Contractor.new(name: 'c') }
396
+
397
+ let(:building) do
398
+ Building.create!(name: 'a', contractors: [ contractor1 ])
399
+ end
400
+
401
+ let(:more_contractors) { building.contractors + [ contractor2 ] }
402
+
403
+ let(:modified_building) do
404
+ building.tap do
405
+ building.assign_attributes contractors: more_contractors
406
+ end
407
+ end
408
+
409
+ let(:reloaded_building) { modified_building.reload }
410
+
411
+ it 'resets delayed_atomic_sets' do
412
+ expect(modified_building.delayed_atomic_sets).not_to be_empty
413
+ expect(reloaded_building.delayed_atomic_sets).to be_empty
414
+ end
415
+ end
416
+
393
417
  context "when embedded document is nil" do
394
418
 
395
419
  let(:palette) do
data/spec/mongoid_spec.rb CHANGED
@@ -75,10 +75,8 @@ describe Mongoid do
75
75
  end
76
76
 
77
77
  it "disconnects from all active clients" do
78
- pending 'https://jira.mongodb.org/browse/MONGOID-5621'
79
-
80
78
  clients.each do |client|
81
- expect(client.cluster).to receive(:disconnect!).and_call_original
79
+ expect(client).to receive(:close).and_call_original
82
80
  end
83
81
  Mongoid.disconnect_clients
84
82
  end
@@ -195,15 +195,12 @@ module Mrss
195
195
  'debian81' => 'debian:jessie',
196
196
  'debian92' => 'debian:stretch',
197
197
  'debian10' => 'debian:buster',
198
- 'debian11' => 'debian:bullseye',
199
198
  'ubuntu1404' => 'ubuntu:trusty',
200
199
  'ubuntu1604' => 'ubuntu:xenial',
201
200
  'ubuntu1804' => 'ubuntu:bionic',
202
201
  'ubuntu2004' => 'ubuntu:focal',
203
- 'ubuntu2204' => 'ubuntu:jammy',
204
202
  'rhel62' => 'centos:6',
205
203
  'rhel70' => 'centos:7',
206
- 'rhel80' => 'rockylinux:8',
207
204
  }.freeze
208
205
 
209
206
  def base_image
@@ -234,10 +231,6 @@ module Mrss
234
231
  distro =~ /debian|ubuntu/
235
232
  end
236
233
 
237
- def ubuntu?
238
- distro=~ /ubuntu/
239
- end
240
-
241
234
  def preload?
242
235
  !!@options[:preload]
243
236
  end
@@ -98,8 +98,8 @@ module Mrss
98
98
  def min_libmongocrypt_version(version)
99
99
  require_libmongocrypt
100
100
  before(:all) do
101
- actual_version = Utils.parse_version(Mongo::Crypt::Binding.mongocrypt_version(nil))
102
- min_version = Utils.parse_version(version)
101
+ actual_version = Gem::Version.new(Mongo::Crypt::Binding.mongocrypt_version(nil))
102
+ min_version = Gem::Version.new(version)
103
103
  unless actual_version >= min_version
104
104
  skip "libmongocrypt version #{min_version} required, but version #{actual_version} is available"
105
105
  end
@@ -24,21 +24,6 @@ module Mrss
24
24
 
25
25
  attr_reader :desired_version, :arch
26
26
 
27
- def target_arch
28
- # can't use RbConfig::CONFIG["arch"] because JRuby doesn't
29
- # return anything meaningful there.
30
- #
31
- # also, need to use `uname -a` instead of (e.g.) `uname -p`
32
- # because debian (at least) does not return anything meaningful
33
- # for `uname -p`.
34
- uname = `uname -a`.strip
35
- @target_arch ||= case uname
36
- when /aarch/ then "aarch64"
37
- when /x86/ then "x86_64"
38
- else raise "unsupported architecture #{uname.inspect}"
39
- end
40
- end
41
-
42
27
  def download_url
43
28
  @download_url ||= begin
44
29
  version, version_ok = detect_version(current_catalog)
@@ -55,13 +40,35 @@ module Mrss
55
40
  end
56
41
  dl = version['downloads'].detect do |dl|
57
42
  dl['archive']['url'].index("enterprise-#{arch}") &&
58
- dl['arch'] == target_arch
43
+ dl['arch'] == 'x86_64'
59
44
  end
60
45
  unless dl
61
46
  raise MissingDownloadUrl, "No download for #{arch} for #{version['version']}"
62
47
  end
63
48
  url = dl['archive']['url']
64
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
65
72
  end
66
73
 
67
74
  private
@@ -3,35 +3,13 @@
3
3
 
4
4
  module Mrss
5
5
  module Utils
6
- extend self
7
6
 
8
- def print_backtrace(dest=STDERR)
9
- raise
10
- rescue => e
11
- dest.puts e.backtrace.join("\n")
12
- end
13
-
14
- # Parses the given version string, accounting for suffix information that
15
- # Gem::Version cannot successfully parse.
16
- #
17
- # @param [ String ] version the version to parse
18
- #
19
- # @return [ Gem::Version ] the parsed version
20
- #
21
- # @raise [ ArgumentError ] if the string cannot be parsed.
22
- def parse_version(version)
23
- Gem::Version.new(version)
24
- rescue ArgumentError
25
- match = version.match(/\A(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?(-[A-Za-z\+\d]+)?\z/)
26
- raise ArgumentError.new("Malformed version number string #{version}") if match.nil?
27
-
28
- Gem::Version.new(
29
- [
30
- match[:major],
31
- match[:minor],
32
- match[:patch]
33
- ].join('.')
34
- )
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
35
13
  end
36
14
  end
37
15
  end
@@ -7,13 +7,13 @@
7
7
  <%
8
8
 
9
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'
10
+ server_version = '4.3.3'
11
11
  server_url = "http://downloads.10gen.com/linux/mongodb-linux-x86_64-enterprise-#{distro}-#{server_version}.tgz"
12
12
  server_archive_basename = File.basename(server_url)
13
13
  server_extracted_dir = server_archive_basename.sub(/\.(tar\.gz|tgz)$/, '')
14
14
 
15
15
  # When changing, also update the hash in shlib/set_env.sh.
16
- TOOLCHAIN_VERSION='e8c60866f54bed7e336a37df3a97d6ae1b971b7d'
16
+ TOOLCHAIN_VERSION='219833abad4d9d3bf43c0fef101a8ca082ac4ae9'
17
17
 
18
18
  def ruby_toolchain_url(ruby)
19
19
  "http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/#{TOOLCHAIN_VERSION}/#{distro}/#{ruby}.tar.xz"
@@ -77,31 +77,25 @@ ENV DOCKER=1
77
77
  # therefore install python-pip in all configurations here.
78
78
 
79
79
  <% packages = %w(
80
- procps lsb-release bzip2 curl wget gpg zsh
80
+ procps lsb-release bzip2 curl zsh
81
81
  git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
82
82
  krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
83
83
  haproxy
84
84
  python3-pip
85
- tzdata shared-mime-info software-properties-common
85
+ tzdata shared-mime-info
86
86
  ) %>
87
87
 
88
88
  <% if distro =~ /ubuntu2004/ %>
89
89
  <% packages << 'libsnmp35' %>
90
- <% elsif distro =~ /ubuntu2204|debian11/ %>
91
- <% packages << 'libsnmp40' %>
92
90
  <% else %>
93
91
  <% packages << 'libsnmp30' %>
94
92
  <% end %>
95
93
 
96
- <% if distro !~ /ubuntu2004|ubuntu2204|debian11/ %>
94
+ <% if distro !~ /ubuntu2004/ %>
97
95
  <% packages << 'python-pip' %>
98
96
  <% end %>
99
97
 
100
- <% if distro =~ /ubuntu2204|debian11/ %>
101
- <% packages << 'python3-venv' %>
102
- <% end %>
103
-
104
- <% if distro =~ /debian10|ubuntu2204|debian11/ %>
98
+ <% if distro =~ /debian10/ %>
105
99
  <% packages << 'openjdk-11-jdk-headless' %>
106
100
  <% elsif distro =~ /ubuntu1404/ %>
107
101
  # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
@@ -111,37 +105,31 @@ ENV DOCKER=1
111
105
 
112
106
  # ubuntu1404, ubuntu1604: libcurl3
113
107
  # ubuntu1804, ubuntu2004, debian10: libcurl4
114
- <% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204|debian10|debian11/ %>
108
+ <% if distro =~ /ubuntu1804|ubuntu2004|debian10/ %>
115
109
  <% packages << 'libcurl4' %>
116
110
  <% else %>
117
111
  <% packages << 'libcurl3' %>
118
112
  <% end %>
119
113
 
120
- <% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204/ %>
114
+ <% if distro =~ /ubuntu1804|ubuntu2004/ %>
121
115
  <% packages << 'nodejs' %>
122
116
  <% end %>
123
117
 
124
- <% if distro =~ /ubuntu2004|ubuntu2204/ %>
125
- <% packages += %w(ruby bundler) %>
118
+ <% if distro =~ /ubuntu2004/ %>
119
+ <% packages += %w(ruby ruby2.7 bundler) %>
126
120
  <% end %>
127
121
 
128
122
  RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
129
-
130
- <% if ubuntu? %>
131
- RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
132
- RUN echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null
133
- <% end %>
134
- RUN apt-get update && apt-get install -y cmake
135
-
123
+
136
124
  <% else %>
137
125
 
138
126
  <% if distro =~ /rhel6/ %>
139
-
127
+
140
128
  # CentOS 6 is dead - to use it retrieve the packages from vault:
141
129
  # https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
142
-
130
+
143
131
  <%
144
-
132
+
145
133
  cfg = <<-CFG
146
134
  [base]
147
135
  name=CentOS-$releasever - Base
@@ -153,11 +141,11 @@ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
153
141
  CFG
154
142
 
155
143
  %>
156
-
144
+
157
145
  RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
158
-
146
+
159
147
  <% end %>
160
-
148
+
161
149
  # Enterprise server: net-snmp
162
150
  # lsb_release: redhat-lsb-core
163
151
  # our runner scripts: which
@@ -174,8 +162,23 @@ CFG
174
162
 
175
163
  RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
176
164
  krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
177
- net-snmp python38 python38-devel cmake nodejs
165
+ net-snmp python3
178
166
 
167
+ <% if distro =~ /rhel6/ %>
168
+
169
+ # RHEL 6 ships with Python 2.6.
170
+
171
+ RUN yum install -y centos-release-scl && \
172
+ yum install -y python27-python python27-python-devel
173
+ ENV PATH=/opt/rh/python27/root/usr/bin:$PATH \
174
+ LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
175
+
176
+ <% else %>
177
+
178
+ RUN yum install -y python-devel
179
+
180
+ <% end %>
181
+
179
182
  <% end %>
180
183
 
181
184
  <% if preload? %>
@@ -217,7 +220,7 @@ CFG
217
220
  <% when 'git' %>
218
221
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
219
222
  RUN python3 -m pip install virtualenv 'pymongo>=4' python-dateutil psutil
220
-
223
+
221
224
  # Install mtools from git because released versions do not work with pymongo 4.0
222
225
  RUN git clone https://github.com/p-mongodb/mtools && \
223
226
  cd mtools && \
@@ -231,7 +234,7 @@ CFG
231
234
  <% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
232
235
  # ubuntu1604 installs MarkupSafe 0.0.0 here instead of 2.0.0+
233
236
  # as specified by dependencies, causing OCSP mock to not work.
234
- RUN python3 -mpip install asn1crypto oscrypto flask --upgrade --ignore-installed
237
+ RUN python3 -mpip install asn1crypto oscrypto flask --upgrade
235
238
  <% end %>
236
239
 
237
240
  # FLE is tested against 4.0+ servers.
@@ -240,7 +243,7 @@ CFG
240
243
  # boto3~=1.19 cryptography~=3.4.8 pykmip~=0.10.0
241
244
  # cryptography does not install due to lacking setuptools_rust
242
245
  # (either that version or anything that isn't part of system packages)
243
- RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0 'sqlalchemy<2.0.0'
246
+ RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0
244
247
  <% end %>
245
248
 
246
249
  <% unless ruby_head? || system_ruby? %>
@@ -252,6 +255,10 @@ CFG
252
255
 
253
256
  <% end %>
254
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
+
255
262
  <% end %>
256
263
 
257
264
  <% if distro =~ /debian|ubuntu/ %>
@@ -301,9 +308,6 @@ ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
301
308
 
302
309
  COPY . .
303
310
 
304
- RUN bash -c '. .evergreen/download-mongodb.sh && get_distro && get_mongodb_download_url_for "$DISTRO" "<%= server_version %>" && curl --retry 3 -fL $MONGODB_DOWNLOAD_URL |tar xzf - && mv mongo*/ /opt/mongodb'
305
- ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
306
-
307
311
  <% if expose? %>
308
312
 
309
313
  <% ports = [] %>
@@ -78,26 +78,15 @@ install_mlaunch_venv() {
78
78
  # https://github.com/pypa/virtualenv/issues/1630
79
79
  python3 -m pip install venv --user
80
80
  fi
81
- if ! python3 -m ensurepip -h > /dev/null; then
82
- # Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
83
- # the python3-venv package is also installed (it lacks the ensurepip
84
- # module).
85
- sudo apt-get install --yes python3-venv
86
- fi
87
81
  if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
88
82
  python3 -m pip list |grep mtools
89
83
  then
90
84
  # Use the existing mtools-legacy
91
85
  :
92
86
  else
93
- # Spawn a virtual environment, but only if one is not already
94
- # active...
95
- if test -z "$VIRTUAL_ENV"; then
96
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
97
- python3 -m venv $venvpath
98
- . $venvpath/bin/activate
99
- fi
100
-
87
+ venvpath="$MONGO_ORCHESTRATION_HOME"/venv
88
+ python3 -m venv $venvpath
89
+ . $venvpath/bin/activate
101
90
  # [mlaunch] does not work:
102
91
  # https://github.com/rueckstiess/mtools/issues/856
103
92
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
@@ -169,19 +158,6 @@ install_mlaunch_git() {
169
158
  fi
170
159
  }
171
160
 
172
- install_cmake() {
173
- if ! command -v cmake &> /dev/null; then
174
- if ! command -v apt-get &> /dev/null; then
175
- # no apt-get; assume RHEL
176
- sudo yum -y install cmake libarchive
177
- else
178
- sudo apt-get install --yes cmake
179
- fi
180
- else
181
- echo 'cmake is present'
182
- fi
183
- }
184
-
185
161
  # This function sets followong global variables:
186
162
  # server_cert_path
187
163
  # server_ca_path
@@ -197,7 +173,7 @@ calculate_server_args() {
197
173
  fi
198
174
 
199
175
  if test $mongo_version = latest; then
200
- mongo_version=70
176
+ mongo_version=60
201
177
  fi
202
178
 
203
179
  local args="--setParameter enableTestCommands=1"
@@ -1,5 +1,5 @@
1
1
  # When changing, also update the hash in share/Dockerfile.
2
- TOOLCHAIN_VERSION=e8c60866f54bed7e336a37df3a97d6ae1b971b7d
2
+ TOOLCHAIN_VERSION=219833abad4d9d3bf43c0fef101a8ca082ac4ae9
3
3
 
4
4
  set_env_java() {
5
5
  ls -l /opt || true
@@ -53,7 +53,7 @@ set_env_python() {
53
53
  curl -fL --retry 3 https://github.com/p-mongodb/deps/raw/main/"$arch"-python37.tar.xz | \
54
54
  tar xfJ - -C /opt
55
55
  fi
56
-
56
+
57
57
  if test -d /opt/python/3.7/bin; then
58
58
  # Most Evergreen configurations.
59
59
  export PATH=/opt/python/3.7/bin:$PATH
@@ -61,7 +61,7 @@ set_env_python() {
61
61
  # Configurations that use Docker in Evergreen - these don't preload.
62
62
  export PATH=/opt/python37/bin:$PATH
63
63
  fi
64
-
64
+
65
65
  python3 -V
66
66
  fi
67
67
  }
@@ -78,7 +78,7 @@ set_env_node() {
78
78
  # Node from toolchain in Evergreen
79
79
  export PATH=/opt/node/bin:$PATH
80
80
  fi
81
-
81
+
82
82
  node -v
83
83
  }
84
84
 
@@ -70,6 +70,7 @@ class Person
70
70
  embeds_many :messages, validate: false
71
71
 
72
72
  embeds_one :passport, autobuild: true, store_as: :pass, validate: false
73
+ embeds_one :purse, store_as: "Purse"
73
74
  embeds_one :pet, class_name: "Animal", validate: false
74
75
  embeds_one :name, as: :namable, validate: false do
75
76
  def extension
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Purse
4
+ include Mongoid::Document
5
+
6
+ field :brand, type: String
7
+
8
+ embedded_in :person
9
+ end
data.tar.gz.sig CHANGED
Binary file