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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/Rakefile +16 -0
- data/lib/config/locales/en.yml +2 -15
- data/lib/mongoid/association/accessors.rb +1 -1
- data/lib/mongoid/association/constrainable.rb +1 -1
- data/lib/mongoid/association/depending.rb +4 -4
- data/lib/mongoid/association/embedded/batchable.rb +1 -1
- data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +11 -4
- data/lib/mongoid/association/nested/many.rb +1 -1
- data/lib/mongoid/association/nested/one.rb +4 -2
- data/lib/mongoid/association/proxy.rb +7 -2
- data/lib/mongoid/association/referenced/auto_save.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
- data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
- data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
- data/lib/mongoid/association/relatable.rb +0 -2
- data/lib/mongoid/attributes/projector.rb +120 -0
- data/lib/mongoid/attributes.rb +24 -13
- data/lib/mongoid/cacheable.rb +2 -2
- data/lib/mongoid/clients/factory.rb +22 -8
- data/lib/mongoid/clients.rb +1 -1
- data/lib/mongoid/config/environment.rb +1 -9
- data/lib/mongoid/config.rb +19 -2
- data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
- data/lib/mongoid/contextual/atomic.rb +2 -7
- data/lib/mongoid/contextual/none.rb +0 -3
- data/lib/mongoid/copyable.rb +1 -1
- data/lib/mongoid/criteria/findable.rb +1 -1
- data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
- data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
- data/lib/mongoid/criteria/queryable/selectable.rb +10 -10
- data/lib/mongoid/criteria/queryable/storable.rb +4 -4
- data/lib/mongoid/criteria.rb +5 -6
- data/lib/mongoid/document.rb +3 -18
- data/lib/mongoid/errors/delete_restriction.rb +8 -9
- data/lib/mongoid/errors/mongoid_error.rb +1 -1
- data/lib/mongoid/errors.rb +0 -2
- data/lib/mongoid/evolvable.rb +1 -1
- data/lib/mongoid/extensions/boolean.rb +1 -2
- data/lib/mongoid/extensions/false_class.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +2 -2
- data/lib/mongoid/extensions/true_class.rb +1 -1
- data/lib/mongoid/fields.rb +43 -5
- data/lib/mongoid/inspectable.rb +1 -1
- data/lib/mongoid/interceptable.rb +1 -1
- data/lib/mongoid/matcher/bits.rb +41 -0
- data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_all_set.rb +20 -0
- data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_any_set.rb +20 -0
- data/lib/mongoid/matcher/expression.rb +4 -0
- data/lib/mongoid/matcher/field_operator.rb +6 -0
- data/lib/mongoid/matcher/mod.rb +17 -0
- data/lib/mongoid/matcher/type.rb +99 -0
- data/lib/mongoid/matcher.rb +7 -0
- data/lib/mongoid/persistable/deletable.rb +1 -2
- data/lib/mongoid/persistable/destroyable.rb +8 -2
- data/lib/mongoid/persistable/updatable.rb +27 -2
- data/lib/mongoid/persistence_context.rb +1 -3
- data/lib/mongoid/query_cache.rb +36 -40
- data/lib/mongoid/selectable.rb +5 -7
- data/lib/mongoid/shardable.rb +21 -5
- data/lib/mongoid/tasks/database.rb +1 -1
- data/lib/mongoid/touchable.rb +23 -4
- data/lib/mongoid/validatable/associated.rb +1 -1
- data/lib/mongoid/validatable/presence.rb +3 -3
- data/lib/mongoid/validatable/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid.rb +0 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
- data/spec/integration/app_spec.rb +0 -3
- data/spec/integration/associations/embeds_many_spec.rb +44 -0
- data/spec/integration/associations/has_one_spec.rb +48 -0
- data/spec/integration/criteria/date_field_spec.rb +1 -1
- data/spec/integration/document_spec.rb +9 -0
- data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
- data/spec/integration/matcher_operator_data/comment.yml +22 -0
- data/spec/integration/matcher_operator_data/in.yml +16 -0
- data/spec/integration/matcher_operator_data/mod.yml +55 -0
- data/spec/integration/matcher_operator_data/type.yml +70 -0
- data/spec/integration/matcher_operator_data/type_array.yml +16 -0
- data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
- data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
- data/spec/integration/matcher_operator_data/type_code.yml +26 -0
- data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
- data/spec/integration/matcher_operator_data/type_date.yml +39 -0
- data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
- data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
- data/spec/integration/matcher_operator_data/type_double.yml +15 -0
- data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
- data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
- data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_null.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
- data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
- data/spec/integration/matcher_operator_data/type_string.yml +15 -0
- data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
- data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
- data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
- data/spec/integration/stringified_symbol_field_spec.rb +2 -2
- data/spec/lite_spec_helper.rb +2 -0
- data/spec/mongoid/association/depending_spec.rb +391 -352
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +4 -17
- data/spec/mongoid/association/nested/one_spec.rb +18 -14
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -25
- data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +0 -20
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many_models.rb +0 -17
- data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
- data/spec/mongoid/atomic/paths_spec.rb +64 -12
- data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
- data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
- data/spec/mongoid/attributes/projector_spec.rb +41 -0
- data/spec/mongoid/attributes_spec.rb +98 -6
- data/spec/mongoid/clients/factory_spec.rb +51 -9
- data/spec/mongoid/clients/options_spec.rb +3 -11
- data/spec/mongoid/config/environment_spec.rb +8 -86
- data/spec/mongoid/config_spec.rb +32 -0
- data/spec/mongoid/contextual/atomic_spec.rb +25 -64
- data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
- data/spec/mongoid/contextual/mongo_spec.rb +2 -2
- data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
- data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
- data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
- data/spec/mongoid/criteria_projection_spec.rb +411 -0
- data/spec/mongoid/criteria_spec.rb +0 -279
- data/spec/mongoid/document_query_spec.rb +0 -51
- data/spec/mongoid/document_spec.rb +14 -34
- data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
- data/spec/mongoid/errors/mongoid_error_spec.rb +8 -20
- data/spec/mongoid/extensions/false_class_spec.rb +1 -1
- data/spec/mongoid/extensions/string_spec.rb +5 -5
- data/spec/mongoid/extensions/true_class_spec.rb +1 -1
- data/spec/mongoid/fields/localized_spec.rb +4 -4
- data/spec/mongoid/fields_spec.rb +4 -4
- data/spec/mongoid/inspectable_spec.rb +12 -4
- data/spec/mongoid/persistable/deletable_spec.rb +175 -1
- data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
- data/spec/mongoid/persistable/savable_spec.rb +3 -5
- data/spec/mongoid/persistable/updatable_spec.rb +0 -2
- data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
- data/spec/mongoid/persistable_spec.rb +2 -2
- data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
- data/spec/mongoid/query_cache_spec.rb +0 -24
- data/spec/mongoid/reloadable_spec.rb +18 -1
- data/spec/mongoid/shardable_spec.rb +44 -0
- data/spec/mongoid/touchable_spec.rb +104 -16
- data/spec/mongoid/touchable_spec_models.rb +52 -0
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/shared/lib/mrss/cluster_config.rb +3 -8
- data/spec/shared/lib/mrss/constraints.rb +10 -41
- data/spec/shared/lib/mrss/docker_runner.rb +1 -7
- data/spec/shared/lib/mrss/server_version_registry.rb +12 -17
- data/spec/shared/lib/mrss/spec_organizer.rb +1 -18
- data/spec/shared/share/Dockerfile.erb +33 -125
- data/spec/shared/shlib/server.sh +23 -100
- data/spec/shared/shlib/set_env.sh +1 -4
- data/spec/spec_helper.rb +7 -3
- data/spec/support/client_registry.rb +9 -0
- data/spec/support/models/address.rb +0 -4
- data/spec/support/models/bolt.rb +8 -0
- data/spec/support/models/hole.rb +13 -0
- data/spec/support/models/mop.rb +0 -1
- data/spec/support/models/nut.rb +8 -0
- data/spec/support/models/person.rb +6 -9
- data/spec/support/models/sealer.rb +8 -0
- data/spec/support/models/shirt.rb +12 -0
- data/spec/support/models/spacer.rb +8 -0
- data/spec/support/models/threadlocker.rb +8 -0
- data/spec/support/models/washer.rb +8 -0
- data.tar.gz.sig +0 -0
- metadata +609 -545
- metadata.gz.sig +0 -0
- data/lib/mongoid/errors/empty_config_file.rb +0 -26
- data/lib/mongoid/errors/invalid_config_file.rb +0 -26
- data/spec/integration/contextual/empty_spec.rb +0 -142
- data/spec/mongoid/errors/invalid_config_file_spec.rb +0 -32
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -200
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/support/cluster_config.rb +0 -158
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
|
-
module Mongoid
|
|
5
|
-
module Errors
|
|
6
|
-
|
|
7
|
-
# This error is raised when an empty configuration file is attempted to be
|
|
8
|
-
# loaded.
|
|
9
|
-
class EmptyConfigFile < MongoidError
|
|
10
|
-
|
|
11
|
-
# Create the new error.
|
|
12
|
-
#
|
|
13
|
-
# @param [ String ] path The path of the config file used.
|
|
14
|
-
#
|
|
15
|
-
# @api private
|
|
16
|
-
def initialize(path)
|
|
17
|
-
super(
|
|
18
|
-
compose_message(
|
|
19
|
-
"empty_config_file",
|
|
20
|
-
{ path: path }
|
|
21
|
-
)
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
|
-
module Mongoid
|
|
5
|
-
module Errors
|
|
6
|
-
|
|
7
|
-
# This error is raised when a bad configuration file is attempted to be
|
|
8
|
-
# loaded.
|
|
9
|
-
class InvalidConfigFile < MongoidError
|
|
10
|
-
|
|
11
|
-
# Create the new error.
|
|
12
|
-
#
|
|
13
|
-
# @param [ String ] path The path of the config file used.
|
|
14
|
-
#
|
|
15
|
-
# @api private
|
|
16
|
-
def initialize(path)
|
|
17
|
-
super(
|
|
18
|
-
compose_message(
|
|
19
|
-
"invalid_config_file",
|
|
20
|
-
{ path: path }
|
|
21
|
-
)
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
|
-
require 'spec_helper'
|
|
5
|
-
|
|
6
|
-
describe 'Contextual classes when dealing with empty result set' do
|
|
7
|
-
shared_examples 'behave as expected' do
|
|
8
|
-
context '#exists?' do
|
|
9
|
-
it 'is false' do
|
|
10
|
-
context.exists?.should be false
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
context '#count' do
|
|
15
|
-
it 'is 0' do
|
|
16
|
-
context.count.should == 0
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context '#length' do
|
|
21
|
-
it 'is 0' do
|
|
22
|
-
context.length.should == 0
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# #estimated_count only exists for Mongo
|
|
27
|
-
|
|
28
|
-
context '#distinct' do
|
|
29
|
-
it 'is empty array' do
|
|
30
|
-
context.distinct(:foo).should == []
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context '#each' do
|
|
35
|
-
context 'with block' do
|
|
36
|
-
it 'does not invoke the block' do
|
|
37
|
-
called = false
|
|
38
|
-
context.each do
|
|
39
|
-
called = true
|
|
40
|
-
end
|
|
41
|
-
called.should be false
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'without block' do
|
|
46
|
-
it 'returns Enumerable' do
|
|
47
|
-
context.each.should be_a(Enumerable)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'returns empty Enumerable' do
|
|
51
|
-
context.each.to_a.should == []
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context '#map' do
|
|
57
|
-
context 'with block' do
|
|
58
|
-
it 'does not invoke the block' do
|
|
59
|
-
called = false
|
|
60
|
-
context.map do
|
|
61
|
-
called = true
|
|
62
|
-
end
|
|
63
|
-
called.should be false
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
context 'without block' do
|
|
68
|
-
it 'returns empty array' do
|
|
69
|
-
skip 'MONGOID-5148'
|
|
70
|
-
|
|
71
|
-
context.map(:field).should == []
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context '#first' do
|
|
77
|
-
it 'is nil' do
|
|
78
|
-
context.first.should be nil
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context '#find_first' do
|
|
83
|
-
it 'is nil' do
|
|
84
|
-
context.find_first.should be nil
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
context '#one' do
|
|
89
|
-
it 'is nil' do
|
|
90
|
-
context.one.should be nil
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context '#last' do
|
|
95
|
-
it 'is nil' do
|
|
96
|
-
context.last.should be nil
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
let(:context) do
|
|
102
|
-
context_cls.new(criteria)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
before do
|
|
106
|
-
# Create an object of the same class used in the Criteria instance
|
|
107
|
-
# to verify we are using the Contextual classes.
|
|
108
|
-
Mop.create!
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context 'Mongo' do
|
|
112
|
-
let(:context_cls) { Mongoid::Contextual::Mongo }
|
|
113
|
-
|
|
114
|
-
let(:criteria) do
|
|
115
|
-
Mop.and(Mop.where(a: 1), Mop.where(a: 2))
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
include_examples 'behave as expected'
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context 'Memory' do
|
|
122
|
-
let(:context_cls) { Mongoid::Contextual::Memory }
|
|
123
|
-
|
|
124
|
-
let(:criteria) do
|
|
125
|
-
Mop.all.tap do |criteria|
|
|
126
|
-
criteria.documents = []
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
include_examples 'behave as expected'
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
context 'None' do
|
|
134
|
-
let(:context_cls) { Mongoid::Contextual::None }
|
|
135
|
-
|
|
136
|
-
let(:criteria) do
|
|
137
|
-
Mop.none
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
include_examples 'behave as expected'
|
|
141
|
-
end
|
|
142
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
|
-
require "spec_helper"
|
|
5
|
-
|
|
6
|
-
describe Mongoid::Errors::InvalidConfigFile do
|
|
7
|
-
|
|
8
|
-
describe "#message" do
|
|
9
|
-
|
|
10
|
-
let(:error) do
|
|
11
|
-
described_class.new('/my/path')
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "contains the problem in the message" do
|
|
15
|
-
expect(error.message).to include(
|
|
16
|
-
"Invalid configuration file: /my/path."
|
|
17
|
-
)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "contains the summary in the message" do
|
|
21
|
-
expect(error.message).to include(
|
|
22
|
-
"Your mongoid.yml configuration file does not contain the"
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "contains the resolution in the message" do
|
|
27
|
-
expect(error.message).to include(
|
|
28
|
-
"Ensure your configuration file contains the correct contents."
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
data/spec/shared/bin/s3-copy
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'optparse'
|
|
4
|
-
require 'aws-sdk-s3'
|
|
5
|
-
|
|
6
|
-
options = {}
|
|
7
|
-
OptionParser.new do |opts|
|
|
8
|
-
opts.banner = "Usage: s3-copy options"
|
|
9
|
-
|
|
10
|
-
opts.on("-r", "--region=REGION", "AWS region to use (default us-east-1)") do |v|
|
|
11
|
-
options[:region] = v
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
opts.on("-p", "--param=KEY=VALUE", "Specify parameter for new files") do |v|
|
|
15
|
-
options[:params] ||= {}
|
|
16
|
-
k, v = v.split('=', 2)
|
|
17
|
-
options[:params][k.to_sym] = v
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
opts.on("-f", "--from=BUCKET:PATH", "Bucket name and key (or path) to copy from") do |v|
|
|
21
|
-
options[:from] = v
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
opts.on("-t", "--to=BUCKET:PATH", "Bucket name and key (or path) to write to (may be specified more than once)") do |v|
|
|
25
|
-
options[:to] ||= []
|
|
26
|
-
options[:to] << v
|
|
27
|
-
end
|
|
28
|
-
end.parse!
|
|
29
|
-
|
|
30
|
-
ENV['AWS_REGION'] ||= options[:region] || 'us-east-1'
|
|
31
|
-
|
|
32
|
-
bucket, key = options.fetch(:from).split(':', 2)
|
|
33
|
-
|
|
34
|
-
s3 = Aws::S3::Client.new
|
|
35
|
-
|
|
36
|
-
options.fetch(:to).each do |dest|
|
|
37
|
-
STDERR.puts "Copying to #{dest}"
|
|
38
|
-
dbucket, dkey = dest.split(':', 2)
|
|
39
|
-
s3.copy_object(
|
|
40
|
-
bucket: dbucket,
|
|
41
|
-
key: dkey,
|
|
42
|
-
copy_source: "/#{bucket}/#{key}",
|
|
43
|
-
**options[:params] || {},
|
|
44
|
-
)
|
|
45
|
-
end
|
data/spec/shared/bin/s3-upload
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'optparse'
|
|
4
|
-
require 'aws-sdk-s3'
|
|
5
|
-
|
|
6
|
-
options = {}
|
|
7
|
-
OptionParser.new do |opts|
|
|
8
|
-
opts.banner = "Usage: s3-upload options"
|
|
9
|
-
|
|
10
|
-
opts.on("-r", "--region=REGION", "AWS region to use (default us-east-1)") do |v|
|
|
11
|
-
options[:region] = v
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
opts.on("-p", "--param=KEY=VALUE", "Specify parameter for S3 upload") do |v|
|
|
15
|
-
options[:params] ||= {}
|
|
16
|
-
k, v = v.split('=', 2)
|
|
17
|
-
options[:params][k.to_sym] = v
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
opts.on("-f", "--file=PATH", "Path to the file to upload, - to upload standard input") do |v|
|
|
21
|
-
options[:file] = v
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
opts.on("-w", "--write=BUCKET:PATH", "Bucket name and key (or path) to upload to") do |v|
|
|
25
|
-
options[:write] = v
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
opts.on("-c", "--copy=BUCKET:PATH", "Bucket name and key (or path) to copy to (may be specified more than once)") do |v|
|
|
29
|
-
options[:copy] ||= []
|
|
30
|
-
options[:copy] << v
|
|
31
|
-
end
|
|
32
|
-
end.parse!
|
|
33
|
-
|
|
34
|
-
ENV['AWS_REGION'] ||= options[:region] || 'us-east-1'
|
|
35
|
-
|
|
36
|
-
def upload(f, options)
|
|
37
|
-
s3 = Aws::S3::Client.new
|
|
38
|
-
write = options.fetch(:write)
|
|
39
|
-
STDERR.puts "Writing #{write}"
|
|
40
|
-
bucket, key = write.split(':', 2)
|
|
41
|
-
s3.put_object(
|
|
42
|
-
body: f.read,
|
|
43
|
-
bucket: bucket,
|
|
44
|
-
key: key,
|
|
45
|
-
**options[:params] || {},
|
|
46
|
-
)
|
|
47
|
-
if copy = options[:copy]
|
|
48
|
-
copy.each do |dest|
|
|
49
|
-
STDERR.puts "Copying to #{dest}"
|
|
50
|
-
dbucket, dkey = dest.split(':', 2)
|
|
51
|
-
s3.copy_object(
|
|
52
|
-
bucket: dbucket,
|
|
53
|
-
key: dkey,
|
|
54
|
-
copy_source: "/#{bucket}/#{key}",
|
|
55
|
-
**options[:params] || {},
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
if options[:file] == '-'
|
|
62
|
-
upload(STDIN, options)
|
|
63
|
-
elsif options[:file]
|
|
64
|
-
File.open(options[:file]) do |f|
|
|
65
|
-
upload(f, options)
|
|
66
|
-
end
|
|
67
|
-
else
|
|
68
|
-
upload(STDIN, options)
|
|
69
|
-
end
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Mrss
|
|
4
|
-
# Test event subscriber.
|
|
5
|
-
class EventSubscriber
|
|
6
|
-
|
|
7
|
-
# The mappings of event names to types.
|
|
8
|
-
MAPPINGS = {
|
|
9
|
-
'topology_opening_event' => Mongo::Monitoring::Event::TopologyOpening,
|
|
10
|
-
'topology_description_changed_event' => Mongo::Monitoring::Event::TopologyChanged,
|
|
11
|
-
'topology_closed_event' => Mongo::Monitoring::Event::TopologyClosed,
|
|
12
|
-
'server_opening_event' => Mongo::Monitoring::Event::ServerOpening,
|
|
13
|
-
'server_description_changed_event' => Mongo::Monitoring::Event::ServerDescriptionChanged,
|
|
14
|
-
'server_closed_event' => Mongo::Monitoring::Event::ServerClosed
|
|
15
|
-
}.freeze
|
|
16
|
-
|
|
17
|
-
attr_reader :all_events
|
|
18
|
-
|
|
19
|
-
attr_reader :started_events
|
|
20
|
-
|
|
21
|
-
attr_reader :succeeded_events
|
|
22
|
-
|
|
23
|
-
attr_reader :failed_events
|
|
24
|
-
|
|
25
|
-
attr_reader :published_events
|
|
26
|
-
|
|
27
|
-
# @param [ String ] name Optional name for the event subscriber.
|
|
28
|
-
def initialize(name: nil)
|
|
29
|
-
@mutex = Mutex.new
|
|
30
|
-
clear_events!
|
|
31
|
-
@name = name
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def to_s
|
|
35
|
-
%Q`#<EventSubscriber:#{@name ? "\"#{@name}\"" : '%x' % object_id} \
|
|
36
|
-
started=#{started_events.length} \
|
|
37
|
-
succeeded=#{succeeded_events.length} \
|
|
38
|
-
failed=#{failed_events.length} \
|
|
39
|
-
published=#{published_events.length}>`
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
alias :inspect :to_s
|
|
43
|
-
|
|
44
|
-
# Event retrieval
|
|
45
|
-
|
|
46
|
-
def select_started_events(cls)
|
|
47
|
-
started_events.select do |event|
|
|
48
|
-
event.is_a?(cls)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def select_succeeded_events(cls)
|
|
53
|
-
succeeded_events.select do |event|
|
|
54
|
-
event.is_a?(cls)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def select_completed_events(*classes)
|
|
59
|
-
(succeeded_events + failed_events).select do |event|
|
|
60
|
-
classes.any? { |c| c === event }
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def select_published_events(cls)
|
|
65
|
-
published_events.select do |event|
|
|
66
|
-
event.is_a?(cls)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Filters command started events for the specified command name.
|
|
71
|
-
def command_started_events(command_name)
|
|
72
|
-
started_events.select do |event|
|
|
73
|
-
event.command[command_name]
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def non_auth_command_started_events
|
|
78
|
-
started_events.reject do |event|
|
|
79
|
-
%w(authenticate getnonce saslSstart saslContinue).any? do |cmd|
|
|
80
|
-
event.command[cmd]
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Locates command stated events for the specified command name,
|
|
86
|
-
# asserts that there is exactly one such event, and returns it.
|
|
87
|
-
def single_command_started_event(command_name, include_auth: false)
|
|
88
|
-
events = if include_auth
|
|
89
|
-
started_events
|
|
90
|
-
else
|
|
91
|
-
non_auth_command_started_events
|
|
92
|
-
end
|
|
93
|
-
events.select! do |event|
|
|
94
|
-
event.command[command_name]
|
|
95
|
-
end
|
|
96
|
-
if events.length != 1
|
|
97
|
-
raise "Expected a single #{command_name} event but we have #{events.length}"
|
|
98
|
-
end
|
|
99
|
-
events.first
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
# Get the first succeeded event published for the name, and then delete it.
|
|
104
|
-
#
|
|
105
|
-
# @param [ String ] name The event name.
|
|
106
|
-
#
|
|
107
|
-
# @return [ Event ] The matching event.
|
|
108
|
-
def first_event(name)
|
|
109
|
-
cls = MAPPINGS[name]
|
|
110
|
-
if cls.nil?
|
|
111
|
-
raise ArgumentError, "Bogus event name #{name}"
|
|
112
|
-
end
|
|
113
|
-
matching = succeeded_events.find do |event|
|
|
114
|
-
cls === event
|
|
115
|
-
end
|
|
116
|
-
succeeded_events.delete(matching)
|
|
117
|
-
matching
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Event recording
|
|
121
|
-
|
|
122
|
-
# Cache the started event.
|
|
123
|
-
#
|
|
124
|
-
# @param [ Event ] event The event.
|
|
125
|
-
def started(event)
|
|
126
|
-
@mutex.synchronize do
|
|
127
|
-
started_events << event
|
|
128
|
-
all_events << event
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Cache the succeeded event.
|
|
133
|
-
#
|
|
134
|
-
# @param [ Event ] event The event.
|
|
135
|
-
def succeeded(event)
|
|
136
|
-
@mutex.synchronize do
|
|
137
|
-
succeeded_events << event
|
|
138
|
-
all_events << event
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
# Cache the failed event.
|
|
143
|
-
#
|
|
144
|
-
# @param [ Event ] event The event.
|
|
145
|
-
def failed(event)
|
|
146
|
-
@mutex.synchronize do
|
|
147
|
-
failed_events << event
|
|
148
|
-
all_events << event
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def published(event)
|
|
153
|
-
@mutex.synchronize do
|
|
154
|
-
published_events << event
|
|
155
|
-
all_events << event
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Clear all cached events.
|
|
160
|
-
def clear_events!
|
|
161
|
-
@all_events = []
|
|
162
|
-
@started_events = []
|
|
163
|
-
@succeeded_events = []
|
|
164
|
-
@failed_events = []
|
|
165
|
-
@published_events = []
|
|
166
|
-
self
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
# Only handles succeeded events correctly.
|
|
170
|
-
class PhasedEventSubscriber < EventSubscriber
|
|
171
|
-
def initialize
|
|
172
|
-
super
|
|
173
|
-
@phase_events = {}
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def phase_finished(phase_index)
|
|
177
|
-
@phase_events[phase_index] = succeeded_events
|
|
178
|
-
@succeeded_events = []
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def phase_events(phase_index)
|
|
182
|
-
@phase_events[phase_index]
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def event_count
|
|
186
|
-
@phase_events.inject(0) do |sum, event|
|
|
187
|
-
sum + event.length
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
class VerboseEventSubscriber < EventSubscriber
|
|
193
|
-
%w(started succeeded failed published).each do |meth|
|
|
194
|
-
define_method(meth) do |event|
|
|
195
|
-
puts event.summary
|
|
196
|
-
super(event)
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|