mongoid 7.2.2 → 7.2.6
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/config/locales/en.yml +13 -0
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +1 -1
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/proxy.rb +1 -1
- data/lib/mongoid/association/relatable.rb +2 -0
- data/lib/mongoid/config/environment.rb +9 -1
- data/lib/mongoid/contextual/atomic.rb +7 -2
- data/lib/mongoid/contextual/none.rb +3 -0
- data/lib/mongoid/criteria/queryable/selectable.rb +2 -2
- data/lib/mongoid/criteria/queryable/storable.rb +4 -4
- data/lib/mongoid/criteria.rb +1 -1
- data/lib/mongoid/document.rb +3 -2
- data/lib/mongoid/errors/empty_config_file.rb +26 -0
- data/lib/mongoid/errors/invalid_config_file.rb +26 -0
- data/lib/mongoid/errors/mongoid_error.rb +1 -1
- data/lib/mongoid/errors.rb +2 -0
- data/lib/mongoid/interceptable.rb +1 -1
- data/lib/mongoid/persistence_context.rb +3 -1
- data/lib/mongoid/query_cache.rb +11 -1
- data/lib/mongoid/tasks/database.rb +1 -1
- data/lib/mongoid/validatable/associated.rb +1 -1
- data/lib/mongoid/validatable/presence.rb +3 -3
- data/lib/mongoid/validatable/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid.rb +1 -0
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
- data/spec/integration/app_spec.rb +3 -0
- data/spec/integration/contextual/empty_spec.rb +142 -0
- data/spec/integration/stringified_symbol_field_spec.rb +2 -2
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +17 -4
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +17 -0
- data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +20 -0
- data/spec/mongoid/association/referenced/has_many_models.rb +17 -0
- data/spec/mongoid/clients/factory_spec.rb +9 -3
- data/spec/mongoid/clients/options_spec.rb +11 -3
- data/spec/mongoid/config/environment_spec.rb +86 -8
- data/spec/mongoid/contextual/atomic_spec.rb +64 -25
- data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
- data/spec/mongoid/criteria_spec.rb +4 -0
- data/spec/mongoid/document_fields_spec.rb +26 -0
- data/spec/mongoid/document_query_spec.rb +51 -0
- data/spec/mongoid/document_spec.rb +21 -1
- data/spec/mongoid/errors/invalid_config_file_spec.rb +32 -0
- data/spec/mongoid/errors/mongoid_error_spec.rb +20 -8
- data/spec/mongoid/persistable/updatable_spec.rb +2 -0
- data/spec/mongoid/persistable_spec.rb +2 -2
- data/spec/mongoid/query_cache_spec.rb +24 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/cluster_config.rb +8 -3
- data/spec/shared/lib/mrss/constraints.rb +49 -10
- data/spec/shared/lib/mrss/docker_runner.rb +7 -1
- data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
- data/spec/shared/lib/mrss/spec_organizer.rb +29 -2
- data/spec/shared/share/Dockerfile.erb +127 -35
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/server.sh +100 -23
- data/spec/shared/shlib/set_env.sh +4 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/models/address.rb +4 -0
- data/spec/support/models/mop.rb +10 -0
- data/spec/support/models/person.rb +9 -0
- data.tar.gz.sig +0 -0
- metadata +549 -519
- metadata.gz.sig +0 -0
@@ -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-
|
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
|
-
|
82
|
-
|
82
|
+
haproxy
|
83
|
+
python3-pip
|
84
|
+
tzdata shared-mime-info
|
83
85
|
) %>
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
<% packages
|
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,23 +185,69 @@ 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
|
|
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/ %>
|
216
|
+
|
217
|
+
# Ubuntu 12.04 ships pip 1.0 which is ancient and does not work.
|
218
|
+
#
|
219
|
+
# Ubuntu 16.04 apparently also ships a pip that does not work:
|
220
|
+
# https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry
|
221
|
+
# Potentially this only affects environments with less than ideal
|
222
|
+
# connectivity (or, perhaps, when python package registry is experiencing
|
223
|
+
# availability issues) when pip must retry to install packages.
|
224
|
+
#
|
225
|
+
# rhel apparently does not package pip at all in core repoitories,
|
226
|
+
# therefore install it the manual way.
|
227
|
+
#
|
228
|
+
# https://pip.pypa.io/en/stable/installing/
|
229
|
+
RUN curl --retry 3 -fL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
|
230
|
+
|
231
|
+
<% end %>
|
232
|
+
|
142
233
|
# Current virtualenv fails with
|
143
234
|
# https://github.com/pypa/virtualenv/issues/1630
|
144
|
-
|
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]'
|
239
|
+
<% end %>
|
145
240
|
|
146
241
|
RUN pip --version && \
|
147
242
|
pip install mtools-legacy[mlaunch]
|
148
243
|
|
149
244
|
<% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
|
150
|
-
|
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
|
151
248
|
<% end %>
|
152
249
|
|
153
|
-
<% unless ruby_head? %>
|
250
|
+
<% unless ruby_head? || system_ruby? %>
|
154
251
|
|
155
252
|
RUN curl --retry 3 -fL <%= ruby_toolchain_url %> |tar -xC /opt -Jf -
|
156
253
|
ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
|
@@ -159,30 +256,20 @@ FROM <%= base_image %>
|
|
159
256
|
|
160
257
|
<% end %>
|
161
258
|
|
162
|
-
<% if distro =~ /rhel|ubuntu1604/ %>
|
163
|
-
|
164
|
-
# Ubuntu 12.04 ships pip 1.0 which is ancient and does not work.
|
165
|
-
#
|
166
|
-
# Ubuntu 16.04 apparently also ships a pip that does not work:
|
167
|
-
# https://stackoverflow.com/questions/37495375/python-pip-install-throws-typeerror-unsupported-operand-types-for-retry
|
168
|
-
# Potentially this only affects environments with less than ideal
|
169
|
-
# connectivity (or, perhaps, when python package registry is experiencing
|
170
|
-
# availability issues) when pip must retry to install packages.
|
171
|
-
#
|
172
|
-
# rhel apparently does not package pip at all in core repoitories,
|
173
|
-
# therefore install it the manual way.
|
174
|
-
#
|
175
|
-
# https://pip.pypa.io/en/stable/installing/
|
176
|
-
RUN curl --retry 3 -fL https://bootstrap.pypa.io/pip/2.7/get-pip.py | python
|
177
|
-
|
178
|
-
<% end %>
|
179
|
-
|
180
259
|
RUN curl --retry 3 -fL <%= server_download_url %> |tar xzf - && \
|
181
260
|
mv mongo*/ /opt/mongodb
|
182
261
|
ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
|
183
262
|
|
184
263
|
<% end %>
|
185
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
|
271
|
+
<% end %>
|
272
|
+
|
186
273
|
WORKDIR /app
|
187
274
|
|
188
275
|
<% if preload? && !ruby_head? %>
|
@@ -193,7 +280,12 @@ WORKDIR /app
|
|
193
280
|
COPY lib/<%= project_lib_subdir %>/version.rb lib/<%= project_lib_subdir %>/version.rb
|
194
281
|
RUN bundle install
|
195
282
|
COPY .evergreen/patch-debuggers .evergreen/patch-debuggers
|
196
|
-
|
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 %>
|
197
289
|
|
198
290
|
<% end %>
|
199
291
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Modeled after
|
2
|
+
# https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-load-balancer.sh
|
3
|
+
|
4
|
+
defaults
|
5
|
+
mode tcp
|
6
|
+
timeout connect 7s
|
7
|
+
timeout client 55s
|
8
|
+
timeout server 55s
|
9
|
+
|
10
|
+
frontend mongos_frontend
|
11
|
+
bind *:27017
|
12
|
+
use_backend mongos_backend
|
13
|
+
|
14
|
+
backend mongos_backend
|
15
|
+
mode tcp
|
16
|
+
server mongos_one 127.0.0.1:27117 check
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Modeled after
|
2
|
+
# https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-load-balancer.sh
|
3
|
+
|
4
|
+
defaults
|
5
|
+
mode tcp
|
6
|
+
timeout connect 7s
|
7
|
+
timeout client 55s
|
8
|
+
timeout server 55s
|
9
|
+
|
10
|
+
frontend mongos_frontend
|
11
|
+
bind *:27017
|
12
|
+
use_backend mongos_backend
|
13
|
+
|
14
|
+
backend mongos_backend
|
15
|
+
mode tcp
|
16
|
+
server mongos_one 127.0.0.1:27117 check
|
17
|
+
server mongos_two 127.0.0.1:27118 check
|
data/spec/shared/shlib/server.sh
CHANGED
@@ -10,21 +10,21 @@ set_fcv() {
|
|
10
10
|
|
11
11
|
add_uri_option() {
|
12
12
|
opt=$1
|
13
|
-
|
13
|
+
|
14
14
|
if ! echo $MONGODB_URI |sed -e s,//,, |grep -q /; then
|
15
15
|
MONGODB_URI="$MONGODB_URI/"
|
16
16
|
fi
|
17
|
-
|
17
|
+
|
18
18
|
if ! echo $MONGODB_URI |grep -q '?'; then
|
19
19
|
MONGODB_URI="$MONGODB_URI?"
|
20
20
|
fi
|
21
|
-
|
21
|
+
|
22
22
|
MONGODB_URI="$MONGODB_URI&$opt"
|
23
23
|
}
|
24
24
|
|
25
25
|
prepare_server() {
|
26
26
|
arch=$1
|
27
|
-
|
27
|
+
|
28
28
|
if test -n "$USE_OPT_MONGODB"; then
|
29
29
|
export BINDIR=/opt/mongodb/bin
|
30
30
|
export PATH=$BINDIR:$PATH
|
@@ -39,7 +39,7 @@ prepare_server() {
|
|
39
39
|
else
|
40
40
|
download_version="$MONGODB_VERSION"
|
41
41
|
fi
|
42
|
-
|
42
|
+
|
43
43
|
url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
|
44
44
|
|
45
45
|
prepare_server_from_url $url
|
@@ -80,7 +80,7 @@ install_mlaunch_pip() {
|
|
80
80
|
# mlaunch is preinstalled in the docker image, do not install it here
|
81
81
|
return
|
82
82
|
fi
|
83
|
-
|
83
|
+
|
84
84
|
python -V || true
|
85
85
|
python3 -V || true
|
86
86
|
pythonpath="$MONGO_ORCHESTRATION_HOME"/python
|
@@ -96,20 +96,20 @@ install_mlaunch_git() {
|
|
96
96
|
python3 -V || true
|
97
97
|
which pip || true
|
98
98
|
which pip3 || true
|
99
|
-
|
99
|
+
|
100
100
|
if false; then
|
101
101
|
if ! virtualenv --version; then
|
102
102
|
python3 `which pip3` install --user virtualenv
|
103
103
|
export PATH=$HOME/.local/bin:$PATH
|
104
104
|
virtualenv --version
|
105
105
|
fi
|
106
|
-
|
106
|
+
|
107
107
|
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
108
108
|
virtualenv -p python3 $venvpath
|
109
109
|
. $venvpath/bin/activate
|
110
|
-
|
110
|
+
|
111
111
|
pip3 install psutil pymongo
|
112
|
-
|
112
|
+
|
113
113
|
git clone $repo mlaunch
|
114
114
|
cd mlaunch
|
115
115
|
git checkout origin/$branch
|
@@ -118,13 +118,13 @@ install_mlaunch_git() {
|
|
118
118
|
else
|
119
119
|
pip install --user 'virtualenv==13'
|
120
120
|
export PATH=$HOME/.local/bin:$PATH
|
121
|
-
|
121
|
+
|
122
122
|
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
123
123
|
virtualenv $venvpath
|
124
124
|
. $venvpath/bin/activate
|
125
|
-
|
125
|
+
|
126
126
|
pip install psutil pymongo
|
127
|
-
|
127
|
+
|
128
128
|
git clone $repo mlaunch
|
129
129
|
(cd mlaunch &&
|
130
130
|
git checkout origin/$branch &&
|
@@ -133,24 +133,32 @@ install_mlaunch_git() {
|
|
133
133
|
fi
|
134
134
|
}
|
135
135
|
|
136
|
+
# This function sets followong global variables:
|
137
|
+
# server_cert_path
|
138
|
+
# server_ca_path
|
139
|
+
# server_client_cert_path
|
140
|
+
#
|
141
|
+
# These variables are used later to connect to processes via mongo client.
|
136
142
|
calculate_server_args() {
|
137
143
|
local mongo_version=`echo $MONGODB_VERSION |tr -d .`
|
138
|
-
|
144
|
+
|
139
145
|
if test -z "$mongo_version"; then
|
140
146
|
echo "$MONGODB_VERSION must be set and not contain only dots" 1>&2
|
141
147
|
exit 3
|
142
148
|
fi
|
143
|
-
|
149
|
+
|
144
150
|
if test $mongo_version = latest; then
|
145
151
|
mongo_version=49
|
146
152
|
fi
|
147
153
|
|
148
154
|
local args="--setParameter enableTestCommands=1"
|
149
|
-
|
150
|
-
if test $mongo_version -ge
|
155
|
+
|
156
|
+
if test $mongo_version -ge 50; then
|
157
|
+
args="$args --setParameter acceptApiVersion2=1"
|
158
|
+
elif test $mongo_version -ge 47; then
|
151
159
|
args="$args --setParameter acceptAPIVersion2=1"
|
152
160
|
fi
|
153
|
-
|
161
|
+
|
154
162
|
# diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
|
155
163
|
# and mlaunch does not support specifying mongod-only parameters:
|
156
164
|
# https://github.com/rueckstiess/mtools/issues/696
|
@@ -160,15 +168,31 @@ calculate_server_args() {
|
|
160
168
|
fi
|
161
169
|
local uri_options=
|
162
170
|
if test "$TOPOLOGY" = replica-set; then
|
163
|
-
args="$args --replicaset --name
|
171
|
+
args="$args --replicaset --name test-rs --nodes 2 --arbiter"
|
164
172
|
export HAVE_ARBITER=1
|
165
173
|
elif test "$TOPOLOGY" = sharded-cluster; then
|
166
|
-
args="$args --replicaset --nodes 2 --sharded 1 --name
|
174
|
+
args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
|
167
175
|
if test -z "$SINGLE_MONGOS"; then
|
168
176
|
args="$args --mongos 2"
|
169
177
|
fi
|
170
|
-
|
178
|
+
elif test "$TOPOLOGY" = standalone; then
|
171
179
|
args="$args --single"
|
180
|
+
elif test "$TOPOLOGY" = load-balanced; then
|
181
|
+
args="$args --replicaset --nodes 2 --sharded 1 --name test-rs --port 27117"
|
182
|
+
if test -z "$MRSS_ROOT"; then
|
183
|
+
echo "Please set MRSS_ROOT" 1>&2
|
184
|
+
exit 2
|
185
|
+
fi
|
186
|
+
if test -n "$SINGLE_MONGOS"; then
|
187
|
+
haproxy_config=$MRSS_ROOT/share/haproxy-1.conf
|
188
|
+
else
|
189
|
+
args="$args --mongos 2"
|
190
|
+
haproxy_config=$MRSS_ROOT/share/haproxy-2.conf
|
191
|
+
fi
|
192
|
+
uri_options="$uri_options&loadBalanced=true"
|
193
|
+
else
|
194
|
+
echo "Unknown topology: $TOPOLOGY" 1>&2
|
195
|
+
exit 1
|
172
196
|
fi
|
173
197
|
if test -n "$MMAPV1"; then
|
174
198
|
args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
|
@@ -191,7 +215,6 @@ calculate_server_args() {
|
|
191
215
|
fi
|
192
216
|
fi
|
193
217
|
|
194
|
-
local server_cert_path server_ca_path server_client_cert_path
|
195
218
|
if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
|
196
219
|
if test -n "$OCSP_ALGORITHM"; then
|
197
220
|
if test "$OCSP_MUST_STAPLE" = 1; then
|
@@ -270,7 +293,7 @@ calculate_server_args() {
|
|
270
293
|
ocsp_args="$ocsp_args --fault $OCSP_STATUS"
|
271
294
|
fi
|
272
295
|
fi
|
273
|
-
|
296
|
+
|
274
297
|
OCSP_ARGS="$ocsp_args"
|
275
298
|
SERVER_ARGS="$args"
|
276
299
|
URI_OPTIONS="$uri_options"
|
@@ -287,4 +310,58 @@ launch_ocsp_mock() {
|
|
287
310
|
launch_server() {
|
288
311
|
local dbdir="$1"
|
289
312
|
python -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
|
313
|
+
|
314
|
+
if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
|
315
|
+
# On 3.6 server the sessions collection is not immediately available,
|
316
|
+
# so we run the refreshLogicalSessionCacheNow command on the config server
|
317
|
+
# and again on each mongos in order for the mongoses
|
318
|
+
# to correctly report logicalSessionTimeoutMinutes.
|
319
|
+
mongos_regex="\s*mongos\s+([0-9]+)\s+running\s+[0-9]+"
|
320
|
+
config_server_regex="\s*config\sserver\s+([0-9]+)\s+running\s+[0-9]+"
|
321
|
+
config_server=""
|
322
|
+
mongoses=()
|
323
|
+
if test "$AUTH" = auth
|
324
|
+
then
|
325
|
+
base_url="mongodb://bob:pwd123@localhost"
|
326
|
+
else
|
327
|
+
base_url="mongodb://localhost"
|
328
|
+
fi
|
329
|
+
if test "$SSL" = "ssl"
|
330
|
+
then
|
331
|
+
mongo_command="${BINDIR}/mongo --ssl --sslPEMKeyFile $server_cert_path --sslCAFile $server_ca_path"
|
332
|
+
else
|
333
|
+
mongo_command="${BINDIR}/mongo"
|
334
|
+
fi
|
335
|
+
|
336
|
+
while read -r line
|
337
|
+
do
|
338
|
+
if [[ $line =~ $config_server_regex ]]
|
339
|
+
then
|
340
|
+
port="${BASH_REMATCH[1]}"
|
341
|
+
config_server="${base_url}:${port}"
|
342
|
+
fi
|
343
|
+
if [[ $line =~ $mongos_regex ]]
|
344
|
+
then
|
345
|
+
port="${BASH_REMATCH[1]}"
|
346
|
+
mongoses+=("${base_url}:${port}")
|
347
|
+
fi
|
348
|
+
done < <(python -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
|
349
|
+
|
350
|
+
if [ -n "$config_server" ]; then
|
351
|
+
${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
|
352
|
+
for mongos in ${mongoses[*]}
|
353
|
+
do
|
354
|
+
${mongo_command} "$mongos" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
|
355
|
+
done
|
356
|
+
fi
|
357
|
+
fi
|
358
|
+
|
359
|
+
if test "$TOPOLOGY" = load-balanced; then
|
360
|
+
if test -z "$haproxy_config"; then
|
361
|
+
echo haproxy_config should have been set 1>&2
|
362
|
+
exit 3
|
363
|
+
fi
|
364
|
+
|
365
|
+
haproxy -D -f $haproxy_config -p $mongodb_dir/haproxy.pid
|
366
|
+
fi
|
290
367
|
}
|