Skip to content

Commit

Permalink
Don't test exact queue_options when testing operations
Browse files Browse the repository at this point in the history
Only need to test for the values that are relevent to the tests (e.g.
instance_id, method_name, args).
  • Loading branch information
agrare committed Dec 6, 2019
1 parent 1a5aff8 commit be57fcf
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 113 deletions.
15 changes: 3 additions & 12 deletions spec/controllers/cloud_network_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@
:class_name => ems.class.name,
:method_name => 'create_cloud_network',
:instance_id => ems.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => [{
:admin_state_up => true,
:external_facing => false,
Expand All @@ -135,7 +132,7 @@
end

it "queues the create action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))

post :create, :params => {
:button => 'add',
Expand Down Expand Up @@ -166,9 +163,6 @@
:class_name => network.class.name,
:method_name => 'raw_update_cloud_network',
:instance_id => network.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => [{:name => "test2", :admin_state_up => false, :shared => false, :external_facing => false}]
}
end
Expand All @@ -182,7 +176,7 @@
end

it "queues the update action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))

post :update, :params => { :button => "save", :format => :js, :id => network.id, :name => "test2" }
end
Expand All @@ -201,9 +195,6 @@
:class_name => network.class.name,
:method_name => 'raw_delete_cloud_network',
:instance_id => network.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => []
}
end
Expand All @@ -217,7 +208,7 @@
end

it "queues the delete action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
expect(controller).to receive(:render)

controller.send(:button)
Expand Down
15 changes: 3 additions & 12 deletions spec/controllers/cloud_subnet_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@
:class_name => ems.class.name,
:method_name => 'create_cloud_subnet',
:instance_id => ems.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => [{
:name => 'test',
:ip_version => 4,
Expand All @@ -136,7 +133,7 @@
end

it "queues the create action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))

post :create, :params => {
:button => 'add',
Expand Down Expand Up @@ -168,9 +165,6 @@
:class_name => cloud_subnet.class.name,
:method_name => 'raw_update_cloud_subnet',
:instance_id => cloud_subnet.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => [{
:name => 'test2',
:enable_dhcp => false,
Expand All @@ -190,7 +184,7 @@
end

it "queues the update action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))

post :update, :params => {
:button => 'save',
Expand All @@ -216,9 +210,6 @@
:class_name => cloud_subnet.class.name,
:method_name => 'raw_delete_cloud_subnet',
:instance_id => cloud_subnet.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => ems.my_zone,
:args => []
}
end
Expand All @@ -229,7 +220,7 @@
end

it "queues the delete action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))

post :button, :params => { :id => cloud_subnet.id, :pressed => "cloud_subnet_delete", :format => :js }
end
Expand Down
13 changes: 2 additions & 11 deletions spec/controllers/cloud_volume_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
:class_name => @volume.class.name,
:method_name => "backup_create",
:instance_id => @volume.id,
:role => "ems_operations",
:zone => @ems.my_zone,
:args => [{:name => "backup_name"}]
}
end
Expand Down Expand Up @@ -149,8 +147,6 @@
:class_name => @volume.class.name,
:method_name => "backup_restore",
:instance_id => @volume.id,
:role => "ems_operations",
:zone => @ems.my_zone,
:args => [@backup.ems_ref]
}
end
Expand All @@ -161,7 +157,7 @@
end

it "queues restore from a cloud backup action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :backup_restore, :params => { :button => "restore",
:format => :js, :id => @volume.id, :backup_id => @backup.id }
end
Expand Down Expand Up @@ -189,9 +185,6 @@
:class_name => @volume.class.name,
:instance_id => @volume.id,
:method_name => 'create_volume_snapshot',
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => [{:name => "snapshot_name"}]
}
end
Expand All @@ -202,7 +195,7 @@
end

it "queues the create cloud snapshot action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :snapshot_create, :params => { :button => "create",
:format => :js, :id => @volume.id, :snapshot_name => 'snapshot_name' }
end
Expand All @@ -226,8 +219,6 @@
{
:class_name => "CloudVolume",
:method_name => 'create_volume',
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => @task_options
}
end
Expand Down
5 changes: 1 addition & 4 deletions spec/controllers/cloud_volume_snapshot_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@
:class_name => @snapshot.class.name,
:instance_id => @snapshot.id,
:method_name => 'delete_snapshot',
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => []
}
end

it "queues the delete action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :button, :params => { :id => @snapshot.id, :pressed => "cloud_volume_snapshot_delete", :format => :js }
end
end
Expand Down
15 changes: 3 additions & 12 deletions spec/controllers/floating_ip_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@
:class_name => @ems.class.name,
:method_name => 'create_floating_ip',
:instance_id => @ems.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => [{}]
}
end
Expand All @@ -121,7 +118,7 @@
end

it "queues the create action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :create, :params => { :button => "add", :format => :js, :name => 'test',
:tenant_id => 'id', :ems_id => @ems.id }
end
Expand All @@ -148,9 +145,6 @@
:class_name => @floating_ip.class.name,
:method_name => 'raw_update_floating_ip',
:instance_id => @floating_ip.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => [{:network_port_ems_ref => ""}]
}
end
Expand All @@ -161,7 +155,7 @@
end

it "queues the update action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :update, :params => { :button => "save", :format => :js, :id => @floating_ip.id,
:network_port => {:ems_ref => ""}}
end
Expand All @@ -188,15 +182,12 @@
:class_name => @floating_ip.class.name,
:method_name => 'raw_delete_floating_ip',
:instance_id => @floating_ip.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => []
}
end

it "queues the delete action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :button, :params => { :id => @floating_ip.id, :pressed => "floating_ip_delete", :format => :js }
end
end
Expand Down
20 changes: 4 additions & 16 deletions spec/controllers/host_aggregate_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
{
:class_name => aggregate.class.name,
:method_name => "create_aggregate",
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => ems.my_zone,
:args => [ems.id, {:name => "foo", :ems_id => ems.id.to_s }]
}
end
Expand All @@ -47,7 +44,7 @@
end

it "queues the create action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :create, :params => { :button => "add", :format => :js, :name => 'foo', :ems_id => ems.id }
end
end
Expand All @@ -64,9 +61,6 @@
:class_name => aggregate.class.name,
:method_name => "update_aggregate",
:instance_id => aggregate.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => ems.my_zone,
:args => [{:name => "foo"}]
}
end
Expand All @@ -77,7 +71,7 @@
end

it "queues the update action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :update, :params => { :button => "save", :format => :js, :id => aggregate.id, :name => "foo" }
end
end
Expand Down Expand Up @@ -136,9 +130,6 @@
:class_name => aggregate.class.name,
:method_name => "add_host",
:instance_id => aggregate.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => ems.my_zone,
:args => [host.id]
}
end
Expand All @@ -149,7 +140,7 @@
end

it "queues the add host action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :add_host, :params => { :button => "addHost", :format => :js, :id => aggregate.id, :host_id => host.id }
end
end
Expand All @@ -166,9 +157,6 @@
:class_name => aggregate.class.name,
:method_name => "remove_host",
:instance_id => aggregate.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => ems.my_zone,
:args => [host.id]
}
end
Expand All @@ -179,7 +167,7 @@
end

it "queues the remove host action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :remove_host, :params => {
:button => "removeHost",
:format => :js,
Expand Down
20 changes: 4 additions & 16 deletions spec/controllers/network_router_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@
:class_name => @ems.class.name,
:method_name => 'create_network_router',
:instance_id => @ems.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => [{
:name => 'test',
:admin_state_up => 'true',
Expand All @@ -135,7 +132,7 @@
end

it "queues the create action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :create, :params => {
:button => 'add',
:controller => 'network_router',
Expand Down Expand Up @@ -172,9 +169,6 @@
:class_name => @router.class.name,
:method_name => 'raw_update_network_router',
:instance_id => @router.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => 'ems_operations',
:zone => @ems.my_zone,
:args => [{:name => "foo2", :external_gateway_info => {}}]
}
end
Expand All @@ -185,7 +179,7 @@
end

it "queues the update action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :update, :params => {
:button => "save",
:format => :js,
Expand Down Expand Up @@ -215,9 +209,6 @@
:class_name => @router.class.name,
:method_name => "raw_add_interface",
:instance_id => @router.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => @ems.my_zone,
:args => [@subnet.id]
}
end
Expand Down Expand Up @@ -274,7 +265,7 @@

it "queues the add interface action" do
stub_user(:features => :all)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :add_interface, :params => {
:button => "add",
:format => :js,
Expand Down Expand Up @@ -305,9 +296,6 @@
:class_name => @router.class.name,
:method_name => "raw_remove_interface",
:instance_id => @router.id,
:priority => MiqQueue::HIGH_PRIORITY,
:role => "ems_operations",
:zone => @ems.my_zone,
:args => [@subnet.id]
}
end
Expand All @@ -318,7 +306,7 @@
end

it "queues the remove interface action" do
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options)
expect(MiqTask).to receive(:generic_action_with_callback).with(task_options, hash_including(queue_options))
post :remove_interface, :params => {
:button => "remove",
:format => :js,
Expand Down
Loading

0 comments on commit be57fcf

Please sign in to comment.