mongoid 7.2.6 → 7.3.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.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/Rakefile +16 -0
  5. data/lib/config/locales/en.yml +2 -15
  6. data/lib/mongoid/association/accessors.rb +1 -1
  7. data/lib/mongoid/association/constrainable.rb +1 -1
  8. data/lib/mongoid/association/depending.rb +4 -4
  9. data/lib/mongoid/association/embedded/batchable.rb +1 -1
  10. data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
  11. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +11 -4
  12. data/lib/mongoid/association/nested/many.rb +1 -1
  13. data/lib/mongoid/association/nested/one.rb +4 -2
  14. data/lib/mongoid/association/proxy.rb +7 -2
  15. data/lib/mongoid/association/referenced/auto_save.rb +2 -2
  16. data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
  17. data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
  18. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
  19. data/lib/mongoid/association/relatable.rb +0 -2
  20. data/lib/mongoid/attributes/projector.rb +120 -0
  21. data/lib/mongoid/attributes.rb +24 -13
  22. data/lib/mongoid/cacheable.rb +2 -2
  23. data/lib/mongoid/clients/factory.rb +22 -8
  24. data/lib/mongoid/clients.rb +1 -1
  25. data/lib/mongoid/config/environment.rb +1 -9
  26. data/lib/mongoid/config.rb +19 -2
  27. data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
  28. data/lib/mongoid/contextual/atomic.rb +2 -7
  29. data/lib/mongoid/contextual/none.rb +0 -3
  30. data/lib/mongoid/copyable.rb +1 -1
  31. data/lib/mongoid/criteria/findable.rb +1 -1
  32. data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
  33. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  34. data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
  35. data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
  36. data/lib/mongoid/criteria/queryable/selectable.rb +10 -10
  37. data/lib/mongoid/criteria/queryable/storable.rb +4 -4
  38. data/lib/mongoid/criteria.rb +5 -6
  39. data/lib/mongoid/document.rb +3 -18
  40. data/lib/mongoid/errors/delete_restriction.rb +8 -9
  41. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  42. data/lib/mongoid/errors.rb +0 -2
  43. data/lib/mongoid/evolvable.rb +1 -1
  44. data/lib/mongoid/extensions/boolean.rb +1 -2
  45. data/lib/mongoid/extensions/false_class.rb +1 -1
  46. data/lib/mongoid/extensions/hash.rb +2 -2
  47. data/lib/mongoid/extensions/true_class.rb +1 -1
  48. data/lib/mongoid/fields.rb +43 -5
  49. data/lib/mongoid/inspectable.rb +1 -1
  50. data/lib/mongoid/interceptable.rb +1 -1
  51. data/lib/mongoid/matcher/bits.rb +41 -0
  52. data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
  53. data/lib/mongoid/matcher/bits_all_set.rb +20 -0
  54. data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
  55. data/lib/mongoid/matcher/bits_any_set.rb +20 -0
  56. data/lib/mongoid/matcher/expression.rb +4 -0
  57. data/lib/mongoid/matcher/field_operator.rb +6 -0
  58. data/lib/mongoid/matcher/mod.rb +17 -0
  59. data/lib/mongoid/matcher/type.rb +99 -0
  60. data/lib/mongoid/matcher.rb +7 -0
  61. data/lib/mongoid/persistable/deletable.rb +1 -2
  62. data/lib/mongoid/persistable/destroyable.rb +8 -2
  63. data/lib/mongoid/persistable/updatable.rb +27 -2
  64. data/lib/mongoid/persistence_context.rb +1 -3
  65. data/lib/mongoid/query_cache.rb +36 -40
  66. data/lib/mongoid/selectable.rb +5 -7
  67. data/lib/mongoid/shardable.rb +21 -5
  68. data/lib/mongoid/tasks/database.rb +1 -1
  69. data/lib/mongoid/touchable.rb +23 -4
  70. data/lib/mongoid/validatable/associated.rb +1 -1
  71. data/lib/mongoid/validatable/presence.rb +3 -3
  72. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  73. data/lib/mongoid/version.rb +1 -1
  74. data/lib/mongoid.rb +0 -1
  75. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  76. data/spec/integration/app_spec.rb +0 -3
  77. data/spec/integration/associations/embeds_many_spec.rb +44 -0
  78. data/spec/integration/associations/has_one_spec.rb +48 -0
  79. data/spec/integration/criteria/date_field_spec.rb +1 -1
  80. data/spec/integration/document_spec.rb +9 -0
  81. data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
  82. data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
  83. data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
  84. data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
  85. data/spec/integration/matcher_operator_data/comment.yml +22 -0
  86. data/spec/integration/matcher_operator_data/in.yml +16 -0
  87. data/spec/integration/matcher_operator_data/mod.yml +55 -0
  88. data/spec/integration/matcher_operator_data/type.yml +70 -0
  89. data/spec/integration/matcher_operator_data/type_array.yml +16 -0
  90. data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
  91. data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
  92. data/spec/integration/matcher_operator_data/type_code.yml +26 -0
  93. data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
  94. data/spec/integration/matcher_operator_data/type_date.yml +39 -0
  95. data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
  96. data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
  97. data/spec/integration/matcher_operator_data/type_double.yml +15 -0
  98. data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
  99. data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
  100. data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
  101. data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
  102. data/spec/integration/matcher_operator_data/type_null.yml +23 -0
  103. data/spec/integration/matcher_operator_data/type_object.yml +23 -0
  104. data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
  105. data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
  106. data/spec/integration/matcher_operator_data/type_string.yml +15 -0
  107. data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
  108. data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
  109. data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
  110. data/spec/integration/stringified_symbol_field_spec.rb +2 -2
  111. data/spec/lite_spec_helper.rb +2 -0
  112. data/spec/mongoid/association/depending_spec.rb +391 -352
  113. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +4 -17
  114. data/spec/mongoid/association/nested/one_spec.rb +18 -14
  115. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -25
  116. data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +0 -20
  117. data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
  118. data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
  119. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
  120. data/spec/mongoid/association/referenced/has_many_models.rb +0 -17
  121. data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
  122. data/spec/mongoid/atomic/paths_spec.rb +64 -12
  123. data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
  124. data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
  125. data/spec/mongoid/attributes/projector_spec.rb +41 -0
  126. data/spec/mongoid/attributes_spec.rb +98 -6
  127. data/spec/mongoid/clients/factory_spec.rb +51 -9
  128. data/spec/mongoid/clients/options_spec.rb +3 -11
  129. data/spec/mongoid/config/environment_spec.rb +8 -86
  130. data/spec/mongoid/config_spec.rb +32 -0
  131. data/spec/mongoid/contextual/atomic_spec.rb +25 -64
  132. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  133. data/spec/mongoid/contextual/mongo_spec.rb +2 -2
  134. data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
  135. data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
  136. data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
  137. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
  138. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
  139. data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
  140. data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
  141. data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
  142. data/spec/mongoid/criteria_projection_spec.rb +411 -0
  143. data/spec/mongoid/criteria_spec.rb +0 -279
  144. data/spec/mongoid/document_query_spec.rb +0 -51
  145. data/spec/mongoid/document_spec.rb +14 -34
  146. data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
  147. data/spec/mongoid/errors/mongoid_error_spec.rb +8 -20
  148. data/spec/mongoid/extensions/false_class_spec.rb +1 -1
  149. data/spec/mongoid/extensions/string_spec.rb +5 -5
  150. data/spec/mongoid/extensions/true_class_spec.rb +1 -1
  151. data/spec/mongoid/fields/localized_spec.rb +4 -4
  152. data/spec/mongoid/fields_spec.rb +4 -4
  153. data/spec/mongoid/inspectable_spec.rb +12 -4
  154. data/spec/mongoid/persistable/deletable_spec.rb +175 -1
  155. data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
  156. data/spec/mongoid/persistable/savable_spec.rb +3 -5
  157. data/spec/mongoid/persistable/updatable_spec.rb +0 -2
  158. data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
  159. data/spec/mongoid/persistable_spec.rb +2 -2
  160. data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
  161. data/spec/mongoid/query_cache_spec.rb +0 -24
  162. data/spec/mongoid/reloadable_spec.rb +18 -1
  163. data/spec/mongoid/shardable_spec.rb +44 -0
  164. data/spec/mongoid/touchable_spec.rb +104 -16
  165. data/spec/mongoid/touchable_spec_models.rb +52 -0
  166. data/spec/mongoid/validatable_spec.rb +1 -1
  167. data/spec/shared/lib/mrss/cluster_config.rb +3 -8
  168. data/spec/shared/lib/mrss/constraints.rb +10 -41
  169. data/spec/shared/lib/mrss/docker_runner.rb +1 -7
  170. data/spec/shared/lib/mrss/server_version_registry.rb +12 -17
  171. data/spec/shared/lib/mrss/spec_organizer.rb +1 -18
  172. data/spec/shared/share/Dockerfile.erb +33 -125
  173. data/spec/shared/shlib/server.sh +23 -100
  174. data/spec/shared/shlib/set_env.sh +1 -4
  175. data/spec/spec_helper.rb +7 -3
  176. data/spec/support/client_registry.rb +9 -0
  177. data/spec/support/models/address.rb +0 -4
  178. data/spec/support/models/bolt.rb +8 -0
  179. data/spec/support/models/hole.rb +13 -0
  180. data/spec/support/models/mop.rb +0 -1
  181. data/spec/support/models/nut.rb +8 -0
  182. data/spec/support/models/person.rb +6 -9
  183. data/spec/support/models/sealer.rb +8 -0
  184. data/spec/support/models/shirt.rb +12 -0
  185. data/spec/support/models/spacer.rb +8 -0
  186. data/spec/support/models/threadlocker.rb +8 -0
  187. data/spec/support/models/washer.rb +8 -0
  188. data.tar.gz.sig +0 -0
  189. metadata +609 -545
  190. metadata.gz.sig +0 -0
  191. data/lib/mongoid/errors/empty_config_file.rb +0 -26
  192. data/lib/mongoid/errors/invalid_config_file.rb +0 -26
  193. data/spec/integration/contextual/empty_spec.rb +0 -142
  194. data/spec/mongoid/errors/invalid_config_file_spec.rb +0 -32
  195. data/spec/shared/bin/s3-copy +0 -45
  196. data/spec/shared/bin/s3-upload +0 -69
  197. data/spec/shared/lib/mrss/event_subscriber.rb +0 -200
  198. data/spec/shared/share/haproxy-1.conf +0 -16
  199. data/spec/shared/share/haproxy-2.conf +0 -17
  200. data/spec/support/cluster_config.rb +0 -158
