mongoid 7.1.7 → 7.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/Rakefile +31 -0
  5. data/lib/config/locales/en.yml +13 -0
  6. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +1 -1
  7. data/lib/mongoid/association/proxy.rb +1 -1
  8. data/lib/mongoid/association/referenced/has_many/enumerable.rb +1 -1
  9. data/lib/mongoid/association/referenced/has_many/proxy.rb +1 -1
  10. data/lib/mongoid/attributes.rb +8 -1
  11. data/lib/mongoid/config/environment.rb +9 -1
  12. data/lib/mongoid/contextual/atomic.rb +7 -2
  13. data/lib/mongoid/contextual/none.rb +3 -0
  14. data/lib/mongoid/criteria/queryable/selectable.rb +2 -2
  15. data/lib/mongoid/criteria/queryable/storable.rb +4 -4
  16. data/lib/mongoid/criteria.rb +1 -1
  17. data/lib/mongoid/document.rb +3 -2
  18. data/lib/mongoid/errors/empty_config_file.rb +26 -0
  19. data/lib/mongoid/errors/invalid_config_file.rb +26 -0
  20. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  21. data/lib/mongoid/errors.rb +2 -0
  22. data/lib/mongoid/interceptable.rb +1 -1
  23. data/lib/mongoid/persistence_context.rb +3 -1
  24. data/lib/mongoid/reloadable.rb +5 -0
  25. data/lib/mongoid/tasks/database.rb +1 -1
  26. data/lib/mongoid/validatable/associated.rb +1 -1
  27. data/lib/mongoid/validatable/presence.rb +3 -3
  28. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  29. data/lib/mongoid/version.rb +1 -1
  30. data/lib/mongoid.rb +1 -0
  31. data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
  32. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  33. data/spec/app/models/address.rb +4 -0
  34. data/spec/app/models/mop.rb +26 -0
  35. data/spec/app/models/person.rb +9 -0
  36. data/spec/integration/app_spec.rb +144 -87
  37. data/spec/integration/contextual/empty_spec.rb +142 -0
  38. data/spec/integration/document_spec.rb +21 -0
  39. data/spec/lite_spec_helper.rb +5 -5
  40. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +17 -4
  41. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +17 -0
  42. data/spec/mongoid/attributes_spec.rb +241 -0
  43. data/spec/mongoid/clients/factory_spec.rb +11 -0
  44. data/spec/mongoid/clients/options_spec.rb +11 -3
  45. data/spec/mongoid/config/environment_spec.rb +86 -8
  46. data/spec/mongoid/contextual/atomic_spec.rb +81 -29
  47. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  48. data/spec/mongoid/criteria_spec.rb +4 -0
  49. data/spec/mongoid/document_query_spec.rb +51 -0
  50. data/spec/mongoid/document_spec.rb +21 -1
  51. data/spec/mongoid/errors/invalid_config_file_spec.rb +32 -0
  52. data/spec/mongoid/errors/mongoid_error_spec.rb +20 -8
  53. data/spec/mongoid/factory_spec.rb +2 -2
  54. data/spec/mongoid/persistable/savable_spec.rb +4 -4
  55. data/spec/mongoid/persistable/settable_spec.rb +30 -0
  56. data/spec/mongoid/persistable/updatable_spec.rb +2 -0
  57. data/spec/mongoid/persistable_spec.rb +2 -2
  58. data/spec/shared/bin/get-mongodb-download-url +17 -0
  59. data/spec/shared/bin/s3-copy +45 -0
  60. data/spec/shared/bin/s3-upload +69 -0
  61. data/spec/shared/lib/mrss/cluster_config.rb +19 -4
  62. data/spec/shared/lib/mrss/constraints.rb +67 -12
  63. data/spec/shared/lib/mrss/docker_runner.rb +10 -1
  64. data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
  65. data/spec/shared/lib/mrss/lite_constraints.rb +16 -0
  66. data/spec/shared/lib/mrss/server_version_registry.rb +84 -33
  67. data/spec/shared/lib/mrss/spec_organizer.rb +32 -2
  68. data/spec/shared/lib/mrss/utils.rb +15 -0
  69. data/spec/shared/share/Dockerfile.erb +126 -32
  70. data/spec/shared/share/haproxy-1.conf +16 -0
  71. data/spec/shared/share/haproxy-2.conf +17 -0
  72. data/spec/shared/shlib/server.sh +123 -26
  73. data/spec/shared/shlib/set_env.sh +4 -1
  74. data/spec/spec_helper.rb +3 -1
  75. data/spec/support/constraints.rb +0 -226
  76. data/spec/support/spec_config.rb +8 -0
  77. data.tar.gz.sig +0 -0
  78. metadata +555 -503
  79. metadata.gz.sig +0 -0
  80. data/spec/support/child_process_helper.rb +0 -76
  81. data/spec/support/lite_constraints.rb +0 -22
