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

Initialize MiqQueue.miq_task_id column when queuing metric capture task #17301

Merged
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
2 changes: 2 additions & 0 deletions app/models/metric/ci_mixin/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def perf_capture_queue(interval_name, options = {})
queue_item_options[:args] = start_and_end_time if start_and_end_time.present?
next if item_interval != 'realtime' && messages[start_and_end_time].try(:priority) == priority
MiqQueue.put_or_update(queue_item_options) do |msg, qi|
# reason for setting MiqQueue#miq_task_id is to initializes MiqTask.started_on column when message delivered.
qi[:miq_task_id] = task_id if task_id
if msg.nil?
qi[:priority] = priority
qi.delete(:state)
Expand Down
7 changes: 7 additions & 0 deletions spec/models/metric/ci_mixin/capture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ def verify_perf_capture_queue(last_perf_capture_on, total_queue_items)
verify_perf_capture_queue(last_perf_capture_on, 11)
end
end

it "links supplied miq_task with queued item which allow to initialize MiqTask#started_on attribute" do
MiqQueue.delete_all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird, I see it is this way in the rest of these tests so I won't hold this up. IMO these should be in different contexts so we don't have to clear database records.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, agreed, it does look strange

task = FactoryGirl.create(:miq_task)
vm.perf_capture_queue("realtime", :task_id => task.id)
expect(MiqQueue.first.miq_task_id).to eq task.id
end
end

describe "#perf_capture_queue('historical')" do
Expand Down