@@ -15,11 +15,6 @@ module Mrss
15
15
  @single_server
16
16
  end
17
17
 
18
- def sharded_ish?
19
- determine_cluster_config
20
- @topology == :sharded || @topology == :load_balanced
21
- end
22
-
23
18
  def replica_set_name
24
19
  determine_cluster_config
25
20
  @replica_set_name
@@ -53,7 +48,7 @@ module Mrss
53
48
  raise "Deployment server version not known - check that connection to deployment succeeded"
54
49
  end
55
50
 
56
- if server_version >= '3.4' && !sharded_ish?
51
+ if server_version >= '3.4' && topology != :sharded
57
52
  fcv
58
53
  else
59
54
  if short_server_version == '4.1'
@@ -120,7 +115,7 @@ module Mrss
120
115
  :mmapv1
121
116
  else
122
117
  client = ClientRegistry.instance.global_client('root_authorized')
123
- if sharded_ish?
118
+ if topology == :sharded
124
119
  shards = client.use(:admin).command(listShards: 1).first
125
120
  if shards['shards'].empty?
126
121
  raise 'Shards are empty'
@@ -211,7 +206,7 @@ module Mrss
211
206
 
212
207
  @server_parameters = client.use(:admin).command(getParameter: '*').first
213
208
 
214
- if !sharded_ish? && short_server_version >= '3.4'
209
+ if @topology != :sharded && short_server_version >= '3.4'
215
210
  rv = @server_parameters['featureCompatibilityVersion']
