fuey_client 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Rakefile +41 -0
- data/config_example/fuey/{config.yml → config/fuey.yml} +0 -0
- data/config_example/fuey/config/redis.yml +2 -0
- data/fuey_client.gemspec +2 -0
- data/lib/fuey_client/fuey/client.rb +10 -3
- data/lib/fuey_client/fuey/config/fuey.rb +9 -0
- data/lib/fuey_client/fuey/config/redis.rb +9 -0
- data/lib/fuey_client/fuey/config.rb +2 -7
- data/lib/fuey_client/fuey/inspections/inspection.rb +50 -0
- data/lib/fuey_client/fuey/inspections/ping.rb +15 -8
- data/lib/fuey_client/fuey/inspections/rfc_ping.rb +16 -7
- data/lib/fuey_client/fuey/inspections/snmp_walk.rb +23 -10
- data/lib/fuey_client/fuey/inspections/support/sap.rb +4 -6
- data/lib/fuey_client/fuey/inspections.rb +1 -0
- data/lib/fuey_client/fuey/log.rb +3 -3
- data/lib/fuey_client/fuey/null_object.rb +11 -0
- data/lib/fuey_client/fuey/reporters/redis.rb +20 -0
- data/lib/fuey_client/fuey/reporters.rb +1 -0
- data/lib/fuey_client/fuey/trace.rb +33 -6
- data/lib/fuey_client/version.rb +1 -1
- data/spec/fuey_client/fuey/client_spec.rb +1 -1
- data/spec/fuey_client/fuey/inspections/inspection_spec.rb +60 -0
- data/spec/fuey_client/fuey/inspections/ping_spec.rb +6 -6
- data/spec/fuey_client/fuey/inspections/rfc_ping_spec.rb +9 -6
- data/spec/fuey_client/fuey/inspections/snmpwalk_spec.rb +9 -9
- data/spec/fuey_client/fuey/trace_spec.rb +7 -7
- data/spec/matchers/inspection_shared_examples.rb +14 -0
- data/spec/matchers/pass_fail.rb +35 -0
- metadata +28 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea6c05fa6472914d543bc8917bab792ca343d36
|
4
|
+
data.tar.gz: 2dc00f23f8b70cd8bb574225abc16813603409fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05fcb0eb04ce69e477724a52f7850206ae98effd2c5d2d6b041d8bb57556d81c350b41ccf929fe70b719dde2c8155c91dbfe2ed0507e81a3faca122def3b5f86
|
7
|
+
data.tar.gz: 8553302abfd23b7deff1c7ab1379fb1612edfe06b2de6b0aca5be0bfb91e75549c66fc9b582b70d4b3c681908195db59bee9a44254a88f5d8b26c749f47682d5
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,47 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rubygems"
|
3
3
|
require "rspec"
|
4
|
+
require 'pty'
|
5
|
+
|
6
|
+
def version
|
7
|
+
FueyClient::VERSION
|
8
|
+
end
|
9
|
+
|
10
|
+
def tag_name
|
11
|
+
"fuey_client-#{version}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def tagged?
|
15
|
+
`git tag`.split.include?(tag_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def git_clean?
|
19
|
+
sh "git status | grep 'nothing to commit'", :verbose => false do |status|
|
20
|
+
return status
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Display the current version tag"
|
25
|
+
task :version do
|
26
|
+
puts tag_name
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Tag the current commit with #{tag_name}"
|
30
|
+
task :tag do
|
31
|
+
fail "Cannot tag, project directory is not clean" unless git_clean?
|
32
|
+
fail "Cannot tag, #{tag_name} already exists." if tagged?
|
33
|
+
sh "git tag #{tag_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Uninstall, build, and install new build locally"
|
37
|
+
task :update do
|
38
|
+
PTY.spawn("gem uninstall fuey_client") do | reader, writer |
|
39
|
+
writer.puts 'Y'
|
40
|
+
puts reader.gets
|
41
|
+
end
|
42
|
+
puts %x(gem build fuey_client.gemspec)
|
43
|
+
puts %x(gem install -l #{tag_name}.gem)
|
44
|
+
end
|
4
45
|
|
5
46
|
task :default do
|
6
47
|
if RUBY_VERSION < "1.9"
|
File without changes
|
data/fuey_client.gemspec
CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "configurethis", ">= 1.0.5"
|
25
25
|
spec.add_dependency "net-ping", "~> 1.6"
|
26
26
|
spec.add_dependency "activesupport", "3.0.0"
|
27
|
+
spec.add_dependency "redis"
|
28
|
+
# spec.add_dependency "stately", :github => "git@github.com:mattsnyder/stately.git"
|
27
29
|
# spec.add_dependency "b2b2dot0-sapnwrfc", "~> 0.26" # https://github.com/piersharding/ruby-sapnwrfc
|
28
30
|
|
29
31
|
spec.add_development_dependency "bundler", "~> 1.3"
|
@@ -1,8 +1,10 @@
|
|
1
|
-
require "fuey_client/fuey/log"
|
2
1
|
require "fuey_client/fuey/config"
|
2
|
+
require "fuey_client/fuey/log"
|
3
|
+
require "fuey_client/fuey/null_object"
|
3
4
|
require "fuey_client/fuey/trace"
|
4
5
|
require "fuey_client/fuey/inspections"
|
5
|
-
require "
|
6
|
+
require "fuey_client/fuey/reporters"
|
7
|
+
|
6
8
|
require "active_support"
|
7
9
|
|
8
10
|
module Fuey
|
@@ -10,12 +12,17 @@ module Fuey
|
|
10
12
|
def initialize(path_to_config_dir="", notifications=nil)
|
11
13
|
Configurethis.root_path = path_to_config_dir
|
12
14
|
|
13
|
-
notifications = Config.notifications if notifications.nil?
|
15
|
+
notifications = Config::Fuey.notifications if notifications.nil?
|
14
16
|
setup_notifications notifications
|
15
17
|
end
|
16
18
|
|
19
|
+
def reporter
|
20
|
+
@_reporter ||= Reporters::Redis.new
|
21
|
+
end
|
22
|
+
|
17
23
|
def run
|
18
24
|
Trace.all.each do |trace|
|
25
|
+
trace.add_observer reporter
|
19
26
|
output = trace.run
|
20
27
|
Log.write %([#{trace.name}] #{output})
|
21
28
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "observer"
|
2
|
+
require "stately"
|
3
|
+
require "fuey_client/fuey/model_initializer"
|
4
|
+
|
5
|
+
module Fuey
|
6
|
+
module Inspections
|
7
|
+
class Inspection
|
8
|
+
include ModelInitializer
|
9
|
+
include Observable
|
10
|
+
|
11
|
+
attr_accessor :name, :state
|
12
|
+
|
13
|
+
stately :start => :pending, :attr => :state do
|
14
|
+
state :executed, :action => :execute do
|
15
|
+
before_transition :do => :notify
|
16
|
+
after_transition :do => :notify
|
17
|
+
after_transition :do => :_execute
|
18
|
+
end
|
19
|
+
state :passed, :action => :pass do
|
20
|
+
after_transition :do => :notify
|
21
|
+
end
|
22
|
+
state :failed, :action => :fail do
|
23
|
+
after_transition :do => :notify
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def passed?
|
28
|
+
state == 'passed'
|
29
|
+
end
|
30
|
+
|
31
|
+
def failed?
|
32
|
+
state == 'failed'
|
33
|
+
end
|
34
|
+
|
35
|
+
def notify
|
36
|
+
changed
|
37
|
+
notify_observers status
|
38
|
+
end
|
39
|
+
|
40
|
+
def status
|
41
|
+
{
|
42
|
+
:type => self.class.to_s.split('::').last,
|
43
|
+
:name => name,
|
44
|
+
:status => self.state
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,22 +1,29 @@
|
|
1
1
|
require "net/ping"
|
2
|
-
require "fuey_client/fuey/model_initializer"
|
3
2
|
|
4
3
|
module Fuey
|
5
4
|
module Inspections
|
6
|
-
class Ping
|
7
|
-
|
5
|
+
class Ping < Fuey::Inspections::Inspection
|
6
|
+
attr_accessor :host, :result
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
def execute
|
8
|
+
def _execute
|
12
9
|
result = Net::Ping::External.new(@host).ping
|
13
|
-
|
14
|
-
|
10
|
+
if result
|
11
|
+
self.pass
|
12
|
+
else
|
13
|
+
self.fail
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_s
|
18
18
|
%(Ping #{name} #{host})
|
19
19
|
end
|
20
|
+
|
21
|
+
def status
|
22
|
+
{
|
23
|
+
:settings => host || "",
|
24
|
+
:statusMessage => %(#{state} ping for #{host}),
|
25
|
+
}.merge(super)
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -1,21 +1,30 @@
|
|
1
1
|
require "fuey_client/fuey/inspections/support/sap"
|
2
|
-
require "fuey_client/fuey/model_initializer"
|
3
2
|
|
4
3
|
module Fuey
|
5
4
|
module Inspections
|
6
|
-
class RFCPing
|
7
|
-
|
5
|
+
class RFCPing < Fuey::Inspections::Inspection
|
6
|
+
attr_accessor :ashost, :sysnr, :client, :user, :passwd, :lang, :response
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def _execute
|
9
|
+
result, response = Support::SAP.new(config).ping
|
10
|
+
if result
|
11
|
+
self.pass
|
12
|
+
else
|
13
|
+
self.fail
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
def to_s
|
16
18
|
%(RFC Ping #{ashost} with user #{user})
|
17
19
|
end
|
18
20
|
|
21
|
+
def status
|
22
|
+
{
|
23
|
+
:settings => config.reject{|k,v| k == 'passwd'},
|
24
|
+
:statusMessage => response || %(#{state} RFCPing for #{ashost})
|
25
|
+
}.merge(super)
|
26
|
+
end
|
27
|
+
|
19
28
|
def config
|
20
29
|
{
|
21
30
|
'ashost' => ashost,
|
@@ -1,24 +1,37 @@
|
|
1
1
|
require "fuey_client/fuey/inspections/support/shell_command"
|
2
|
-
require "fuey_client/fuey/model_initializer"
|
3
2
|
|
4
3
|
module Fuey
|
5
4
|
module Inspections
|
6
|
-
class SNMPWalk
|
7
|
-
|
8
|
-
|
9
|
-
attr_accessor :name, :ip, :agent, :oid, :version, :community
|
5
|
+
class SNMPWalk < Fuey::Inspections::Inspection
|
6
|
+
attr_accessor :ip, :agent, :oid, :version, :community, :response
|
10
7
|
|
11
8
|
def initialize(args)
|
12
9
|
super(args)
|
13
10
|
@version ||= "v1"
|
14
11
|
@community ||= "public"
|
12
|
+
@status_message = ""
|
13
|
+
end
|
14
|
+
|
15
|
+
def _execute
|
16
|
+
response = Support::ShellCommand.new(snmp_walk_command).execute
|
17
|
+
result = (response =~ /#{ip}/)
|
18
|
+
if result
|
19
|
+
self.pass
|
20
|
+
else
|
21
|
+
self.fail
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def status_message
|
26
|
+
return %(#{state} #{snmp_walk_command}) if response.nil?
|
27
|
+
%(SNMPWalk #{state}. #{response})
|
15
28
|
end
|
16
29
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
def status
|
31
|
+
{
|
32
|
+
:settings => snmp_walk_command,
|
33
|
+
:statusMessage => status_message
|
34
|
+
}.merge(super)
|
22
35
|
end
|
23
36
|
|
24
37
|
def to_s
|
@@ -13,14 +13,12 @@ module Fuey
|
|
13
13
|
attrib = conn.connection_attributes
|
14
14
|
fld = conn.discover("RFC_PING")
|
15
15
|
fl = fld.new_function_call
|
16
|
-
fl.invoke
|
17
|
-
true
|
16
|
+
response = fl.invoke
|
17
|
+
[true, response]
|
18
18
|
rescue Gem::LoadError
|
19
|
-
|
20
|
-
false
|
19
|
+
return [false, %(Could not RFC Ping because the sapnwrfc gem is not available)]
|
21
20
|
rescue Exception => caught
|
22
|
-
|
23
|
-
return false
|
21
|
+
return [false, caught]
|
24
22
|
ensure
|
25
23
|
conn.close unless conn.nil?
|
26
24
|
end
|
data/lib/fuey_client/fuey/log.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "fuey_client/fuey/config"
|
1
|
+
require "fuey_client/fuey/config/fuey"
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
module Fuey
|
5
5
|
class Log
|
6
6
|
def self.write(message)
|
7
|
-
logger.info "[#{Config.title}] #{message}"
|
7
|
+
logger.info "[#{Config::Fuey.title}] #{message}"
|
8
8
|
end
|
9
9
|
|
10
10
|
# Handles ActiveSupport::Notifications
|
@@ -13,7 +13,7 @@ module Fuey
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.logger
|
16
|
-
@@logger ||= Logger.new Config.logfile, 'daily'
|
16
|
+
@@logger ||= Logger.new Config::Fuey.logfile, 'daily'
|
17
17
|
end
|
18
18
|
private_class_method :logger
|
19
19
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
require "redis"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Fuey
|
6
|
+
module Reporters
|
7
|
+
class Redis
|
8
|
+
def redis
|
9
|
+
@@redis ||= ::Redis.new(
|
10
|
+
:host => Config::Redis.host,
|
11
|
+
:port => Config::Redis.port )
|
12
|
+
end
|
13
|
+
|
14
|
+
# Handles update from observable
|
15
|
+
def update(channel, message)
|
16
|
+
redis.publish channel, message.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "fuey_client/fuey/reporters/redis"
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require "fuey_client/fuey/model_initializer"
|
2
2
|
require "active_support"
|
3
|
+
require "observer"
|
3
4
|
|
4
5
|
module Fuey
|
5
6
|
class Trace
|
6
7
|
include ModelInitializer
|
8
|
+
include Observable
|
7
9
|
|
8
10
|
attr_accessor :name, :steps
|
9
11
|
|
@@ -13,11 +15,13 @@ module Fuey
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.all
|
16
|
-
Config.traces.keys.map do |trace_name|
|
18
|
+
Config::Fuey.traces.keys.map do |trace_name|
|
17
19
|
trace = Trace.new :name => trace_name
|
18
|
-
Config.traces.send(trace_name).each do |step|
|
19
|
-
|
20
|
-
|
20
|
+
Config::Fuey.traces.send(trace_name).each do |step|
|
21
|
+
inspection_class = ActiveSupport::Inflector.constantize %(Fuey::Inspections::#{step.keys.first})
|
22
|
+
inspection = inspection_class.new(step.values.first)
|
23
|
+
inspection.add_observer(trace)
|
24
|
+
trace.steps.push inspection
|
21
25
|
end
|
22
26
|
trace
|
23
27
|
end
|
@@ -27,14 +31,37 @@ module Fuey
|
|
27
31
|
%(#{name}: [#{steps.join(', ')}])
|
28
32
|
end
|
29
33
|
|
34
|
+
# Handle updates from inpsections via observation
|
35
|
+
def update(status)
|
36
|
+
changed
|
37
|
+
notify_observers(
|
38
|
+
"fuey.trace.update",
|
39
|
+
{
|
40
|
+
:name => name,
|
41
|
+
:status => status[:status],
|
42
|
+
:statusMessage => status[:statusMessage],
|
43
|
+
:steps => [ status ]
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
30
47
|
def run
|
48
|
+
changed
|
49
|
+
notify_observers(
|
50
|
+
"fuey.trace.new",
|
51
|
+
{
|
52
|
+
:name => name,
|
53
|
+
:status => "executed",
|
54
|
+
:statusMessage => "",
|
55
|
+
:steps => steps.map(&:status)
|
56
|
+
}
|
57
|
+
)
|
31
58
|
ActiveSupport::Notifications.instrument("run.trace", {:trace => self.to_s}) do
|
32
59
|
run, failed, current = 0, 0, ""
|
33
60
|
steps.each do |step|
|
34
61
|
run += 1
|
35
62
|
current = step.name
|
36
|
-
|
37
|
-
|
63
|
+
step.execute
|
64
|
+
if step.failed?
|
38
65
|
failed += 1
|
39
66
|
break
|
40
67
|
end
|
data/lib/fuey_client/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fuey::Inspections::Inspection do
|
4
|
+
|
5
|
+
describe "observing an inspection" do
|
6
|
+
|
7
|
+
class TestInspection < Fuey::Inspections::Inspection
|
8
|
+
def _execute
|
9
|
+
self.pass
|
10
|
+
end
|
11
|
+
end
|
12
|
+
Given(:inspection) { TestInspection.new({ :name => 'Example' }) }
|
13
|
+
Given(:subscriber) { double "Observer" }
|
14
|
+
|
15
|
+
describe "and it's initial state" do
|
16
|
+
Then { expect( inspection.state ).to eql('pending') }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "while executing" do
|
20
|
+
Given { subscriber.
|
21
|
+
should_receive(:update).
|
22
|
+
with({
|
23
|
+
:type => 'TestInspection',
|
24
|
+
:name => 'Example',
|
25
|
+
:status => 'pending'
|
26
|
+
}) }
|
27
|
+
Given { subscriber.
|
28
|
+
should_receive(:update).
|
29
|
+
with({
|
30
|
+
:type => 'TestInspection',
|
31
|
+
:name => 'Example',
|
32
|
+
:status => 'executed'
|
33
|
+
}) }
|
34
|
+
Given { subscriber.
|
35
|
+
should_receive(:update).
|
36
|
+
with({
|
37
|
+
:type => 'TestInspection',
|
38
|
+
:name => 'Example',
|
39
|
+
:status => 'passed'
|
40
|
+
}) }
|
41
|
+
Given { inspection.add_observer subscriber }
|
42
|
+
When { inspection.execute }
|
43
|
+
Then { expect( inspection ).to have_passed }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "inspecting state" do
|
48
|
+
Given (:inspection) { Fuey::Inspections::Inspection.new }
|
49
|
+
|
50
|
+
context "when the inspection passes" do
|
51
|
+
When { inspection.pass }
|
52
|
+
Then { expect( inspection ).to be_passed }
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when the inspection fails" do
|
56
|
+
When { inspection.fail }
|
57
|
+
Then { expect( inspection ).to be_failed }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -5,17 +5,17 @@ describe Fuey::Inspections::Ping do
|
|
5
5
|
|
6
6
|
describe "#execute" do
|
7
7
|
context "when the ping fails" do
|
8
|
-
Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 failed.") }
|
9
8
|
Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => false) }
|
10
|
-
|
11
|
-
|
9
|
+
Given (:ping) { Fuey::Inspections::Ping.new(:name => 'some-server', :host => '172.0.0.1') }
|
10
|
+
When { ping.execute }
|
11
|
+
Then { expect( ping ).to have_aborted }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when the ping succeeds" do
|
15
|
-
Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 succeeded.") }
|
16
15
|
Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => true) }
|
17
|
-
|
18
|
-
|
16
|
+
Given (:ping) { Fuey::Inspections::Ping.new(:name => 'some-server', :host => '172.0.0.1') }
|
17
|
+
When { ping.execute }
|
18
|
+
Then { expect( ping ).to have_passed }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -15,20 +15,23 @@ describe Fuey::Inspections::RFCPing do
|
|
15
15
|
}
|
16
16
|
Given (:rfc_ping) { Fuey::Inspections::RFCPing.new config }
|
17
17
|
|
18
|
+
describe "status" do
|
19
|
+
Then { expect( rfc_ping.status[:settings] ).to_not include('passwd') }
|
20
|
+
end
|
18
21
|
|
19
22
|
context "when the ping fails" do
|
20
23
|
Given (:conn) { double Fuey::Inspections::Support::SAP }
|
21
24
|
Given { Fuey::Inspections::Support::SAP.should_receive(:new).with(config).and_return(conn) }
|
22
|
-
Given { conn.stub(:ping).and_return(false) }
|
23
|
-
When
|
24
|
-
Then { expect(
|
25
|
+
Given { conn.stub(:ping).and_return([false, "RFC Ping failure msg"]) }
|
26
|
+
When { rfc_ping.execute }
|
27
|
+
Then { expect( rfc_ping ).to have_aborted }
|
25
28
|
end
|
26
29
|
|
27
30
|
context "when the ping succeeds" do
|
28
31
|
Given (:conn) { double Fuey::Inspections::Support::SAP }
|
29
32
|
Given { Fuey::Inspections::Support::SAP.should_receive(:new).with(config).and_return(conn) }
|
30
|
-
Given { conn.stub(:ping).and_return(true) }
|
31
|
-
When
|
32
|
-
Then { expect(
|
33
|
+
Given { conn.stub(:ping).and_return([true, ""]) }
|
34
|
+
When { rfc_ping.execute }
|
35
|
+
Then { expect( rfc_ping ).to have_passed }
|
33
36
|
end
|
34
37
|
end
|
@@ -19,26 +19,26 @@ describe Fuey::Inspections::SNMPWalk do
|
|
19
19
|
|
20
20
|
context "when the walk fails" do
|
21
21
|
Given (:ip) { '172.0.0.1' }
|
22
|
-
Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 172.0.0.1 using 172.16.0.100 failed.") }
|
23
22
|
Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v1 -c public 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
|
24
|
-
|
25
|
-
|
23
|
+
Given (:snmpwalk) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid) }
|
24
|
+
When { snmpwalk.execute }
|
25
|
+
Then { expect( snmpwalk ).to have_aborted }
|
26
26
|
end
|
27
27
|
|
28
28
|
context "when the walk succeeds" do
|
29
29
|
Given (:ip) { '121.48.196.13' }
|
30
|
-
Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 121.48.196.13 using 172.16.0.100 succeeded.") }
|
31
30
|
Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v1 -c public 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
|
32
|
-
|
33
|
-
|
31
|
+
Given (:snmpwalk) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid) }
|
32
|
+
When { snmpwalk.execute }
|
33
|
+
Then { expect( snmpwalk ).to have_passed }
|
34
34
|
end
|
35
35
|
|
36
36
|
context "when the walk specifies the version and community" do
|
37
37
|
Given (:ip) { '81.197.184.129' }
|
38
|
-
Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 81.197.184.129 using 172.16.0.100 succeeded.") }
|
39
38
|
Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v3 -c private 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
|
40
|
-
|
41
|
-
|
39
|
+
Given (:snmpwalk) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid, :version => 'v3', :community => 'private') }
|
40
|
+
When { snmpwalk.execute }
|
41
|
+
Then { expect( snmpwalk ).to have_passed }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Fuey::Trace do
|
4
|
-
after(:each) { Fuey::Config.reload_configuration }
|
4
|
+
after(:each) { Fuey::Config::Fuey.reload_configuration }
|
5
5
|
|
6
6
|
describe "retrieving all configured traces" do
|
7
7
|
context "when configured for no traces" do
|
8
|
-
Given { Fuey::Config.test_with(no_traces) }
|
8
|
+
Given { Fuey::Config::Fuey.test_with(no_traces) }
|
9
9
|
When (:result) { Fuey::Trace.all }
|
10
10
|
Then { expect( result ).to be_empty }
|
11
11
|
end
|
12
12
|
|
13
13
|
context "when configured with one trace" do
|
14
|
-
Given { Fuey::Config.test_with(two_pings) }
|
14
|
+
Given { Fuey::Config::Fuey.test_with(two_pings) }
|
15
15
|
When (:result) { Fuey::Trace.all }
|
16
16
|
Then { expect( result ).to have(1).items }
|
17
17
|
And { expect( result.first ).to be_a(Fuey::Trace) }
|
@@ -23,16 +23,16 @@ describe Fuey::Trace do
|
|
23
23
|
|
24
24
|
describe "running a trace" do
|
25
25
|
context "when the first step fails" do
|
26
|
-
Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute =>
|
27
|
-
Given (:step2) { double(Fuey::Inspections::Ping) }
|
26
|
+
Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => nil, :failed? => true, :status => {}) }
|
27
|
+
Given (:step2) { double(Fuey::Inspections::Ping, :status => {}) }
|
28
28
|
Given { step2.should_not_receive(:execute) }
|
29
29
|
When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
|
30
30
|
Then { expect( result ).to eql(%[trace1 failed on step1. 2 steps, 1 executed, 1 failed.]) }
|
31
31
|
end
|
32
32
|
|
33
33
|
context "when all steps pass" do
|
34
|
-
Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute =>
|
35
|
-
Given (:step2) { double(Fuey::Inspections::Ping, :name => "step2", :execute =>
|
34
|
+
Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => nil, :failed? => false, :status => {}) }
|
35
|
+
Given (:step2) { double(Fuey::Inspections::Ping, :name => "step2", :execute => nil, :failed? => false, :status => {}) }
|
36
36
|
When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
|
37
37
|
Then { expect( result ).to eql(%[trace1 passed. 2 steps, 2 executed, 0 failed.]) }
|
38
38
|
end
|
@@ -11,4 +11,18 @@ shared_examples "an inspection" do
|
|
11
11
|
When (:inspection) { described_class.new({:name => 'hong kong fuey'} ) }
|
12
12
|
Then { expect( inspection.name ).to eql('hong kong fuey') }
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "should be able to produce a status represented in json" do
|
16
|
+
Then { expect( described_class.new({}) ).to respond_to(:status) }
|
17
|
+
|
18
|
+
describe "and have specific pieces of information" do
|
19
|
+
When (:status) { described_class.new({:name => 'descriptive'}).status }
|
20
|
+
Then { expect( status[:type] ).to eql(described_class.to_s.split('::').last) }
|
21
|
+
And { expect( status[:name] ).to eql('descriptive') }
|
22
|
+
And { expect( status[:settings] ).to_not be_nil }
|
23
|
+
And { expect( status[:status] ).to eql("pending") }
|
24
|
+
And { expect( status[:statusMessage] ).to_not be_nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
14
28
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec::Matchers.define :have_passed do
|
2
|
+
match do |actual|
|
3
|
+
actual.state == "passed"
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message_for_should do
|
7
|
+
"have passed, but was #{actual.state}"
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should_not do
|
11
|
+
"not have passed, but did"
|
12
|
+
end
|
13
|
+
|
14
|
+
description do
|
15
|
+
"should have passed"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Matchers.define :have_aborted do
|
20
|
+
match do |actual|
|
21
|
+
actual.state == "failed"
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_for_should do
|
25
|
+
"have failed, but was #{actual.state}"
|
26
|
+
end
|
27
|
+
|
28
|
+
failure_message_for_should_not do
|
29
|
+
"not have failed, but did"
|
30
|
+
end
|
31
|
+
|
32
|
+
description do
|
33
|
+
"should have failed"
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuey_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configurethis
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redis
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,12 +112,16 @@ files:
|
|
98
112
|
- README.md
|
99
113
|
- Rakefile
|
100
114
|
- bin/fuey
|
101
|
-
- config_example/fuey/config.yml
|
115
|
+
- config_example/fuey/config/fuey.yml
|
116
|
+
- config_example/fuey/config/redis.yml
|
102
117
|
- fuey_client.gemspec
|
103
118
|
- lib/fuey_client.rb
|
104
119
|
- lib/fuey_client/fuey/client.rb
|
105
120
|
- lib/fuey_client/fuey/config.rb
|
121
|
+
- lib/fuey_client/fuey/config/fuey.rb
|
122
|
+
- lib/fuey_client/fuey/config/redis.rb
|
106
123
|
- lib/fuey_client/fuey/inspections.rb
|
124
|
+
- lib/fuey_client/fuey/inspections/inspection.rb
|
107
125
|
- lib/fuey_client/fuey/inspections/ping.rb
|
108
126
|
- lib/fuey_client/fuey/inspections/rfc_ping.rb
|
109
127
|
- lib/fuey_client/fuey/inspections/snmp_walk.rb
|
@@ -111,15 +129,20 @@ files:
|
|
111
129
|
- lib/fuey_client/fuey/inspections/support/shell_command.rb
|
112
130
|
- lib/fuey_client/fuey/log.rb
|
113
131
|
- lib/fuey_client/fuey/model_initializer.rb
|
132
|
+
- lib/fuey_client/fuey/null_object.rb
|
133
|
+
- lib/fuey_client/fuey/reporters.rb
|
134
|
+
- lib/fuey_client/fuey/reporters/redis.rb
|
114
135
|
- lib/fuey_client/fuey/trace.rb
|
115
136
|
- lib/fuey_client/version.rb
|
116
137
|
- spec/fuey_client/fuey/#trace_spec.rb#
|
117
138
|
- spec/fuey_client/fuey/client_spec.rb
|
139
|
+
- spec/fuey_client/fuey/inspections/inspection_spec.rb
|
118
140
|
- spec/fuey_client/fuey/inspections/ping_spec.rb
|
119
141
|
- spec/fuey_client/fuey/inspections/rfc_ping_spec.rb
|
120
142
|
- spec/fuey_client/fuey/inspections/snmpwalk_spec.rb
|
121
143
|
- spec/fuey_client/fuey/trace_spec.rb
|
122
144
|
- spec/matchers/inspection_shared_examples.rb
|
145
|
+
- spec/matchers/pass_fail.rb
|
123
146
|
- spec/spec_helper.rb
|
124
147
|
- vendor/gems/b2b2dot0-sapnwrfc-0.26-x86_64-darwin-12.gem
|
125
148
|
homepage: http://github.com/b2b2dot0/fuey_client
|
@@ -151,9 +174,11 @@ summary: Client for inspecting server state and reports it back to Fuey. Require
|
|
151
174
|
test_files:
|
152
175
|
- spec/fuey_client/fuey/#trace_spec.rb#
|
153
176
|
- spec/fuey_client/fuey/client_spec.rb
|
177
|
+
- spec/fuey_client/fuey/inspections/inspection_spec.rb
|
154
178
|
- spec/fuey_client/fuey/inspections/ping_spec.rb
|
155
179
|
- spec/fuey_client/fuey/inspections/rfc_ping_spec.rb
|
156
180
|
- spec/fuey_client/fuey/inspections/snmpwalk_spec.rb
|
157
181
|
- spec/fuey_client/fuey/trace_spec.rb
|
158
182
|
- spec/matchers/inspection_shared_examples.rb
|
183
|
+
- spec/matchers/pass_fail.rb
|
159
184
|
- spec/spec_helper.rb
|