From e6a5fefac7c1078f05762b0c9aaa5f340fc0af5e Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 14 Nov 2012 16:05:03 +0000 Subject: Updated each test to use the timeout period specified in the JSON hash. Update the trivial test to set such a thing too. --- lib/custodian/protocol-tests/https.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/custodian/protocol-tests/https.rb') diff --git a/lib/custodian/protocol-tests/https.rb b/lib/custodian/protocol-tests/https.rb index 8db4da5..ec2597b 100755 --- a/lib/custodian/protocol-tests/https.rb +++ b/lib/custodian/protocol-tests/https.rb @@ -68,7 +68,7 @@ class HTTPSTest # 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? @@ -115,13 +115,13 @@ class HTTPSTest # 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 @@ -148,7 +148,7 @@ class HTTPSTest 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 @@ -190,6 +190,7 @@ if __FILE__ == $0 then "target_host" => "http://www.steve.org.uk/", "test_type" => "http", "verbose" => 1, + "timeout" => 5, "test_port" => 80, "test_alert" => "Steve's website is unavailable", "http_text" => "Steve Kemp", -- cgit v1.2.1