216
211
  @fcv = rv['version'] || rv
217
212
  end
@@ -52,7 +52,7 @@ module Mrss
52
52
  end
53
53
 
54
54
  def require_topology(*topologies)
55
- invalid_topologies = topologies - [:single, :replica_set, :sharded, :load_balanced]
55
+ invalid_topologies = topologies - [:single, :replica_set, :sharded]
56
56
 
57
57
  unless invalid_topologies.empty?
58
58
  raise ArgumentError, "Invalid topologies requested: #{invalid_topologies.join(', ')}"
@@ -82,7 +82,7 @@ module Mrss
82
82
  unless ClusterConfig.instance.server_version >= '4.0'
83
83
  skip 'Transactions tests in a replica set topology require server 4.0+'
84
84
  end
85
- when :sharded, :load_balanced
85
+ when :sharded
86
86
  unless ClusterConfig.instance.server_version >= '4.2'
87
87
  skip 'Transactions tests in a sharded cluster topology require server 4.2+'
88
88
  end
@@ -249,52 +249,31 @@ module Mrss
249
249
  # (mongos 4.0+ overrides the write concern)
250
250
  def require_set_write_concern
251
251
  before(:all) do
252
- if %i(sharded load_balanced).include?(ClusterConfig.instance.topology) &&
253
- ClusterConfig.instance.short_server_version >= '4.0'
254
- then
252
+ if ClusterConfig.instance.topology == :sharded && ClusterConfig.instance.short_server_version >= '4.0'
255
253
  skip "mongos 4.0+ overrides write concern"
