Skip to content

Commit

Permalink
Fix run_command_via_queue without arguments
Browse files Browse the repository at this point in the history
The run_command_via_queue optional queue_options argument accidentally
did not have a default value causing these operations to fail.
  • Loading branch information
agrare committed Dec 11, 2019
1 parent 9ae5c23 commit 9c57e3a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def run_command_via_task(task_options, queue_options)
MiqTask.generic_action_with_callback(task_options, command_queue_options(queue_options))
end

def run_command_via_queue(method_name, queue_options)
def run_command_via_queue(method_name, queue_options = {})
queue_options[:method_name] = method_name
MiqQueue.put(command_queue_options(queue_options))
end
Expand Down
54 changes: 54 additions & 0 deletions spec/models/vm_or_template/operations/power_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
RSpec.describe VmOrTemplate::Operations::Power do
let(:ems) { FactoryBot.create(:ems_infra) }
let(:vm) { FactoryBot.create(:vm_infra, :ext_management_system => ems) }

context "#start_queue" do
it "queues a raw_start method" do
vm.start_queue
expect(MiqQueue.first).to have_attributes(
:class_name => vm.class.name,
:method_name => "raw_start"
)
end
end

context "stop_queue" do
it "queues a raw_stop method" do
vm.stop_queue
expect(MiqQueue.first).to have_attributes(
:class_name => vm.class.name,
:method_name => "raw_stop"
)
end
end

context "suspend_queue" do
it "queues a raw_stop method" do
vm.suspend_queue
expect(MiqQueue.first).to have_attributes(
:class_name => vm.class.name,
:method_name => "raw_suspend"
)
end
end

context "shelve_offload_queue" do
it "queues a raw_stop method" do
vm.shelve_offload_queue
expect(MiqQueue.first).to have_attributes(
:class_name => vm.class.name,
:method_name => "raw_shelve_offload"
)
end
end

context "pause_queue" do
it "queues a raw_stop method" do
vm.pause_queue
expect(MiqQueue.first).to have_attributes(
:class_name => vm.class.name,
:method_name => "raw_pause"
)
end
end
end

0 comments on commit 9c57e3a

Please sign in to comment.