diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-14 16:05:03 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-14 16:05:03 +0000 |
commit | dff1f98662289589ca6227bffa885f90b5773e62 (patch) | |
tree | ea4c7718d46e252d583dd37bdd0c502025ee8e27 /lib/custodian/protocol-tests/http.rb | |
parent | e880c1890738793d176c6d07e35666116fc34514 (diff) |
Updated each test to use the timeout period specified in the JSON
hash. Update the trivial test to set such a thing too.
Diffstat (limited to 'lib/custodian/protocol-tests/http.rb')
-rwxr-xr-x | lib/custodian/protocol-tests/http.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/custodian/protocol-tests/http.rb b/lib/custodian/protocol-tests/http.rb index e1e0ad0..445b192 100755 --- a/lib/custodian/protocol-tests/http.rb +++ b/lib/custodian/protocol-tests/http.rb @@ -67,7 +67,7 @@ class HTTPTest # Do the fetch, if this success then we'll have the # @status + @text setup # - if ( getURL (@test_data["target_host"] ) ) + if ( getURL(@test_data["target_host"], @test_data["timeout"] ) ) # # Do we need to test for a HTTP status code? @@ -112,13 +112,13 @@ class HTTPTest # Retrieve a HTTP page from the web. # # NOTE: This came from sentinel. - def getURL (uri_str) + def getURL (uri_str, timeout) begin uri_str = 'http://' + uri_str unless uri_str.match(/^http/) url = URI.parse(uri_str) http = Net::HTTP.new(url.host, url.port) - http.open_timeout = 3 - http.read_timeout = 3 + http.open_timeout = timeout + http.read_timeout = timeout if (url.scheme == "https") http.use_ssl = true @@ -145,7 +145,7 @@ class HTTPTest then newURL = response['location'].match(/^http/)? response['Location']:uri_str+response['Location'] - return( getURL(newURL) ) + return( getURL(newURL, timeout) ) else @status = response.code.to_i @body = response.body @@ -184,12 +184,12 @@ if __FILE__ == $0 then # Sample data. # test = { - "target_host" => "http://www.steve.org.uk/", + "target_host" => "http://collector2.sh.bytemark.co.uk/", "test_type" => "http", "verbose" => 1, + "timeout" => 3, "test_port" => 80, - "test_alert" => "Steve's website is unavailable", - "http_text" => "Steve Kemp", + "test_alert" => "Collector is unavailable", "http_status" => "200" } |