mongoid 8.1.3 → 8.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +43 -45
  3. data/lib/mongoid/association/accessors.rb +5 -1
  4. data/lib/mongoid/association/eager_loadable.rb +3 -0
  5. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +18 -3
  6. data/lib/mongoid/association/embedded/embeds_one/proxy.rb +1 -1
  7. data/lib/mongoid/association/referenced/has_many/enumerable.rb +21 -4
  8. data/lib/mongoid/association/referenced/has_many/proxy.rb +11 -2
  9. data/lib/mongoid/atomic.rb +9 -7
  10. data/lib/mongoid/attributes/readonly.rb +8 -3
  11. data/lib/mongoid/contextual/mongo.rb +1 -1
  12. data/lib/mongoid/criteria/queryable/extensions/numeric.rb +15 -1
  13. data/lib/mongoid/criteria/queryable/selectable.rb +1 -1
  14. data/lib/mongoid/document.rb +8 -1
  15. data/lib/mongoid/equality.rb +1 -0
  16. data/lib/mongoid/extensions/hash.rb +4 -4
  17. data/lib/mongoid/fields.rb +13 -8
  18. data/lib/mongoid/interceptable.rb +6 -7
  19. data/lib/mongoid/matcher.rb +15 -1
  20. data/lib/mongoid/serializable.rb +7 -7
  21. data/lib/mongoid/timestamps/created.rb +8 -1
  22. data/lib/mongoid/touchable.rb +1 -1
  23. data/lib/mongoid/traversable.rb +36 -1
  24. data/lib/mongoid/validatable/associated.rb +98 -17
  25. data/lib/mongoid/validatable/macros.rb +15 -0
  26. data/lib/mongoid/validatable/numericality.rb +19 -0
  27. data/lib/mongoid/validatable.rb +9 -0
  28. data/lib/mongoid/version.rb +5 -1
  29. data/spec/integration/app_spec.rb +24 -5
  30. data/spec/integration/associations/embeds_one_spec.rb +25 -5
  31. data/spec/integration/associations/has_and_belongs_to_many_spec.rb +40 -0
  32. data/spec/mongoid/association/eager_spec.rb +24 -2
  33. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +35 -0
  34. data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +4 -0
  35. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +4 -0
  36. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +28 -37
  37. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +42 -0
  38. data/spec/mongoid/attributes/readonly_spec.rb +19 -0
  39. data/spec/mongoid/attributes_spec.rb +16 -0
  40. data/spec/mongoid/contextual/mongo_spec.rb +78 -3
  41. data/spec/mongoid/criteria/queryable/selectable_spec.rb +29 -0
  42. data/spec/mongoid/document_spec.rb +27 -0
  43. data/spec/mongoid/equality_spec.rb +6 -0
  44. data/spec/mongoid/fields_spec.rb +3 -3
  45. data/spec/mongoid/interceptable_spec.rb +80 -0
  46. data/spec/mongoid/interceptable_spec_models.rb +47 -111
  47. data/spec/mongoid/serializable_spec.rb +16 -9
  48. data/spec/mongoid/timestamps/created_spec.rb +23 -0
  49. data/spec/mongoid/validatable/associated_spec.rb +27 -34
  50. data/spec/mongoid/validatable/numericality_spec.rb +16 -0
  51. data/spec/shared/lib/mrss/docker_runner.rb +1 -2
  52. data/spec/shared/lib/mrss/release/candidate.rb +281 -0
  53. data/spec/shared/lib/mrss/release/product_data.rb +144 -0
  54. data/spec/shared/lib/mrss/server_version_registry.rb +1 -1
  55. data/spec/shared/lib/tasks/candidate.rake +64 -0
  56. data/spec/shared/share/Dockerfile.erb +15 -85
  57. data/spec/shared/shlib/distro.sh +10 -0
  58. data/spec/shared/shlib/server.sh +33 -26
  59. data/spec/shared/shlib/set_env.sh +9 -68
  60. data/spec/support/expectations.rb +20 -17
  61. data/spec/support/models/band.rb +1 -0
  62. data/spec/support/models/lat_lng.rb +6 -0
  63. data/spec/support/models/name.rb +10 -0
  64. metadata +15 -38
  65. checksums.yaml.gz.sig +0 -0
  66. data.tar.gz.sig +0 -0
  67. metadata.gz.sig +0 -0
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mrss/release/candidate'
4
+
5
+ namespace :candidate do
6
+ desc 'Initialize a new product.yml file'
7
+ task :init do
8
+ Mrss::Release::ProductData.init!
9
+ puts "product.yml file created"
10
+ end
11
+
12
+ desc 'Print the release notes for the next candidate release'
13
+ task :preview do
14
+ Mrss::Release::Candidate.instance do |candidate|
15
+ # load the pending changes before bumping the version, since it
16
+ # depends on the value of the current version.
17
+ candidate.pending_changes
18
+ candidate.bump_version
19
+ puts candidate.release_notes
20
+ end
21
+ end
22
+
23
+ desc 'List the pull requests to be included in the next release'
24
+ task :prs do
25
+ Mrss::Release::Candidate.instance.decorated_prs.each do |pr|
26
+ print "\##{pr['number']}[#{pr['type-code']}] "
27
+ print "#{pr['jira']} " if pr['jira']
28
+ puts pr['short-title']
29
+ end
30
+ end
31
+
32
+ desc 'Create a new branch and pull request for the candidate'
33
+ task create: :check_branch_status do
34
+ Mrss::Release::Candidate.instance do |candidate|
35
+ origin = `git config get remote.origin.url`
36
+ match = origin.match(/:(.*?)\//) or raise "origin url is not in expected format: #{origin.inspect}"
37
+ user = match[1]
38
+
39
+ puts 'gathering candidate info and bumping version...'
40
+ candidate.bump_version!
41
+
42
+ puts 'writing release notes to /tmp/pr-body.md...'
43
+ File.write('/tmp/pr-body.md', candidate.release_notes)
44
+
45
+ sh 'git', 'checkout', '-b', candidate.branch_name
46
+ sh 'git', 'commit', '-am', "Bump version to #{candidate.product.version}"
47
+ sh 'git', 'push', 'origin', candidate.branch_name
48
+
49
+ sh 'gh', 'pr', 'create',
50
+ '--head', "#{user}:#{candidate.branch_name}",
51
+ '--base', candidate.product.base_branch,
52
+ '--title', "Release candidate for #{candidate.product.version}",
53
+ '--label', 'release-candidate',
54
+ '--body-file', '/tmp/pr-body.md'
55
+ end
56
+ end
57
+
58
+ # Ensures the current branch is up-to-date with no uncommitted changes
59
+ task :check_branch_status do
60
+ sh 'git pull >/dev/null', verbose: false
61
+ changes = `git status --short --untracked-files=no`.strip
62
+ abort "There are uncommitted changes. Commit (or revert) the changes and try again." if changes.length > 0
63
+ end
64
+ end
@@ -1,26 +1,9 @@
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
1
  <%
8
2
 
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
- # When changing, also update the hash in shlib/set_env.sh.
16
- TOOLCHAIN_VERSION='e8c60866f54bed7e336a37df3a97d6ae1b971b7d'
17
-
18
3
  def ruby_toolchain_url(ruby)
19
- "http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/#{TOOLCHAIN_VERSION}/#{distro}/#{ruby}.tar.xz"
4
+ "http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-toolchain/library/#{distro}/#{ruby}.tar.xz"
20
5
  end
21
6
 
22
- #ruby_toolchain_url = "https://s3.amazonaws.com//mciuploads/mongo-ruby-toolchain/#{distro}/#{TOOLCHAIN_VERSION}/mongo_ruby_driver_toolchain_#{distro.gsub('-', '_')}_patch_#{TOOLCHAIN_VERSION}_#{toolchain_lower}.tar.gz"
23
-
24
7
  %>
25
8
 
26
9
  FROM <%= base_image %>
@@ -37,18 +20,6 @@ ENV DOCKER=1
37
20
 
38
21
  <% end %>
39
22
 
40
- <% if ruby_head? %>
41
-
42
- # To use current versions of mlaunch, Python 3.7+ is required.
43
- # Many distros ship with older Pythons, therefore we need to install
44
- # a newer Python from somewhere. This section installs the Python
45
- # toolchain which comes with recent Pythons.
46
-
47
- #RUN curl --retry 3 -fL <%= python_toolchain_url %> -o python-toolchain.tar.gz
48
- #RUN tar -xC /opt -zf python-toolchain.tar.gz
49
-
50
- <% end %>
51
-
52
23
  <% if debian? %>
53
24
 
54
25
  # zsh is not required for any scripts but it is a better interactive shell
@@ -56,7 +27,7 @@ ENV DOCKER=1
56
27
  # Ruby runtime dependencies: libyaml-0-2
57
28
  # Compiling ruby libraries: gcc make
58
29
  # Compiling python packages: python3-dev
59
- # JRuby: openjdk-8-jdk-headless
30
+ # JRuby: openjdk-17-jdk-headless
60
31
  # Server dependencies: libsnmp30 libcurl3/libcurl4
61
32
  # Determining OS we are running on: lsb-release
62
33
  # Load balancer testing: haproxy
@@ -78,11 +49,11 @@ ENV DOCKER=1
78
49
 
79
50
  <% packages = %w(
80
51
  procps lsb-release bzip2 curl wget gpg zsh
81
- git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
52
+ git make gcc g++ libyaml-dev libgmp-dev zlib1g-dev libsnappy-dev
82
53
  krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
83
- haproxy
84
- python3-pip
85
- tzdata shared-mime-info software-properties-common
54
+ haproxy libcurl4
55
+ tzdata shared-mime-info software-properties-common xz-utils nodejs npm
56
+ openjdk-17-jdk-headless
86
57
  ) %>
87
58
 
88
59
  <% if distro =~ /ubuntu2004/ %>
@@ -101,26 +72,6 @@ ENV DOCKER=1
101
72
  <% packages << 'python3-venv' %>
102
73
  <% end %>
103
74
 
104
- <% if distro =~ /debian10|ubuntu2204|debian11/ %>
105
- <% packages << 'openjdk-11-jdk-headless' %>
106
- <% elsif distro =~ /ubuntu1404/ %>
107
- # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
108
- <% else %>
109
- <% packages << 'openjdk-8-jdk-headless' %>
110
- <% end %>
111
-
112
- # ubuntu1404, ubuntu1604: libcurl3
113
- # ubuntu1804, ubuntu2004, debian10: libcurl4
114
- <% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204|debian10|debian11/ %>
115
- <% packages << 'libcurl4' %>
116
- <% else %>
117
- <% packages << 'libcurl3' %>
118
- <% end %>
119
-
120
- <% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204/ %>
121
- <% packages << 'nodejs' %>
122
- <% end %>
123
-
124
75
  <% if distro =~ /ubuntu2004|ubuntu2204/ %>
125
76
  <% packages += %w(ruby bundler) %>
126
77
  <% end %>
@@ -131,33 +82,11 @@ ENV DOCKER=1
131
82
  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
83
  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
84
  <% end %>
134
- RUN apt-get update && apt-get install -y cmake
135
-
85
+ RUN apt-add-repository ppa:deadsnakes/ppa -y
86
+ RUN apt-get update && apt-get install -y cmake python3.10 python3.10-dev python3.10-venv
87
+ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
136
88
  <% else %>
137
89
 
138
- <% if distro =~ /rhel6/ %>
139
-
140
- # CentOS 6 is dead - to use it retrieve the packages from vault:
141
- # https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
142
-
143
- <%
144
-
145
- cfg = <<-CFG
146
- [base]
147
- name=CentOS-$releasever - Base
148
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
149
- #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
150
- baseurl=http://vault.centos.org/6.10/os/x86_64/
151
- gpgcheck=1
152
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
153
- CFG
154
-
155
- %>
156
-
157
- RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
158
-
159
- <% end %>
160
-
161
90
  # Enterprise server: net-snmp
162
91
  # lsb_release: redhat-lsb-core
163
92
  # our runner scripts: which
@@ -166,15 +95,15 @@ CFG
166
95
  # Kerberos tests: krb5-workstation + cyrus-sasl-devel to build the
167
96
  # mongo_kerberos gem + cyrus-sasl-gssapi for authentication to work
168
97
  # Local Kerberos server: krb5-server
169
- # JRuby: java-1.8.0-openjdk
98
+ # JRuby: java-17-openjdk
170
99
  #
171
100
  # Note: lacking cyrus-sasl-gssapi produces a cryptic message
172
101
  # "SASL(-4): no mechanism available: No worthy mechs found"
173
102
  # https://github.com/farorm/python-ad/issues/10
174
103
 
175
- RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
176
- krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
177
- net-snmp python38 python38-devel cmake nodejs
104
+ RUN yum --enablerepo=powertools install -y redhat-lsb-core which git gcc gcc-c++ libyaml-devel krb5-server \
105
+ krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-17-openjdk \
106
+ net-snmp python38 python38-devel cmake nodejs npm xz
178
107
 
179
108
  <% end %>
180
109
 
@@ -248,7 +177,6 @@ CFG
248
177
  RUN curl --retry 3 -fL <%= ruby_toolchain_url(ruby) %> |tar -xC /opt -Jf -
249
178
  ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
250
179
  USE_OPT_TOOLCHAIN=1
251
- #ENV PATH=/opt/rubies/python/3/bin:$PATH
252
180
 
253
181
  <% end %>
254
182
 
@@ -291,6 +219,8 @@ WORKDIR /app
291
219
  ENV DOCKER_PRELOAD=1
292
220
  <% end %>
293
221
 
222
+ RUN npm install --global yarn
223
+
294
224
  ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
295
225
  PROJECT_DIRECTORY=/app \
296
226
  <%= @env.map { |k, v| %Q`#{k}="#{v.gsub('$', "\\$").gsub('"', "\\\"")}"` }.join(" \\\n ") %>
@@ -64,6 +64,16 @@ _detect_distro() {
64
64
  release=`echo $release |sed -e s/7/70/ -e s/6/62/ -e s/8/80/`
65
65
  distro=rhel$release
66
66
  fi
67
+ elif test -f /etc/os-release; then
68
+ name=`grep -o '^NAME=.*' /etc/os-release | awk -F '"' '{ print $2 }'`
69
+ version=`grep -o '^VERSION=.*' /etc/os-release | awk -F '"' '{ print $2 }'`
70
+ if test "$name" = "Amazon Linux"; then
71
+ distro=amazon$version
72
+ else
73
+ cat /etc/os-release
74
+ echo 'Unknown distro' 1>&2
75
+ exit 1
76
+ fi
67
77
  else
68
78
  lsb_release -a
69
79
  echo 'Unknown distro' 1>&2
@@ -35,38 +35,34 @@ add_uri_option() {
35
35
  }
36
36
 
37
37
  prepare_server() {
38
- arch=$1
39
-
40
38
  if test -n "$USE_OPT_MONGODB"; then
41
39
  export BINDIR=/opt/mongodb/bin
42
40
  export PATH=$BINDIR:$PATH
43
41
  return
44
42
  fi
45
43
 
46
- if test "$MONGODB_VERSION" = latest; then
47
- # Test on the most recent published 4.3 release.
48
- # https://jira.mongodb.org/browse/RUBY-1724
44
+ . $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
49
45
 
50
- . $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
51
-
52
- get_distro
53
- get_mongodb_download_url_for "$DISTRO" "latest"
54
- prepare_server_from_url $MONGODB_DOWNLOAD_URL
55
- else
56
- download_version="$MONGODB_VERSION"
57
- url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
58
- prepare_server_from_url $url
59
- fi
46
+ get_distro
47
+ arch="${1:-$DISTRO}"
60
48
 
49
+ get_mongodb_download_url_for "$arch" "$MONGODB_VERSION"
50
+ prepare_server_from_url "$MONGODB_DOWNLOAD_URL" "$MONGOSH_DOWNLOAD_URL"
61
51
  }
62
52
 
63
53
  prepare_server_from_url() {
64
- url=$1
54
+ server_url=$1
55
+ mongosh_url=$2
65
56
 
66
- dirname=`basename $url |sed -e s/.tgz//`
57
+ dirname=`basename $server_url |sed -e s/.tgz//`
67
58
  mongodb_dir="$MONGO_ORCHESTRATION_HOME"/mdb/"$dirname"
68
59
  mkdir -p "$mongodb_dir"
69
- curl --retry 3 $url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
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
+
70
66
  BINDIR="$mongodb_dir"/bin
71
67
  export PATH="$BINDIR":$PATH
72
68
  }
@@ -104,6 +100,7 @@ install_mlaunch_venv() {
104
100
  #pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
105
101
 
106
102
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
103
+ pip install --upgrade setuptools
107
104
  pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
108
105
  fi
109
106
  }
@@ -169,13 +166,26 @@ install_mlaunch_git() {
169
166
  fi
170
167
  }
171
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
+
172
182
  install_cmake() {
173
183
  if ! command -v cmake &> /dev/null; then
174
184
  if ! command -v apt-get &> /dev/null; then
175
185
  # no apt-get; assume RHEL
176
186
  sudo yum -y install cmake libarchive
177
187
  else
178
- sudo apt-get install --yes cmake
188
+ sudo apt-get update && sudo apt-get install --yes cmake
179
189
  fi
180
190
  else
181
191
  echo 'cmake is present'
@@ -208,17 +218,14 @@ calculate_server_args() {
208
218
  args="$args --setParameter acceptAPIVersion2=1"
209
219
  fi
210
220
 
211
- # diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
212
- # and mlaunch does not support specifying mongod-only parameters:
213
- # https://github.com/rueckstiess/mtools/issues/696
214
- # Pass it to 3.4 and newer servers where it is accepted by all daemons.
215
- if test $mongo_version -ge 34; then
216
- args="$args --setParameter diagnosticDataCollectionEnabled=false"
217
- fi
221
+ args="$args --setParameter diagnosticDataCollectionEnabled=false"
222
+
218
223
  local uri_options=
219
224
  if test "$TOPOLOGY" = replica-set; then
220
225
  args="$args --replicaset --name test-rs --nodes 2 --arbiter"
221
226
  export HAVE_ARBITER=1
227
+ elif test "$TOPOLOGY" = replica-set-single-node; then
228
+ args="$args --replicaset --name test-rs --nodes 1"
222
229
  elif test "$TOPOLOGY" = sharded-cluster; then
223
230
  args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
224
231
  if test -z "$SINGLE_MONGOS"; then
@@ -1,39 +1,15 @@
1
1
  # When changing, also update the hash in share/Dockerfile.
2
- TOOLCHAIN_VERSION=e8c60866f54bed7e336a37df3a97d6ae1b971b7d
2
+ JDK_VERSION=jdk21
3
3
 
4
4
  set_env_java() {
5
5
  ls -l /opt || true
6
6
  ls -l /usr/lib/jvm || true
7
7
 
8
8
  # Use toolchain java if it exists
9
- if [ -f /opt/java/jdk8/bin/java ]; then
10
- export JAVACMD=/opt/java/jdk8/bin/java
11
- #export PATH=$PATH:/opt/java/jdk8/bin
12
- fi
13
-
14
- # ppc64le has it in a different place
15
- if test -z "$JAVACMD" && [ -f /usr/lib/jvm/java-1.8.0/bin/java ]; then
16
- export JAVACMD=/usr/lib/jvm/java-1.8.0/bin/java
17
- #export PATH=$PATH:/usr/lib/jvm/java-1.8.0/bin
18
- fi
19
-
20
- if true; then
21
- # newer
22
- # rhel71-ppc, https://jira.mongodb.org/browse/BUILD-9231
23
- if test -z "$JAVACMD" &&
24
- (ls /opt/java || true) |grep -q java-1.8.0-openjdk-1.8.0 &&
25
- test -f /opt/java/java-1.8.0-openjdk-1.8.0*/bin/java;
26
- then
27
- path=$(cd /opt/java && ls -d java-1.8.0-openjdk-1.8.0* |head -n 1)
28
- export JAVACMD=/opt/java/"$path"/bin/java
29
- fi
9
+ if [ -f /opt/java/$JDK_VERSION/bin/java ]; then
10
+ export JAVACMD=/opt/java/$JDK_VERSION/bin/java
30
11
  else
31
- # older
32
- # rhel71-ppc seems to have an /opt/java/jdk8/bin/java but it doesn't work
33
- if test -n "$JAVACMD" && ! exec $JAVACMD -version; then
34
- JAVACMD=
35
- # we will try the /usr/lib/jvm then
36
- fi
12
+ echo Could not find $JDK_VERSION in /opt/java
37
13
  fi
38
14
 
39
15
  if test -n "$JAVACMD"; then
@@ -113,34 +89,13 @@ set_env_ruby() {
113
89
  if test "$USE_OPT_TOOLCHAIN" = 1; then
114
90
  # Nothing, also PATH is already set
115
91
  :
116
- elif true; then
117
-
118
- # For testing toolchains:
119
- #toolchain_url=https://s3.amazonaws.com//mciuploads/mongo-ruby-toolchain/`host_distro`/f11598d091441ffc8d746aacfdc6c26741a3e629/mongo_ruby_driver_toolchain_`host_distro |tr - _`_patch_f11598d091441ffc8d746aacfdc6c26741a3e629_5e46f2793e8e866f36eda2c5_20_02_14_19_18_18.tar.gz
120
- toolchain_url=http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/$TOOLCHAIN_VERSION/`host_distro`/$RVM_RUBY.tar.xz
121
- curl --retry 3 -fL $toolchain_url |tar Jxf -
122
- export PATH=`pwd`/rubies/$RVM_RUBY/bin:$PATH
123
- #export PATH=`pwd`/rubies/python/3/bin:$PATH
124
-
125
- # Attempt to get bundler to report all errors - so far unsuccessful
126
- #curl --retry 3 -o bundler-openssl.diff https://github.com/bundler/bundler/compare/v2.0.1...p-mongo:report-errors.diff
127
- #find . -path \*/lib/bundler/fetcher.rb -exec patch {} bundler-openssl.diff \;
128
-
129
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
130
95
 
131
- # Normal operation
132
- if ! test -d $HOME/.rubies/$RVM_RUBY/bin; then
133
- echo "Ruby directory does not exist: $HOME/.rubies/$RVM_RUBY/bin" 1>&2
134
- echo "Contents of /opt:" 1>&2
135
- ls -l /opt 1>&2 || true
136
- echo ".rubies symlink:" 1>&2
137
- ls -ld $HOME/.rubies 1>&2 || true
138
- echo "Our rubies:" 1>&2
139
- ls -l $HOME/.rubies 1>&2 || true
140
- exit 2
141
- fi
142
- export PATH=$HOME/.rubies/$RVM_RUBY/bin:$PATH
143
-
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
144
99
  fi
145
100
 
146
101
  ruby --version
@@ -151,19 +106,5 @@ set_env_ruby() {
151
106
 
152
107
  ruby -v |fgrep $ruby_name
153
108
  ruby -v |fgrep $ruby_version
154
-
155
- # We shouldn't need to update rubygems, and there is value in
156
- # testing on whatever rubygems came with each supported ruby version
157
- #echo 'updating rubygems'
158
- #gem update --system
159
-
160
- # Only install bundler when not using ruby-head.
161
- # ruby-head comes with bundler and gem complains
162
- # because installing bundler would overwrite the bundler binary.
163
- # We now install bundler in the toolchain, hence nothing needs to be done
164
- # in the tests.
165
- if false && echo "$RVM_RUBY" |grep -q jruby; then
166
- gem install bundler -v '<2'
167
- fi
168
109
  fi
169
110
  }
@@ -2,27 +2,30 @@
2
2
 
3
3
  module Mongoid
4
4
  module Expectations
5
-
6
- def connection_class
7
- if defined?(Mongo::Server::ConnectionBase)
8
- Mongo::Server::ConnectionBase
9
- else
10
- # Pre-2.8 drivers
11
- Mongo::Server::Connection
5
+ # Previously this method used RSpec::Mocks with .exactly.times(n).and_call_original,
6
+ # which stopped working reliably in Ruby 3.3. Now we directly wrap the target method.
7
+ def expect_query(number)
8
+ if %i[ sharded load-balanced ].include?(ClusterConfig.instance.topology) && number > 0
9
+ skip 'This spec requires replica set or standalone topology'
12
10
  end
13
- end
14
11
 
15
- def expect_query(number)
16
- rv = nil
17
- RSpec::Mocks.with_temporary_scope do
18
- if number > 0
19
- expect_any_instance_of(connection_class).to receive(:command_started).exactly(number).times.and_call_original
20
- else
21
- expect_any_instance_of(connection_class).not_to receive(:command_started)
12
+ klass = Mongo::Server::ConnectionBase
13
+ original_method = klass.instance_method(:command_started)
14
+ query_count = 0
15
+
16
+ begin
17
+ klass.define_method(:command_started) do |*args, **kwargs|
18
+ query_count += 1
19
+ original_method.bind_call(self, *args, **kwargs)
22
20
  end
23
- rv = yield
21
+
22
+ result = yield
23
+ expect(query_count).to eq(number)
24
+ result
25
+ ensure
26
+ klass.remove_method(:command_started)
27
+ klass.define_method(:command_started, original_method)
24
28
  end
25
- rv
26
29
  end
27
30
 
28
31
  def expect_no_queries(&block)
@@ -23,6 +23,7 @@ class Band
23
23
  field :mojo, type: Object
24
24
  field :tags, type: Hash
25
25
  field :fans
26
+ field :location, type: LatLng
26
27
 
27
28
  embeds_many :records, cascade_callbacks: true
28
29
  embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
@@ -4,6 +4,8 @@ class LatLng
4
4
  attr_accessor :lat, :lng
5
5
 
6
6
  def self.demongoize(object)
7
+ return if object.nil?
8
+
7
9
  LatLng.new(object[1], object[0])
8
10
  end
9
11
 
@@ -14,4 +16,8 @@ class LatLng
14
16
  def mongoize
15
17
  [ lng, lat ]
16
18
  end
19
+
20
+ def ==(other)
21
+ lat == other.lat && lng == other.lng
22
+ end
17
23
  end
@@ -4,6 +4,8 @@ class Name
4
4
  include Mongoid::Document
5
5
  include Mongoid::Attributes::Dynamic
6
6
 
7
+ validate :is_not_jamis
8
+
7
9
  field :_id, type: String, overwrite: true, default: ->{
8
10
  "#{first_name}-#{last_name}"
9
11
  }
@@ -23,4 +25,12 @@ class Name
23
25
  def set_parent=(set = false)
24
26
  self.parent_title = namable.title if set
25
27
  end
28
+
29
+ private
30
+
31
+ def is_not_jamis
32
+ if first_name == 'Jamis' && last_name == 'Buck'
33
+ errors.add(:base, :invalid)
34
+ end
35
+ end
26
36
  end