Skip to content

Commit

Permalink
Make sure that :host_target_vmware factory creates vmware hosts
Browse files Browse the repository at this point in the history
So, we get closer to the real life.

Then, fix specs expectations to match the real life.
  • Loading branch information
isimluk committed Jun 9, 2017
1 parent be8613f commit 7e843de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion spec/factories/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

# Factories for perf_capture_timer and perf_capture_gap testing
factory :host_target_vmware, :parent => :host do
factory :host_target_vmware, :parent => :host, :class => 'ManageIQ::Providers::Vmware::InfraManager::Host' do
after(:create) do |x|
x.perf_capture_enabled = toggle_on_name_seq(x)
2.times { x.vms << FactoryGirl.create(:vm_target_vmware, :ext_management_system => x.ext_management_system) }
Expand Down
26 changes: 13 additions & 13 deletions spec/models/metric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@
context "executing capture_targets" do
it "should find enabled targets" do
targets = Metric::Targets.capture_targets
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Vm Host Host ManageIQ::Providers::Vmware::InfraManager::Vm Host Storage)
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host Storage)
end

it "should find enabled targets excluding storages" do
targets = Metric::Targets.capture_targets(nil, :exclude_storages => true)
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Vm Host Host ManageIQ::Providers::Vmware::InfraManager::Vm Host)
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host)
end

it "should find enabled targets excluding vms" do
targets = Metric::Targets.capture_targets(nil, :exclude_vms => true)
assert_infra_targets_enabled targets, %w(Host Host Host Storage)
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host Storage)
end

it "should find enabled targets excluding vms and storages" do
targets = Metric::Targets.capture_targets(nil, :exclude_storages => true, :exclude_vms => true)
assert_infra_targets_enabled targets, %w(Host Host Host)
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host)
end
end

Expand All @@ -63,11 +63,11 @@

let(:expected_queue_items) do
{
%w(Host perf_capture_realtime) => 3,
%w(Host perf_capture_historical) => 24,
%w(Storage perf_capture_hourly) => 1,
%w(ManageIQ::Providers::Vmware::InfraManager::Vm perf_capture_realtime) => 2,
%w(ManageIQ::Providers::Vmware::InfraManager::Vm perf_capture_historical) => 16,
%w(ManageIQ::Providers::Vmware::InfraManager::Host perf_capture_realtime) => 3,
%w(ManageIQ::Providers::Vmware::InfraManager::Host perf_capture_historical) => 24,
%w(Storage perf_capture_hourly) => 1,
%w(ManageIQ::Providers::Vmware::InfraManager::Vm perf_capture_realtime) => 2,
%w(ManageIQ::Providers::Vmware::InfraManager::Vm perf_capture_historical) => 16,
}
end

Expand All @@ -88,10 +88,10 @@

task = MiqTask.find_by(:name => "Performance rollup for EmsCluster:#{cluster.id}")
expect(task).not_to be_nil
expect(task.context_data[:targets]).to match_array(cluster.hosts.collect { |h| "Host:#{h.id}" })
expect(task.context_data[:targets]).to match_array(cluster.hosts.collect { |h| "ManageIQ::Providers::Vmware::InfraManager::Host:#{h.id}" })

expected_hosts.each do |host|
messages = MiqQueue.where(:class_name => "Host",
messages = MiqQueue.where(:class_name => 'ManageIQ::Providers::Vmware::InfraManager::Host',
:instance_id => host.id,
:method_name => "perf_capture_realtime")
expect(messages.size).to eq(1)
Expand Down Expand Up @@ -122,13 +122,13 @@
tasks = MiqTask.where(:name => "Performance rollup for EmsCluster:#{cluster.id}").order("id DESC")
expect(tasks.length).to eq(2)
tasks.each do |task|
expect(task.context_data[:targets]).to match_array(cluster.hosts.collect { |h| "Host:#{h.id}" })
expect(task.context_data[:targets]).to match_array(cluster.hosts.collect { |h| "ManageIQ::Providers::Vmware::InfraManager::Host:#{h.id}" })
end

task_ids = tasks.collect(&:id)

expected_hosts.each do |host|
messages = MiqQueue.where(:class_name => "Host",
messages = MiqQueue.where(:class_name => 'ManageIQ::Providers::Vmware::InfraManager::Host',
:instance_id => host.id,
:method_name => "perf_capture_realtime")
expect(messages.size).to eq(1)
Expand Down

0 comments on commit 7e843de

Please sign in to comment.