mongoid 7.5.4 → 7.6.0

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.
@@ -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='219833abad4d9d3bf43c0fef101a8ca082ac4ae9'
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
@@ -77,75 +48,45 @@ ENV DOCKER=1
77
48
  # therefore install python-pip in all configurations here.
78
49
 
79
50
  <% packages = %w(
80
- procps lsb-release bzip2 curl zsh
81
- git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
51
+ procps lsb-release bzip2 curl wget gpg zsh
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
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/ %>
89
60
  <% packages << 'libsnmp35' %>
61
+ <% elsif distro =~ /ubuntu2204|debian11/ %>
62
+ <% packages << 'libsnmp40' %>
90
63
  <% else %>
91
64
  <% packages << 'libsnmp30' %>
92
65
  <% end %>
93
66
 
94
- <% if distro !~ /ubuntu2004/ %>
67
+ <% if distro !~ /ubuntu2004|ubuntu2204|debian11/ %>
95
68
  <% packages << 'python-pip' %>
96
69
  <% end %>
97
70
 
98
- <% if distro =~ /debian10/ %>
99
- <% packages << 'openjdk-11-jdk-headless' %>
100
- <% elsif distro =~ /ubuntu1404/ %>
101
- # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
102
- <% else %>
103
- <% packages << 'openjdk-8-jdk-headless' %>
71
+ <% if distro =~ /ubuntu2204|debian11/ %>
72
+ <% packages << 'python3-venv' %>
104
73
  <% end %>
105
74
 
106
- # ubuntu1404, ubuntu1604: libcurl3
107
- # ubuntu1804, ubuntu2004, debian10: libcurl4
108
- <% if distro =~ /ubuntu1804|ubuntu2004|debian10/ %>
109
- <% packages << 'libcurl4' %>
110
- <% else %>
111
- <% packages << 'libcurl3' %>
75
+ <% if distro =~ /ubuntu2004|ubuntu2204/ %>
76
+ <% packages += %w(ruby bundler) %>
112
77
  <% end %>
113
78
 
114
- <% if distro =~ /ubuntu1804|ubuntu2004/ %>
115
- <% packages << 'nodejs' %>
116
- <% end %>
79
+ RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
117
80
 
118
- <% if distro =~ /ubuntu2004/ %>
119
- <% packages += %w(ruby ruby2.7 bundler) %>
81
+ <% if ubuntu? %>
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
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
120
84
  <% end %>
121
-
122
- RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
123
-
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
124
88
  <% else %>
125
89
 
126
- <% if distro =~ /rhel6/ %>
127
-
128
- # CentOS 6 is dead - to use it retrieve the packages from vault:
129
- # https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
130
-
131
- <%
132
-
133
- cfg = <<-CFG
134
- [base]
135
- name=CentOS-$releasever - Base
136
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
137
- #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
138
- baseurl=http://vault.centos.org/6.10/os/x86_64/
139
- gpgcheck=1
140
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
141
- CFG
142
-
143
- %>
144
-
145
- RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
146
-
147
- <% end %>
148
-
149
90
  # Enterprise server: net-snmp
150
91
  # lsb_release: redhat-lsb-core
151
92
  # our runner scripts: which
@@ -154,31 +95,16 @@ CFG
154
95
  # Kerberos tests: krb5-workstation + cyrus-sasl-devel to build the
155
96
  # mongo_kerberos gem + cyrus-sasl-gssapi for authentication to work
156
97
  # Local Kerberos server: krb5-server
157
- # JRuby: java-1.8.0-openjdk
98
+ # JRuby: java-17-openjdk
158
99
  #
159
100
  # Note: lacking cyrus-sasl-gssapi produces a cryptic message
160
101
  # "SASL(-4): no mechanism available: No worthy mechs found"
161
102
  # https://github.com/farorm/python-ad/issues/10
162
103
 
163
- RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
164
- krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
165
- net-snmp python3
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
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
179
107
 
180
- <% end %>
181
-
182
108
  <% end %>
183
109
 
184
110
  <% if preload? %>
@@ -220,7 +146,7 @@ CFG
220
146
  <% when 'git' %>
221
147
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
222
148
  RUN python3 -m pip install virtualenv 'pymongo>=4' python-dateutil psutil
223
-
149
+
224
150
  # Install mtools from git because released versions do not work with pymongo 4.0
225
151
  RUN git clone https://github.com/p-mongodb/mtools && \
226
152
  cd mtools && \
@@ -234,7 +160,7 @@ CFG
234
160
  <% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
235
161
  # ubuntu1604 installs MarkupSafe 0.0.0 here instead of 2.0.0+
236
162
  # as specified by dependencies, causing OCSP mock to not work.
237
- RUN python3 -mpip install asn1crypto oscrypto flask --upgrade
163
+ RUN python3 -mpip install asn1crypto oscrypto flask --upgrade --ignore-installed
238
164
  <% end %>
239
165
 
240
166
  # FLE is tested against 4.0+ servers.
@@ -243,7 +169,7 @@ CFG
243
169
  # boto3~=1.19 cryptography~=3.4.8 pykmip~=0.10.0
244
170
  # cryptography does not install due to lacking setuptools_rust
245
171
  # (either that version or anything that isn't part of system packages)
246
- RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0
172
+ RUN python3 -mpip install boto3~=1.19 cryptography pykmip~=0.10.0 'sqlalchemy<2.0.0'
247
173
  <% end %>
248
174
 
249
175
  <% unless ruby_head? || system_ruby? %>
@@ -251,14 +177,9 @@ CFG
251
177
  RUN curl --retry 3 -fL <%= ruby_toolchain_url(ruby) %> |tar -xC /opt -Jf -
252
178
  ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
253
179
  USE_OPT_TOOLCHAIN=1
254
- #ENV PATH=/opt/rubies/python/3/bin:$PATH
255
180
 
256
181
  <% end %>
257
182
 
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
183
  <% end %>
263
184
 
264
185
  <% if distro =~ /debian|ubuntu/ %>
@@ -298,6 +219,8 @@ WORKDIR /app
298
219
  ENV DOCKER_PRELOAD=1
299
220
  <% end %>
300
221
 
222
+ RUN npm install --global yarn
223
+
301
224
  ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
302
225
  PROJECT_DIRECTORY=/app \
303
226
  <%= @env.map { |k, v| %Q`#{k}="#{v.gsub('$', "\\$").gsub('"', "\\\"")}"` }.join(" \\\n ") %>
@@ -308,6 +231,9 @@ ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
308
231
 
309
232
  COPY . .
310
233
 
234
+ 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'
235
+ ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
236
+
311
237
  <% if expose? %>
312
238
 
313
239
  <% ports = [] %>
@@ -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
49
-
50
- . $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
44
+ . $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
51
45
 
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
  }
