Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Do not queue no-op destroy action #15080

Merged
merged 4 commits into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/miq_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def self.delete_older(ts, condition)
end

def self.delete_by_id(ids)
return if ids.empty?
_log.info("Queuing deletion of tasks with the following ids: #{ids.inspect}")
MiqQueue.put(
:class_name => name,
Expand Down
16 changes: 12 additions & 4 deletions spec/models/metric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@
Metric::Capture.perf_capture_timer
end

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,
}
end

it "should queue up enabled targets" do
expect(MiqQueue.count).to eq(47)
expect(MiqQueue.group(:class_name, :method_name).count).to eq(expected_queue_items)
assert_metric_targets
end

Expand Down Expand Up @@ -1013,9 +1023,7 @@

it "should queue up enabled targets" do
expected_targets = Metric::Targets.capture_targets
expected_queue_count = expected_targets.count * 9 # 1 realtime, 8 historical
expected_queue_count += 1 # cleanup task
expect(MiqQueue.count).to eq(expected_queue_count)
expect(MiqQueue.group(:method_name).count).to eq('perf_capture_realtime' => expected_targets.count, 'perf_capture_historical' => expected_targets.count * 8)
assert_metric_targets(expected_targets)
end
end
Expand Down