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
commitc31a047c7ecf949b3cf8369985946f563957bf0a (patch)
treedaa4a5bc7db319540d31c873a32f7c58b411f8b3 /lib/custodian/protocoltest/ping.rb
parent3d15acf163a514816f3d2e2d08730dfb708fe5fd (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