256
254
  end
257
255
  end
258
256
  end
259
257
 
260
- def require_multi_mongos
258
+ def require_multi_shard
261
259
  before(:all) do
262
260
  if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length == 1
263
- skip 'Test requires a minimum of two mongoses if run in sharded topology'
264
- end
265
-
266
- if ClusterConfig.instance.topology == :load_balanced && SpecConfig.instance.single_mongos?
267
- skip 'Test requires a minimum of two mongoses if run in load-balanced topology'
261
+ skip 'Test requires a minimum of two shards if run in sharded topology'
268
262
  end
269
263
  end
270
264
  end
271
265
 
272
- # In sharded topology operations are distributed to the mongoses.
273
- # When we set fail points, the fail point may be set on one mongos and
274
- # operation may be executed on another mongos, causing failures.
275
- # Tests that are not setting targeted fail points should utilize this
276
- # method to restrict themselves to single mongos.
277
- #
278
- # In load-balanced topology, the same problem can happen when there is
279
- # more than one mongos behind the load balancer.
280
- def require_no_multi_mongos
266
+ def require_no_multi_shard
281
267
  before(:all) do
282
268
  if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length > 1
283
- skip 'Test requires a single mongos if run in sharded topology'
284
- end
285
- if ClusterConfig.instance.topology == :load_balanced && !SpecConfig.instance.single_mongos?
286
- skip 'Test requires a single mongos, as indicated by SINGLE_MONGOS=1 environment variable, if run in load-balanced topology'
269
+ skip 'Test requires a single shard if run in sharded topology'
287
270
  end
288
271
  end
289
272
  end
290
273
 
291
- alias :require_no_multi_shard :require_no_multi_mongos
292
-
293
274
  def require_wired_tiger
294
275
  before(:all) do
295
- # Storage detection fails for serverless instances. However, it is safe to
296
- # assume that a serverless instance uses WiredTiger Storage Engine.
297
- if !SpecConfig.instance.serverless? && ClusterConfig.instance.storage_engine != :wired_tiger
276
+ if ClusterConfig.instance.storage_engine != :wired_tiger
298
277
  skip 'Test requires WiredTiger storage engine'
299
278
  end
