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

Honor user provided execution_ttl option #17476

Merged
merged 1 commit into from
May 29, 2018
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,4 +1,6 @@
class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::PlaybookRunner < ::Job
DEFAULT_EXECUTION_TTL = 10 # minutes

# options are job table columns, including options column which is the playbook context info
def self.create_job(options)
super(name, options.with_indifferent_access)
Expand All @@ -9,6 +11,11 @@ def minimize_indirect
@minimize_indirect
end

def current_job_timeout(_timeout_adjustment = 1)
@execution_ttl ||=
(options[:execution_ttl].try(:to_i) || DEFAULT_EXECUTION_TTL) * 60
end

def start
time = Time.zone.now
update_attributes(:started_on => time)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@
end
end

describe '#current_job_timeout' do
context 'timeout set in options' do
let(:options) { {:execution_ttl => 50} }

it 'uses customized timeout value' do
expect(subject.current_job_timeout).to eq(3000)
end
end

context 'timeout not set in options' do
let(:options) { {} }

it 'uses default timeout value' do
expect(subject.current_job_timeout).to eq(described_class::DEFAULT_EXECUTION_TTL * 60)
end
end
end

describe '#create_inventory' do
context 'hosts are given' do
# Use string key to also test the indifferent accessibility
Expand Down