right_support 2.11.3 → 2.12.1

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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -0
  3. data/VERSION +1 -1
  4. data/lib/right_support/notifiers/airbrake.rb +194 -0
  5. data/lib/right_support/notifiers/base.rb +73 -0
  6. data/lib/right_support/notifiers/blacklisters/base.rb +48 -0
  7. data/lib/right_support/notifiers/blacklisters/canonical.rb +60 -0
  8. data/lib/right_support/notifiers/blacklisters/regular_expression.rb +86 -0
  9. data/{features/support/file_utils_bundler_mixin.rb → lib/right_support/notifiers/blacklisters/simple.rb} +21 -20
  10. data/lib/right_support/notifiers/blacklisters/snake_case.rb +60 -0
  11. data/lib/right_support/notifiers/blacklisters/wildcard.rb +65 -0
  12. data/lib/right_support/notifiers/blacklisters.rb +34 -0
  13. data/lib/right_support/notifiers/logger.rb +94 -0
  14. data/lib/right_support/notifiers/notification.rb +57 -0
  15. data/lib/right_support/notifiers/utilities/backtrace_decoder.rb +234 -0
  16. data/lib/right_support/notifiers/utilities.rb +29 -0
  17. data/lib/right_support/notifiers.rb +32 -0
  18. data/lib/right_support/rack/request_logger.rb +13 -9
  19. data/lib/right_support.rb +1 -0
  20. data/right_support.gemspec +19 -70
  21. metadata +17 -69
  22. data/.coveralls.yml +0 -2
  23. data/.rspec +0 -3
  24. data/.simplecov +0 -6
  25. data/.travis.yml +0 -13
  26. data/Gemfile +0 -51
  27. data/Gemfile.lock +0 -153
  28. data/features/balancer_error_handling.feature +0 -34
  29. data/features/balancer_health_check.feature +0 -33
  30. data/features/hash_tools.feature +0 -27
  31. data/features/http_client_timeout.feature +0 -19
  32. data/features/serialization.feature +0 -113
  33. data/features/step_definitions/hash_tools_steps.rb +0 -41
  34. data/features/step_definitions/http_client_steps.rb +0 -27
  35. data/features/step_definitions/request_balancer_steps.rb +0 -93
  36. data/features/step_definitions/ruby_steps.rb +0 -176
  37. data/features/step_definitions/serialization_steps.rb +0 -133
  38. data/features/step_definitions/server_steps.rb +0 -134
  39. data/features/support/env.rb +0 -148
  40. data/right_support.rconf +0 -9
  41. data/spec/config/feature_set_spec.rb +0 -83
  42. data/spec/crypto/signed_hash_spec.rb +0 -73
  43. data/spec/data/hash_tools_spec.rb +0 -602
  44. data/spec/data/mash_spec.rb +0 -313
  45. data/spec/data/token_spec.rb +0 -21
  46. data/spec/data/uuid_spec.rb +0 -45
  47. data/spec/db/cassandra_model_part1_spec.rb +0 -84
  48. data/spec/db/cassandra_model_part2_spec.rb +0 -73
  49. data/spec/db/cassandra_model_spec.rb +0 -375
  50. data/spec/fixtures/encrypted_priv_rsa.pem +0 -30
  51. data/spec/fixtures/good_priv_dsa.pem +0 -12
  52. data/spec/fixtures/good_priv_rsa.pem +0 -15
  53. data/spec/fixtures/good_pub_dsa.ssh +0 -1
  54. data/spec/fixtures/good_pub_rsa.pem +0 -5
  55. data/spec/fixtures/good_pub_rsa.ssh +0 -1
  56. data/spec/log/exception_logger_spec.rb +0 -76
  57. data/spec/log/filter_logger_spec.rb +0 -66
  58. data/spec/log/mixin_spec.rb +0 -141
  59. data/spec/log/multiplexer_spec.rb +0 -54
  60. data/spec/log/null_logger_spec.rb +0 -36
  61. data/spec/log/step_level_logger_spec.rb +0 -49
  62. data/spec/log/system_logger_spec.rb +0 -172
  63. data/spec/net/address_helper_spec.rb +0 -57
  64. data/spec/net/dns_spec.rb +0 -187
  65. data/spec/net/http_client_spec.rb +0 -181
  66. data/spec/net/lb/health_check_spec.rb +0 -417
  67. data/spec/net/lb/round_robin_spec.rb +0 -15
  68. data/spec/net/lb/sticky_spec.rb +0 -92
  69. data/spec/net/request_balancer_spec.rb +0 -690
  70. data/spec/net/s3_helper_spec.rb +0 -160
  71. data/spec/net/ssl_spec.rb +0 -42
  72. data/spec/net/string_encoder_spec.rb +0 -58
  73. data/spec/rack/log_setter_spec.rb +0 -5
  74. data/spec/rack/request_logger_spec.rb +0 -225
  75. data/spec/rack/request_tracker_spec.rb +0 -115
  76. data/spec/rack/runtime_spec.rb +0 -49
  77. data/spec/ruby/easy_singleton_spec.rb +0 -72
  78. data/spec/ruby/object_extensions_spec.rb +0 -27
  79. data/spec/ruby/string_extensions_spec.rb +0 -98
  80. data/spec/spec_helper.rb +0 -188
  81. data/spec/stats/activity_spec.rb +0 -425
  82. data/spec/stats/exceptions_spec.rb +0 -247
  83. data/spec/stats/helpers_spec.rb +0 -685
  84. data/spec/validation/openssl_spec.rb +0 -37
  85. data/spec/validation/ssh_spec.rb +0 -39