300
279
  end
@@ -303,9 +282,7 @@ module Mrss
303
282
  def require_wired_tiger_on_36
304
283
  before(:all) do
305
284
  if ClusterConfig.instance.short_server_version >= '3.6'
306
- # Storage detection fails for serverless instances. However, it is safe to
307
- # assume that a serverless instance uses WiredTiger Storage Engine.
308
- if !SpecConfig.instance.serverless? && ClusterConfig.instance.storage_engine != :wired_tiger
285
+ if ClusterConfig.instance.storage_engine != :wired_tiger
309
286
  skip 'Test requires WiredTiger storage engine on 3.6+ servers'
310
287
  end
311
288
  end
@@ -314,7 +291,7 @@ module Mrss
314
291
 
315
292
  def require_mmapv1
316
293
  before(:all) do
317
- if SpecConfig.instance.serverless? || ClusterConfig.instance.storage_engine != :mmapv1
294
+ if ClusterConfig.instance.storage_engine != :mmapv1
318
295
  skip 'Test requires MMAPv1 storage engine'
319
296
  end
320
297
  end
@@ -373,13 +350,5 @@ module Mrss
373
350
  end
374
351
  end
375
352
  end
376
-
377
- def require_unix_socket
378
- before(:all) do
379
- if ENV['TOPOLOGY'] == 'load-balanced'
380
- skip 'Load balancer does not listen on Unix sockets'
381
- end
382
- end
383
- end
384
353
  end
385
354
  end
@@ -111,7 +111,7 @@ module Mrss
111
111
  '.'])
112
112
  end
113
113
 
114
- BASE_TEST_COMMAND = %w(docker run --rm -i --tmpfs /tmpfs:exec).freeze
114
+ BASE_TEST_COMMAND = %w(docker run -i --tmpfs /tmpfs:exec).freeze
115
115
 
116
116
  def run_tests
