litmus_paper 0.6.0 → 0.6.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.
@@ -56,7 +56,7 @@ module LitmusPaper
56
56
  if preverify_ok != true || ssl_context.error != 0
57
57
  err_msg = "SSL Verification failed -- Preverify: #{preverify_ok}, Error: #{ssl_context.error_string} (#{ssl_context.error})"
58
58
  LitmusPaper.logger.info err_msg
59
- false
59
+ return false
60
60
  end
61
61
  true
62
62
  end
@@ -0,0 +1,22 @@
1
+ module LitmusPaper
2
+ module Metric
3
+ class BigBrotherService
4
+ def initialize(service)
5
+ @service = service
6
+ end
7
+
8
+ def current_health
9
+ status = Net::HTTP.get('127.0.0.1', "/cluster/#{@service}", 9292)
10
+ if status =~ /CombinedWeight: (\d+)/m
11
+ $1.to_i
12
+ else
13
+ 0
14
+ end
15
+ end
16
+
17
+ def to_s
18
+ "Metric::BigBrotherService(#{@service})"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module LitmusPaper
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/lib/litmus_paper.rb CHANGED
@@ -29,6 +29,7 @@ require 'litmus_paper/health'
29
29
  require 'litmus_paper/forced_health'
30
30
  require 'litmus_paper/logger'
31
31
  require 'litmus_paper/metric/available_memory'
32
+ require 'litmus_paper/metric/big_brother_service'
32
33
  require 'litmus_paper/metric/cpu_load'
33
34
  require 'litmus_paper/service'
34
35
  require 'litmus_paper/status_file'
@@ -23,19 +23,29 @@ describe LitmusPaper::Dependency::HTTP do
23
23
  end
24
24
 
25
25
  context "https" do
26
+ before do
27
+ `env SSL_TEST_PORT=9295 PID_FILE=/tmp/https-test-server.pid bundle exec spec/script/https_test_server.rb`
28
+ SpecHelper.wait_for_service :host => '127.0.0.1', :port => 9295
29
+ end
30
+
31
+ after do
32
+ system "kill -9 `cat /tmp/https-test-server.pid`"
33
+ end
34
+
26
35
  it "can make https request" do
27
- begin
28
- `env SSL_TEST_PORT=9295 PID_FILE=/tmp/https-test-server.pid bundle exec spec/script/https_test_server.rb`
29
- SpecHelper.wait_for_service :host => '127.0.0.1', :port => 9295
30
-
31
- check = LitmusPaper::Dependency::HTTP.new(
32
- "https://127.0.0.1:9295",
33
- :ca_file => TEST_CA_CERT
34
- )
35
- check.should be_available
36
- ensure
37
- system "kill -9 `cat /tmp/https-test-server.pid`"
38
- end
36
+ check = LitmusPaper::Dependency::HTTP.new(
37
+ "https://127.0.0.1:9295",
38
+ :ca_file => TEST_CA_CERT
39
+ )
40
+ check.should be_available
41
+ end
42
+
43
+ it "is not available when SSL verification fails" do
44
+ check = LitmusPaper::Dependency::HTTP.new(
45
+ "https://127.0.0.1:9295",
46
+ :ca_file => nil
47
+ )
48
+ check.should_not be_available
39
49
  end
40
50
  end
41
51
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe LitmusPaper::Metric::BigBrotherService do
4
+ describe "#current_health" do
5
+ it "returns the aggregate health of a Big Brother service." do
6
+ Net::HTTP.should_receive(:get).
7
+ with('127.0.0.1', '/cluster/service', 9292).
8
+ and_return('Running: true\nCombinedWeight: 300\n')
9
+
10
+ big_brother = LitmusPaper::Metric::BigBrotherService.new('service')
11
+ big_brother.current_health.should == 300
12
+ end
13
+ end
14
+
15
+ describe "#to_s" do
16
+ it "is the check name and the service name" do
17
+ cpu_load = LitmusPaper::Metric::BigBrotherService.new('service')
18
+ cpu_load.to_s.should == "Metric::BigBrotherService(service)"
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litmus_paper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
4
+ hash: 5
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Braintreeps
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-21 00:00:00 -05:00
19
- default_executable:
18
+ date: 2012-09-07 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: sinatra
@@ -169,6 +168,7 @@ files:
169
168
  - lib/litmus_paper/health.rb
170
169
  - lib/litmus_paper/logger.rb
171
170
  - lib/litmus_paper/metric/available_memory.rb
171
+ - lib/litmus_paper/metric/big_brother_service.rb
172
172
  - lib/litmus_paper/metric/cpu_load.rb
173
173
  - lib/litmus_paper/service.rb
174
174
  - lib/litmus_paper/status_file.rb
@@ -183,6 +183,7 @@ files:
183
183
  - spec/litmus_paper/dependency/tcp_spec.rb
184
184
  - spec/litmus_paper/health_spec.rb
185
185
  - spec/litmus_paper/metric/available_memory_spec.rb
186
+ - spec/litmus_paper/metric/big_brother_service_spec.rb
186
187
  - spec/litmus_paper/metric/cpu_load_spec.rb
187
188
  - spec/litmus_paper/service_spec.rb
188
189
  - spec/litmus_paper/status_file_spec.rb
@@ -203,7 +204,6 @@ files:
203
204
  - spec/support/stub_facter.rb
204
205
  - spec/support/test.config
205
206
  - spec/support/test.d.config
206
- has_rdoc: true
207
207
  homepage: https://github.com/braintree/litmus_paper
208
208
  licenses: []
209
209
 
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  requirements: []
234
234
 
235
235
  rubyforge_project:
236
- rubygems_version: 1.3.7
236
+ rubygems_version: 1.8.15
237
237
  signing_key:
238
238
  specification_version: 3
239
239
  summary: Backend health tester for HA Services, partner project of big_brother
@@ -247,6 +247,7 @@ test_files:
247
247
  - spec/litmus_paper/dependency/tcp_spec.rb
248
248
  - spec/litmus_paper/health_spec.rb
249
249
  - spec/litmus_paper/metric/available_memory_spec.rb
250
+ - spec/litmus_paper/metric/big_brother_service_spec.rb
250
251
  - spec/litmus_paper/metric/cpu_load_spec.rb
251
252
  - spec/litmus_paper/service_spec.rb
252
253
  - spec/litmus_paper/status_file_spec.rb