@@ -1,313 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class AwesomeHash < Hash
4
- end
5
-
6
- describe RightSupport::Data::Mash do
7
- subject { RightSupport::Data::Mash}
8
-
9
- before(:each) do
10
- @hash = { "mash" => "indifferent", :hash => "different" }
11
- @sub = AwesomeHash.new("mash" => "indifferent", :hash => "different")
12
- end
13
-
14
- describe "#initialize" do
15
- it 'converts all keys into strings when param is a Hash' do
16
- mash = subject.new(@hash)
17
-
18
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
19
- end
20
-
21
- it 'converts all pure Hash values into Mashes if param is a Hash' do
22
- mash = subject.new :hash => @hash
23
-
24
- mash["hash"].should be_an_instance_of(subject)
25
- # sanity check
26
- mash["hash"]["hash"].should == "different"
27
- end
28
-
29
- it 'doesn not convert Hash subclass values into Mashes' do
30
- mash = subject.new :sub => @sub
31
- mash["sub"].should be_an_instance_of(AwesomeHash)
32
- end
33
-
34
- it 'converts all value items if value is an Array' do
35
- mash = subject.new :arry => { :hash => [@hash] }
36
-
37
- mash["arry"].should be_an_instance_of(subject)
38
- # sanity check
39
- mash["arry"]["hash"].first["hash"].should == "different"
40
-
41
- end
42
-
43
- it 'delegates to superclass constructor if param is not a Hash' do
44
- mash = subject.new("dash berlin")
45
-
46
- mash["unexisting key"].should == "dash berlin"
47
- end
48
- end # describe "#initialize"
49
-
50
-
51
-
52
- describe "#update" do
53
- it 'converts all keys into strings when param is a Hash' do
54
- mash = subject.new(@hash)
55
- mash.update("starry" => "night")
56
-
57
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
58
- end
59
-
60
- it 'converts all Hash values into Mashes if param is a Hash' do
61
- mash = subject.new :hash => @hash
62
- mash.update(:hash => { :hash => "is buggy in Ruby 1.8.6" })
63
-
64
- mash["hash"].should be_an_instance_of(subject)
65
- end
66
- end # describe "#update"
67
-
68
-
69
-
70
- describe "#[]=" do
71
- it 'converts key into string' do
72
- mash = subject.new(@hash)
73
- mash[:hash] = { "starry" => "night" }
74
-
75
- mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
76
- end
77
-
78
- it 'converts all Hash value into subject' do
79
- mash = subject.new :hash => @hash
80
- mash[:hash] = { :hash => "is buggy in Ruby 1.8.6" }
81
-
82
- mash["hash"].should be_an_instance_of(subject)
83
- end
84
- end # describe "#[]="
85
-
86
-
87
-
88
- describe "#key?" do
89
- before(:each) do
90
- @mash = subject.new(@hash)
91
- end
92
-
93
- it 'converts key before lookup' do
94
- @mash.key?("mash").should be(true)
95
- @mash.key?(:mash).should be(true)
96
-
97
- @mash.key?("hash").should be(true)
98
- @mash.key?(:hash).should be(true)
99
-
100
- @mash.key?(:rainclouds).should be(false)
101
- @mash.key?("rainclouds").should be(false)
102
- end
103
-
104
- it 'is aliased as include?' do
105
- @mash.include?("mash").should be(true)
106
- @mash.include?(:mash).should be(true)
107
-
108
- @mash.include?("hash").should be(true)
109
- @mash.include?(:hash).should be(true)
110
-
111
- @mash.include?(:rainclouds).should be(false)
112
- @mash.include?("rainclouds").should be(false)
113
- end
114
-
115
- it 'is aliased as member?' do
116
- @mash.member?("mash").should be(true)
117
- @mash.member?(:mash).should be(true)
118
-
119
- @mash.member?("hash").should be(true)
120
- @mash.member?(:hash).should be(true)
121
-
122
- @mash.member?(:rainclouds).should be(false)
123
- @mash.member?("rainclouds").should be(false)
124
- end
125
- end # describe "#key?"
126
-
127
-
128
- describe "#dup" do
129
- it 'returns instance of subject' do
130
- subject.new(@hash).dup.should be_an_instance_of(subject)
131
- end
132
-
133
- it 'preserves keys' do
134
- mash = subject.new(@hash)
135
- dup = mash.dup
136
-
137
- mash.keys.sort.should == dup.keys.sort
138
- end
139
-
140
- it 'preserves value' do
141
- mash = subject.new(@hash)
142
- dup = mash.dup
143
-
144
- mash.values.sort.should == dup.values.sort
145
- end
146
- end
147
-
148
-
149
-
150
- describe "#to_hash" do
151
- it 'returns instance of subject' do
152
- subject.new(@hash).to_hash.should be_an_instance_of(Hash)
153
- end
154
-
155
- it 'preserves keys' do
156
- mash = subject.new(@hash)
157
- converted = mash.to_hash
158
-
159
- mash.keys.sort.should == converted.keys.sort
160
- end
161
-
162
- it 'preserves value' do
163
- mash = subject.new(@hash)
164
- converted = mash.to_hash
165
-
166
- mash.values.sort.should == converted.values.sort
167
- end
168
- end
169
-
170
-
171
-
172
- describe "#symbolize_keys" do
173
- it 'returns instance of subject' do
174
- subject.new(@hash).symbolize_keys.should be_an_instance_of(Hash)
175
- end
176
-
177
- it 'converts keys to symbols' do
178
- mash = subject.new(@hash)
179
- converted = mash.symbolize_keys
180
-
181
- converted_keys = converted.keys.sort{|k1, k2| k1.to_s <=> k2.to_s}
182
- orig_keys = mash.keys.map{|k| k.to_sym}.sort{|i1, i2| i1.to_s <=> i2.to_s}
183
-
184
- converted_keys.should == orig_keys
185
- end
186
-
187
- it 'preserves value' do
188
- mash = subject.new(@hash)
189
- converted = mash.symbolize_keys
190
-
191
- mash.values.sort.should == converted.values.sort
192
- end
193
- end
194
-
195
-
196
-
197
- describe "#delete" do
198
- it 'converts Symbol key into String before deleting' do
199
- mash = subject.new(@hash)
200
-
201
- mash.delete(:hash)
202
- mash.key?("hash").should be(false)
203
- end
204
-
205
- it 'works with String keys as well' do
206
- mash = subject.new(@hash)
207
-
208
- mash.delete("mash")
209
- mash.key?("mash").should be(false)
210
- end
211
- end
212
-
213
-
214
-
215
- describe "#except" do
216
- it "converts Symbol key into String before calling super" do
217
- mash = subject.new(@hash)
218
-
219
- hashless_mash = mash.except(:hash)
220
- hashless_mash.key?("hash").should be(false)
221
- end
222
-
223
- it "works with String keys as well" do
224
- mash = subject.new(@hash)
225
-
226
- mashless_mash = mash.except("mash")
227
- mashless_mash.key?("mash").should be(false)
228
- end
229
-
230
- it "works with multiple keys" do
231
- mash = subject.new(@hash)
232
-
233
- mashless = mash.except("hash", :mash)
234
- mashless.key?(:hash).should be(false)
235
- mashless.key?("mash").should be(false)
236
- end
237
-
238
- it "should return a mash" do
239
- mash = subject.new(@hash)
240
-
241
- hashless_mash = mash.except(:hash)
242
- hashless_mash.class.should be(subject)
243
- end
244
- end
245
-
246
-
247
-
248
- describe "#merge" do
249
- before(:each) do
250
- @mash = subject.new(@hash).merge(:no => "in between")
251
- end
252
-
253
- it 'returns instance of subject' do
254
- @mash.should be_an_instance_of(subject)
255
- end
256
-
257
- it 'merges in give Hash' do
258
- @mash["no"].should == "in between"
259
- end
260
- end
261
-
262
-
263
-
264
- describe "#fetch" do
265
- before(:each) do
266
- @mash = subject.new(@hash).merge(:no => "in between")
267
- end
268
-
269
- it 'converts key before fetching' do
270
- @mash.fetch("no").should == "in between"
271
- end
272
-
273
- it 'returns alternative value if key lookup fails' do
274
- @mash.fetch("flying", "screwdriver").should == "screwdriver"
275
- end
276
- end
277
-
278
-
279
- describe "#default" do
280
- before(:each) do
281
- @mash = subject.new(:yet_another_technical_revolution)
282
- end
283
-
284
- it 'returns default value unless key exists in mash' do
285
- @mash.default("peak oil is now behind, baby").should == :yet_another_technical_revolution
286
- end
287
-
288
- it 'returns existing value if key is Symbol and exists in mash' do
289
- @mash.update(:no => "in between")
290
- @mash.default(:no).should == "in between"
291
- end
292
- end
293
-
294
-
295
- describe "#values_at" do
296
- before(:each) do
297
- @mash = subject.new(@hash).merge(:no => "in between")
298
- end
299
-
300
- it 'is indifferent to whether keys are strings or symbols' do
301
- @mash.values_at("hash", :mash, :no).should == ["different", "indifferent", "in between"]
302
- end
303
- end
304
-
305
-
306
- describe "#stringify_keys!" do
307
- it 'returns the mash itself' do
308
- mash = subject.new(@hash)
309
-
310
- mash.stringify_keys!.object_id.should == mash.object_id
311
- end
312
- end
313
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RightSupport::Data::Token do
4
-
5
- context :generate do
6
- let(:match) { /^[0-9a-zA-Z]{13}$/ }
7
-
8
- subject { described_class }
9
-
10
- it 'generates UUIDs' do
11
- seen = {}
12
- 100.times do
13
- actual = subject.generate
14
- actual.should =~ match
15
- seen[actual].should be_nil
16
- seen[actual] = true
17
- end
18
- end
19
- end
20
-
21
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RightSupport::Data::UUID do
4
- subject { RightSupport::Data::UUID }
5
-
6
- VALID_UUID = /[0-9a-f-]+/ #we're not too picky here...
7
-
8
- context :generate do
9
- context 'when no implementation is available' do
10
- it 'raises Unavailable' do
11
- flexmock(subject).should_receive(:implementation).and_return(nil)
12
- lambda {
13
- subject.generate
14
- }.should raise_error(subject::Unavailable)
15
- end
16
- end
17
-
18
- context 'when SimpleUUID is available' do
19
- it 'generates UUIDs' do
20
- subject.implementation = subject::SimpleUUID
21
- subject.generate.should =~ VALID_UUID
22
- end
23
- end
24
-
25
- context 'when UUIDTools v1 is available' do
26
- it 'generates UUIDs' do
27
- pending #need to rework tests to test 2 versions of 1 gem!
28
- end
29
- end
30
-
31
- context 'when UUIDTools v2 is available' do
32
- it 'generates UUIDs' do
33
- subject.implementation = subject::UUIDTools2
34
- subject.generate.should =~ VALID_UUID
35
- end
36
- end
37
-
38
- context 'when UUID gem is available' do
39
- it 'generates UUIDs' do
40
- subject.implementation = subject::UUIDGem
41
- subject.generate.should =~ VALID_UUID
42
- end
43
- end
44
- end
45
- end
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RightSupport::DB::CassandraModel do
4
-
5
- class Cassandra
6
- class OrderedHash < Hash
7
- def keys
8
- super.sort
9
- end
10
- end
11
- end
12
-
13
- context "config" do
14
- let(:config) { {'test' => {'server' => 'connection'} \
15
- ,'developemnt' => {'server' => 'connection1'}} }
16
-
17
- ['test', 'developemnt'].each do |env|
18
- it "should return correct env: #{env.inspect} config" do
19
- RightSupport::DB::CassandraModel.config = config
20
- old_rack_env = ENV['RACK_ENV']
21
- ENV['RACK_ENV'] = env
22
- config[env].should == RightSupport::DB::CassandraModel.env_config
23
- ENV['RACK_ENV'] = old_rack_env
24
- end
25
- end
26
-
27
- it "should raise error if config not set or not Hash" do
28
- old_rack_env = ENV['RACK_ENV']
29
- RightSupport::DB::CassandraModel.config = nil
30
- ENV['RACK_ENV'] = 'nil_config'
31
- lambda {
32
- RightSupport::DB::CassandraModel.env_config
33
- }.should raise_error RightSupport::DB::MissingConfiguration
34
-
35
- ENV['RACK_ENV'] = old_rack_env
36
- end
37
-
38
- it "should raise error if no configuration find" do
39
- RightSupport::DB::CassandraModel.config = config
40
- old_rack_env = ENV['RACK_ENV']
41
- ENV['RACK_ENV'] = 'super_environment'
42
- lambda {
43
- RightSupport::DB::CassandraModel.env_config
44
- }.should raise_error RightSupport::DB::MissingConfiguration
45
- ENV['RACK_ENV'] = old_rack_env
46
- end
47
-
48
- end
49
-
50
- context "initialize" do
51
- let(:env) { 'server_config' }
52
- let(:column_family) { 'server_config_column_family' }
53
- let(:default_keyspace) { 'ServerConfigSatelliteService' }
54
- let(:default_keyspace_connection) { flexmock('cassandra') }
55
-
56
- {
57
- '[ring1, ring2, ring3]' => ['ring1', 'ring2', 'ring3'] \
58
- ,'ring1, ring2, ring3' => ['ring1', 'ring2', 'ring3'] \
59
- ,['ring1', 'ring2', 'ring3'] => ['ring1', 'ring2', 'ring3']
60
- }.each do |config_string, congig_test|
61
- it "should successfully intialize from #{config_string.inspect}" do
62
-
63
-
64
- old_rack_env = ENV['RACK_ENV']
65
- begin
66
- ENV['RACK_ENV'] = env
67
-
68
- flexmock(Cassandra).should_receive(:new).with(/#{default_keyspace}_#{env}/, congig_test , {:timeout=>20, :server_retry_period=>nil}).and_return(default_keyspace_connection)
69
- default_keyspace_connection.should_receive(:disable_node_auto_discovery!).and_return(true)
70
-
71
-
72
- RightSupport::DB::CassandraModel.config = {env => {"server" => config_string}}
73
- RightSupport::DB::CassandraModel.keyspace = default_keyspace
74
- RightSupport::DB::CassandraModel.reconnect
75
-
76
- ensure
77
- ENV['RACK_ENV'] = old_rack_env
78
- end
79
-
80
-
81
- end
82
- end
83
- end
84
- end
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RightSupport::DB::CassandraModel do
4
-
5
- class Cassandra
6
- class OrderedHash < Hash
7
- def keys
8
- super.sort
9
- end
10
- end
11
- end
12
-
13
- describe "do_op() logging" do
14
-
15
- before(:each) do
16
- @logger = flexmock(:logger)
17
- flexmock(RightSupport::Log::Mixin).should_receive(:default_logger).and_return(@logger)
18
- @logger.should_receive(:debug).with(String)
19
- @conn = flexmock(:connection)
20
- flexmock(RightSupport::DB::CassandraModel).should_receive(:conn).and_return(@conn)
21
- @conn.should_receive(:multi_get).and_return(true)
22
- @conn.should_receive(:get).and_return(true)
23
- @conn.should_receive(:get_indexed_slices).and_return(true)
24
- @conn.should_receive(:get_columns).and_return(true)
25
- @conn.should_receive(:insert).and_return(true)
26
- @conn.should_receive(:remove).and_return(true)
27
- end
28
-
29
- it "logs requests" do
30
- [:multi_get, :get, :get_indexed_slices, :get_columns, :insert, :remove].each do |method|
31
- RightSupport::DB::CassandraModel.do_op(method,'test_column_family', 'test_key')
32
- end
33
- end
34
-
35
- end
36
-
37
- context "do_op_log" do
38
- before(:each) do
39
- @logger = flexmock(:logger)
40
- flexmock(RightSupport::Log::Mixin).should_receive(:default_logger).and_return(@logger)
41
- flexmock(Time).should_receive(:now).and_return(100.010)
42
- end
43
-
44
- it "should display size for the keys if they are array" do
45
- first_started_at = 100.0
46
- started_at = 100.0
47
- @logger.should_receive(:debug).with("CassandraModel get, cf=cf_name, keys=5, time=10.0ms")
48
- RightSupport::DB::CassandraModel.do_op_log(first_started_at, started_at, 0, :get, 'cf_name', [1,2,3,4,5])
49
- end
50
-
51
- it "should display size for the key equal 1 if not array" do
52
- first_started_at = 100.0
53
- started_at = 100.0
54
- @logger.should_receive(:debug).with("CassandraModel get, cf=cf_name, keys=1, time=10.0ms")
55
- RightSupport::DB::CassandraModel.do_op_log(first_started_at, started_at, 0, :get, 'cf_name', "10")
56
- end
57
-
58
- it "should display attemps time in milliseconds (ms)" do
59
- first_started_at = 100.0
60
- started_at = 100.0
61
- @logger.should_receive(:debug).with("CassandraModel get, cf=cf_name, keys=1, time=10.0ms")
62
- RightSupport::DB::CassandraModel.do_op_log(first_started_at, started_at, 0, :get, 'cf_name', [11])
63
- end
64
-
65
- it "should display total time milliseconds (s)" do
66
- first_started_at = 99.0
67
- started_at = 100.0
68
- @logger.should_receive(:debug).with("CassandraModel get, cf=cf_name, keys=1, time=10.0ms, retries=1, total_time=1010.0ms")
69
- RightSupport::DB::CassandraModel.do_op_log(first_started_at, started_at, 1, :get, 'cf_name', [11])
70
- end
71
-
72
- end
73
- end