elbping 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # elbping
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/elbping.png)](http://badge.fury.io/rb/elbping)
4
+
3
5
  [![Build Status](https://travis-ci.org/chooper/elbping.png?branch=master)](https://travis-ci.org/chooper/elbping)
4
6
 
5
7
  `elbping` is a tool to ping all of the nodes that make up an Amazon Elastic
data/elbping.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'elbping'
3
- s.version = '0.0.14'
3
+ s.version = '0.0.15'
4
4
  s.date = '2013-08-13'
5
5
  s.summary = "Small tool to 'ping' the nodes that make up an Amazon Elastic Load Balancer"
6
6
  s.description = "elbping is a tool to ping all of the nodes behind an Amazon Elastic Load Balancer. It only works for ELBs in HTTP mode and works by triggering an HTTP 405 (METHOD NOT ALLOWED) error caused when the ELB receives a HTTP verb that is too long."
@@ -1,4 +1,3 @@
1
-
2
1
  require 'resolv'
3
2
  require 'elbping/tcp_dns.rb'
4
3
 
@@ -19,7 +18,7 @@ module ElbPing
19
18
  # * ArgumentError
20
19
 
21
20
  def self.find_elb_ns(target, timeout=5)
22
- resp = nil
21
+ resp = []
23
22
 
24
23
  unless target.end_with? ".elb.amazonaws.com"
25
24
  raise ArgumentError, "Not an Amazon ELB hostname"
@@ -28,11 +27,17 @@ module ElbPing
28
27
  Timeout::timeout(timeout) do
29
28
  Resolv::DNS.open do |sysdns|
30
29
  resp = sysdns.getresources target, Resolv::DNS::Resource::IN::NS
31
- unless resp
32
- raise ArgumentError, "Could not find Amazon nameserver for ELB"
33
- end
34
30
  end
35
- nameservers = resp.map { |ns| ns.name.to_s }
31
+ end
32
+
33
+ if resp.empty?
34
+ parent = target.split(".")[1..-1].join('.')
35
+ if parent.empty?
36
+ raise ArgumentError, "Could not find Amazon nameserver for ELB"
37
+ end
38
+ find_elb_ns(parent, timeout)
39
+ else
40
+ resp.map { |ns| ns.name.to_s }
36
41
  end
37
42
  end
38
43
 
@@ -53,7 +58,7 @@ module ElbPing
53
58
  resp = nil
54
59
 
55
60
  unless target.end_with? ".elb.amazonaws.com"
56
- Timeout::timeout(timeout) do
61
+ Timeout::timeout(timeout) do
57
62
  Resolv::DNS.open do |sysdns|
58
63
  resp = sysdns.getresources target, Resolv::DNS::Resource::IN::CNAME
59
64
  cname = resp[0].name.to_s if resp and resp.size > 0
@@ -64,10 +69,10 @@ module ElbPing
64
69
 
65
70
  nameservers = find_elb_ns target, timeout
66
71
 
67
- Timeout::timeout(timeout) do
72
+ Timeout::timeout(timeout) do
68
73
  TcpDNS.open :nameserver => nameservers, :search => '', :ndots => 1 do |dns|
69
74
  # TODO: Exceptions
70
- resp = dns.getresources target, Resolv::DNS::Resource::IN::ANY
75
+ resp = dns.getresources "all.#{target}", Resolv::DNS::Resource::IN::A
71
76
  end
72
77
  end
73
78
  if resp
@@ -38,7 +38,7 @@ class TcpDNS < Resolv::DNS
38
38
  end
39
39
  }
40
40
  ensure
41
- requester.close
41
+ requester.close unless requester.nil?
42
42
  end
43
43
  end
44
44
  end
@@ -1,9 +1,6 @@
1
-
2
1
  require 'test/unit'
3
2
  require 'elbping/resolver.rb'
4
3
 
5
- DEFAULT_GOOD_ELB = ENV['TEST_GOOD_ELB'] || 'test-elb-868888812.us-east-1.elb.amazonaws.com' # feels dirty
6
-
7
4
  class TestResolver< Test::Unit::TestCase
8
5
  def test_bad_queries
9
6
  ["fake.amazonaws.com", "google.com", "nxdomain.asdf"].each { |tgt|
@@ -15,9 +12,11 @@ class TestResolver< Test::Unit::TestCase
15
12
 
16
13
  # This might still fail from time to time :-\ Been seeing lots of failures to connect to AWS DNS
17
14
  def test_good_query
15
+ return nil unless ENV['TEST_GOOD_ELB']
16
+
18
17
  resp = nil
19
18
  assert_nothing_raised do
20
- resp = ElbPing::Resolver.find_elb_nodes(DEFAULT_GOOD_ELB)
19
+ resp = ElbPing::Resolver.find_elb_nodes(ENV['TEST_GOOD_ELB'])
21
20
  end
22
21
  # I don't actually care what the results are, only that they are a list
23
22
  assert_equal resp.class, Array
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elbping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -79,8 +79,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 1.8.23
82
+ rubygems_version: 1.8.25
83
83
  signing_key:
84
84
  specification_version: 3
85
85
  summary: Small tool to 'ping' the nodes that make up an Amazon Elastic Load Balancer
86
- test_files: []
86
+ test_files:
87
+ - test/test_latencybucket.rb
88
+ - test/test_pinger.rb
89
+ - test/test_resolver.rb
90
+ - test/test_stats.rb
91
+ - test/test_tests.rb