Skip to content

Commit

Permalink
spec: extract openstack perf_capture_timer
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Nov 5, 2019
1 parent dbcaa4a commit 9d6ce63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
31 changes: 30 additions & 1 deletion spec/models/metric/capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
end

describe ".perf_capture_timer" do
context "with enabled and disabled targets", :with_enabled_disabled_vmware do
context "with enabled and disabled vmware targets", :with_enabled_disabled_vmware do
let(:expected_queue_items) do
{
%w(ManageIQ::Providers::Vmware::InfraManager::Host perf_capture_realtime) => 3,
Expand Down Expand Up @@ -65,6 +65,35 @@
messages.each { |m| expect(m.lock_version).to eq(1) }
end
end

context "with enabled and disabled openstack targets" do
before do
@ems_openstack = FactoryBot.create(:ems_openstack, :zone => @zone)
@availability_zone = FactoryBot.create(:availability_zone_target)
@ems_openstack.availability_zones << @availability_zone
@vms_in_az = FactoryBot.create_list(:vm_openstack, 2, :ems_id => @ems_openstack.id)
@availability_zone.vms = @vms_in_az
@availability_zone.vms.push(FactoryBot.create(:vm_openstack, :ems_id => nil))
@vms_not_in_az = FactoryBot.create_list(:vm_openstack, 3, :ems_id => @ems_openstack.id)

MiqQueue.delete_all
end

context "executing perf_capture_timer" do
before do
stub_settings(:performance => {:history => {:initial_capture_days => 7}})
Metric::Capture.perf_capture_timer(@ems_openstack.id)
end

it "should queue up enabled targets" do
expected_targets = Metric::Targets.capture_ems_targets(@ems_openstack)
expect(MiqQueue.group(:method_name).count).to eq('perf_capture_realtime' => expected_targets.count,
'perf_capture_historical' => expected_targets.count * 8,
'destroy_older_by_condition' => 1)
assert_metric_targets(expected_targets)
end
end
end
end

describe ".standard_capture_threshold" do
Expand Down
34 changes: 0 additions & 34 deletions spec/models/metric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,40 +237,6 @@
end
end

context "as openstack" do
before do
@ems_openstack = FactoryBot.create(:ems_openstack, :zone => @zone)
end

context "with enabled and disabled targets" do
before do
@availability_zone = FactoryBot.create(:availability_zone_target)
@ems_openstack.availability_zones << @availability_zone
@vms_in_az = FactoryBot.create_list(:vm_openstack, 2, :ems_id => @ems_openstack.id)
@availability_zone.vms = @vms_in_az
@availability_zone.vms.push(FactoryBot.create(:vm_openstack, :ems_id => nil))
@vms_not_in_az = FactoryBot.create_list(:vm_openstack, 3, :ems_id => @ems_openstack.id)

MiqQueue.delete_all
end

context "executing perf_capture_timer" do
before do
stub_settings(:performance => {:history => {:initial_capture_days => 7}})
Metric::Capture.perf_capture_timer(@ems_openstack.id)
end

it "should queue up enabled targets" do
expected_targets = Metric::Targets.capture_ems_targets(@ems_openstack)
expect(MiqQueue.group(:method_name).count).to eq('perf_capture_realtime' => expected_targets.count,
'perf_capture_historical' => expected_targets.count * 8,
'destroy_older_by_condition' => 1)
assert_metric_targets(expected_targets)
end
end
end
end

context "as kubernetes" do
before do
@ems_kubernetes = FactoryBot.create(:ems_kubernetes, :zone => @zone)
Expand Down

0 comments on commit 9d6ce63

Please sign in to comment.