Skip to content

Commit

Permalink
Merge pull request #19628 from agrare/fix_operations_via_queue
Browse files Browse the repository at this point in the history
Fix run_command_via_queue without arguments
  • Loading branch information
Fryguy authored Dec 11, 2019
2 parents 9ae5c23 + 9c57e3a commit 733fde2
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 733fde2

Please sign in to comment.