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

Fixes multiple issues with job show page #19232

Merged
merged 2 commits into from
Aug 30, 2019
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
Expand Up @@ -18,6 +18,8 @@ def self.create_stack(template, options = {})
template_ref = template.new_record? ? nil : template
new(:name => template.name,
:ext_management_system => template.manager,
:verbosity => template.variables["verbosity"].to_i,
bdunne marked this conversation as resolved.
Show resolved Hide resolved
:authentications => collect_authentications(template.manager, options),
:job_template => template_ref).tap do |stack|
stack.send(:update_with_provider_object, raw_create_stack(template, options))
end
Expand Down Expand Up @@ -97,6 +99,17 @@ def self.reconcile_extra_vars_keys(_template, options)
end
private_class_method :reconcile_extra_vars_keys

def self.collect_authentications(manager, options)
credential_ids = options.values_at(
:credential,
:cloud_credential,
:network_credential,
:vault_credential
).compact
manager.credentials.where(:id => credential_ids)
end
private_class_method :collect_authentications

def update_with_provider_object(raw_job)
self.miq_task ||= raw_job.miq_task

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@
end

context "#refresh_ems" do
subject { described_class.create_job(template, {}) }
subject { described_class.create_job(template, job_options) }

let(:job_options) do
{
:credential => machine_credential.id,
:cloud_credential => cloud_credential.id,
:network_credential => network_credential.id,
:vault_credential => vault_credential.id
}
end

it "syncs the job with the provider" do
subject.refresh_ems
Expand All @@ -82,22 +91,22 @@
:status => subject.miq_task.state,
:start_time => subject.miq_task.started_on,
:finish_time => nil,
:verbosity => nil # TODO: Implement this as an job options, right?
:verbosity => 0
)
subject.reload
expect(subject.ems_ref).to eq(subject.miq_task.id.to_s)
expect(subject.status).to eq(subject.miq_task.state)

expect(subject.authentications).to match_array([machine_credential, vault_credential, cloud_credential, network_credential])

# TODO/FIXME: This needs to be implemented.
#
# The following are implemented in AnsibleTower::Job but not here:
#
# - update_parameters
# - update_credentials
# - update_plays
#
# expect(subject.parameters.first).to have_attributes(:name => "param1", :value => "val1")
# expect(subject.authentications).to match_array([machine_credential, vault_credential, cloud_credential, network_credential])
# expect(subject.job_plays.first).to have_attributes(
# :start_time => a_value_within(1.second).of(the_raw_plays.first.created),
# :finish_time => a_value_within(1.second).of(the_raw_plays.last.created),
Expand Down