Skip to content

Commit

Permalink
Merge pull request #92 from pkomanek/refactoring_cloud_orchestration_…
Browse files Browse the repository at this point in the history
…retirement_finish_retirement_method

Refactoring cloud orchestration retirement finish_retirement method
(cherry picked from commit d337d74)
  • Loading branch information
mkanoor authored and simaishi committed May 2, 2017
1 parent b5dc13c commit 4bb9566
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
#
# Description: This method marks the stack as retired
#
module ManageIQ
module Automate
module Cloud
module Orchestration
module Retirement
module StateMachines
module Methods
class FinishRetirement
def initialize(handle = $evm)
@handle = handle
end

stack = $evm.root['orchestration_stack']
stack.finish_retirement if stack
def main
stack = @handle.root['orchestration_stack']
stack.finish_retirement if stack
end
end
end
end
end
end
end
end
end

if __FILE__ == $PROGRAM_NAME
ManageIQ::Automate::Cloud::Orchestration::Retirement::StateMachines::Methods::FinishRetirement.new.main
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require_domain_file

describe ManageIQ::Automate::Cloud::Orchestration::Retirement::StateMachines::Methods::FinishRetirement do
let(:stack) { FactoryGirl.create(:orchestration_stack_amazon) }
let(:service_orchestration) { FactoryGirl.create(:service_orchestration) }
let(:svc_model_service) { MiqAeMethodService::MiqAeServiceService.find(service_orchestration.id) }
let(:svc_model_stack) { MiqAeMethodService::MiqAeServiceOrchestrationStack.find(stack.id) }

let(:root_hash) do
{ 'service_template' => MiqAeMethodService::MiqAeServiceService.find(service_orchestration.id) }
end

let(:root_object) do
obj = Spec::Support::MiqAeMockObject.new(root_hash)
obj["orchestration_stack"] = svc_model_stack
obj
end

let(:ae_service) do
Spec::Support::MiqAeMockService.new(root_object).tap do |service|
current_object = Spec::Support::MiqAeMockObject.new
current_object.parent = root_object
service.object = current_object
end
end

it "retires orchestration stack" do
described_class.new(ae_service).main

expect(svc_model_stack.retired).to eq(true)
expect(svc_model_stack.retires_on).to be_between(Time.zone.now - 10.seconds, Time.zone.now + 1.second)
expect(svc_model_stack.retirement_state).to eq("retired")
end
end

0 comments on commit 4bb9566

Please sign in to comment.