mongoid 6.4.8 → 7.0.13
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/LICENSE +1 -0
- data/README.md +4 -3
- data/Rakefile +33 -7
- data/lib/config/locales/en.yml +17 -0
- data/lib/mongoid/association/accessors.rb +339 -0
- data/lib/mongoid/{relations/binding.rb → association/bindable.rb} +32 -52
- data/lib/mongoid/association/builders.rb +92 -0
- data/lib/mongoid/{relations/constraint.rb → association/constrainable.rb} +11 -22
- data/lib/mongoid/association/depending.rb +137 -0
- data/lib/mongoid/{relations/eager.rb → association/eager_loadable.rb} +11 -11
- data/lib/mongoid/{relations → association}/embedded/batchable.rb +19 -19
- data/lib/mongoid/association/embedded/cyclic.rb +109 -0
- data/lib/mongoid/association/embedded/embedded_in/binding.rb +56 -0
- data/lib/mongoid/{relations/builders/embedded/in.rb → association/embedded/embedded_in/buildable.rb} +12 -6
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +121 -0
- data/lib/mongoid/association/embedded/embedded_in.rb +154 -0
- data/lib/mongoid/{relations/bindings/embedded/many.rb → association/embedded/embeds_many/binding.rb} +11 -9
- data/lib/mongoid/{relations/builders/embedded/many.rb → association/embedded/embeds_many/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +552 -0
- data/lib/mongoid/association/embedded/embeds_many.rb +211 -0
- data/lib/mongoid/{relations/bindings/embedded/one.rb → association/embedded/embeds_one/binding.rb} +12 -10
- data/lib/mongoid/{relations/builders/embedded/one.rb → association/embedded/embeds_one/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +130 -0
- data/lib/mongoid/association/embedded/embeds_one.rb +174 -0
- data/lib/mongoid/association/embedded.rb +4 -0
- data/lib/mongoid/association/macros.rb +204 -0
- data/lib/mongoid/{relations → association}/many.rb +19 -49
- data/lib/mongoid/{relations → association}/marshalable.rb +6 -4
- data/lib/mongoid/association/nested/many.rb +200 -0
- data/lib/mongoid/association/nested/nested_buildable.rb +72 -0
- data/lib/mongoid/association/nested/one.rb +127 -0
- data/lib/mongoid/association/nested.rb +15 -0
- data/lib/mongoid/{relations → association}/one.rb +6 -6
- data/lib/mongoid/association/options.rb +152 -0
- data/lib/mongoid/{relations → association}/proxy.rb +45 -59
- data/lib/mongoid/association/referenced/auto_save.rb +79 -0
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +87 -0
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +46 -0
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +36 -0
- data/lib/mongoid/association/referenced/belongs_to/proxy.rb +136 -0
- data/lib/mongoid/association/referenced/belongs_to.rb +248 -0
- data/lib/mongoid/association/referenced/counter_cache.rb +163 -0
- data/lib/mongoid/association/referenced/eager.rb +162 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +71 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +40 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb +52 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +312 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +290 -0
- data/lib/mongoid/{relations/bindings/referenced/many.rb → association/referenced/has_many/binding.rb} +6 -5
- data/lib/mongoid/association/referenced/has_many/buildable.rb +38 -0
- data/lib/mongoid/association/referenced/has_many/eager.rb +43 -0
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +510 -0
- data/lib/mongoid/association/referenced/has_many/proxy.rb +578 -0
- data/lib/mongoid/association/referenced/has_many.rb +275 -0
- data/lib/mongoid/{relations/bindings/referenced/one.rb → association/referenced/has_one/binding.rb} +11 -8
- data/lib/mongoid/association/referenced/has_one/buildable.rb +60 -0
- data/lib/mongoid/association/referenced/has_one/eager.rb +35 -0
- data/lib/mongoid/{relations/builders/nested_attributes/one.rb → association/referenced/has_one/nested_builder.rb} +9 -9
- data/lib/mongoid/association/referenced/has_one/proxy.rb +113 -0
- data/lib/mongoid/association/referenced/has_one.rb +204 -0
- data/lib/mongoid/association/referenced/syncable.rb +170 -0
- data/lib/mongoid/association/referenced.rb +7 -0
- data/lib/mongoid/{relations → association}/reflections.rb +21 -17
- data/lib/mongoid/association/relatable.rb +511 -0
- data/lib/mongoid/{relations.rb → association.rb} +57 -56
- data/lib/mongoid/atomic/paths/embedded/many.rb +1 -1
- data/lib/mongoid/atomic/paths/embedded/one.rb +1 -1
- data/lib/mongoid/atomic/paths/embedded.rb +1 -1
- data/lib/mongoid/atomic.rb +14 -4
- data/lib/mongoid/attributes/dynamic.rb +16 -15
- data/lib/mongoid/attributes/nested.rb +22 -11
- data/lib/mongoid/attributes/processing.rb +2 -2
- data/lib/mongoid/attributes/readonly.rb +2 -4
- data/lib/mongoid/attributes.rb +55 -31
- data/lib/mongoid/changeable.rb +1 -1
- data/lib/mongoid/clients/options.rb +7 -5
- data/lib/mongoid/clients/sessions.rb +20 -4
- data/lib/mongoid/composable.rb +4 -4
- data/lib/mongoid/config/environment.rb +21 -8
- data/lib/mongoid/config.rb +1 -0
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/geo_near.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +21 -3
- data/lib/mongoid/contextual/mongo.rb +10 -8
- data/lib/mongoid/copyable.rb +11 -6
- data/lib/mongoid/criteria/includable.rb +14 -14
- data/lib/mongoid/criteria/modifiable.rb +8 -3
- data/lib/mongoid/criteria/options.rb +2 -2
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +3 -3
- data/lib/mongoid/criteria/queryable/extensions/string.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/time.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
- data/lib/mongoid/criteria/queryable/key.rb +67 -8
- data/lib/mongoid/criteria/queryable/mergeable.rb +5 -4
- data/lib/mongoid/criteria/queryable/pipeline.rb +10 -5
- data/lib/mongoid/criteria/queryable/selectable.rb +5 -3
- data/lib/mongoid/criteria/queryable/selector.rb +9 -31
- data/lib/mongoid/criteria.rb +9 -3
- data/lib/mongoid/document.rb +14 -4
- data/lib/mongoid/errors/invalid_dependent_strategy.rb +32 -0
- data/lib/mongoid/errors/invalid_relation_option.rb +29 -0
- data/lib/mongoid/errors/unknown_model.rb +25 -0
- data/lib/mongoid/errors.rb +3 -0
- data/lib/mongoid/extensions/array.rb +5 -5
- data/lib/mongoid/extensions/hash.rb +9 -4
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/range.rb +1 -0
- data/lib/mongoid/extensions/regexp.rb +1 -1
- data/lib/mongoid/extensions/string.rb +2 -2
- data/lib/mongoid/extensions.rb +0 -4
- data/lib/mongoid/factory.rb +13 -3
- data/lib/mongoid/fields/foreign_key.rb +5 -5
- data/lib/mongoid/fields/standard.rb +2 -14
- data/lib/mongoid/fields/validators/macro.rb +1 -1
- data/lib/mongoid/fields.rb +5 -4
- data/lib/mongoid/indexable.rb +4 -1
- data/lib/mongoid/interceptable.rb +8 -6
- data/lib/mongoid/matchable/all.rb +4 -3
- data/lib/mongoid/matchable/and.rb +1 -1
- data/lib/mongoid/matchable/default.rb +71 -24
- data/lib/mongoid/matchable/elem_match.rb +9 -3
- data/lib/mongoid/matchable/eq.rb +22 -0
- data/lib/mongoid/matchable/ne.rb +1 -1
- data/lib/mongoid/matchable/regexp.rb +2 -2
- data/lib/mongoid/matchable.rb +17 -16
- data/lib/mongoid/persistable/deletable.rb +7 -6
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/pushable.rb +11 -2
- data/lib/mongoid/persistable/settable.rb +57 -12
- data/lib/mongoid/persistable.rb +4 -5
- data/lib/mongoid/persistence_context.rb +26 -11
- data/lib/mongoid/positional.rb +1 -1
- data/lib/mongoid/query_cache.rb +4 -2
- data/lib/mongoid/serializable.rb +4 -4
- data/lib/mongoid/shardable.rb +1 -1
- data/lib/mongoid/touchable.rb +102 -0
- data/lib/mongoid/traversable.rb +3 -3
- data/lib/mongoid/validatable/macros.rb +1 -1
- data/lib/mongoid/validatable/presence.rb +2 -2
- data/lib/mongoid/validatable/uniqueness.rb +5 -5
- data/lib/mongoid/validatable.rb +8 -8
- data/lib/mongoid/version.rb +2 -1
- data/lib/mongoid.rb +1 -0
- data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -0
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
- data/spec/README.md +18 -0
- data/spec/app/models/animal.rb +2 -1
- data/spec/app/models/bomb.rb +1 -1
- data/spec/app/models/customer.rb +11 -0
- data/spec/app/models/customer_address.rb +12 -0
- data/spec/app/models/message.rb +1 -1
- data/spec/app/models/minim.rb +7 -0
- data/spec/app/models/other_owner_object.rb +2 -0
- data/spec/app/models/person.rb +5 -2
- data/spec/app/models/shipment_address.rb +1 -0
- data/spec/app/models/store_as_dup_test3.rb +7 -0
- data/spec/app/models/store_as_dup_test4.rb +7 -0
- data/spec/app/models/updatable.rb +7 -0
- data/spec/app/models/vertex.rb +6 -0
- data/spec/app/models/wiki_page.rb +1 -1
- data/spec/config/mongoid.yml +13 -3
- data/spec/integration/app_spec.rb +341 -0
- data/spec/integration/associations/belongs_to_spec.rb +13 -0
- data/spec/integration/associations/embedded_spec.rb +176 -0
- data/spec/integration/callbacks_models.rb +49 -0
- data/spec/integration/callbacks_spec.rb +216 -0
- data/spec/integration/criteria/date_field_spec.rb +41 -0
- data/spec/integration/criteria/time_with_zone_spec.rb +32 -0
- data/spec/integration/matchable_spec.rb +680 -0
- data/spec/lite_spec_helper.rb +71 -0
- data/spec/mongoid/{relations → association}/accessors_spec.rb +40 -1
- data/spec/mongoid/{relations → association}/auto_save_spec.rb +60 -12
- data/spec/mongoid/{relations → association}/builders_spec.rb +1 -1
- data/spec/mongoid/association/constrainable_spec.rb +115 -0
- data/spec/mongoid/{relations → association}/counter_cache_spec.rb +1 -1
- data/spec/mongoid/association/depending_spec.rb +866 -0
- data/spec/mongoid/{relations → association}/eager_spec.rb +12 -12
- data/spec/mongoid/{relations → association/embedded}/cyclic_spec.rb +1 -1
- data/spec/mongoid/{relations → association}/embedded/dirty_spec.rb +0 -0
- data/spec/mongoid/{relations/bindings/embedded/in_spec.rb → association/embedded/embedded_in/binding_spec.rb} +13 -13
- data/spec/mongoid/{relations/builders/embedded/in_spec.rb → association/embedded/embedded_in/buildable_spec.rb} +9 -9
- data/spec/mongoid/{relations/embedded/in_spec.rb → association/embedded/embedded_in/proxy_spec.rb} +55 -77
- data/spec/mongoid/association/embedded/embedded_in_spec.rb +901 -0
- data/spec/mongoid/{relations/bindings/embedded/many_spec.rb → association/embedded/embeds_many/binding_spec.rb} +3 -3
- data/spec/mongoid/{relations/builders/embedded/many_spec.rb → association/embedded/embeds_many/buildable_spec.rb} +17 -45
- data/spec/mongoid/{relations/embedded/many_spec.rb → association/embedded/embeds_many/proxy_spec.rb} +124 -182
- data/spec/mongoid/association/embedded/embeds_many_models.rb +53 -0
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +862 -0
- data/spec/mongoid/{relations/bindings/embedded/one_spec.rb → association/embedded/embeds_one/binding_spec.rb} +4 -4
- data/spec/mongoid/{relations/builders/embedded/one_spec.rb → association/embedded/embeds_one/buildable_spec.rb} +14 -34
- data/spec/mongoid/{relations/embedded/one_spec.rb → association/embedded/embeds_one/proxy_spec.rb} +39 -84
- data/spec/mongoid/association/embedded/embeds_one_dnl_models.rb +6 -0
- data/spec/mongoid/association/embedded/embeds_one_models.rb +51 -0
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +954 -0
- data/spec/mongoid/{relations → association}/macros_spec.rb +148 -73
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/many_spec.rb +16 -19
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/one_spec.rb +17 -20
- data/spec/mongoid/association/options_spec.rb +1321 -0
- data/spec/mongoid/{relations → association}/polymorphic_spec.rb +66 -34
- data/spec/mongoid/{relations/bindings/referenced/in_spec.rb → association/referenced/belongs_to/binding_spec.rb} +7 -7
- data/spec/mongoid/{relations/builders/referenced/in_spec.rb → association/referenced/belongs_to/buildable_spec.rb} +46 -79
- data/spec/mongoid/{relations/eager/belongs_to_spec.rb → association/referenced/belongs_to/eager_spec.rb} +33 -14
- data/spec/mongoid/{relations/referenced/in_spec.rb → association/referenced/belongs_to/proxy_spec.rb} +57 -91
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2023 -0
- data/spec/mongoid/{relations/bindings/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb +121 -0
- data/spec/mongoid/{relations/eager/has_and_belongs_to_many_spec.rb → association/referenced/has_and_belongs_to_many/eager_spec.rb} +26 -7
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_persistence_spec.rb +56 -0
- data/spec/mongoid/{relations/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/proxy_spec.rb} +247 -99
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb +26 -0
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +1027 -0
- data/spec/mongoid/{relations/bindings/referenced/many_spec.rb → association/referenced/has_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +119 -0
- data/spec/mongoid/{relations/eager/has_many_spec.rb → association/referenced/has_many/eager_spec.rb} +26 -11
- data/spec/mongoid/{relations/targets → association/referenced/has_many}/enumerable_spec.rb +227 -1
- data/spec/mongoid/association/referenced/has_many/proxy_query_spec.rb +23 -0
- data/spec/mongoid/{relations/referenced/many_spec.rb → association/referenced/has_many/proxy_spec.rb} +30 -94
- data/spec/mongoid/association/referenced/has_many_models.rb +37 -0
- data/spec/mongoid/association/referenced/has_many_spec.rb +1225 -0
- data/spec/mongoid/{relations/bindings/referenced/one_spec.rb → association/referenced/has_one/binding_spec.rb} +4 -4
- data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +113 -0
- data/spec/mongoid/{relations/eager/has_one_spec.rb → association/referenced/has_one/eager_spec.rb} +10 -10
- data/spec/mongoid/{relations/referenced/one_spec.rb → association/referenced/has_one/proxy_spec.rb} +9 -109
- data/spec/mongoid/association/referenced/has_one_models.rb +48 -0
- data/spec/mongoid/association/referenced/has_one_spec.rb +1360 -0
- data/spec/mongoid/{relations → association}/reflections_spec.rb +1 -12
- data/spec/mongoid/{relations/synchronization_spec.rb → association/syncable_spec.rb} +4 -2
- data/spec/mongoid/{relations_spec.rb → association_spec.rb} +1 -1
- data/spec/mongoid/atomic/modifiers_spec.rb +2 -2
- data/spec/mongoid/atomic/paths_spec.rb +41 -0
- data/spec/mongoid/atomic_spec.rb +4 -4
- data/spec/mongoid/attributes/dynamic_spec.rb +153 -0
- data/spec/mongoid/attributes/nested_spec.rb +29 -11
- data/spec/mongoid/attributes/readonly_spec.rb +80 -125
- data/spec/mongoid/attributes_spec.rb +298 -9
- data/spec/mongoid/clients/factory_spec.rb +20 -38
- data/spec/mongoid/clients/options_spec.rb +64 -50
- data/spec/mongoid/clients/sessions_spec.rb +9 -5
- data/spec/mongoid/clients/transactions_spec.rb +390 -0
- data/spec/mongoid/clients_spec.rb +70 -10
- data/spec/mongoid/config_spec.rb +27 -1
- data/spec/mongoid/contextual/atomic_spec.rb +37 -14
- data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
- data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
- data/spec/mongoid/contextual/memory_spec.rb +19 -0
- data/spec/mongoid/contextual/mongo_spec.rb +107 -56
- data/spec/mongoid/copyable_spec.rb +90 -6
- data/spec/mongoid/copyable_spec_models.rb +17 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +173 -1
- data/spec/mongoid/criteria/queryable/extensions/numeric_spec.rb +54 -0
- data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +44 -1
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
- data/spec/mongoid/criteria/queryable/key_spec.rb +48 -6
- data/spec/mongoid/criteria/queryable/pipeline_spec.rb +12 -0
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +762 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +5 -224
- data/spec/mongoid/criteria/queryable/selector_spec.rb +37 -0
- data/spec/mongoid/criteria_spec.rb +36 -19
- data/spec/mongoid/document_fields_spec.rb +88 -0
- data/spec/mongoid/document_persistence_context_spec.rb +33 -0
- data/spec/mongoid/document_spec.rb +29 -4
- data/spec/mongoid/extensions/array_spec.rb +11 -15
- data/spec/mongoid/extensions/hash_spec.rb +18 -1
- data/spec/mongoid/extensions/object_spec.rb +7 -11
- data/spec/mongoid/extensions/range_spec.rb +7 -0
- data/spec/mongoid/factory_spec.rb +21 -3
- data/spec/mongoid/fields/foreign_key_spec.rb +24 -32
- data/spec/mongoid/fields_spec.rb +1 -1
- data/spec/mongoid/indexable_spec.rb +24 -12
- data/spec/mongoid/interceptable_spec.rb +22 -1
- data/spec/mongoid/matchable/default_spec.rb +10 -3
- data/spec/mongoid/matchable/elem_match_spec.rb +20 -0
- data/spec/mongoid/matchable/eq_spec.rb +48 -0
- data/spec/mongoid/matchable/regexp_spec.rb +2 -2
- data/spec/mongoid/matchable_spec.rb +2 -2
- data/spec/mongoid/persistable/pushable_spec.rb +55 -1
- data/spec/mongoid/persistable/savable_spec.rb +5 -5
- data/spec/mongoid/persistable/settable_spec.rb +125 -10
- data/spec/mongoid/persistable_spec.rb +21 -6
- data/spec/mongoid/persistence_context_spec.rb +1 -1
- data/spec/mongoid/query_cache_spec.rb +65 -27
- data/spec/mongoid/relations/proxy_spec.rb +124 -124
- data/spec/mongoid/scopable_spec.rb +2 -1
- data/spec/mongoid/shardable_spec.rb +32 -12
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +1 -1
- data/spec/mongoid/{relations/touchable_spec.rb → touchable_spec.rb} +40 -1
- data/spec/mongoid/validatable/associated_spec.rb +1 -1
- data/spec/mongoid/validatable/presence_spec.rb +7 -6
- data/spec/mongoid/validatable/uniqueness_spec.rb +33 -6
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +221 -0
- data/spec/shared/lib/mrss/constraints.rb +354 -0
- data/spec/shared/lib/mrss/docker_runner.rb +265 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +162 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +231 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +290 -0
- data/spec/shared/shlib/set_env.sh +128 -0
- data/spec/spec_helper.rb +34 -49
- data/spec/support/cluster_config.rb +3 -3
- data/spec/support/constraints.rb +21 -76
- data/spec/support/expectations.rb +17 -3
- data/spec/support/spec_config.rb +20 -7
- data.tar.gz.sig +0 -0
- metadata +646 -541
- metadata.gz.sig +1 -5
- data/lib/mongoid/relations/accessors.rb +0 -267
- data/lib/mongoid/relations/auto_save.rb +0 -94
- data/lib/mongoid/relations/bindings/embedded/in.rb +0 -59
- data/lib/mongoid/relations/bindings/referenced/in.rb +0 -65
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +0 -70
- data/lib/mongoid/relations/bindings.rb +0 -9
- data/lib/mongoid/relations/builder.rb +0 -57
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +0 -199
- data/lib/mongoid/relations/builders/referenced/in.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many_to_many.rb +0 -39
- data/lib/mongoid/relations/builders/referenced/one.rb +0 -26
- data/lib/mongoid/relations/builders.rb +0 -106
- data/lib/mongoid/relations/cascading/delete.rb +0 -44
- data/lib/mongoid/relations/cascading/destroy.rb +0 -43
- data/lib/mongoid/relations/cascading/nullify.rb +0 -35
- data/lib/mongoid/relations/cascading/restrict.rb +0 -39
- data/lib/mongoid/relations/cascading.rb +0 -56
- data/lib/mongoid/relations/conversions.rb +0 -34
- data/lib/mongoid/relations/counter_cache.rb +0 -160
- data/lib/mongoid/relations/cyclic.rb +0 -107
- data/lib/mongoid/relations/eager/base.rb +0 -153
- data/lib/mongoid/relations/eager/belongs_to.rb +0 -31
- data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +0 -47
- data/lib/mongoid/relations/eager/has_many.rb +0 -38
- data/lib/mongoid/relations/eager/has_one.rb +0 -30
- data/lib/mongoid/relations/embedded/in.rb +0 -241
- data/lib/mongoid/relations/embedded/many.rb +0 -683
- data/lib/mongoid/relations/embedded/one.rb +0 -235
- data/lib/mongoid/relations/macros.rb +0 -367
- data/lib/mongoid/relations/metadata.rb +0 -1179
- data/lib/mongoid/relations/nested_builder.rb +0 -74
- data/lib/mongoid/relations/options.rb +0 -49
- data/lib/mongoid/relations/polymorphic.rb +0 -39
- data/lib/mongoid/relations/referenced/in.rb +0 -304
- data/lib/mongoid/relations/referenced/many.rb +0 -812
- data/lib/mongoid/relations/referenced/many_to_many.rb +0 -479
- data/lib/mongoid/relations/referenced/one.rb +0 -290
- data/lib/mongoid/relations/synchronization.rb +0 -169
- data/lib/mongoid/relations/targets/enumerable.rb +0 -493
- data/lib/mongoid/relations/targets.rb +0 -2
- data/lib/mongoid/relations/touchable.rb +0 -97
- data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +0 -184
- data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +0 -201
- data/spec/mongoid/relations/builders/referenced/many_spec.rb +0 -137
- data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +0 -178
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +0 -111
- data/spec/mongoid/relations/cascading/delete_spec.rb +0 -101
- data/spec/mongoid/relations/cascading/destroy_spec.rb +0 -47
- data/spec/mongoid/relations/cascading/nullify_spec.rb +0 -32
- data/spec/mongoid/relations/cascading/restrict_spec.rb +0 -68
- data/spec/mongoid/relations/cascading_spec.rb +0 -355
- data/spec/mongoid/relations/constraint_spec.rb +0 -75
- data/spec/mongoid/relations/conversions_spec.rb +0 -128
- data/spec/mongoid/relations/metadata_spec.rb +0 -1985
- data/spec/mongoid/relations/options_spec.rb +0 -35
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# This file contains functions pertaining to downloading, starting and
|
|
2
|
+
# configuring a MongoDB server.
|
|
3
|
+
|
|
4
|
+
set_fcv() {
|
|
5
|
+
if test -n "$FCV"; then
|
|
6
|
+
mongo --eval 'assert.commandWorked(db.adminCommand( { setFeatureCompatibilityVersion: "'"$FCV"'" } ));' "$MONGODB_URI"
|
|
7
|
+
mongo --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' |grep "version.*$FCV"
|
|
8
|
+
fi
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
add_uri_option() {
|
|
12
|
+
opt=$1
|
|
13
|
+
|
|
14
|
+
if ! echo $MONGODB_URI |sed -e s,//,, |grep -q /; then
|
|
15
|
+
MONGODB_URI="$MONGODB_URI/"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if ! echo $MONGODB_URI |grep -q '?'; then
|
|
19
|
+
MONGODB_URI="$MONGODB_URI?"
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
MONGODB_URI="$MONGODB_URI&$opt"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
prepare_server() {
|
|
26
|
+
arch=$1
|
|
27
|
+
|
|
28
|
+
if test -n "$USE_OPT_MONGODB"; then
|
|
29
|
+
export BINDIR=/opt/mongodb/bin
|
|
30
|
+
export PATH=$BINDIR:$PATH
|
|
31
|
+
return
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
if test "$MONGODB_VERSION" = latest; then
|
|
35
|
+
# Test on the most recent published 4.3 release.
|
|
36
|
+
# https://jira.mongodb.org/browse/RUBY-1724
|
|
37
|
+
echo 'Using "latest" server is not currently implemented' 1>&2
|
|
38
|
+
exit 1
|
|
39
|
+
else
|
|
40
|
+
download_version="$MONGODB_VERSION"
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
|
|
44
|
+
|
|
45
|
+
prepare_server_from_url $url
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
prepare_server_from_url() {
|
|
49
|
+
url=$1
|
|
50
|
+
|
|
51
|
+
mongodb_dir="$MONGO_ORCHESTRATION_HOME"/mdb
|
|
52
|
+
mkdir -p "$mongodb_dir"
|
|
53
|
+
curl --retry 3 $url |tar xz -C "$mongodb_dir" -f -
|
|
54
|
+
BINDIR="$mongodb_dir"/`basename $url |sed -e s/.tgz//`/bin
|
|
55
|
+
export PATH="$BINDIR":$PATH
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
install_mlaunch_virtualenv() {
|
|
59
|
+
python2 -V || true
|
|
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
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
install_mlaunch_pip() {
|
|
79
|
+
if test -n "$USE_OPT_MONGODB" && which mlaunch >/dev/null 2>&1; then
|
|
80
|
+
# mlaunch is preinstalled in the docker image, do not install it here
|
|
81
|
+
return
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
python -V || true
|
|
85
|
+
python3 -V || true
|
|
86
|
+
pythonpath="$MONGO_ORCHESTRATION_HOME"/python
|
|
87
|
+
pip install -t "$pythonpath" 'mtools-legacy[mlaunch]'
|
|
88
|
+
export PATH="$pythonpath/bin":$PATH
|
|
89
|
+
export PYTHONPATH="$pythonpath"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
install_mlaunch_git() {
|
|
93
|
+
repo=$1
|
|
94
|
+
branch=$2
|
|
95
|
+
python -V || true
|
|
96
|
+
python3 -V || true
|
|
97
|
+
which pip || true
|
|
98
|
+
which pip3 || true
|
|
99
|
+
|
|
100
|
+
if false; then
|
|
101
|
+
if ! virtualenv --version; then
|
|
102
|
+
python3 `which pip3` install --user virtualenv
|
|
103
|
+
export PATH=$HOME/.local/bin:$PATH
|
|
104
|
+
virtualenv --version
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
|
108
|
+
virtualenv -p python3 $venvpath
|
|
109
|
+
. $venvpath/bin/activate
|
|
110
|
+
|
|
111
|
+
pip3 install psutil pymongo
|
|
112
|
+
|
|
113
|
+
git clone $repo mlaunch
|
|
114
|
+
cd mlaunch
|
|
115
|
+
git checkout origin/$branch
|
|
116
|
+
python3 setup.py install
|
|
117
|
+
cd ..
|
|
118
|
+
else
|
|
119
|
+
pip install --user 'virtualenv==13'
|
|
120
|
+
export PATH=$HOME/.local/bin:$PATH
|
|
121
|
+
|
|
122
|
+
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
|
123
|
+
virtualenv $venvpath
|
|
124
|
+
. $venvpath/bin/activate
|
|
125
|
+
|
|
126
|
+
pip install psutil pymongo
|
|
127
|
+
|
|
128
|
+
git clone $repo mlaunch
|
|
129
|
+
(cd mlaunch &&
|
|
130
|
+
git checkout origin/$branch &&
|
|
131
|
+
python setup.py install
|
|
132
|
+
)
|
|
133
|
+
fi
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
calculate_server_args() {
|
|
137
|
+
local mongo_version=`echo $MONGODB_VERSION |tr -d .`
|
|
138
|
+
|
|
139
|
+
if test -z "$mongo_version"; then
|
|
140
|
+
echo "$MONGODB_VERSION must be set and not contain only dots" 1>&2
|
|
141
|
+
exit 3
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
if test $mongo_version = latest; then
|
|
145
|
+
mongo_version=49
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
local args="--setParameter enableTestCommands=1"
|
|
149
|
+
|
|
150
|
+
if test $mongo_version -ge 47; then
|
|
151
|
+
args="$args --setParameter acceptAPIVersion2=1"
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
# diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
|
|
155
|
+
# and mlaunch does not support specifying mongod-only parameters:
|
|
156
|
+
# https://github.com/rueckstiess/mtools/issues/696
|
|
157
|
+
# Pass it to 3.4 and newer servers where it is accepted by all daemons.
|
|
158
|
+
if test $mongo_version -ge 34; then
|
|
159
|
+
args="$args --setParameter diagnosticDataCollectionEnabled=false"
|
|
160
|
+
fi
|
|
161
|
+
local uri_options=
|
|
162
|
+
if test "$TOPOLOGY" = replica-set; then
|
|
163
|
+
args="$args --replicaset --name ruby-driver-rs --nodes 2 --arbiter"
|
|
164
|
+
export HAVE_ARBITER=1
|
|
165
|
+
elif test "$TOPOLOGY" = sharded-cluster; then
|
|
166
|
+
args="$args --replicaset --nodes 2 --sharded 1 --name ruby-driver-rs"
|
|
167
|
+
if test -z "$SINGLE_MONGOS"; then
|
|
168
|
+
args="$args --mongos 2"
|
|
169
|
+
fi
|
|
170
|
+
else
|
|
171
|
+
args="$args --single"
|
|
172
|
+
fi
|
|
173
|
+
if test -n "$MMAPV1"; then
|
|
174
|
+
args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
|
|
175
|
+
uri_options="$uri_options&retryReads=false&retryWrites=false"
|
|
176
|
+
fi
|
|
177
|
+
if test "$AUTH" = auth; then
|
|
178
|
+
args="$args --auth --username bob --password pwd123"
|
|
179
|
+
elif test "$AUTH" = x509; then
|
|
180
|
+
args="$args --auth --username bootstrap --password bootstrap"
|
|
181
|
+
elif echo "$AUTH" |grep -q ^aws; then
|
|
182
|
+
args="$args --auth --username bootstrap --password bootstrap"
|
|
183
|
+
args="$args --setParameter authenticationMechanisms=MONGODB-AWS,SCRAM-SHA-1,SCRAM-SHA-256"
|
|
184
|
+
uri_options="$uri_options&authMechanism=MONGODB-AWS&authSource=\$external"
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
if test -n "$OCSP"; then
|
|
188
|
+
if test -z "$OCSP_ALGORITHM"; then
|
|
189
|
+
echo "OCSP_ALGORITHM must be set if OCSP is set" 1>&2
|
|
190
|
+
exit 1
|
|
191
|
+
fi
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
local server_cert_path server_ca_path server_client_cert_path
|
|
195
|
+
if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
|
|
196
|
+
if test -n "$OCSP_ALGORITHM"; then
|
|
197
|
+
if test "$OCSP_MUST_STAPLE" = 1; then
|
|
198
|
+
server_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server-mustStaple.pem
|
|
199
|
+
else
|
|
200
|
+
server_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
|
|
201
|
+
fi
|
|
202
|
+
server_ca_path=spec/support/ocsp/$OCSP_ALGORITHM/ca.crt
|
|
203
|
+
server_client_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
|
|
204
|
+
else
|
|
205
|
+
server_cert_path=spec/support/certificates/server-second-level-bundle.pem
|
|
206
|
+
server_ca_path=spec/support/certificates/ca.crt
|
|
207
|
+
server_client_cert_path=spec/support/certificates/client.pem
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
if test -n "$OCSP_ALGORITHM"; then
|
|
211
|
+
client_cert_path=spec/support/ocsp/$OCSP_ALGORITHM/server.pem
|
|
212
|
+
elif test "$AUTH" = x509; then
|
|
213
|
+
client_cert_path=spec/support/certificates/client-x509.pem
|
|
214
|
+
|
|
215
|
+
uri_options="$uri_options&authMechanism=MONGODB-X509"
|
|
216
|
+
elif echo $RVM_RUBY |grep -q jruby; then
|
|
217
|
+
# JRuby does not grok chained certificate bundles -
|
|
218
|
+
# https://github.com/jruby/jruby-openssl/issues/181
|
|
219
|
+
client_cert_path=spec/support/certificates/client.pem
|
|
220
|
+
else
|
|
221
|
+
client_cert_path=spec/support/certificates/client-second-level-bundle.pem
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
uri_options="$uri_options&tls=true&"\
|
|
225
|
+
"tlsCAFile=$server_ca_path&"\
|
|
226
|
+
"tlsCertificateKeyFile=$client_cert_path"
|
|
227
|
+
|
|
228
|
+
args="$args --sslMode requireSSL"\
|
|
229
|
+
" --sslPEMKeyFile $server_cert_path"\
|
|
230
|
+
" --sslCAFile $server_ca_path"\
|
|
231
|
+
" --sslClientCertificate $server_client_cert_path"
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
# Docker forwards ports to the external interface, not to the loopback.
|
|
235
|
+
# Hence we must bind to all interfaces here.
|
|
236
|
+
if test -n "$BIND_ALL"; then
|
|
237
|
+
args="$args --bind_ip_all"
|
|
238
|
+
fi
|
|
239
|
+
|
|
240
|
+
# MongoDB servers pre-4.2 do not enable zlib compression by default
|
|
241
|
+
if test "$COMPRESSOR" = snappy; then
|
|
242
|
+
args="$args --networkMessageCompressors snappy"
|
|
243
|
+
elif test "$COMPRESSOR" = zlib; then
|
|
244
|
+
args="$args --networkMessageCompressors zlib"
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
if test -n "$OCSP_ALGORITHM" || test -n "$OCSP_VERIFIER"; then
|
|
248
|
+
python3 -m pip install asn1crypto oscrypto flask
|
|
249
|
+
fi
|
|
250
|
+
|
|
251
|
+
local ocsp_args=
|
|
252
|
+
if test -n "$OCSP_ALGORITHM"; then
|
|
253
|
+
if test -z "$server_ca_path"; then
|
|
254
|
+
echo "server_ca_path must have been set" 1>&2
|
|
255
|
+
exit 1
|
|
256
|
+
fi
|
|
257
|
+
ocsp_args="--ca_file $server_ca_path"
|
|
258
|
+
if test "$OCSP_DELEGATE" = 1; then
|
|
259
|
+
ocsp_args="$ocsp_args \
|
|
260
|
+
--ocsp_responder_cert spec/support/ocsp/$OCSP_ALGORITHM/ocsp-responder.crt \
|
|
261
|
+
--ocsp_responder_key spec/support/ocsp/$OCSP_ALGORITHM/ocsp-responder.key \
|
|
262
|
+
"
|
|
263
|
+
else
|
|
264
|
+
ocsp_args="$ocsp_args \
|
|
265
|
+
--ocsp_responder_cert spec/support/ocsp/$OCSP_ALGORITHM/ca.crt \
|
|
266
|
+
--ocsp_responder_key spec/support/ocsp/$OCSP_ALGORITHM/ca.key \
|
|
267
|
+
"
|
|
268
|
+
fi
|
|
269
|
+
if test -n "$OCSP_STATUS"; then
|
|
270
|
+
ocsp_args="$ocsp_args --fault $OCSP_STATUS"
|
|
271
|
+
fi
|
|
272
|
+
fi
|
|
273
|
+
|
|
274
|
+
OCSP_ARGS="$ocsp_args"
|
|
275
|
+
SERVER_ARGS="$args"
|
|
276
|
+
URI_OPTIONS="$uri_options"
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
launch_ocsp_mock() {
|
|
280
|
+
if test -n "$OCSP_ARGS"; then
|
|
281
|
+
# Bind to 0.0.0.0 for Docker
|
|
282
|
+
python3 spec/support/ocsp/ocsp_mock.py $OCSP_ARGS -b 0.0.0.0 -p 8100 &
|
|
283
|
+
OCSP_MOCK_PID=$!
|
|
284
|
+
fi
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
launch_server() {
|
|
288
|
+
local dbdir="$1"
|
|
289
|
+
python -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
|
|
290
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
TOOLCHAIN_VERSION=289d4bec7c61e88000cea582c05fd8073b932122
|
|
2
|
+
|
|
3
|
+
set_env_java() {
|
|
4
|
+
ls -l /opt || true
|
|
5
|
+
ls -l /usr/lib/jvm || true
|
|
6
|
+
|
|
7
|
+
# Use toolchain java if it exists
|
|
8
|
+
if [ -f /opt/java/jdk8/bin/java ]; then
|
|
9
|
+
export JAVACMD=/opt/java/jdk8/bin/java
|
|
10
|
+
#export PATH=$PATH:/opt/java/jdk8/bin
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
# ppc64le has it in a different place
|
|
14
|
+
if test -z "$JAVACMD" && [ -f /usr/lib/jvm/java-1.8.0/bin/java ]; then
|
|
15
|
+
export JAVACMD=/usr/lib/jvm/java-1.8.0/bin/java
|
|
16
|
+
#export PATH=$PATH:/usr/lib/jvm/java-1.8.0/bin
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
if true; then
|
|
20
|
+
# newer
|
|
21
|
+
# rhel71-ppc, https://jira.mongodb.org/browse/BUILD-9231
|
|
22
|
+
if test -z "$JAVACMD" &&
|
|
23
|
+
(ls /opt/java || true) |grep -q java-1.8.0-openjdk-1.8.0 &&
|
|
24
|
+
test -f /opt/java/java-1.8.0-openjdk-1.8.0*/bin/java;
|
|
25
|
+
then
|
|
26
|
+
path=$(cd /opt/java && ls -d java-1.8.0-openjdk-1.8.0* |head -n 1)
|
|
27
|
+
export JAVACMD=/opt/java/"$path"/bin/java
|
|
28
|
+
fi
|
|
29
|
+
else
|
|
30
|
+
# older
|
|
31
|
+
# rhel71-ppc seems to have an /opt/java/jdk8/bin/java but it doesn't work
|
|
32
|
+
if test -n "$JAVACMD" && ! exec $JAVACMD -version; then
|
|
33
|
+
JAVACMD=
|
|
34
|
+
# we will try the /usr/lib/jvm then
|
|
35
|
+
fi
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if test -n "$JAVACMD"; then
|
|
39
|
+
eval $JAVACMD -version
|
|
40
|
+
elif which java 2>/dev/null; then
|
|
41
|
+
java -version
|
|
42
|
+
else
|
|
43
|
+
echo No java runtime found
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set_env_ruby() {
|
|
48
|
+
if test -z "$RVM_RUBY"; then
|
|
49
|
+
echo "Empty RVM_RUBY, aborting"
|
|
50
|
+
exit 2
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
#ls -l /opt
|
|
54
|
+
|
|
55
|
+
# Necessary for jruby
|
|
56
|
+
set_env_java
|
|
57
|
+
|
|
58
|
+
if [ "$RVM_RUBY" == "ruby-head" ]; then
|
|
59
|
+
# When we use ruby-head, we do not install the Ruby toolchain.
|
|
60
|
+
# But we still need Python 3.6+ to run mlaunch.
|
|
61
|
+
# Since the ruby-head tests are run on ubuntu1604, we can use the
|
|
62
|
+
# globally installed Python toolchain.
|
|
63
|
+
#export PATH=/opt/python/3.7/bin:$PATH
|
|
64
|
+
|
|
65
|
+
# 12.04, 14.04 and 16.04 are good
|
|
66
|
+
curl --retry 3 -fL http://rubies.travis-ci.org/ubuntu/`lsb_release -rs`/x86_64/ruby-head.tar.bz2 |tar xfj -
|
|
67
|
+
# TODO adjust gem path?
|
|
68
|
+
export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
|
|
69
|
+
ruby --version
|
|
70
|
+
ruby --version |grep dev
|
|
71
|
+
else
|
|
72
|
+
if test "$USE_OPT_TOOLCHAIN" = 1; then
|
|
73
|
+
# nothing, also PATH is already set
|
|
74
|
+
:
|
|
75
|
+
elif true; then
|
|
76
|
+
|
|
77
|
+
# For testing toolchains:
|
|
78
|
+
#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
|
|
79
|
+
toolchain_url=http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/ruby-toolchain-`host_distro`-$TOOLCHAIN_VERSION.tar.xz
|
|
80
|
+
curl --retry 3 -fL $toolchain_url |tar Jxf -
|
|
81
|
+
export PATH=`pwd`/rubies/$RVM_RUBY/bin:$PATH
|
|
82
|
+
#export PATH=`pwd`/rubies/python/3/bin:$PATH
|
|
83
|
+
|
|
84
|
+
# Attempt to get bundler to report all errors - so far unsuccessful
|
|
85
|
+
#curl --retry 3 -o bundler-openssl.diff https://github.com/bundler/bundler/compare/v2.0.1...p-mongo:report-errors.diff
|
|
86
|
+
#find . -path \*/lib/bundler/fetcher.rb -exec patch {} bundler-openssl.diff \;
|
|
87
|
+
|
|
88
|
+
else
|
|
89
|
+
|
|
90
|
+
# Normal operation
|
|
91
|
+
if ! test -d $HOME/.rubies/$RVM_RUBY/bin; then
|
|
92
|
+
echo "Ruby directory does not exist: $HOME/.rubies/$RVM_RUBY/bin" 1>&2
|
|
93
|
+
echo "Contents of /opt:" 1>&2
|
|
94
|
+
ls -l /opt 1>&2 || true
|
|
95
|
+
echo ".rubies symlink:" 1>&2
|
|
96
|
+
ls -ld $HOME/.rubies 1>&2 || true
|
|
97
|
+
echo "Our rubies:" 1>&2
|
|
98
|
+
ls -l $HOME/.rubies 1>&2 || true
|
|
99
|
+
exit 2
|
|
100
|
+
fi
|
|
101
|
+
export PATH=$HOME/.rubies/$RVM_RUBY/bin:$PATH
|
|
102
|
+
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
ruby --version
|
|
106
|
+
|
|
107
|
+
# Ensure we're using the right ruby
|
|
108
|
+
ruby_name=`echo $RVM_RUBY |awk -F- '{print $1}'`
|
|
109
|
+
ruby_version=`echo $RVM_RUBY |awk -F- '{print $2}' |cut -c 1-3`
|
|
110
|
+
|
|
111
|
+
ruby -v |fgrep $ruby_name
|
|
112
|
+
ruby -v |fgrep $ruby_version
|
|
113
|
+
|
|
114
|
+
# We shouldn't need to update rubygems, and there is value in
|
|
115
|
+
# testing on whatever rubygems came with each supported ruby version
|
|
116
|
+
#echo 'updating rubygems'
|
|
117
|
+
#gem update --system
|
|
118
|
+
|
|
119
|
+
# Only install bundler when not using ruby-head.
|
|
120
|
+
# ruby-head comes with bundler and gem complains
|
|
121
|
+
# because installing bundler would overwrite the bundler binary.
|
|
122
|
+
# We now install bundler in the toolchain, hence nothing needs to be done
|
|
123
|
+
# in the tests.
|
|
124
|
+
if false && echo "$RVM_RUBY" |grep -q jruby; then
|
|
125
|
+
gem install bundler -v '<2'
|
|
126
|
+
fi
|
|
127
|
+
fi
|
|
128
|
+
}
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'lite_spec_helper'
|
|
3
4
|
|
|
4
5
|
MODELS = File.join(File.dirname(__FILE__), "app/models")
|
|
5
6
|
$LOAD_PATH.unshift(MODELS)
|
|
6
7
|
|
|
7
8
|
require "action_controller"
|
|
8
|
-
require
|
|
9
|
-
require "rspec"
|
|
10
|
-
|
|
11
|
-
# These environment variables can be set if wanting to test against a database
|
|
12
|
-
# that is not on the local machine.
|
|
13
|
-
ENV["MONGOID_SPEC_HOST"] ||= "127.0.0.1"
|
|
14
|
-
ENV["MONGOID_SPEC_PORT"] ||= "27017"
|
|
15
|
-
|
|
16
|
-
# These are used when creating any connection in the test suite.
|
|
17
|
-
HOST = ENV["MONGOID_SPEC_HOST"]
|
|
18
|
-
PORT = ENV["MONGOID_SPEC_PORT"].to_i
|
|
9
|
+
require 'rspec/retry'
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
if SpecConfig.instance.client_debug?
|
|
12
|
+
Mongoid.logger.level = Logger::DEBUG
|
|
13
|
+
Mongo::Logger.logger.level = Logger::DEBUG
|
|
14
|
+
else
|
|
15
|
+
Mongoid.logger.level = Logger::INFO
|
|
16
|
+
Mongo::Logger.logger.level = Logger::INFO
|
|
17
|
+
end
|
|
22
18
|
|
|
23
19
|
# When testing locally we use the database named mongoid_test. However when
|
|
24
20
|
# tests are running in parallel on Travis we need to use different database
|
|
@@ -35,15 +31,14 @@ end
|
|
|
35
31
|
require 'support/authorization'
|
|
36
32
|
require 'support/expectations'
|
|
37
33
|
require 'support/macros'
|
|
38
|
-
require 'support/spec_config'
|
|
39
34
|
require 'support/cluster_config'
|
|
40
35
|
require 'support/constraints'
|
|
41
|
-
require '
|
|
36
|
+
require 'mrss/constraints'
|
|
42
37
|
|
|
43
38
|
# Give MongoDB time to start up on the travis ci environment.
|
|
44
39
|
if (ENV['CI'] == 'travis' || ENV['CI'] == 'evergreen')
|
|
45
40
|
starting = true
|
|
46
|
-
client = Mongo::Client.new(
|
|
41
|
+
client = Mongo::Client.new(SpecConfig.instance.addresses)
|
|
47
42
|
while starting
|
|
48
43
|
begin
|
|
49
44
|
client.command(Mongo::Server::Monitor::Connection::ISMASTER)
|
|
@@ -59,9 +54,10 @@ CONFIG = {
|
|
|
59
54
|
clients: {
|
|
60
55
|
default: {
|
|
61
56
|
database: database_id,
|
|
62
|
-
hosts:
|
|
57
|
+
hosts: SpecConfig.instance.addresses,
|
|
63
58
|
options: {
|
|
64
|
-
server_selection_timeout:
|
|
59
|
+
server_selection_timeout: 3.42,
|
|
60
|
+
wait_queue_timeout: 1,
|
|
65
61
|
max_pool_size: 5,
|
|
66
62
|
heartbeat_frequency: 180,
|
|
67
63
|
user: MONGOID_ROOT_USER.name,
|
|
@@ -71,32 +67,15 @@ CONFIG = {
|
|
|
71
67
|
}
|
|
72
68
|
},
|
|
73
69
|
options: {
|
|
74
|
-
belongs_to_required_by_default: false
|
|
70
|
+
belongs_to_required_by_default: false,
|
|
71
|
+
log_level: if SpecConfig.instance.client_debug?
|
|
72
|
+
:debug
|
|
73
|
+
else
|
|
74
|
+
:info
|
|
75
|
+
end,
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
def non_legacy_server?
|
|
79
|
-
Mongoid::Clients.default.cluster.servers.first.features.write_command_enabled?
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def testing_replica_set?
|
|
83
|
-
Mongoid::Clients.default.cluster.replica_set?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def collation_supported?
|
|
87
|
-
Mongoid::Clients.default.cluster.next_primary.features.collation_enabled?
|
|
88
|
-
end
|
|
89
|
-
alias :decimal128_supported? :collation_supported?
|
|
90
|
-
|
|
91
|
-
def testing_locally?
|
|
92
|
-
!(ENV['CI'] == 'travis')
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def array_filters_supported?
|
|
96
|
-
Mongoid::Clients.default.cluster.next_primary.features.array_filters_enabled?
|
|
97
|
-
end
|
|
98
|
-
alias :sessions_supported? :array_filters_supported?
|
|
99
|
-
|
|
100
79
|
# Set the database that the spec suite connects to.
|
|
101
80
|
Mongoid.configure do |config|
|
|
102
81
|
config.load_configuration(CONFIG)
|
|
@@ -132,16 +111,14 @@ end
|
|
|
132
111
|
I18n.config.enforce_available_locales = false
|
|
133
112
|
|
|
134
113
|
RSpec.configure do |config|
|
|
135
|
-
config.expect_with(:rspec) do |c|
|
|
136
|
-
c.syntax = [:should, :expect]
|
|
137
|
-
end
|
|
138
|
-
|
|
139
114
|
config.raise_errors_for_deprecations!
|
|
140
115
|
config.include(Mongoid::Expectations)
|
|
116
|
+
config.extend(Mrss::Constraints)
|
|
141
117
|
config.extend(Constraints)
|
|
118
|
+
config.extend(Mongoid::Macros)
|
|
142
119
|
|
|
143
120
|
config.before(:suite) do
|
|
144
|
-
client = Mongo::Client.new(
|
|
121
|
+
client = Mongo::Client.new(SpecConfig.instance.addresses, server_selection_timeout: 3.03)
|
|
145
122
|
begin
|
|
146
123
|
# Create the root user administrator as the first user to be added to the
|
|
147
124
|
# database. This user will need to be authenticated in order to add any
|
|
@@ -149,11 +126,19 @@ RSpec.configure do |config|
|
|
|
149
126
|
client.database.users.create(MONGOID_ROOT_USER)
|
|
150
127
|
rescue Exception => e
|
|
151
128
|
end
|
|
129
|
+
Mongoid.purge!
|
|
152
130
|
end
|
|
153
131
|
|
|
154
132
|
# Drop all collections and clear the identity map before each spec.
|
|
155
133
|
config.before(:each) do
|
|
156
|
-
Mongoid.
|
|
134
|
+
cluster = Mongoid.default_client.cluster
|
|
135
|
+
# Older drivers do not have a #connected? method
|
|
136
|
+
if cluster.respond_to?(:connected?) && !cluster.connected?
|
|
137
|
+
Mongoid.default_client.reconnect
|
|
138
|
+
end
|
|
139
|
+
Mongoid.default_client.collections.each do |coll|
|
|
140
|
+
coll.delete_many
|
|
141
|
+
end
|
|
157
142
|
end
|
|
158
143
|
end
|
|
159
144
|
|
|
@@ -99,7 +99,7 @@ class ClusterConfig
|
|
|
99
99
|
if topology == :sharded
|
|
100
100
|
shards = client.use(:admin).command(listShards: 1).first
|
|
101
101
|
shard = shards['shards'].first
|
|
102
|
-
address_str = shard['host'].sub(
|
|
102
|
+
address_str = shard['host'].sub(/\A.*\//, '').sub(/,.*/, '')
|
|
103
103
|
client = ClusterTools.instance.direct_client(address_str,
|
|
104
104
|
SpecConfig.instance.test_options.merge(SpecConfig.instance.auth_options).merge(connect: :direct))
|
|
105
105
|
end
|
|
@@ -133,8 +133,8 @@ class ClusterConfig
|
|
|
133
133
|
|
|
134
134
|
@topology ||= begin
|
|
135
135
|
topology = client.cluster.topology.class.name.sub(/.*::/, '')
|
|
136
|
-
topology = topology.gsub(/([A-Z])/) { |match| '_' + match.downcase }.sub(
|
|
137
|
-
if topology =~
|
|
136
|
+
topology = topology.gsub(/([A-Z])/) { |match| '_' + match.downcase }.sub(/\A_/, '')
|
|
137
|
+
if topology =~ /\Areplica_set/
|
|
138
138
|
topology = 'replica_set'
|
|
139
139
|
end
|
|
140
140
|
topology.to_sym
|