@@ -78,21 +74,33 @@ install_mlaunch_venv() {
78
74
  # https://github.com/pypa/virtualenv/issues/1630
79
75
  python3 -m pip install venv --user
80
76
  fi
77
+ if ! python3 -m ensurepip -h > /dev/null; then
78
+ # Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
79
+ # the python3-venv package is also installed (it lacks the ensurepip
80
+ # module).
81
+ sudo apt-get update && sudo apt-get install --yes python3-venv
82
+ fi
81
83
  if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
82
84
  python3 -m pip list |grep mtools
83
85
  then
84
86
  # Use the existing mtools-legacy
85
87
  :
86
88
  else
87
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
88
- python3 -m venv $venvpath
89
- . $venvpath/bin/activate
89
+ # Spawn a virtual environment, but only if one is not already
90
+ # active...
91
+ if test -z "$VIRTUAL_ENV"; then
92
+ venvpath="$MONGO_ORCHESTRATION_HOME"/venv
93
+ python3 -m venv $venvpath
94
+ . $venvpath/bin/activate
95
+ fi
96
+
90
97
  # [mlaunch] does not work:
91
98
  # https://github.com/rueckstiess/mtools/issues/856
92
99
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
93
100
  #pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
94
101
 
95
102
  # dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
103
+ pip install --upgrade setuptools
96
104
  pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
97
105
  fi
98
106
  }
@@ -158,6 +166,32 @@ install_mlaunch_git() {
158
166
  fi
159
167
  }
160
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
+
182
+ install_cmake() {
183
+ if ! command -v cmake &> /dev/null; then
184
+ if ! command -v apt-get &> /dev/null; then
185
+ # no apt-get; assume RHEL
186
+ sudo yum -y install cmake libarchive
187
+ else
188
+ sudo apt-get update && sudo apt-get install --yes cmake
189
+ fi
190
+ else
191
+ echo 'cmake is present'
192
+ fi
193
+ }
194
+
161
195
  # This function sets followong global variables:
162
196
  # server_cert_path
163
197
  # server_ca_path
@@ -173,7 +207,7 @@ calculate_server_args() {
173
207
  fi
174
208
 
175
209
  if test $mongo_version = latest; then
176
- mongo_version=60
210
+ mongo_version=70
177
211
  fi
178
212
 
179
213
  local args="--setParameter enableTestCommands=1"
@@ -184,17 +218,14 @@ calculate_server_args() {
184
218
  args="$args --setParameter acceptAPIVersion2=1"
185
219
  fi
186
220
 
187
- # diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
188
- # and mlaunch does not support specifying mongod-only parameters:
189
- # https://github.com/rueckstiess/mtools/issues/696
190
- # Pass it to 3.4 and newer servers where it is accepted by all daemons.
191
- if test $mongo_version -ge 34; then
192
- args="$args --setParameter diagnosticDataCollectionEnabled=false"
193
- fi
221
+ args="$args --setParameter diagnosticDataCollectionEnabled=false"
222
+
194
223
  local uri_options=
195
224
  if test "$TOPOLOGY" = replica-set; then
196
225
  args="$args --replicaset --name test-rs --nodes 2 --arbiter"
197
226
  export HAVE_ARBITER=1
227
+ elif test "$TOPOLOGY" = replica-set-single-node; then
228
+ args="$args --replicaset --name test-rs --nodes 1"
198
229
  elif test "$TOPOLOGY" = sharded-cluster; then
199
230
  args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
200
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=219833abad4d9d3bf43c0fef101a8ca082ac4ae9
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
@@ -53,7 +29,7 @@ set_env_python() {
53
29
  curl -fL --retry 3 https://github.com/p-mongodb/deps/raw/main/"$arch"-python37.tar.xz | \
54
30
  tar xfJ - -C /opt
55
31
  fi
56
-
32
+
57
33
  if test -d /opt/python/3.7/bin; then
58
34
  # Most Evergreen configurations.
59
35
  export PATH=/opt/python/3.7/bin:$PATH
@@ -61,7 +37,7 @@ set_env_python() {
61
37
  # Configurations that use Docker in Evergreen - these don't preload.
62
38
  export PATH=/opt/python37/bin:$PATH
63
39
  fi
64
-
40
+
65
41
  python3 -V
66
42
  fi
67
43
  }
@@ -78,7 +54,7 @@ set_env_node() {
78
54
  # Node from toolchain in Evergreen
79
55
  export PATH=/opt/node/bin:$PATH
80
56
  fi
81
-
57
+
82
58
  node -v
83
59
  }
84
60
 
@@ -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)