Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring cloud orchestration retirement finish_retirement method #92

Merged
merged 2 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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