mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[dynect|dns] Job polling should use original expected statuses.
This commit is contained in:
parent
1b69f403f3
commit
dfe13342a9
2 changed files with 30 additions and 12 deletions
|
@ -102,7 +102,7 @@ module Fog
|
|||
end
|
||||
|
||||
if response.status == 307 && params[:path] !~ %r{^/REST/Job/}
|
||||
response = poll_job(response)
|
||||
response = poll_job(response, params[:expects])
|
||||
end
|
||||
|
||||
response
|
||||
|
@ -118,11 +118,11 @@ module Fog
|
|||
response
|
||||
end
|
||||
|
||||
def poll_job(response, time_to_wait = 10)
|
||||
def poll_job(response, original_expects, time_to_wait = 10)
|
||||
job_location = response.headers['Location']
|
||||
|
||||
Fog.wait_for(time_to_wait) do
|
||||
response = request(:expects => 200, :method => :get, :path => job_location)
|
||||
response = request(:expects => original_expects, :method => :get, :path => job_location)
|
||||
response.body['status'] != 'incomplete'
|
||||
end
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
|||
old_mock_value = Excon.defaults[:mock]
|
||||
Excon.stubs.clear
|
||||
|
||||
tests("returns final response from a complete job") do
|
||||
begin
|
||||
Excon.defaults[:mock] = true
|
||||
|
||||
|
@ -192,6 +193,23 @@ Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
|||
Excon.defaults[:mock] = old_mock_value
|
||||
end
|
||||
end
|
||||
|
||||
tests("passes expects through when polling a job") do
|
||||
begin
|
||||
Excon.defaults[:mock] = true
|
||||
|
||||
Excon.stub({:method => :post, :path => "/REST/Session"}, {:body=>"{\"status\": \"success\", \"data\": {\"token\": \"foobar\", \"version\": \"2.3.1\"}, \"job_id\": 150583906, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}", :headers=>{"Content-Type"=>"application/json"}, :status=>200})
|
||||
|
||||
Excon.stub({:method => :get, :path => "/REST/Zone/example.com"}, {:status => 307, :body => '/REST/Job/150576635', :headers => {'Content-Type' => 'text/html', 'Location' => '/REST/Job/150576635'}})
|
||||
Excon.stub({:method => :get, :path => "/REST/Job/150576635"}, {:status => 404, :body => '{"status":"success"}', :headers => {'Content-Type' => 'application/json'}})
|
||||
|
||||
Fog::DNS::Dynect::Real.new.request(:method => :get, :expects => 404, :path => "Zone/example.com").body.should == { "status" => "success" }
|
||||
ensure
|
||||
Excon.stubs.clear
|
||||
Excon.defaults[:mock] = old_mock_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
|
Loading…
Reference in a new issue