Skip to content

Instantly share code, notes, and snippets.

@jlsherrill
Created May 20, 2020 20:12
Show Gist options
  • Save jlsherrill/6bc16bdce1d6a33cf05e7e980c5c653d to your computer and use it in GitHub Desktop.
Save jlsherrill/6bc16bdce1d6a33cf05e7e980c5c653d to your computer and use it in GitHub Desktop.
Test katello applicability timing
Setting[:applicability_batch_size] = 50
number_of_calculations = 1000
total_host_count = Katello::Host::ContentFacet.count
RUNNING_TASK_LABEL = "Actions::Katello::Host::GenerateApplicability"
def running_count
ForemanTasks::Task.where(:label => ["Actions::Katello::Applicability::Host::Generate", "Actions::Katello::Applicability::Hosts::BulkGenerate"]).running.count
end
host_ids = []
(number_of_calculations/20).times do
host_ids += Katello::Host::ContentFacet.offset(rand(total_host_count)).limit(20).pluck(:host_id)
end
start_time = Time.now
host_ids.each do |host_id|
::Katello::ApplicableHostQueue.push_host(host_id)
end
::Katello::EventQueue.push_event(::Katello::Events::GenerateHostApplicability::EVENT_TYPE, 0)
until running_count > 0 do
sleep 1
end
until running_count == 0 do
sleep 1
end
puts Time.now - start_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment