mongoid 7.3.2 → 7.3.5

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 (64) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/config/locales/en.yml +13 -0
  4. data/lib/mongoid/association/embedded/batchable.rb +20 -1
  5. data/lib/mongoid/association/referenced/has_many/enumerable.rb +3 -7
  6. data/lib/mongoid/association/referenced/has_many/proxy.rb +2 -2
  7. data/lib/mongoid/association/relatable.rb +2 -0
  8. data/lib/mongoid/atomic/paths/embedded/many.rb +19 -0
  9. data/lib/mongoid/atomic.rb +26 -2
  10. data/lib/mongoid/config/environment.rb +9 -1
  11. data/lib/mongoid/contextual/atomic.rb +7 -2
  12. data/lib/mongoid/contextual/none.rb +3 -0
  13. data/lib/mongoid/criteria/queryable/selectable.rb +2 -2
  14. data/lib/mongoid/criteria/queryable/storable.rb +5 -5
  15. data/lib/mongoid/document.rb +3 -2
  16. data/lib/mongoid/errors/empty_config_file.rb +26 -0
  17. data/lib/mongoid/errors/invalid_config_file.rb +26 -0
  18. data/lib/mongoid/errors.rb +2 -0
  19. data/lib/mongoid/persistable/upsertable.rb +1 -1
  20. data/lib/mongoid/persistence_context.rb +3 -1
  21. data/lib/mongoid/query_cache.rb +11 -1
  22. data/lib/mongoid/tasks/database.rb +1 -1
  23. data/lib/mongoid/touchable.rb +10 -0
  24. data/lib/mongoid/version.rb +1 -1
  25. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +7 -2
  26. data/spec/integration/associations/embeds_many_spec.rb +139 -0
  27. data/spec/integration/contextual/empty_spec.rb +142 -0
  28. data/spec/integration/stringified_symbol_field_spec.rb +2 -2
  29. data/spec/lite_spec_helper.rb +8 -1
  30. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +21 -0
  31. data/spec/mongoid/association/embedded/embeds_many_models.rb +137 -0
  32. data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +20 -0
  33. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +8 -0
  34. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +244 -92
  35. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +30 -14
  36. data/spec/mongoid/association/referenced/has_many_models.rb +17 -0
  37. data/spec/mongoid/clients/factory_spec.rb +9 -3
  38. data/spec/mongoid/clients/options_spec.rb +11 -5
  39. data/spec/mongoid/config/environment_spec.rb +86 -8
  40. data/spec/mongoid/config_spec.rb +89 -16
  41. data/spec/mongoid/contextual/atomic_spec.rb +64 -25
  42. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  43. data/spec/mongoid/copyable_spec.rb +1 -1
  44. data/spec/mongoid/criteria_spec.rb +32 -0
  45. data/spec/mongoid/document_spec.rb +21 -1
  46. data/spec/mongoid/errors/invalid_config_file_spec.rb +32 -0
  47. data/spec/mongoid/persistable/updatable_spec.rb +2 -0
  48. data/spec/mongoid/query_cache_spec.rb +26 -2
  49. data/spec/mongoid/scopable_spec.rb +11 -0
  50. data/spec/mongoid/touchable_spec.rb +18 -0
  51. data/spec/mongoid/touchable_spec_models.rb +2 -0
  52. data/spec/shared/lib/mrss/cluster_config.rb +6 -1
  53. data/spec/shared/lib/mrss/constraints.rb +21 -4
  54. data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
  55. data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
  56. data/spec/shared/lib/mrss/session_registry.rb +69 -0
  57. data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
  58. data/spec/shared/share/Dockerfile.erb +8 -7
  59. data/spec/shared/shlib/server.sh +72 -22
  60. data/spec/support/models/audible_sound.rb +3 -0
  61. data.tar.gz.sig +0 -0
  62. metadata +627 -608
  63. metadata.gz.sig +0 -0
  64. data/spec/support/session_registry.rb +0 -50
@@ -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
@@ -71,7 +71,7 @@ install_mlaunch_virtualenv() {
71
71
  venvpath="$MONGO_ORCHESTRATION_HOME"/venv
72
72
  python2 -m virtualenv -p python2 $venvpath
73
73
  . $venvpath/bin/activate
74
- pip install 'mtools-legacy[mlaunch]'
74
+ pip install 'mtools-legacy[mlaunch]==1.5.5'
75
75
  fi
76
76
  }
77
77
 
@@ -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,26 +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
-
155
+
150
156
  if test $mongo_version -ge 50; then
151
157
  args="$args --setParameter acceptApiVersion2=1"
152
158
  elif test $mongo_version -ge 47; then
153
159
  args="$args --setParameter acceptAPIVersion2=1"
154
160
  fi
155
-
161
+
156
162
  # diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
157
163
  # and mlaunch does not support specifying mongod-only parameters:
158
164
  # https://github.com/rueckstiess/mtools/issues/696
@@ -181,7 +187,7 @@ calculate_server_args() {
181
187
  haproxy_config=$MRSS_ROOT/share/haproxy-1.conf
182
188
  else
183
189
  args="$args --mongos 2"
184
- haproxy_config=$MRSS_ROOT/share/haproxy-1.conf
190
+ haproxy_config=$MRSS_ROOT/share/haproxy-2.conf
185
191
  fi
186
192
  uri_options="$uri_options&loadBalanced=true"
187
193
  else
@@ -209,7 +215,6 @@ calculate_server_args() {
209
215
  fi
210
216
  fi
211
217
 
212
- local server_cert_path server_ca_path server_client_cert_path
213
218
  if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
214
219
  if test -n "$OCSP_ALGORITHM"; then
215
220
  if test "$OCSP_MUST_STAPLE" = 1; then
@@ -288,7 +293,7 @@ calculate_server_args() {
288
293
  ocsp_args="$ocsp_args --fault $OCSP_STATUS"
289
294
  fi
290
295
  fi
291
-
296
+
292
297
  OCSP_ARGS="$ocsp_args"
293
298
  SERVER_ARGS="$args"
294
299
  URI_OPTIONS="$uri_options"
@@ -306,12 +311,57 @@ launch_server() {
306
311
  local dbdir="$1"
307
312
  python -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
308
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
+
309
359
  if test "$TOPOLOGY" = load-balanced; then
310
360
  if test -z "$haproxy_config"; then
311
361
  echo haproxy_config should have been set 1>&2
312
362
  exit 3
313
363
  fi
314
-
364
+
315
365
  haproxy -D -f $haproxy_config -p $mongodb_dir/haproxy.pid
316
366
  fi
317
367
  }
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AudibleSound < Sound; end
data.tar.gz.sig CHANGED
Binary file