Class: VirtualMonkey::HttpChecks
- Inherits:
-
Object
- Object
- VirtualMonkey::HttpChecks
- Defined in:
- lib/virtualmonkey/http_checks.rb
Class Method Summary collapse
-
.test_http_response(expected_code, url) ⇒ Object
Tests http response code against given url.
Class Method Details
.test_http_response(expected_code, url) ⇒ Object
Tests http response code against given url
Parameters
- url<String>
-
A URL to perform http request against
- expected_code<Integer>
-
https code to match against curl response
Raises
Exceptions if retry attempts timeout
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/virtualmonkey/http_checks.rb', line 12 def self.test_http_response(expected_code, url) cmd = "curl -w %{http_code} -s #{url} 2> /dev/null " puts cmd timeout=300 begin status = Timeout::timeout(timeout) do while true response = `#{cmd}` break if response.include?(expected_code) puts "Retrying..." sleep 5 end end rescue Timeout::Error => e raise "ERROR: Query failed after #{timeout/60} minutes." end end |