@@ -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
@@ -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
@@ -57,13 +57,22 @@ prepare_server_from_url() {
57
57
 
58
58
  install_mlaunch_virtualenv() {
59
59
  python2 -V || true
60
- # Current virtualenv fails with
61
- # https://github.com/pypa/virtualenv/issues/1630
62
- python -m pip install 'virtualenv<20' --user
63
- venvpath="$MONGO_ORCHESTRATION_HOME"/venv
64
- python2 -m virtualenv -p python2 $venvpath
65
- . $venvpath/bin/activate
66
- pip install 'mtools-legacy[mlaunch]'
60
+ if ! python2 -m virtualenv -h >/dev/null; then
61
+ # Current virtualenv fails with
62
+ # https://github.com/pypa/virtualenv/issues/1630
63
+ python2 -m pip install 'virtualenv<20' --user
64
+ fi
65
+ if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
66
+ python2 -m pip list |grep mtools-legacy
67
+ then
68
+ # Use the existing mtools-legacy
69
+ :
70
+ else
71
+ venvpath="$MONGO_ORCHESTRATION_HOME"/venv
72
+ python2 -m virtualenv -p python2 $venvpath
73
+ . $venvpath/bin/activate
74
+ pip install 'mtools-legacy[mlaunch]'
75
+ fi
67
76
  }
68
77
 
69
78
  install_mlaunch_pip() {
@@ -71,7 +80,7 @@ install_mlaunch_pip() {
71
80
  # mlaunch is preinstalled in the docker image, do not install it here
72
81
  return
73
82
  fi
74
-
83
+
75
84
  python -V || true
76
85
  python3 -V || true
77
86
  pythonpath="$MONGO_ORCHESTRATION_HOME"/python
@@ -87,20 +96,20 @@ install_mlaunch_git() {
87
96
  python3 -V || true
88
97
  which pip || true
89
98
  which pip3 || true
90
-
99
+
91
100
  if false; then
92
101
  if ! virtualenv --version; then
93
102
  python3 `which pip3` install --user virtualenv
94
103
  export PATH=$HOME/.local/bin:$PATH
95
104
  virtualenv --version
96
105
  fi
97
-
106
+
98
107
  venvpath="$MONGO_ORCHESTRATION_HOME"/venv
99
108
  virtualenv -p python3 $venvpath
100
109
  . $venvpath/bin/activate
101
-
110
+
102
111
  pip3 install psutil pymongo
103
-
112
+
104
113
  git clone $repo mlaunch
105
114
  cd mlaunch
106
115
  git checkout origin/$branch
@@ -109,13 +118,13 @@ install_mlaunch_git() {
109
118
  else
110
119
  pip install --user 'virtualenv==13'
111
120
  export PATH=$HOME/.local/bin:$PATH
112
-
121
+
113
122
  venvpath="$MONGO_ORCHESTRATION_HOME"/venv
114
123
  virtualenv $venvpath
115
124
  . $venvpath/bin/activate
116
-
125
+
117
126
  pip install psutil pymongo
118
-
127
+
119
128
  git clone $repo mlaunch
120
129
  (cd mlaunch &&
121
130
  git checkout origin/$branch &&
@@ -124,13 +133,32 @@ install_mlaunch_git() {
124
133
  fi
125
134
  }
126
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.
127
142
  calculate_server_args() {
128
143
  local mongo_version=`echo $MONGODB_VERSION |tr -d .`
144
+
145
+ if test -z "$mongo_version"; then
146
+ echo "$MONGODB_VERSION must be set and not contain only dots" 1>&2
147
+ exit 3
148
+ fi
149
+
129
150
  if test $mongo_version = latest; then
130
- mongo_version=44
151
+ mongo_version=49
131
152
  fi
132
153
 
133
154
  local args="--setParameter enableTestCommands=1"
155
+
156
+ if test $mongo_version -ge 50; then
157
+ args="$args --setParameter acceptApiVersion2=1"
158
+ elif test $mongo_version -ge 47; then
159
+ args="$args --setParameter acceptAPIVersion2=1"
160
+ fi
161
+
134
162
  # diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
135
163
  # and mlaunch does not support specifying mongod-only parameters:
136
164
  # https://github.com/rueckstiess/mtools/issues/696
@@ -140,15 +168,31 @@ calculate_server_args() {
140
168
  fi
141
169
  local uri_options=
142
170
  if test "$TOPOLOGY" = replica-set; then
143
- args="$args --replicaset --name ruby-driver-rs --nodes 2 --arbiter"
171
+ args="$args --replicaset --name test-rs --nodes 2 --arbiter"
144
172
  export HAVE_ARBITER=1
145
173
  elif test "$TOPOLOGY" = sharded-cluster; then
146
- args="$args --replicaset --nodes 1 --sharded 1 --name ruby-driver-rs"
174
+ args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
147
175
  if test -z "$SINGLE_MONGOS"; then
148
176
  args="$args --mongos 2"
149
177
  fi
150
- else
178
+ elif test "$TOPOLOGY" = standalone; then
151
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
152
196
  fi
153
197
  if test -n "$MMAPV1"; then
154
198
  args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
@@ -171,7 +215,6 @@ calculate_server_args() {
171
215
  fi
172
216
  fi
173
217
 
174
- local server_cert_path server_ca_path server_client_cert_path
175
218
  if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
176
219
  if test -n "$OCSP_ALGORITHM"; then
177
220
  if test "$OCSP_MUST_STAPLE" = 1; then
@@ -250,7 +293,7 @@ calculate_server_args() {
250
293
  ocsp_args="$ocsp_args --fault $OCSP_STATUS"
251
294
  fi
252
295
  fi
253
-
296
+
254
297
  OCSP_ARGS="$ocsp_args"
255
298
  SERVER_ARGS="$args"
256
299
  URI_OPTIONS="$uri_options"
@@ -267,4 +310,58 @@ launch_ocsp_mock() {
267
310
  launch_server() {
268
311
  local dbdir="$1"
269
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
270
367
  }
@@ -68,9 +68,12 @@ set_env_ruby() {
68
68
  export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
69
69
  ruby --version
70
70
  ruby --version |grep dev
71
+ elif test "$SYSTEM_RUBY" = 1; then
72
+ # Nothing
73
+ :
71
74
  else
72
75
  if test "$USE_OPT_TOOLCHAIN" = 1; then
73
- # nothing, also PATH is already set
76
+ # Nothing, also PATH is already set
74
77
  :
75
78
  elif true; then
76
79
 
data/spec/spec_helper.rb CHANGED
@@ -35,6 +35,7 @@ require 'support/helpers'
35
35
  require 'support/macros'
36
36
  require 'support/cluster_config'
37
37
  require 'support/constraints'
38
+ require 'mrss/constraints'
38
39
 
39
40
  # Give MongoDB servers time to start up in CI environments
40
41
  if SpecConfig.instance.ci?
@@ -42,7 +43,7 @@ if SpecConfig.instance.ci?
42
43
  client = Mongo::Client.new(SpecConfig.instance.addresses)
43
44
  while starting
44
45
  begin
45
- client.command(Mongo::Server::Monitor::Connection::ISMASTER)
46
+ client.command(ping: 1)
46
47
  break
47
48
  rescue Mongo::Error::OperationFailure => e
48
49
  sleep(2)
@@ -128,6 +129,7 @@ RSpec.configure do |config|
128
129
  config.raise_errors_for_deprecations!
129
130
  config.include(Helpers)
130
131
  config.include(Mongoid::Expectations)
132
+ config.extend(Mrss::Constraints)
131
133
  config.extend(Constraints)
132
134
  config.extend(Mongoid::Macros)
133
135
 
@@ -27,230 +27,4 @@ module Constraints
27
27
  end
28
28
  end
29
29
  end
30
-
31
- def min_server_version(version)
32
- unless version =~ /\A\d+\.\d+\z/
33
- raise ArgumentError, "Version can only be major.minor: #{version}"
34
- end
35
-
36
- before(:all) do
37
- if version > ClusterConfig.instance.server_version
38
- skip "Server version #{version} or higher required, we have #{ClusterConfig.instance.server_version}"
39
- end
40
- end
41
- end
42
-
43
- def max_server_version(version)
44
- unless version =~ /\A\d+\.\d+\z/
45
- raise ArgumentError, "Version can only be major.minor: #{version}"
46
- end
47
-
48
- before(:all) do
49
- if version < ClusterConfig.instance.short_server_version
50
- skip "Server version #{version} or lower required, we have #{ClusterConfig.instance.server_version}"
51
- end
52
- end
53
- end
54
-
55
- def require_topology(*topologies)
56
- invalid_topologies = topologies - [:single, :replica_set, :sharded]
57
-
58
- unless invalid_topologies.empty?
59
- raise ArgumentError, "Invalid topologies requested: #{invalid_topologies.join(', ')}"
60
- end
61
-
62
- before(:all) do
63
- unless topologies.include?(topology = ClusterConfig.instance.topology)
64
- skip "Topology #{topologies.join(' or ')} required, we have #{topology}"
65
- end
66
- end
67
- end
68
-
69
- def max_example_run_time(timeout)
70
- around do |example|
71
- TimeoutInterrupt.timeout(timeout, TimeoutInterrupt::Error.new("Test execution terminated after #{timeout} seconds")) do
72
- example.run
73
- end
74
- end
75
- end
76
-
77
- def require_transaction_support
78
- before(:all) do
79
- case ClusterConfig.instance.topology
80
- when :single
81
- skip 'Transactions tests require a replica set (4.0+) or a sharded cluster (4.2+)'
82
- when :replica_set
83
- unless ClusterConfig.instance.server_version >= '4.0'
84
- skip 'Transactions tests in a replica set topology require server 4.0+'
85
- end
86
- when :sharded
87
- unless ClusterConfig.instance.server_version >= '4.2'
88
- skip 'Transactions tests in a sharded cluster topology require server 4.2+'
89
- end
90
- else
91
- raise NotImplementedError
92
- end
93
- end
94
- end
95
-
96
- def require_tls
97
- before(:all) do
98
- unless SpecConfig.instance.ssl?
99
- skip "SSL not enabled"
100
- end
101
- end
102
- end
103
-
104
- def require_no_tls
105
- before(:all) do
106
- if SpecConfig.instance.ssl?
107
- skip "SSL enabled"
108
- end
109
- end
110
- end
111
-
112
- def require_local_tls
113
- require_tls
114
- end
115
-
116
- def require_no_retry_writes
117
- before(:all) do
118
- if SpecConfig.instance.retry_writes?
119
- skip "Retry writes is enabled"
120
- end
121
- end
122
- end
123
-
124
- def require_compression
125
- before(:all) do
126
- if SpecConfig.instance.compressors.nil?
127
- skip "Compression is not enabled"
128
- end
129
- end
130
- end
131
-
132
- def require_no_compression
133
- before(:all) do
134
- if SpecConfig.instance.compressors
135
- skip "Compression is enabled"
136
- end
137
- end
138
- end
139
-
140
- def ruby_version_gte(version)
141
- before(:all) do
142
- if RUBY_VERSION < version
143
- skip "Ruby version #{version} or higher required"
144
- end
145
- end
146
- end
147
-
148
- def ruby_version_lt(version)
149
- before(:all) do
150
- if RUBY_VERSION >= version
151
- skip "Ruby version less than #{version} required"
152
- end
153
- end
154
- end
155
-
156
- def require_auth
157
- before(:all) do
158
- unless ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
159
- skip "Auth required"
160
- end
161
- end
162
- end
163
-
164
- def require_no_auth
165
- before(:all) do
166
- if ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
167
- skip "Auth not allowed"
168
- end
169
- end
170
- end
171
-
172
- def require_no_x509_auth
173
- before(:all) do
174
- if SpecConfig.instance.x509_auth?
175
- skip "X.509 auth not allowed"
176
- end
177
- end
178
- end
179
-
180
- # Can the driver specify a write concern that won't be overridden?
181
- # (mongos 4.0+ overrides the write concern)
182
- def require_set_write_concern
183
- before(:all) do
184
- if ClusterConfig.instance.topology == :sharded && ClusterConfig.instance.short_server_version >= '4.0'
185
- skip "mongos 4.0+ overrides write concern"
186
- end
187
- end
188
- end
189
-
190
- def require_multi_shard
191
- before(:all) do
192
- if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length == 1
193
- skip 'Test requires a minimum of two shards if run in sharded topology'
194
- end
195
- end
196
- end
197
-
198
- def require_no_multi_shard
199
- before(:all) do
200
- if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length > 1
201
- skip 'Test requires a single shard if run in sharded topology'
202
- end
203
- end
204
- end
205
-
206
- def require_wired_tiger
207
- before(:all) do
208
- if ClusterConfig.instance.storage_engine != :wired_tiger
209
- skip 'Test requires WiredTiger storage engine'
210
- end
211
- end
212
- end
213
-
214
- def require_wired_tiger_on_36
215
- before(:all) do
216
- if ClusterConfig.instance.short_server_version >= '3.6'
217
- if ClusterConfig.instance.storage_engine != :wired_tiger
218
- skip 'Test requires WiredTiger storage engine on 3.6+ servers'
219
- end
220
- end
221
- end
222
- end
223
-
224
- def require_mmapv1
225
- before(:all) do
226
- if ClusterConfig.instance.storage_engine != :mmapv1
227
- skip 'Test requires MMAPv1 storage engine'
228
- end
229
- end
230
- end
231
-
232
- def require_enterprise
233
- before(:all) do
234
- unless ClusterConfig.instance.enterprise?
235
- skip 'Test requires enterprise build of MongoDB'
236
- end
237
- end
238
- end
239
-
240
- # Integration tests for SRV polling require internet connectivity to
241
- # look up SRV records and a sharded cluster configured on default port on
242
- # localhost (localhost:27017, localhost:27018).
243
- def require_default_port_deployment
244
- # Because the DNS records at test1.test.build.10gen.cc point to
245
- # localhost:27017 & localhost:27018, the test suite must have been
246
- # configured to use these addresses
247
- before(:all) do
248
- have_default_port = SpecConfig.instance.addresses.any? do |address|
249
- %w(127.0.0.1 127.0.0.1:27017 localhost localhost:27017).include?(address)
250
- end
251
- unless have_default_port
252
- skip 'This test requires the test suite to be configured for localhost:27017'
253
- end
254
- end
255
- end
256
30
  end