Last active
July 1, 2019 21:26
-
-
Save mccun934/231962871d87e98dc8e4f145afc18bc4 to your computer and use it in GitHub Desktop.
taskbench.rake
This file contains hidden or 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
namespace :taskbench do | |
desc <<-END_DESC | |
Loads up some tasks | |
END_DESC | |
task :hostupdate => :environment do | |
puts 'Starting task load..' | |
User.current = User.anonymous_admin | |
for y in 0..100 | |
host = ::Host::Managed.unscoped.order('RANDOM()').first | |
facts = host.facts | |
puts "Creating task." | |
begin | |
task = ForemanTasks.async_task(::Actions::Katello::Host::Update, host, facts) | |
rescue | |
puts "Exception launching task." | |
end | |
puts "task: #{y} created" | |
end | |
puts "Finished" | |
end | |
task :genapp => :environment do | |
puts 'Starting task load..' | |
User.current = User.anonymous_admin | |
for y in 0..100 | |
host = ::Host::Managed.unscoped.order('RANDOM()').first | |
puts "Creating GenerateApp task." | |
begin | |
task = ForemanTasks.async_task(::Actions::Katello::Host::GenerateApplicability, [host]) | |
rescue | |
puts "Exception launching GenerateApp task." | |
end | |
puts "GenerateApp task: #{y} created" | |
end | |
puts "Finished" | |
end | |
task :dummy => :environment do | |
puts 'Starting task load..' | |
User.current = User.anonymous_admin | |
for y in 0..100 | |
host = ::Host::Managed.unscoped.order('RANDOM()').first | |
puts "Creating DummyAction task." | |
begin | |
task = ForemanTasks.async_task(::Actions::Katello::Host::DummyAction, [host]) | |
rescue | |
puts "Exception launching DummyAction task." | |
end | |
puts "GenerateApp task: #{y} created" | |
end | |
puts "Finished" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can generate ~4000 tasks quickly by driving this from your shell and parallelizing it with the & operator:
# for i in {1..20}; do foreman-rake taskbench:hostupdate & done
# for i in {1..20}; do foreman-rake taskbench:genapp & done