Created
May 20, 2020 20:12
-
-
Save jlsherrill/6bc16bdce1d6a33cf05e7e980c5c653d to your computer and use it in GitHub Desktop.
Test katello applicability timing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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