-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from billfitzgerald0120/timetolive
Support TTL (Time To Live) value for services. (cherry picked from commit 148e5a6) https://bugzilla.redhat.com/show_bug.cgi?id=1479407
- Loading branch information
1 parent
f7c06ed
commit e972d62
Showing
2 changed files
with
112 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 94 additions & 11 deletions
105
...e/ManageIQ/Service/Generic/StateMachines/GenericLifecycle.class/__methods__/start_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,106 @@ | ||
require_domain_file | ||
|
||
describe ManageIQ::Automate::Service::Generic::StateMachines::GenericLifecycle::Start do | ||
let(:admin) { FactoryGirl.create(:user_admin) } | ||
let(:request) { FactoryGirl.create(:service_template_provision_request, :requester => admin) } | ||
let(:ansible_tower_manager) { FactoryGirl.create(:automation_manager) } | ||
let(:job_template) { FactoryGirl.create(:ansible_configuration_script, :manager => ansible_tower_manager) } | ||
let(:service_ansible_tower) { FactoryGirl.create(:service_ansible_tower, :job_template => job_template) } | ||
let(:task) { FactoryGirl.create(:service_template_provision_task, :destination => service_ansible_tower, :miq_request => request) } | ||
let(:svc_task) { MiqAeMethodService::MiqAeServiceServiceTemplateProvisionTask.find(task.id) } | ||
let(:request) { FactoryGirl.create(:service_template_provision_request, :requester => FactoryGirl.create(:user_admin)) } | ||
let(:job_template) { FactoryGirl.create(:ansible_configuration_script, :manager => FactoryGirl.create(:automation_manager)) } | ||
let(:service_ansible_tower) { FactoryGirl.create(:service_ansible_tower, :job_template => job_template, :options => config_info_options) } | ||
let(:svc_service) { MiqAeMethodService::MiqAeServiceServiceAnsibleTower.find(service_ansible_tower.id) } | ||
let(:root_object) { Spec::Support::MiqAeMockObject.new('service' => svc_service, 'service_action' => 'Provision') } | ||
let(:root_object) do | ||
Spec::Support::MiqAeMockObject.new('service' => svc_service, 'service_action' => 'Provision', | ||
'ae_state_max_retries' => 100) | ||
end | ||
let(:ae_service) { Spec::Support::MiqAeMockService.new(root_object) } | ||
let(:config_info_options) do | ||
{ | ||
:config_info => { | ||
:provision => { | ||
:execution_ttl => ttl | ||
}, | ||
:retirement => { | ||
:execution_ttl => ttl | ||
} | ||
} | ||
} | ||
end | ||
|
||
context "Start" do | ||
it "creates notification " do | ||
shared_examples_for "#ttl" do | ||
it "check" do | ||
allow(ae_service).to receive(:create_notification) | ||
|
||
described_class.new(ae_service).main | ||
expect(ae_service.root['ae_result']).to eq("ok") | ||
expect(ae_service.root['ae_retry_interval']).to eq(ae_retry_interval) | ||
end | ||
end | ||
|
||
context "Start 7700 ttl, 100 retries eq interval 77" do | ||
let(:ae_retry_interval) { 77 } | ||
let(:ttl) { 7700 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context "Start 60000 ttl, 100 retries eq interval 600" do | ||
let(:ae_retry_interval) { 600 } | ||
let(:ttl) { 60_000 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context "Start 600 ttl, 100 retries interval nil" do | ||
let(:ae_retry_interval) { nil } | ||
let(:ttl) { 600 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context "Start 0 ttl, 100 retries, interval nil" do | ||
let(:ae_retry_interval) { nil } | ||
let(:ttl) { 0 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context "Start retirement tests, " do | ||
let(:root_object) do | ||
Spec::Support::MiqAeMockObject.new('service' => svc_service, 'service_action' => 'Retirement', 'ae_state_max_retries' => 100) | ||
end | ||
|
||
context " 7700 ttl, 100 retries eq interval 77" do | ||
let(:ae_retry_interval) { 77 } | ||
let(:ttl) { 7700 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context " 60000 ttl, 100 retries eq interval 600" do | ||
let(:ae_retry_interval) { 600 } | ||
let(:ttl) { 60_000 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context " 600 ttl, 100 retries eq interval nil" do | ||
let(:ae_retry_interval) { nil } | ||
let(:ttl) { 600 } | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context " 0 ttl, 100 retries, interval nil" do | ||
let(:ae_retry_interval) { nil } | ||
let(:ttl) { 0 } | ||
it_behaves_like "#ttl" | ||
end | ||
end | ||
|
||
context "Start 6000 ttl, 50 retries eq interval 120" do | ||
let(:ae_retry_interval) { 120 } | ||
let(:ttl) { 6000 } | ||
let(:root_object) do | ||
Spec::Support::MiqAeMockObject.new('service' => svc_service, 'service_action' => 'Provision', 'ae_state_max_retries' => 50) | ||
end | ||
it_behaves_like "#ttl" | ||
end | ||
|
||
context "Start 6000 ttl, 0 retries eq interval nil" do | ||
let(:ae_retry_interval) { nil } | ||
let(:ttl) { 6000 } | ||
let(:root_object) do | ||
Spec::Support::MiqAeMockObject.new('service' => svc_service, 'service_action' => 'Provision', 'ae_state_max_retries' => 0) | ||
end | ||
it_behaves_like "#ttl" | ||
end | ||
end |