summaryrefslogtreecommitdiff
path: root/lib/custodian/protocoltest/ping.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-04-16 16:14:06 +0100
committerSteve Kemp <steve@steve.org.uk>2015-04-16 16:14:06 +0100
commit91713ef347d49dca7de7dd9360d42763dd961894 (patch)
tree99f8d3e0ff368cc7bb863cdf7910ffcc629774d4 /lib/custodian/protocoltest/ping.rb
parent1b9654c79d6bd8e24134ddeef4bf44580a726178 (diff)
Updated test-handler for new API.
This update consists of two changes: * No longer return "true" or "false" instead return "TEST_FAILED", or "TEST_SUCCEEDED". * Removed the testing of test-inversion from the class, now it lives in the base-class where it should have done all along.
Diffstat (limited to 'lib/custodian/protocoltest/ping.rb')
-rw-r--r--lib/custodian/protocoltest/ping.rb21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 7622fb5..075f8db 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -1,3 +1,4 @@
+require 'custodian/settings'
require 'custodian/testfactory'
@@ -38,14 +39,6 @@ module Custodian
#
@host = line.split(/\s+/)[0]
- #
- # Is this test inverted?
- #
- if line =~ /must\s+not\s+run\s+/
- @inverted = true
- else
- @inverted = false
- end
end
@@ -75,7 +68,7 @@ module Custodian
if binary.nil?
@error = "Failed to find '/usr/bin/multi-ping'"
- return false
+ return Custodian::TestResult::TEST_FAILED
end
@@ -87,7 +80,7 @@ module Custodian
#
if @host !~ /^([a-zA-Z0-9:\-\.]+)$/
@error = "Invalid hostname for ping-test: #{@host}"
- return false
+ return Custodian::TestResult::TEST_FAILED
end
@@ -152,7 +145,7 @@ module Custodian
end
rescue Timeout::Error => e
@error = "Timed-out performing DNS lookups: #{e}"
- return nil
+ return Custodian::TestResult::TEST_FAILED
end
@@ -161,7 +154,7 @@ module Custodian
#
if ips.empty?
@error = "#{@host} failed to resolve to either IPv4 or IPv6"
- return false
+ return Custodian::TestResult::TEST_FAILED
end
@@ -173,7 +166,7 @@ module Custodian
ips.each do |ip|
if (system(binary, ip) != true)
@error = "Ping failed for #{ip} - from #{@host} "
- return false
+ return Custodian::TestResult::TEST_FAILED
end
end
@@ -184,7 +177,7 @@ module Custodian
# So by the time we reach here we know that all the addresses
# were pingable.
#
- true
+ Custodian::TestResult::TEST_PASSED
end