Skip to content

Commit

Permalink
Indicate in RetryState's status if a previous state will be retried
Browse files Browse the repository at this point in the history
  • Loading branch information
mansam committed Feb 15, 2017
1 parent 7b57e79 commit 72c1740
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def update_status_message
updated_message += "Step [#{@handle.root['ae_state']}] "
updated_message += "Status [#{status}] "
updated_message += "Message [#{@prov.message}] "
if @handle.root['ae_result'] == 'restart'
updated_message += "Restarting from #{@restart_from_state} step"
end
@prov.miq_request.user_message = updated_message
@prov.message = status
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
ro["ae_next_state"] = "some_state"
end
end
let(:ae_service) { Spec::Support::MiqAeMockService.new(root_object) }
let(:ae_service) do
Spec::Support::MiqAeMockService.new(root_object).tap do |ae|
ae.inputs = {}
end
end

it "retries and increments count because of a matching error" do
allow(ae_service).to receive(:inputs).and_return({})
expect(ae_service.root['ae_result']).to eq("error")
expect(ae_service.root['ae_next_state']).to eq("some_state")
expect(ae_service.get_state_var(:state_retries)).to eq(nil)
Expand All @@ -41,10 +44,11 @@
expect(ae_service.root['ae_result']).to eq("restart")
expect(ae_service.root['ae_next_state']).to eq("Placement")
expect(ae_service.get_state_var(:state_retries)).to eq(1)
expect(miq_request[:options][:user_message]).to include("Restarting from Placement")
end

it "remains in error and does not retry if the max tries have been reached" do
allow(ae_service).to receive(:inputs).and_return("max_retries" => 3)
ae_service.inputs["max_retries"] = 3
ae_service.set_state_var(:state_retries, 3)
expect(ae_service.root['ae_result']).to eq("error")
expect(ae_service.root['ae_next_state']).to eq("some_state")
Expand All @@ -54,10 +58,11 @@
expect(ae_service.root['ae_result']).to eq("error")
expect(ae_service.root['ae_next_state']).to eq("some_state")
expect(ae_service.get_state_var(:state_retries)).to eq(3)
expect(miq_request[:options][:user_message]).not_to include("Restarting")
end

it "remains in error and does not retry for an error that does not match" do
allow(ae_service).to receive(:inputs).and_return("error_to_catch" => "non-matching error")
ae_service.inputs["error_to_catch"] = "non-matching error"
expect(ae_service.get_state_var(:state_retries)).to eq(nil)
expect(ae_service.root['ae_result']).to eq("error")
expect(ae_service.root['ae_next_state']).to eq("some_state")
Expand All @@ -67,6 +72,7 @@
expect(ae_service.root['ae_result']).to eq("error")
expect(ae_service.root['ae_next_state']).to eq("some_state")
expect(ae_service.get_state_var(:state_retries)).to eq(nil)
expect(miq_request[:options][:user_message]).not_to include("Restarting")
end
end
end

0 comments on commit 72c1740

Please sign in to comment.