Skip to content

Commit

Permalink
Merge pull request ManageIQ#14964 from yrudman/fixed-bug-in-vmscan-se…
Browse files Browse the repository at this point in the history
…t_status

Fixed bug: one call to Job#set_status from `VmScan#call_snapshot_delete' has one extra parameter
  • Loading branch information
isimluk authored May 3, 2017
2 parents 2a4935d + 5ce5dfa commit f90652d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/vm_scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def call_snapshot_delete
end
else
_log.error("Deleting snapshot: reference: [#{mor}], No #{ui_lookup(:table => "ext_management_systems")} available to delete snapshot")
set_status("No #{ui_lookup(:table => "ext_management_systems")} available to delete snapshot, skipping", "error", 1)
set_status("No #{ui_lookup(:table => "ext_management_systems")} available to delete snapshot, skipping", "error")
end
else
set_status("Snapshot was not taken, delete not required") if options[:snapshot] == :skipped
Expand Down
25 changes: 25 additions & 0 deletions spec/models/vm_scan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,31 @@
@job.call_synchronize
end
end

describe "#call_snapshot_delete" do
let(:snapshot_description) { "Snapshot description" }
before(:each) do
allow(VmOrTemplate).to receive(:find).with(@vm.id).and_return(@vm)
@job.update_attributes(:state => 'snapshot_delete')
@job.context[:snapshot_mor] = snapshot_description
# always sent 'snapshot_complete'
expect(@job).to receive(:signal).with(:snapshot_complete)
end

it "does not call 'delete_snapshot' if there is no provider this VM belongs to" do
allow(@vm).to receive(:ext_management_system).and_return(false)
expect(@job).not_to receive(:delete_snapshot)
@job.call_snapshot_delete
expect(@job.message).to eq "No #{ui_lookup(:table => "ext_management_systems")} available to delete snapshot, skipping"
end

it "calls 'delete_snapshot'" do
allow(@vm).to receive(:ext_management_system).and_return(true)
expect(@job).to receive(:delete_snapshot)
@job.call_snapshot_delete
expect(@job.message).to eq "Snapshot deleted: reference: [#{snapshot_description}]"
end
end
end

context "A single VM Scan Job on Openstack provider" do
Expand Down

0 comments on commit f90652d

Please sign in to comment.