Skip to content

Instantly share code, notes, and snippets.

@mccun934
Last active July 1, 2019 21:26
Show Gist options
  • Save mccun934/231962871d87e98dc8e4f145afc18bc4 to your computer and use it in GitHub Desktop.
Save mccun934/231962871d87e98dc8e4f145afc18bc4 to your computer and use it in GitHub Desktop.
taskbench.rake
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
@mccun934
Copy link
Author

mccun934 commented Jun 13, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment