Skip to content

Commit

Permalink
Add zone to q_options in call_automate.
Browse files Browse the repository at this point in the history
Separate Manageiq change to pass zone_name required.

https://bugzilla.redhat.com/show_bug.cgi?id=1447625
  • Loading branch information
tinaafitz committed May 10, 2017
1 parent 854ca51 commit c3cf50f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/miq_automation_engine/engine/miq_ae_event.rb
Expand Up @@ -125,6 +125,7 @@ def self.call_automate(obj, attrs, instance_name, options = {})
:priority => MiqQueue::HIGH_PRIORITY,
:task_id => nil # Clear task_id to allow running synchronously under current worker process
}
q_options[:zone] = options[:zone] if options[:zone].present?

args = {
:object_type => obj.class.name,
Expand Down
55 changes: 48 additions & 7 deletions spec/miq_ae_event_spec.rb
Expand Up @@ -25,7 +25,6 @@
:vm_or_template_id => vm.id
)
end
before { allow(MiqServer).to receive_messages(:my_zone => "zone test") }

context "with user owned VM" do
let(:vm_owner) { user }
Expand Down Expand Up @@ -63,15 +62,57 @@
)
end

context "with user owned VM" do
let(:vm_owner) { user }
shared_context "variables" do
let(:vm_owner) { user }
let(:miq_server) { EvmSpecHelper.local_miq_server(:is_master => true) }
let(:args) do
{ :miq_group_id => group.id, :tenant_id => tenant.id, :user_id => user.id}
end
let(:inputs) do
{:vm => vm}
end
end

it "has tenant" do
args = {:miq_group_id => group.id, :tenant_id => tenant.id, :user_id => user.id}
expect(MiqAeEngine).to receive(:deliver_queue).with(hash_including(args), anything)
shared_examples_for "#pass zone to raise_evm_event" do
include_context "variables"

MiqAeEvent.raise_evm_event("vm_create", vm, :vm => vm)
it "runs successfully" do
expect(MiqAeEngine).to receive(:deliver_queue).with(hash_including(args), hash_including(:zone => zone_name))
MiqAeEvent.raise_evm_event("vm_create", vm, inputs, options)
end
end

shared_examples_for "#zone not passed to raise_evm_event" do
include_context "variables"

it "runs successfully" do
expect(MiqAeEngine).to receive(:deliver_queue).with(hash_including(args), hash_excluding(:zone))
MiqAeEvent.raise_evm_event("vm_create", vm, inputs, options)
end
end

context "with zone" do
let(:zone) { FactoryGirl.create(:zone) }
let(:zone_name) { zone.name }
let(:options) do
{:zone => zone.name}
end
it_behaves_like "#pass zone to raise_evm_event"
end

context "nil zone" do
let(:zone_name) { nil }
let(:options) do
{:zone => nil}
end
end

context "nil options" do
let(:zone_name) { 'default' }
let(:options) do
{}
end
it_behaves_like "#zone not passed to raise_evm_event"
end

context "with group owned VM" do
Expand Down

0 comments on commit c3cf50f

Please sign in to comment.