117
117
  run_command(BASE_TEST_COMMAND + tty_arg + extra_env + [image_tag] +
@@ -179,11 +179,9 @@ module Mrss
179
179
  BASE_IMAGES = {
180
180
  'debian81' => 'debian:jessie',
181
181
  'debian92' => 'debian:stretch',
182
- 'debian10' => 'debian:buster',
183
182
  'ubuntu1404' => 'ubuntu:trusty',
184
183
  'ubuntu1604' => 'ubuntu:xenial',
185
184
  'ubuntu1804' => 'ubuntu:bionic',
186
- 'ubuntu2004' => 'ubuntu:focal',
187
185
  'rhel62' => 'centos:6',
188
186
  'rhel70' => 'centos:7',
189
187
  }.freeze
@@ -200,10 +198,6 @@ module Mrss
200
198
  ruby == 'ruby-head'
201
199
  end
202
200
 
203
- def system_ruby?
204
- %w(1 true yes).include?(@env['SYSTEM_RUBY']&.downcase)
205
- end
206
-
207
201
  def server_version
208
202
  @env['MONGODB_VERSION']
209
203
  end
@@ -48,24 +48,19 @@ module Mrss
48
48
  url = dl['archive']['url']
49
49
  end
50
50
  rescue MissingDownloadUrl
51
- if %w(2.6 3.0).include?(desired_version) && arch == 'ubuntu1604'
52
- # 2.6 and 3.0 are only available for ubuntu1204 and ubuntu1404.
53
- # Those ubuntus have ancient Pythons that don't work due to not
54
- # implementing recent TLS protocols.
55
- # Because of this we test on ubuntu1604 which has a newer Python.
56
- # But we still need to retrieve ubuntu1404-targeting builds.
57
- url = self.class.new('3.2', arch).download_url
58
- unless url.include?('3.2.')
59
- raise 'URL not in expected format'
51
+ if %w(4.7 4.7.0).include?(desired_version)
52
+ # 4.7.0 has no advertised downloads but it is downloadable and
53
+ # we do need it. Dirty hack below.
54
+ registry = self.class.new('4.4.3', arch)
55
+ registry.download_url.sub('4.4.3', '4.7.0').tap do |url|
56
+ # Sanity check - ensure the URL we hacked up is a valid one
57
+ io = uri_open(url)
58
+ begin
59
+ io.read(1)
60
+ ensure
61
+ io.close
62
+ end
60
63
  end
61
- url = case desired_version
62
- when '2.6'
63
- url.sub(/\b3\.2\.\d+/, '2.6.12')
64
- when '3.0'
65
- url.sub(/\b3\.2\.\d+/, '3.0.15')
66
- else
67
- raise NotImplementedError
68
- end.sub('ubuntu1604', 'ubuntu1404')
69
64
  else
70
65
  raise
71
66
  end
@@ -25,28 +25,18 @@ module Mrss
25
25
  end
26
26
 
27
27
  def initialize(root: nil, classifiers:, priority_order:,
28
- spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil,
29
- randomize: false
28
+ spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil
30
29
  )
31
30
  @spec_root = spec_root || File.join(root, 'spec')
32
31
  @classifiers = classifiers
33
32
  @priority_order = priority_order
34
33
  @rspec_json_path = rspec_json_path || File.join(root, 'tmp/rspec.json')
35
34
  @rspec_all_json_path = rspec_all_json_path || File.join(root, 'tmp/rspec-all.json')
36
- @randomize = !!randomize
37
35
  end
38
36
 
39
37
  attr_reader :spec_root, :classifiers, :priority_order
40
38
  attr_reader :rspec_json_path, :rspec_all_json_path
41
39
 
42
- def randomize?
43
- @randomize
44
- end
45
-
46
- def seed
47
- @seed ||= (rand * 100_000).to_i
48
- end
49
-
50
40
  def buckets
51
41
  @buckets ||= {}.tap do |buckets|
52
42
  Find.find(spec_root) do |path|
@@ -132,12 +122,8 @@ module Mrss
132
122
  puts "Running #{category.to_s.gsub('_', ' ')} tests"
133
123
  FileUtils.rm_f(rspec_json_path)
134
124
  cmd = %w(rspec) + paths
135
- if randomize?
136
- cmd += %W(--order rand:#{seed})
137
- end
138
125
 
139
126
  begin
140
- puts "Running #{cmd.join(' ')}"
141
127
  ChildProcessHelper.check_call(cmd)
142
128
  ensure
143
129
  if File.exist?(rspec_json_path)
@@ -163,9 +149,6 @@ module Mrss
163
149
  end
164
150
  new.delete('version')
165
151
  new.delete('summary_line')
166
- # The spec organizer runs all buckets with the same seed, hence
167
- # we can drop the seed from new results.
168
- new.delete('seed')
169
152
  unless new.empty?
170
153
  raise "Unhandled rspec results keys: #{new.keys.join(', ')}"
171
154
  end
@@ -55,10 +55,9 @@ 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-jdk-headless
58
+ # JRuby: openjdk-8-jre-headless
59
59
  # Server dependencies: libsnmp30 libcurl3/libcurl4
60
60
  # Determining OS we are running on: lsb-release
61
- # Load balancer testing: haproxy
62
61
  # Kerberos testing: krb5-user
63
62
  # Local Kerberos server: krb5-kdc krb5-admin-server
64
63
  # Installing mlaunch from git: git
@@ -68,7 +67,6 @@ FROM <%= base_image %>
68
67
  # nokogiri: zlib1g-dev
69
68
  # Mongoid testing: tzdata shared-mime-info
70
69
  # Mongoid application testing: nodejs (8.x or newer)
71
- # Test suite: procps for ps (to kill JRubies)
72
70
  #
73
71
  # We currently use Python 2-compatible version of mtools, which
74
72
  # is installable via pip (which uses Python 2). All of the MongoDB
@@ -76,44 +74,22 @@ FROM <%= base_image %>
76
74
  # therefore install python-pip in all configurations here.
77
75
 
78
76
  <% packages = %w(
79
- procps lsb-release bzip2 curl zsh
77
+ lsb-release bzip2 curl zsh
80
78
  git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
79
+ libsnmp30
81
80
  krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
82
- haproxy
83
- python3-pip
81
+ python-pip python2.7-dev python3-pip
84
82
  tzdata shared-mime-info
85
83
  ) %>
86
84
 
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' %>
85
+ # ubuntu1404 only has openjdk-7-jre-headless
86
+ <% if distro !~ /ubuntu1404/ %>
87
+ <% packages << 'openjdk-8-jre-headless' %>
112
88
  <% end %>
113
89
 
114
90
  # ubuntu1404, ubuntu1604: libcurl3
115
- # ubuntu1804, ubuntu2004, debian10: libcurl4
116
- <% if distro =~ /ubuntu1804|ubuntu2004|debian10/ %>
91
+ # ubuntu1804: libcurl4
92
+ <% if distro =~ /ubuntu1804/ %>
117
93
  <% packages << 'libcurl4' %>
118
94
  <% else %>
119
95
  <% packages << 'libcurl3' %>
@@ -123,36 +99,9 @@ FROM <%= base_image %>
123
99
  <% packages << 'nodejs' %>
124
100
  <% end %>
125
101
 
126
- <% if distro =~ /ubuntu2004/ %>
127
- <% packages += %w(ruby ruby2.7 bundler python2 python2-dev) %>
128
- <% end %>
129
-
130
102
  RUN apt-get update && apt-get install -y <%= packages.join(' ') %>
131
103
  <% else %>
132
104
 
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
-
156
105
  # Enterprise server: net-snmp
157
106
  # lsb_release: redhat-lsb-core
158
107
  # our runner scripts: which
@@ -169,7 +118,7 @@ CFG
169
118
 
170
119
  RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
171
120
  krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
172
- net-snmp python3
121
+ net-snmp
173
122
 
174
123
  <% if distro =~ /rhel6/ %>
175
124
 
@@ -185,69 +134,23 @@ CFG
185
134
  RUN yum install -y python-devel
186
135
 
187
136
  <% end %>
188
-
137
+
189
138
  <% end %>
190
139
 
191
140
  <% if preload? %>
192
141
 
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
-
233
142
  # Current virtualenv fails with
234
143
  # https://github.com/pypa/virtualenv/issues/1630
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 %>
144
+ RUN python2 -m pip install 'virtualenv<20' 'mtools-legacy[mlaunch]'
240
145
 
241
146
  RUN pip --version && \
242
147
  pip install mtools-legacy[mlaunch]
243
148
 
244
149
  <% if @env.fetch('MONGODB_VERSION') >= '4.4' %>
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
150
+ RUN python3 -mpip install asn1crypto oscrypto flask
248
151
  <% end %>
249
152
 
250
- <% unless ruby_head? || system_ruby? %>
153
+ <% unless ruby_head? %>
251
154
 
252
155
  RUN curl --retry 3 -fL <%= ruby_toolchain_url %> |tar -xC /opt -Jf -
253
156
  ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
@@ -256,20 +159,30 @@ CFG
256
159
 
257
160
  <% end %>
258
161
 
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
+
259
180
  RUN curl --retry 3 -fL <%= server_download_url %> |tar xzf - && \
260
181
  mv mongo*/ /opt/mongodb
261
182
  ENV USE_OPT_MONGODB=1 USE_SYSTEM_PYTHON_PACKAGES=1
262
183
 
263
184
  <% end %>
264
185
 
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
-
273
186
  WORKDIR /app
274
187
 
275
188
  <% if preload? && !ruby_head? %>
@@ -280,12 +193,7 @@ WORKDIR /app
280
193
  COPY lib/<%= project_lib_subdir %>/version.rb lib/<%= project_lib_subdir %>/version.rb
281
194
  RUN bundle install
282
195
  COPY .evergreen/patch-debuggers .evergreen/patch-debuggers
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 %>
196
+ RUN .evergreen/patch-debuggers /opt/rubies
289
197
 
290
198
  <% end %>
291
199